Ejemplo n.º 1
0
        public void EndTagName(HtmlNameIndex resolvedNameIndex)
        {
            InternalDebug.Assert(state == BuildStateTagName);

            InternalDebug.Assert(htmlToken.partMinor == HtmlToken.TagPartMinor.BeginName ||
                                 htmlToken.partMinor == HtmlToken.TagPartMinor.ContinueName);

            if (htmlToken.localName.head == htmlToken.whole.tail)
            {
                InternalDebug.Assert(htmlToken.localName.headOffset == tailOffset);

                AddNullRun(HtmlRunKind.Name);
                if (htmlToken.localName.head == htmlToken.name.head)
                {
                    htmlToken.flags |= HtmlToken.TagFlags.EmptyTagName;
                }
            }

            htmlToken.partMinor |= HtmlToken.TagPartMinor.EndName;

            if (htmlToken.IsTagBegin)
            {
                htmlToken.nameIndex = resolvedNameIndex;
                htmlToken.tagIndex  = htmlToken.originalTagIndex = HtmlNameData.names[(int)resolvedNameIndex].tagIndex;
            }

            state = BuildStateTagBeforeAttr;
        }
Ejemplo n.º 2
0
        void IRestartable.Restart()
        {
            if (this.output is IRestartable restartable)
            {
                restartable.Restart();
            }

            this.allowWspBeforeFollowingTag = false;
            this.lastWhitespace             = false;
            this.lineLength        = 0;
            this.longestLineLength = 0;

            this.literalWhitespaceNesting = 0;
            this.literalTags     = false;
            this.literalEntities = false;
            this.cssEscaping     = false;

            this.tagNameIndex         = HtmlNameIndex._NOTANAME;
            this.previousTagNameIndex = HtmlNameIndex._NOTANAME;

            this.isEndTag        = false;
            this.isEmptyScopeTag = false;
            this.copyPending     = false;

            this.outputState = OutputState.OutsideTag;
        }
Ejemplo n.º 3
0
 // Token: 0x06001483 RID: 5251 RVA: 0x000928C4 File Offset: 0x00090AC4
 internal void AddAttribute(HtmlNameIndex nameIndex, string value)
 {
     this.attributes[this.countAttributes].NameIndex = nameIndex;
     this.attributes[this.countAttributes].Value     = value;
     this.attributes[this.countAttributes].ReadIndex = 0;
     this.countAttributes++;
 }
 public FilterAttributeExceptionEntry(HtmlNameIndex tagNameIndex, HtmlNameIndex attrNameIndex, FilterAction action, FilterAction fragmentAction)
 {
     this.tagNameIndex   = tagNameIndex;
     this.attrNameIndex  = attrNameIndex;
     this.action         = action;
     this.fragmentAction = fragmentAction;
 }
Ejemplo n.º 5
0
 internal void WriteAttributeName(HtmlNameIndex nameIndex)
 {
     if (outputState > OutputState.BeforeAttribute)
     {
         OutputAttributeEnd();
     }
     OutputAttributeName(HtmlNameData.names[(int)nameIndex].name);
 }
 internal void InitializeTag(bool isEndTag, HtmlNameIndex tagNameIndex, bool droppedEndTag)
 {
     this.isEndTag           = isEndTag;
     isEmptyElementTag       = false;
     this.tagNameIndex       = tagNameIndex;
     invokeCallbackForEndTag = false;
     deleteInnerContent      = false;
     deleteEndTag            = !this.isEndTag;
     cookie += 1;
 }
Ejemplo n.º 7
0
 public void StartTag(HtmlNameIndex nameIndex, int baseOffset)
 {
     state                      = 20;
     htmlToken.tokenId          = (TokenId)4;
     htmlToken.partMajor        = HtmlToken.TagPartMajor.Begin;
     htmlToken.partMinor        = HtmlToken.TagPartMinor.Empty;
     htmlToken.nameIndex        = nameIndex;
     htmlToken.tagIndex         = HtmlNameData.names[(int)nameIndex].tagIndex;
     htmlToken.whole.headOffset = baseOffset;
     tailOffset                 = baseOffset;
 }
Ejemplo n.º 8
0
 internal void InitializeTag(bool isEndTag, HtmlNameIndex tagNameIndex, bool droppedEndTag)
 {
     this.isEndTag                = isEndTag;
     this.isEmptyElementTag       = false;
     this.tagNameIndex            = tagNameIndex;
     this.writeState              = (droppedEndTag ? HtmlTagContext.TagWriteState.Deleted : HtmlTagContext.TagWriteState.Undefined);
     this.invokeCallbackForEndTag = false;
     this.deleteInnerContent      = false;
     this.deleteEndTag            = !this.isEndTag;
     this.cookie += 1;
 }
