Ejemplo n.º 1
0
        protected override void Rebase(int deltaOffset)
        {
            HtmlToken htmlToken = this.htmlToken;

            htmlToken.Unstructured.HeadOffset = htmlToken.Unstructured.HeadOffset + deltaOffset;
            HtmlToken htmlToken2 = this.htmlToken;

            htmlToken2.UnstructuredPosition.RunOffset = htmlToken2.UnstructuredPosition.RunOffset + deltaOffset;
            HtmlToken htmlToken3 = this.htmlToken;

            htmlToken3.NameInternal.HeadOffset = htmlToken3.NameInternal.HeadOffset + deltaOffset;
            HtmlToken htmlToken4 = this.htmlToken;

            htmlToken4.LocalName.HeadOffset = htmlToken4.LocalName.HeadOffset + deltaOffset;
            HtmlToken htmlToken5 = this.htmlToken;

            htmlToken5.NamePosition.RunOffset = htmlToken5.NamePosition.RunOffset + deltaOffset;
            for (int i = 0; i < this.htmlToken.AttributeTail; i++)
            {
                HtmlToken.AttributeEntry[] attributeList = this.htmlToken.AttributeList;
                int num = i;
                attributeList[num].Name.HeadOffset = attributeList[num].Name.HeadOffset + deltaOffset;
                HtmlToken.AttributeEntry[] attributeList2 = this.htmlToken.AttributeList;
                int num2 = i;
                attributeList2[num2].LocalName.HeadOffset = attributeList2[num2].LocalName.HeadOffset + deltaOffset;
                HtmlToken.AttributeEntry[] attributeList3 = this.htmlToken.AttributeList;
                int num3 = i;
                attributeList3[num3].Value.HeadOffset = attributeList3[num3].Value.HeadOffset + deltaOffset;
            }
            if (this.state >= 24)
            {
                HtmlToken.AttributeEntry[] attributeList4 = this.htmlToken.AttributeList;
                int attributeTail = this.htmlToken.AttributeTail;
                attributeList4[attributeTail].Name.HeadOffset = attributeList4[attributeTail].Name.HeadOffset + deltaOffset;
                HtmlToken.AttributeEntry[] attributeList5 = this.htmlToken.AttributeList;
                int attributeTail2 = this.htmlToken.AttributeTail;
                attributeList5[attributeTail2].LocalName.HeadOffset = attributeList5[attributeTail2].LocalName.HeadOffset + deltaOffset;
                HtmlToken.AttributeEntry[] attributeList6 = this.htmlToken.AttributeList;
                int attributeTail3 = this.htmlToken.AttributeTail;
                attributeList6[attributeTail3].Value.HeadOffset = attributeList6[attributeTail3].Value.HeadOffset + deltaOffset;
            }
            HtmlToken htmlToken6 = this.htmlToken;

            htmlToken6.AttrNamePosition.RunOffset = htmlToken6.AttrNamePosition.RunOffset + deltaOffset;
            HtmlToken htmlToken7 = this.htmlToken;

            htmlToken7.AttrValuePosition.RunOffset = htmlToken7.AttrValuePosition.RunOffset + deltaOffset;
            this.carryOverRunsHeadOffset          += deltaOffset;
            base.Rebase(deltaOffset);
        }
Ejemplo n.º 2
0
        public void EndTagName(HtmlNameIndex resolvedNameIndex)
        {
            if (this.htmlToken.LocalName.Head == this.htmlToken.Whole.Tail)
            {
                this.AddNullRun(HtmlRunKind.Name);
                if (this.htmlToken.LocalName.Head == this.htmlToken.NameInternal.Head)
                {
                    HtmlToken htmlToken = this.htmlToken;
                    htmlToken.Flags |= HtmlToken.TagFlags.EmptyTagName;
                }
            }
            HtmlToken htmlToken2 = this.htmlToken;

            htmlToken2.PartMinor |= HtmlToken.TagPartMinor.EndName;
            if (this.htmlToken.IsTagBegin)
            {
                this.htmlToken.NameIndex = resolvedNameIndex;
                this.htmlToken.TagIndex  = (this.htmlToken.OriginalTagIndex = HtmlNameData.Names[(int)resolvedNameIndex].TagIndex);
            }
            this.state = 23;
        }
