コード例 #1
0
 protected override void OnEndTag(EndTag tag)
 {
     if (_collectingForTag != null)
     {
         if (tag.NameEquals(HTMLTokens.A))
         {
             if (_collectingForTagDepth == 0)
             {
                 _collectingForTag = null;
             }
             else
             {
                 _collectingForTagDepth--;
             }
         }
     }
     base.OnEndTag(tag);
 }
コード例 #2
0
 protected override void OnEndTag(EndTag tag)
 {
     if (_collectingForTag != null)
     {
         if (tag.NameEquals(HTMLTokens.A))
         {
             if (_collectingForTagDepth == 0)
                 _collectingForTag = null;
             else
                 _collectingForTagDepth--;
         }
     }
     base.OnEndTag(tag);
 }
コード例 #3
0
        protected override void OnBeginTag(BeginTag tag)
        {
            if (tag != null)
            {
                // Reset any frame urls
                // This is done because the HTML that is often in this document may have
                // incorrect urls for frames.  The frames enumeration is accurate, so if the
                // name from the frames enumeration is the same as this frame, we should fix its
                // url up.
                if (tag.NameEquals(HTMLTokens.Frame))
                {
                    Attr name = tag.GetAttribute(HTMLTokens.Name);
                    if (name != null && this._frames != null)
                    {
                        LightWeightHTMLDocument frameDoc = GetFrameDocumentByName(name.Value);
                        if (frameDoc != null)
                        {
                            Attr src = tag.GetAttribute(HTMLTokens.Src);
                            if (src != null && src.Value != frameDoc.Url)
                            {
                                Generator.AddSubstitionUrl(new UrlToReplace(src.Value, frameDoc.Url));
                            }
                        }
                    }
                }

                LightWeightTag currentTag = new LightWeightTag(tag);
                // The key we'll use for the table
                string key = tag.Name.ToUpper(CultureInfo.InvariantCulture);
                if (!_tagTable.ContainsKey(key))
                {
                    _tagTable[key] = new LightWeightTag[0];
                }

                LightWeightTag[] currentTags = (LightWeightTag[])_tagTable[key];
                LightWeightTag[] grownTags   = new LightWeightTag[currentTags.Length + 1];
                currentTags.CopyTo(grownTags, 0);
                grownTags[currentTags.Length] = currentTag;
                _tagTable[key] = grownTags;

                // Accumulate the title text
                if (tag.NameEquals(HTMLTokens.Title) && !tag.Complete)
                {
                    _nextTextIsTitleText = true;
                }
                else if (tag.NameEquals(HTMLTokens.A) && !tag.Complete && tag.GetAttribute(HTMLTokens.Href) != null)
                {
                    if (_collectingForTag != null)
                    {
                        if (tag.NameEquals(HTMLTokens.A))
                        {
                            _collectingForTagDepth++;
                        }
                    }
                    else
                    {
                        _collectingForTag = currentTag;
                    }
                }
            }
            base.OnBeginTag(tag);
        }
コード例 #4
0
        protected override void OnBeginTag(BeginTag tag)
        {
            if (tag != null)
            {
                // Reset any frame urls
                // This is done because the HTML that is often in this document may have
                // incorrect urls for frames.  The frames enumeration is accurate, so if the
                // name from the frames enumeration is the same as this frame, we should fix its
                // url up.
                if (tag.NameEquals(HTMLTokens.Frame))
                {
                    Attr name = tag.GetAttribute(HTMLTokens.Name);
                    if (name != null && this._frames != null)
                    {
                        LightWeightHTMLDocument frameDoc = GetFrameDocumentByName(name.Value);
                        if (frameDoc != null)
                        {
                            Attr src = tag.GetAttribute(HTMLTokens.Src);
                            if (src != null && src.Value != frameDoc.Url)
                                Generator.AddSubstitionUrl(new UrlToReplace(src.Value, frameDoc.Url));
                        }
                    }
                }

                LightWeightTag currentTag = new LightWeightTag(tag);
                // The key we'll use for the table
                string key = tag.Name.ToUpper(CultureInfo.InvariantCulture);
                if (!_tagTable.ContainsKey(key))
                    _tagTable[key] = new LightWeightTag[0];

                LightWeightTag[] currentTags = (LightWeightTag[])_tagTable[key];
                LightWeightTag[] grownTags = new LightWeightTag[currentTags.Length + 1];
                currentTags.CopyTo(grownTags, 0);
                grownTags[currentTags.Length] = currentTag;
                _tagTable[key] = grownTags;

                // Accumulate the title text
                if (tag.NameEquals(HTMLTokens.Title) && !tag.Complete)
                    _nextTextIsTitleText = true;
                else if (tag.NameEquals(HTMLTokens.A) && !tag.Complete && tag.GetAttribute(HTMLTokens.Href) != null)
                {
                    if (_collectingForTag != null)
                    {
                        if (tag.NameEquals(HTMLTokens.A))
                            _collectingForTagDepth++;
                    }
                    else
                        _collectingForTag = currentTag;
                }

            }
            base.OnBeginTag(tag);
        }