Ejemplo n.º 9
0
 public void StartTag(HtmlNameIndex nameIndex, int baseOffset)
 {
     this.state = 20;
     this.htmlToken.HtmlTokenId      = HtmlTokenId.Tag;
     this.htmlToken.PartMajor        = HtmlToken.TagPartMajor.Begin;
     this.htmlToken.PartMinor        = HtmlToken.TagPartMinor.Empty;
     this.htmlToken.NameIndex        = nameIndex;
     this.htmlToken.TagIndex         = HtmlNameData.Names[(int)nameIndex].TagIndex;
     this.htmlToken.Whole.HeadOffset = baseOffset;
     this.tailOffset = baseOffset;
 }
Ejemplo n.º 10
0
        internal void WriteAttributeName(HtmlNameIndex nameIndex)
        {
            InternalDebug.Assert(nameIndex > HtmlNameIndex.Unknown && (int)nameIndex < HtmlNameData.names.Length);
            InternalDebug.Assert(this.outputState >= OutputState.WritingTagName);
            InternalDebug.Assert(!this.isEndTag);

            if (this.outputState > OutputState.BeforeAttribute)
            {
                this.OutputAttributeEnd();
            }

            this.OutputAttributeName(HtmlNameData.names[(int)nameIndex].name);
        }
Ejemplo n.º 11
0
        internal void InitializeTag(bool isEndTag, HtmlNameIndex tagNameIndex, bool droppedEndTag)
        {
            this.isEndTag = isEndTag;

            this.isEmptyElementTag = false;
            this.tagNameIndex      = tagNameIndex;

            this.invokeCallbackForEndTag = false;
            this.deleteInnerContent      = false;
            this.deleteEndTag            = !this.isEndTag;

            this.cookie = unchecked ((byte)(this.cookie + 1));
        }