Ejemplo n.º 3
0
        public void EndTagName(int nameLength)
        {
            if (this.htmlToken.LocalName.Head == this.htmlToken.Whole.Tail)
            {
                this.AddNullRun(HtmlRunKind.Name);
                if (this.htmlToken.LocalName.Head == this.htmlToken.NameInternal.Head)
                {
                    HtmlToken htmlToken = this.htmlToken;
                    htmlToken.Flags |= HtmlToken.TagFlags.EmptyTagName;
                }
            }
            HtmlToken htmlToken2 = this.htmlToken;

            htmlToken2.PartMinor |= HtmlToken.TagPartMinor.EndName;
            if (this.htmlToken.IsTagBegin)
            {
                base.AddSentinelRun();
                this.htmlToken.NameIndex = this.LookupName(nameLength, this.htmlToken.NameInternal);
                this.htmlToken.TagIndex  = (this.htmlToken.OriginalTagIndex = HtmlNameData.Names[(int)this.htmlToken.NameIndex].TagIndex);
            }
            this.state = 23;
        }
Ejemplo n.º 4
0
        void IDisposable.Dispose()
        {
            if (this.parser != null /*&& this.parser is IDisposable*/)
            {
                ((IDisposable)this.parser).Dispose();
            }

            if (!this.convertFragment && this.output != null && this.output is IDisposable)
            {
                ((IDisposable)this.output).Dispose();
            }

            if (this.token != null && this.token is IDisposable)
            {
                ((IDisposable)this.token).Dispose();
            }

            this.parser = null;
            this.output = null;

            this.token = null;

            GC.SuppressFinalize(this);
        }
Ejemplo n.º 5
0
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;

            switch (tokenId)
            {
            case HtmlTokenId.Tag:

                if (this.token.TagIndex <= HtmlTagIndex.Unknown)
                {
                    break;
                }

                HtmlDtd.TagDefinition tagDef = GetTagDefinition(this.token.TagIndex);

                if (this.normalizedInput)
                {
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.PushElement(tagDef);
                        }

                        this.ProcessStartTagAttributes(tagDef);
                    }
                    else
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.PopElement(tagDef);
                        }
                    }
                }
                else
                {
                    if (!this.token.IsEndTag)
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.LFillTagB(tagDef);
                            this.PushElement(tagDef);
                            this.RFillTagB(tagDef);
                        }

                        this.ProcessStartTagAttributes(tagDef);
                    }
                    else
                    {
                        if (this.token.IsTagBegin)
                        {
                            this.LFillTagE(tagDef);
                            this.PopElement(tagDef);
                            this.RFillTagE(tagDef);
                        }
                    }
                }
                break;



            case HtmlTokenId.Text:

                if (!this.insideComment)
                {
                    if (this.insideAnchor && this.urlCompareSink.IsActive)
                    {
                        token.Text.WriteTo(this.urlCompareSink);
                    }

                    if (this.insidePre)
                    {
                        this.ProcessPreformatedText();
                    }
                    else if (this.normalizedInput)
                    {
                        this.ProcessText();
                    }
                    else
                    {
                        this.NormalizeProcessText();
                    }
                }
                break;



            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:

                break;



            case HtmlTokenId.Restart:

                break;



            case HtmlTokenId.EncodingChange:

                if (this.output.OutputCodePageSameAsInput)
                {
                    int codePage = this.token.Argument;

                        #if DEBUG
                    Encoding newOutputEncoding;

                    InternalDebug.Assert(Charset.TryGetEncoding(codePage, out newOutputEncoding));
                        #endif



                    this.output.OutputEncoding = Charset.GetEncoding(codePage);
                }

                break;



            case HtmlTokenId.EndOfFile:

                if (this.lineStarted)
                {
                    this.output.OutputNewLine();
                    this.lineStarted = false;
                }

                if (!this.convertFragment)
                {
                    if (this.injection != null && this.injection.HaveHead)
                    {
                        if (this.wideGap)
                        {
                            this.output.OutputNewLine();
                            this.wideGap = false;
                        }

                        this.injection.Inject(false, this.output);
                    }

                    this.output.CloseDocument();
                    this.output.Flush();
                }

                this.endOfFile = true;
                break;
            }
        }
Ejemplo n.º 6
0
        // Token: 0x060013C5 RID: 5061 RVA: 0x0008BA64 File Offset: 0x00089C64
        private void Process(HtmlTokenId tokenId)
        {
            HtmlToken token = this.parser.Token;

            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                this.output.Write("\r\n");
                this.output.Flush();
                this.endOfFile = true;
                break;

            case HtmlTokenId.Text:
                if (!this.insideComment)
                {
                    token.Text.WriteToAndCollapseWhitespace(this.output, ref this.collapseWhitespaceState);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
            {
                ConverterEncodingOutput converterEncodingOutput = this.output as ConverterEncodingOutput;
                if (converterEncodingOutput != null && converterEncodingOutput.CodePageSameAsInput)
                {
                    converterEncodingOutput.Encoding = token.TokenEncoding;
                    return;
                }
                break;
            }

            case HtmlTokenId.Tag:
            {
                if (token.IsTagBegin)
                {
                    switch (token.TagIndex)
                    {
                    case HtmlTagIndex.A:
                        if (!token.IsEndTag)
                        {
                        }
                        break;

                    case HtmlTagIndex.Address:
                    case HtmlTagIndex.BlockQuote:
                    case HtmlTagIndex.BR:
                    case HtmlTagIndex.Caption:
                    case HtmlTagIndex.Center:
                    case HtmlTagIndex.Col:
                    case HtmlTagIndex.ColGroup:
                    case HtmlTagIndex.DD:
                    case HtmlTagIndex.Dir:
                    case HtmlTagIndex.Div:
                    case HtmlTagIndex.DL:
                    case HtmlTagIndex.DT:
                    case HtmlTagIndex.FieldSet:
                    case HtmlTagIndex.Form:
                    case HtmlTagIndex.H1:
                    case HtmlTagIndex.H2:
                    case HtmlTagIndex.H3:
                    case HtmlTagIndex.H4:
                    case HtmlTagIndex.H5:
                    case HtmlTagIndex.H6:
                    case HtmlTagIndex.HR:
                    case HtmlTagIndex.LI:
                    case HtmlTagIndex.Listing:
                    case HtmlTagIndex.Map:
                    case HtmlTagIndex.Marquee:
                    case HtmlTagIndex.Menu:
                    case HtmlTagIndex.OL:
                    case HtmlTagIndex.OptGroup:
                    case HtmlTagIndex.Option:
                    case HtmlTagIndex.P:
                    case HtmlTagIndex.PlainText:
                    case HtmlTagIndex.Pre:
                    case HtmlTagIndex.Select:
                    case HtmlTagIndex.Table:
                    case HtmlTagIndex.Tbody:
                    case HtmlTagIndex.TC:
                    case HtmlTagIndex.Tfoot:
                    case HtmlTagIndex.Thead:
                    case HtmlTagIndex.TR:
                    case HtmlTagIndex.UL:
                        this.collapseWhitespaceState = CollapseWhitespaceState.NewLine;
                        break;

                    case HtmlTagIndex.Comment:
                    case HtmlTagIndex.Script:
                    case HtmlTagIndex.Style:
                        this.insideComment = !token.IsEndTag;
                        break;

                    case HtmlTagIndex.NoEmbed:
                    case HtmlTagIndex.NoFrames:
                        this.insideComment = !token.IsEndTag;
                        break;

                    case HtmlTagIndex.TD:
                    case HtmlTagIndex.TH:
                        if (!token.IsEndTag)
                        {
                            this.output.Write("\t");
                        }
                        break;
                    }
                }
                HtmlTagIndex tagIndex = token.TagIndex;
                if (tagIndex != HtmlTagIndex.A)
                {
                    if (tagIndex != HtmlTagIndex.Area)
                    {
                        switch (tagIndex)
                        {
                        case HtmlTagIndex.Image:
                        case HtmlTagIndex.Img:
                            if (!token.IsEndTag)
                            {
                                return;
                            }
                            break;

                        default:
                            return;
                        }
                    }
                    else if (!token.IsEndTag)
                    {
                        return;
                    }
                }
                else if (!token.IsEndTag)
                {
                    return;
                }
                break;
            }

            case HtmlTokenId.Restart:
            case HtmlTokenId.OverlappedClose:
            case HtmlTokenId.OverlappedReopen:
                break;

            default:
                return;
            }
        }