Ejemplo n.º 12
0
 // Token: 0x06001569 RID: 5481 RVA: 0x000A5F44 File Offset: 0x000A4144
 public bool Find(HtmlNameIndex nameIndex)
 {
     for (int i = 0; i < this.token.AttributeTail; i++)
     {
         if (this.token.AttributeList[i].NameIndex == nameIndex)
         {
             this.token.CurrentAttribute = i;
             this.token.AttrNamePosition.Rewind(this.token.AttributeList[i].Name);
             this.token.AttrValuePosition.Rewind(this.token.AttributeList[i].Value);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 13
0
 // Token: 0x06001273 RID: 4723 RVA: 0x00083E20 File Offset: 0x00082020
 public bool Find(HtmlNameIndex nameId)
 {
     for (int i = this.token.SelectorHead; i < this.token.SelectorTail; i++)
     {
         if (this.token.SelectorList[i].NameId == nameId)
         {
             this.token.CurrentSelector = i;
             this.token.SelectorNamePosition.Rewind(this.token.SelectorList[i].Name);
             this.token.SelectorClassPosition.Rewind(this.token.SelectorList[i].ClassName);
             return(true);
         }
     }
     return(false);
 }
Ejemplo n.º 14
0
 internal void WriteAttribute(HtmlNameIndex nameIndex, string value)
 {
     if (outputState > OutputState.BeforeAttribute)
     {
         OutputAttributeEnd();
     }
     OutputAttributeName(HtmlNameData.names[(int)nameIndex].name);
     if (value != null)
     {
         OutputAttributeValue(value);
         OutputAttributeEnd();
     }
     outputState = OutputState.BeforeAttribute;
 }
Ejemplo n.º 15
0
        internal void InitializeTag(bool isEndTag, HtmlNameIndex tagNameIndex, bool droppedEndTag)
        {
            this.isEndTag     = isEndTag;
            isEmptyElementTag = false;
            this.tagNameIndex = tagNameIndex;
            writeState        = droppedEndTag ? TagWriteState.Deleted : TagWriteState.Undefined;


            invokeCallbackForEndTag = false;
            deleteInnerContent      = false;
            deleteEndTag            = !this.isEndTag;

            cookie = unchecked ((byte)(cookie + 1));
        }
Ejemplo n.º 16
0
        public void StartTag(HtmlNameIndex nameIndex, int baseOffset)
        {
            InternalDebug.Assert(this.state == BuildStateInitialized && this.htmlToken.IsEmpty);

            this.state = BuildStateTagStarted;

            this.htmlToken.tokenId   = (TokenId)HtmlTokenId.Tag;
            this.htmlToken.partMajor = HtmlToken.TagPartMajor.Begin;
            this.htmlToken.partMinor = HtmlToken.TagPartMinor.Empty;
            this.htmlToken.nameIndex = nameIndex;
            this.htmlToken.tagIndex  = HtmlNameData.names[(int)nameIndex].tagIndex;

            this.htmlToken.whole.headOffset = baseOffset;
            this.tailOffset = baseOffset;
        }
Ejemplo n.º 17
0
 internal new void Reset()
 {
     tagIndex  = (originalTagIndex = HtmlTagIndex._NULL);
     nameIndex = HtmlNameIndex._NOTANAME;
     flags     = TagFlags.None;
     partMajor = TagPartMajor.None;
     partMinor = TagPartMinor.Empty;
     name.Reset();
     unstructured.Reset();
     namePosition.Reset();
     unstructuredPosition.Reset();
     attributeTail    = 0;
     currentAttribute = -1;
     attrNamePosition.Reset();
     attrValuePosition.Reset();
 }
Ejemplo n.º 18
0
            public bool Find(HtmlNameIndex nameIndex)
            {
                for (var i = 0; i < token.attributeTail; i++)
                {
                    if (token.attributeList[i].nameIndex == nameIndex)
                    {
                        token.currentAttribute = i;

                        token.attrNamePosition.Rewind(token.attributeList[i].name);
                        token.attrValuePosition.Rewind(token.attributeList[i].value);

                        return(true);
                    }
                }

                return(false);
            }
Ejemplo n.º 19
0
            public bool Find(HtmlNameIndex nameId)
            {
                for (var i = token.selectorHead; i < token.selectorTail; i++)
                {
                    if (token.selectorList[i].nameId == nameId)
                    {
                        token.currentSelector = i;

                        token.selectorNamePosition.Rewind(token.selectorList[i].name);
                        token.selectorClassPosition.Rewind(token.selectorList[i].className);

                        return(true);
                    }
                }

                return(false);
            }
Ejemplo n.º 20
0
        internal void InitializeTag(bool isEndTag, HtmlNameIndex tagNameIndex, bool droppedEndTag)
        {
            this.isEndTag = isEndTag;

            this.isEmptyElementTag = false;
            this.tagNameIndex      = tagNameIndex;

            // Orphaned WPL code.
#if false
            this.writeState = droppedEndTag ? TagWriteState.Deleted : TagWriteState.Undefined;
#endif

            this.invokeCallbackForEndTag = false;
            this.deleteInnerContent      = false;
            this.deleteEndTag            = !this.isEndTag;

            this.cookie = unchecked ((byte)(this.cookie + 1));
        }
Ejemplo n.º 21
0
 protected void CloseContainer(HtmlNameIndex tagName)
 {
     if (!this.ContainerFlushed)
     {
         this.FlushContainer(this.EmptyContainer ? this.BuildStackTop : (this.BuildStackTop - 1));
     }
     if (this.EmptyContainer)
     {
         this.PrepareToCloseContainer(this.BuildStackTop);
     }
     for (int i = this.BuildStackTop - 1; i > 0; i--)
     {
         if (this.BuildStack[i].TagName == tagName)
         {
             this.PopContainer(i);
             return;
         }
     }
 }
Ejemplo n.º 22
0
        internal new void Reset()
        {
            this.tagIndex  = this.originalTagIndex = HtmlTagIndex._NULL;
            this.nameIndex = HtmlNameIndex._NOTANAME;
            this.flags     = HtmlToken.TagFlags.None;
            this.partMajor = HtmlToken.TagPartMajor.None;
            this.partMinor = HtmlToken.TagPartMinor.Empty;

            this.name.Reset();
            this.unstructured.Reset();

            this.namePosition.Reset();
            this.unstructuredPosition.Reset();

            this.attributeTail    = 0;
            this.currentAttribute = -1;

            this.attrNamePosition.Reset();
            this.attrValuePosition.Reset();
        }
Ejemplo n.º 23
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.º 24
0
 void IRestartable.Restart()
 {
     if (output is IRestartable)
     {
         ((IRestartable)output).Restart();
     }
     allowWspBeforeFollowingTag = false;
     lastWhitespace             = false;
     lineLength               = 0;
     longestLineLength        = 0;
     literalWhitespaceNesting = 0;
     literalTags              = false;
     literalEntities          = false;
     cssEscaping              = false;
     tagNameIndex             = HtmlNameIndex._NOTANAME;
     previousTagNameIndex     = HtmlNameIndex._NOTANAME;
     isEndTag        = false;
     isEmptyScopeTag = false;
     copyPending     = false;
     outputState     = OutputState.OutsideTag;
 }
Ejemplo n.º 25
0
        public HtmlTokenId Parse()
        {
            HtmlTokenBuilder htmlTokenBuilder = this.tokenBuilder;

            if (htmlTokenBuilder.Valid)
            {
                if (htmlTokenBuilder.IncompleteTag)
                {
                    int num = htmlTokenBuilder.RewindTag();
                    this.input.ReportProcessed(num - this.parseStart);
                    this.parseStart = num;
                }
                else
                {
                    this.input.ReportProcessed(this.parseCurrent - this.parseStart);
                    this.parseStart = this.parseCurrent;
                    htmlTokenBuilder.Reset();
                }
            }
            char[] array = this.parseBuffer;
            int    num2  = this.parseCurrent;
            int    num3  = this.parseEnd;
            int    num4  = this.parseThreshold;
            ConverterDecodingInput converterDecodingInput;
            int  num5;
            bool flag2;
            int  num6;

            for (;;)
            {
                bool flag = false;
                if (num2 + num4 > num3)
                {
                    if (!this.endOfFile)
                    {
                        this.parseCurrent = num2;
                        if (!this.input.ReadMore(ref this.parseBuffer, ref this.parseStart, ref this.parseCurrent, ref this.parseEnd))
                        {
                            break;
                        }
                        htmlTokenBuilder.BufferChanged(this.parseBuffer, this.parseStart);
                        converterDecodingInput = (this.input as ConverterDecodingInput);
                        if (converterDecodingInput != null && converterDecodingInput.EncodingChanged)
                        {
                            goto Block_7;
                        }
                        array = this.parseBuffer;
                        num2  = this.parseCurrent;
                        num3  = this.parseEnd;
                        if (this.input.EndOfFile)
                        {
                            this.endOfFile = true;
                        }
                        if (!this.endOfFile && num3 - this.parseStart < this.input.MaxTokenSize)
                        {
                            continue;
                        }
                    }
                    flag = true;
                }
                char      c         = array[num2];
                CharClass charClass = ParseSupport.GetCharClass(c);
                if (ParseSupport.InvalidUnicodeCharacter(charClass) || num4 > 1)
                {
                    if (!this.SkipInvalidCharacters(ref c, ref charClass, ref num2))
                    {
                        num3 = this.parseEnd;
                        if (!flag)
                        {
                            continue;
                        }
                        if (num2 == num3 && !htmlTokenBuilder.IsStarted && this.endOfFile)
                        {
                            goto IL_695;
                        }
                    }
                    num3 = this.parseEnd;
                    num4 = (this.parseThreshold = 1);
                }
                num5 = num2;
                switch (this.parseState)
                {
                case EnrichedParser.ParseState.Text:
                    htmlTokenBuilder.StartText(num5);
                    goto IL_1F9;

                case EnrichedParser.ParseState.Tag:
                    if (this.parseEnd - this.parseCurrent < 17 && !flag)
                    {
                        num4 = (this.parseThreshold = 17);
                        continue;
                    }
                    c         = array[++num2];
                    charClass = ParseSupport.GetCharClass(c);
                    flag2     = false;
                    num6      = 1;
                    if (c == '/')
                    {
                        flag2 = true;
                        num6++;
                        c         = array[++num2];
                        charClass = ParseSupport.GetCharClass(c);
                    }
                    c = this.ScanTag(c, ref charClass, ref num2);
                    this.nameLength = num2 - (num5 + num6);
                    if (c == '>')
                    {
                        goto IL_366;
                    }
                    if (this.newLineState == EnrichedParser.NewLineState.OneNewLine)
                    {
                        goto Block_22;
                    }
                    htmlTokenBuilder.StartTag(HtmlNameIndex.Unknown, num5);
                    if (flag2)
                    {
                        htmlTokenBuilder.SetEndTag();
                    }
                    htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.TagPrefix, num5, num5 + num6);
                    htmlTokenBuilder.StartTagName();
                    if (this.nameLength != 0)
                    {
                        htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.Name, num5 + num6, num2);
                    }
                    this.parseState = EnrichedParser.ParseState.LongTag;
                    goto IL_502;

                case EnrichedParser.ParseState.LongTag:
                    if (!htmlTokenBuilder.PrepareToAddMoreRuns(2, num5, HtmlRunKind.Name))
                    {
                        goto IL_545;
                    }
                    c = this.ScanTag(c, ref charClass, ref num2);
                    if (num2 != num5)
                    {
                        this.nameLength += num2 - num5;
                        htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.Name, num5, num2);
                    }
                    if (c == '>')
                    {
                        goto Block_46;
                    }
                    goto IL_502;
                }
                goto Block_15;
IL_1F9:
                this.ParseText(c, charClass, ref num2);
                num4 = this.parseThreshold;
                if (this.token.IsEmpty && !flag)
                {
                    htmlTokenBuilder.Reset();
                    continue;
                }
                goto IL_227;
IL_502:
                if (flag && num2 + num4 >= num3)
                {
                    if (!this.endOfFile)
                    {
                        goto IL_545;
                    }
                    if (!this.token.IsTagBegin)
                    {
                        goto Block_43;
                    }
                    num2 = this.parseStart;
                    htmlTokenBuilder.Reset();
                    num5 = num2;
                    htmlTokenBuilder.StartText(num5);
                    c         = array[++num2];
                    charClass = ParseSupport.GetCharClass(c);
                    this.PrepareToAddTextRun(num5);
                    htmlTokenBuilder.AddTextRun(RunTextType.NonSpace, num5, num2);
                    this.parseState = EnrichedParser.ParseState.Text;
                    goto IL_1F9;
                }
            }
            return(HtmlTokenId.None);

Block_7:
            converterDecodingInput.EncodingChanged = false;
            return(htmlTokenBuilder.MakeEmptyToken(HtmlTokenId.EncodingChange, converterDecodingInput.Encoding));

Block_15:
            this.parseCurrent = num2;
            throw new TextConvertersException("internal error: invalid parse state");
IL_227:
            htmlTokenBuilder.EndText();
            this.parseCurrent = num2;
            return(this.token.HtmlTokenId);

Block_22:
            this.newLineState = EnrichedParser.NewLineState.None;
            htmlTokenBuilder.StartText(num5);
            htmlTokenBuilder.AddLiteralRun(RunTextType.Space, HtmlRunKind.Text, num5, num5, 32);
            htmlTokenBuilder.EndText();
            this.parseCurrent = num5;
            return(this.token.HtmlTokenId);

IL_366:
            num2++;
            HtmlNameIndex htmlNameIndex = HtmlTokenBuilder.LookupName(array, num5 + num6, this.nameLength);

            if (htmlNameIndex == HtmlNameIndex.FlushLeft || htmlNameIndex == HtmlNameIndex.FlushRight || htmlNameIndex == HtmlNameIndex.FlushBoth || htmlNameIndex == HtmlNameIndex.Center || htmlNameIndex == HtmlNameIndex.Nofill || htmlNameIndex == HtmlNameIndex.ParaIndent || htmlNameIndex == HtmlNameIndex.Excerpt)
            {
                this.newLineState = EnrichedParser.NewLineState.EatTwoNewLines;
                if (htmlNameIndex == HtmlNameIndex.Nofill)
                {
                    if (!flag2)
                    {
                        this.nofill++;
                        this.newLineState = EnrichedParser.NewLineState.None;
                    }
                    else if (this.nofill != 0)
                    {
                        this.nofill--;
                    }
                }
            }
            else
            {
                if (this.newLineState == EnrichedParser.NewLineState.OneNewLine)
                {
                    this.newLineState = EnrichedParser.NewLineState.None;
                    htmlTokenBuilder.StartText(num5);
                    htmlTokenBuilder.AddLiteralRun(RunTextType.Space, HtmlRunKind.Text, num5, num5, 32);
                    htmlTokenBuilder.EndText();
                    this.parseCurrent = num5;
                    return(this.token.HtmlTokenId);
                }
                this.newLineState = EnrichedParser.NewLineState.None;
            }
            htmlTokenBuilder.StartTag(HtmlNameIndex.Unknown, num5);
            if (flag2)
            {
                htmlTokenBuilder.SetEndTag();
            }
            htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.TagPrefix, num5, num5 + num6);
            htmlTokenBuilder.StartTagName();
            if (this.nameLength != 0)
            {
                htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.Name, num5 + num6, num2 - 1);
            }
            htmlTokenBuilder.EndTagName(htmlNameIndex);
            htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.TagSuffix, num2 - 1, num2);
            htmlTokenBuilder.EndTag(true);
            if (array[num2] != '<' || num2 + 1 == num3 || array[num2 + 1] == '<' || ParseSupport.InvalidUnicodeCharacter(ParseSupport.GetCharClass(array[num2 + 1])))
            {
                this.parseState = EnrichedParser.ParseState.Text;
            }
            this.parseCurrent = num2;
            return(this.token.HtmlTokenId);

Block_43:
            htmlTokenBuilder.EndTag(true);
            this.parseCurrent = num2;
            return(this.token.HtmlTokenId);

IL_545:
            htmlTokenBuilder.EndTag(false);
            this.parseCurrent = num2;
            return(this.token.HtmlTokenId);

Block_46:
            htmlTokenBuilder.EndTagName(this.nameLength);
            num2++;
            htmlTokenBuilder.AddRun(RunTextType.NonSpace, HtmlRunKind.TagSuffix, num2 - 1, num2);
            htmlTokenBuilder.EndTag(true);
            if (array[num2] == '<' && num2 + 1 < num3 && array[num2 + 1] != '<' && !ParseSupport.InvalidUnicodeCharacter(ParseSupport.GetCharClass(array[num2 + 1])))
            {
                this.parseState = EnrichedParser.ParseState.Tag;
            }
            else
            {
                this.parseState = EnrichedParser.ParseState.Text;
            }
            this.parseCurrent = num2;
            return(this.token.HtmlTokenId);

IL_695:
            this.parseCurrent = num2;
            return(htmlTokenBuilder.MakeEmptyToken(HtmlTokenId.EndOfFile));
        }
        // Token: 0x0600139B RID: 5019 RVA: 0x00089DF8 File Offset: 0x00087FF8
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (this.injection != null && this.injection.HaveTail)
                {
                    if (!this.output.LineEmpty)
                    {
                        this.output.OutputNewLine();
                    }
                    this.injection.Inject(false, this.output);
                }
                this.output.CloseDocument();
                this.output.Flush();
                this.endOfFile = true;
                break;

            case HtmlTokenId.Text:
                if (!this.insideParam)
                {
                    this.OutputText(this.token);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
                if (this.token.IsTagBegin)
                {
                    HtmlNameIndex nameIndex = this.token.NameIndex;
                    if (nameIndex <= HtmlNameIndex.ParaIndent)
                    {
                        if (nameIndex <= HtmlNameIndex.Param)
                        {
                            if (nameIndex != HtmlNameIndex.Nofill && nameIndex != HtmlNameIndex.FlushRight)
                            {
                                if (nameIndex != HtmlNameIndex.Param)
                                {
                                    return;
                                }
                                this.insideParam = !this.token.IsEndTag;
                                return;
                            }
                        }
                        else if (nameIndex <= HtmlNameIndex.Italic)
                        {
                            if (nameIndex != HtmlNameIndex.Color && nameIndex != HtmlNameIndex.Italic)
                            {
                                return;
                            }
                            break;
                        }
                        else
                        {
                            switch (nameIndex)
                            {
                            case HtmlNameIndex.Center:
                            case HtmlNameIndex.FlushBoth:
                                break;

                            case HtmlNameIndex.Height:
                            case HtmlNameIndex.Underline:
                                return;

                            default:
                                if (nameIndex != HtmlNameIndex.ParaIndent)
                                {
                                    return;
                                }
                                break;
                            }
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.FlushLeft)
                    {
                        if (nameIndex == HtmlNameIndex.Fixed || nameIndex == HtmlNameIndex.Smaller)
                        {
                            break;
                        }
                        switch (nameIndex)
                        {
                        case HtmlNameIndex.Bold:
                        case HtmlNameIndex.Strike:
                            return;

                        case HtmlNameIndex.FlushLeft:
                            break;

                        default:
                            return;
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.Lang)
                    {
                        if (nameIndex == HtmlNameIndex.Excerpt)
                        {
                            if (!this.output.LineEmpty)
                            {
                                this.output.OutputNewLine();
                            }
                            if (!this.token.IsEndTag)
                            {
                                this.quotingLevel++;
                            }
                            else
                            {
                                this.quotingLevel--;
                            }
                            this.output.SetQuotingLevel(this.quotingLevel);
                            return;
                        }
                        if (nameIndex != HtmlNameIndex.Lang)
                        {
                            return;
                        }
                        break;
                    }
                    else
                    {
                        if (nameIndex != HtmlNameIndex.Bigger && nameIndex != HtmlNameIndex.FontFamily)
                        {
                            return;
                        }
                        break;
                    }
                    if (!this.output.LineEmpty)
                    {
                        this.output.OutputNewLine();
                        return;
                    }
                }
                break;

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

            default:
                return;
            }
        }
Ejemplo n.º 27
0
        private void Process(HtmlTokenId tokenId)
        {
            this.token = this.parser.Token;
            switch (tokenId)
            {
            case HtmlTokenId.EndOfFile:
                if (this.injection != null)
                {
                    bool haveHead = this.injection.HaveHead;
                }
                base.CloseAllContainersAndSetEOF();
                if (this.output != null)
                {
                    this.output.Flush();
                }
                break;

            case HtmlTokenId.Text:
                if (!this.insideParam)
                {
                    this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                    this.OutputText(this.token);
                    return;
                }
                if (this.tagPendingParameter != HtmlNameIndex._NOTANAME)
                {
                    this.scratch.AppendTokenText(this.token, 256);
                    return;
                }
                break;

            case HtmlTokenId.EncodingChange:
                if (this.output != null && this.output.OutputCodePageSameAsInput)
                {
                    this.output.OutputEncoding = this.token.TokenEncoding;
                    return;
                }
                break;

            case HtmlTokenId.Tag:
                if (this.token.IsTagBegin)
                {
                    if (this.token.IsEndTag)
                    {
                        if (this.token.NameIndex == HtmlNameIndex.Param)
                        {
                            if (this.insideParam)
                            {
                                HtmlNameIndex htmlNameIndex = this.tagPendingParameter;
                                if (htmlNameIndex <= HtmlNameIndex.ParaIndent)
                                {
                                    if (htmlNameIndex != HtmlNameIndex.Color)
                                    {
                                        if (htmlNameIndex == HtmlNameIndex.ParaIndent)
                                        {
                                            BufferString bufferString = this.scratch.BufferString;
                                            bufferString.TrimWhitespace();
                                            int num  = 0;
                                            int num2 = 0;
                                            int num3 = 0;
                                            int num4 = 0;
                                            int num6;
                                            for (int num5 = 0; num5 != bufferString.Length; num5 = num6)
                                            {
                                                int i = num5;
                                                num6 = num5;
                                                while (i < bufferString.Length)
                                                {
                                                    if (bufferString[i] == ',')
                                                    {
                                                        break;
                                                    }
                                                    i++;
                                                    num6++;
                                                }
                                                while (i > num5 && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(bufferString[i - 1])))
                                                {
                                                    i--;
                                                }
                                                if (num6 < bufferString.Length)
                                                {
                                                    do
                                                    {
                                                        num6++;
                                                    }while (num6 < bufferString.Length && ParseSupport.WhitespaceCharacter(ParseSupport.GetCharClass(bufferString[num6])));
                                                }
                                                BufferString bufferString2 = bufferString.SubString(num5, i - num5);
                                                if (bufferString2.EqualsToLowerCaseStringIgnoreCase("left"))
                                                {
                                                    num++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("right"))
                                                {
                                                    num2++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("in"))
                                                {
                                                    num3++;
                                                }
                                                else if (bufferString2.EqualsToLowerCaseStringIgnoreCase("out"))
                                                {
                                                    num4++;
                                                }
                                            }
                                            if (num + num4 != 0)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.LeftPadding, new PropertyValue(LengthUnits.Points, 30 * (num + num4) - ((this.indentLevel == 0) ? 12 : 0)));
                                            }
                                            if (num3 - num4 != 0)
                                            {
                                                if (num3 - num4 > 0)
                                                {
                                                    base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FirstLineIndent, new PropertyValue(LengthUnits.Points, 30 * (num3 - num4) - ((this.indentLevel == 0 && num + num4 == 0) ? 12 : 0)));
                                                }
                                                else
                                                {
                                                    base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FirstLineIndent, new PropertyValue(LengthUnits.Points, 30 * (num3 - num4) + ((this.indentLevel == 0 && num4 - num3 == num + num4) ? 12 : 0)));
                                                }
                                            }
                                            if (num2 != 0)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.RightPadding, new PropertyValue(LengthUnits.Points, 30 * num2));
                                            }
                                            if (num + num4 != 0 && this.indentLevel == 0)
                                            {
                                                this.indentLevel++;
                                            }
                                        }
                                    }
                                    else
                                    {
                                        PropertyValue value = HtmlSupport.ParseColor(this.scratch.BufferString, true, false);
                                        if (value.IsColor)
                                        {
                                            if (value.Color.Red > 250U && value.Color.Green > 250U && value.Color.Blue > 250U)
                                            {
                                                value = new PropertyValue(PropertyType.Color, 14737632U);
                                            }
                                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontColor, value);
                                        }
                                    }
                                }
                                else if (htmlNameIndex != HtmlNameIndex.Excerpt)
                                {
                                    if (htmlNameIndex != HtmlNameIndex.Lang)
                                    {
                                        if (htmlNameIndex == HtmlNameIndex.FontFamily)
                                        {
                                            PropertyValue value = HtmlSupport.ParseFontFace(this.scratch.BufferString, this);
                                            if (!value.IsNull)
                                            {
                                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontFace, value);
                                            }
                                        }
                                    }
                                    else
                                    {
                                        PropertyValue value = HtmlSupport.ParseLanguage(this.scratch.BufferString, null);
                                        if (!value.IsNull)
                                        {
                                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.Language, value);
                                        }
                                    }
                                }
                                this.insideParam = false;
                            }
                        }
                        else if (this.token.NameIndex != HtmlNameIndex.Unknown)
                        {
                            if (this.token.NameIndex == HtmlNameIndex.ParaIndent && this.indentLevel != 0)
                            {
                                this.indentLevel--;
                            }
                            base.CloseContainer(this.token.NameIndex);
                        }
                        this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                        return;
                    }
                    HtmlNameIndex nameIndex = this.token.NameIndex;
                    if (nameIndex <= HtmlNameIndex.ParaIndent)
                    {
                        if (nameIndex <= HtmlNameIndex.Param)
                        {
                            if (nameIndex == HtmlNameIndex.Nofill)
                            {
                                base.OpenContainer(FormatContainerType.Block, false, 2, base.GetStyle(14), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.FlushRight)
                            {
                                base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Right));
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.Param)
                            {
                                this.insideParam = true;
                                this.scratch.Reset();
                                return;
                            }
                        }
                        else if (nameIndex <= HtmlNameIndex.Italic)
                        {
                            if (nameIndex == HtmlNameIndex.Color)
                            {
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex.Color;
                                return;
                            }
                            if (nameIndex == HtmlNameIndex.Italic)
                            {
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(4), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;
                            }
                        }
                        else
                        {
                            switch (nameIndex)
                            {
                            case HtmlNameIndex.Center:
                                base.OpenContainer(FormatContainerType.Block, false, 2, base.GetStyle(13), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            case HtmlNameIndex.Height:
                                break;

                            case HtmlNameIndex.Underline:
                                base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(5), this.token.NameIndex);
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            case HtmlNameIndex.FlushBoth:
                                base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Justify));
                                this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                                return;

                            default:
                                if (nameIndex == HtmlNameIndex.ParaIndent)
                                {
                                    base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                                    this.tagPendingParameter = HtmlNameIndex.ParaIndent;
                                    if (this.indentLevel != 0)
                                    {
                                        this.indentLevel++;
                                        return;
                                    }
                                    return;
                                }
                                break;
                            }
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.FlushLeft)
                    {
                        if (nameIndex == HtmlNameIndex.Fixed)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(10), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.Smaller)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontSize, new PropertyValue(PropertyType.RelHtmlFontUnits, -1));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        switch (nameIndex)
                        {
                        case HtmlNameIndex.Bold:
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(1), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;

                        case HtmlNameIndex.FlushLeft:
                            base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.TextAlignment, new PropertyValue(TextAlign.Left));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                    }
                    else if (nameIndex <= HtmlNameIndex.Lang)
                    {
                        if (nameIndex == HtmlNameIndex.Excerpt)
                        {
                            base.OpenContainer(FormatContainerType.Block, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.QuotingLevelDelta, new PropertyValue(PropertyType.Integer, 1));
                            this.tagPendingParameter = HtmlNameIndex.Excerpt;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.Lang)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, base.GetStyle(6), this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex.Lang;
                            return;
                        }
                    }
                    else
                    {
                        if (nameIndex == HtmlNameIndex.Bigger)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            base.Last.SetProperty(PropertyPrecedence.InlineStyle, PropertyId.FontSize, new PropertyValue(PropertyType.RelHtmlFontUnits, 1));
                            this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                            return;
                        }
                        if (nameIndex == HtmlNameIndex.FontFamily)
                        {
                            base.OpenContainer(FormatContainerType.PropertyContainer, false, 2, FormatStyle.Null, this.token.NameIndex);
                            this.tagPendingParameter = HtmlNameIndex.FontFamily;
                            return;
                        }
                    }
                    this.tagPendingParameter = HtmlNameIndex._NOTANAME;
                    return;
                }
                break;

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

            default:
                return;
            }
        }