Ejemplo n.º 7
0
 // Token: 0x0600157F RID: 5503 RVA: 0x000A6250 File Offset: 0x000A4450
 internal AttributeValueTextReader(HtmlToken token)
 {
     this.token = token;
 }
Ejemplo n.º 8
0
 // Token: 0x0600156F RID: 5487 RVA: 0x000A601D File Offset: 0x000A421D
 internal TagNameTextReader(HtmlToken token)
 {
     this.token = token;
 }
Ejemplo n.º 9
0
 // Token: 0x0600156B RID: 5483 RVA: 0x000A5FE0 File Offset: 0x000A41E0
 internal TagUnstructuredContentTextReader(HtmlToken token)
 {
     this.token = token;
 }
Ejemplo n.º 10
0
 // Token: 0x06001561 RID: 5473 RVA: 0x000A5DAD File Offset: 0x000A3FAD
 internal AttributeEnumerator(HtmlToken token)
 {
     this.token = token;
 }
Ejemplo n.º 11
0
 // Token: 0x06001623 RID: 5667 RVA: 0x000AEC3F File Offset: 0x000ACE3F
 internal HtmlAttribute(HtmlToken token)
 {
     this.token = token;
 }
Ejemplo n.º 12
0
 public void EndTag(bool complete)
 {
     if (complete)
     {
         if (this.state != 23)
         {
             if (this.state == 21)
             {
                 this.EndTagText();
             }
             else if (this.state == 22)
             {
                 this.EndTagName(0);
             }
             else
             {
                 if (this.state == 24)
                 {
                     this.EndAttributeName(0);
                 }
                 else if (this.state == 26)
                 {
                     this.EndValue();
                 }
                 if (this.state == 25 || this.state == 27)
                 {
                     this.EndAttribute();
                 }
             }
         }
         base.AddSentinelRun();
         this.state = 6;
         HtmlToken htmlToken = this.htmlToken;
         htmlToken.PartMajor |= HtmlToken.TagPartMajor.End;
     }
     else if (this.state >= 24)
     {
         if (this.htmlToken.AttributeTail != 0 || this.htmlToken.NameInternal.Head != -1 || this.htmlToken.AttributeList[this.htmlToken.AttributeTail].Name.Head > 0)
         {
             base.AddSentinelRun();
             this.numCarryOverRuns        = this.htmlToken.Whole.Tail - this.htmlToken.AttributeList[this.htmlToken.AttributeTail].Name.Head;
             this.carryOverRunsHeadOffset = this.htmlToken.AttributeList[this.htmlToken.AttributeTail].Name.HeadOffset;
             this.carryOverRunsLength     = this.tailOffset - this.carryOverRunsHeadOffset;
             HtmlToken htmlToken2 = this.htmlToken;
             htmlToken2.Whole.Tail = htmlToken2.Whole.Tail - this.numCarryOverRuns;
         }
         else
         {
             if (this.state == 24)
             {
                 if (this.htmlToken.AttributeList[this.htmlToken.AttributeTail].Name.Head == this.htmlToken.Whole.Tail)
                 {
                     this.AddNullRun(HtmlRunKind.Name);
                 }
             }
             else if (this.state == 26 && this.htmlToken.AttributeList[this.htmlToken.AttributeTail].Value.Head == this.htmlToken.Whole.Tail)
             {
                 this.AddNullRun(HtmlRunKind.AttrValue);
             }
             base.AddSentinelRun();
             this.htmlToken.AttributeTail++;
         }
     }
     else
     {
         if (this.state == 22)
         {
             if (this.htmlToken.NameInternal.Head == this.htmlToken.Whole.Tail)
             {
                 this.AddNullRun(HtmlRunKind.Name);
             }
         }
         else if (this.state == 21 && this.htmlToken.Unstructured.Head == this.htmlToken.Whole.Tail)
         {
             this.AddNullRun(HtmlRunKind.TagText);
         }
         base.AddSentinelRun();
     }
     this.tokenValid = true;
 }
Ejemplo n.º 13
0
        public void SetEmptyScope()
        {
            HtmlToken htmlToken = this.htmlToken;

            htmlToken.Flags |= HtmlToken.TagFlags.EmptyScope;
        }
Ejemplo n.º 14
0
        public void SetEndTag()
        {
            HtmlToken htmlToken = this.htmlToken;

            htmlToken.Flags |= HtmlToken.TagFlags.EndTag;
        }