Ejemplo n.º 28
0
 // Token: 0x06001480 RID: 5248 RVA: 0x00092886 File Offset: 0x00090A86
 public new void InitializeTag(bool isEndTag, HtmlNameIndex tagNameIndex, bool tagDropped)
 {
     base.InitializeTag(isEndTag, tagNameIndex, tagDropped);
     this.countAttributes = 0;
 }
Ejemplo n.º 29
0
        public FormatConverterContainer OpenContainer(FormatContainerType nodeType, bool empty, int inheritanceMaskIndex, FormatStyle baseStyle, HtmlNameIndex tagName)
        {
            if (!this.ContainerFlushed)
            {
                this.FlushContainer(this.EmptyContainer ? this.BuildStackTop : (this.BuildStackTop - 1));
            }
            if (this.EmptyContainer)
            {
                this.PrepareToCloseContainer(this.BuildStackTop);
            }
            int num = this.PushContainer(nodeType, empty, inheritanceMaskIndex);

            if (!baseStyle.IsNull)
            {
                baseStyle.AddRef();
                this.ContainerStyleBuildHelper.AddStyle(10, baseStyle.Handle);
            }
            this.BuildStack[num].TagName = tagName;
            return(new FormatConverterContainer(this, num));
        }
Ejemplo n.º 30
0
 // Token: 0x060014E3 RID: 5347 RVA: 0x00096779 File Offset: 0x00094979
 public HtmlAttributeInstruction(HtmlNameIndex attributeNameId, PropertyId propertyId, PropertyValueParsingMethod parsingMethod)
 {
     this.attributeNameId = attributeNameId;
     this.propertyId      = propertyId;
     this.parsingMethod   = parsingMethod;
 }