Changeset 61973 in webkit


Ignore:
Timestamp:
Jun 27, 2010 3:45:17 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-06-27 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Implement remaining StartTag processing for InHeadNoscriptMode
https://bugs.webkit.org/show_bug.cgi?id=41264

The InHeadNoscriptMode processes some start tags "as if" the tree
builder were in the InHeadMode. This is an idiom we'll see more of
later. My approach is this patch is to factor all the logic for
processing start tags in the InHeadMode into a separate function that
can be called from both locations. This seems cleaner than just
splitting out the parts that are actually used by both modes.

  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processStartTag): (WebCore::HTMLTreeBuilder::processStartTagForInHead): (WebCore::HTMLTreeBuilder::insertSelfClosingElement):
  • html/HTMLTreeBuilder.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r61972 r61973  
     12010-06-27  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Implement remaining StartTag processing for InHeadNoscriptMode
     6        https://bugs.webkit.org/show_bug.cgi?id=41264
     7
     8        The InHeadNoscriptMode processes some start tags "as if" the tree
     9        builder were in the InHeadMode.  This is an idiom we'll see more of
     10        later.  My approach is this patch is to factor all the logic for
     11        processing start tags in the InHeadMode into a separate function that
     12        can be called from both locations.  This seems cleaner than just
     13        splitting out the parts that are actually used by both modes.
     14
     15        * html/HTMLTreeBuilder.cpp:
     16        (WebCore::HTMLTreeBuilder::processStartTag):
     17        (WebCore::HTMLTreeBuilder::processStartTagForInHead):
     18        (WebCore::HTMLTreeBuilder::insertSelfClosingElement):
     19        * html/HTMLTreeBuilder.h:
     20
    1212010-06-27  Adam Barth  <abarth@webkit.org>
    222
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r61972 r61973  
    318318    case InHeadMode:
    319319        ASSERT(insertionMode() == InHeadMode);
    320         if (token.name() == htmlTag) {
    321             insertHTMLStartTagInBody(token);
    322             return;
    323         }
    324         // FIXME: Atomize "command".
    325         if (token.name() == baseTag || token.name() == "command" || token.name() == linkTag) {
    326             insertElement(token);
    327             m_openElements.pop();
    328             notImplemented();
    329             return;
    330         }
    331         if (token.name() == metaTag) {
    332             insertElement(token);
    333             m_openElements.pop();
    334             notImplemented();
    335             return;
    336         }
    337         if (token.name() == titleTag) {
    338             insertGenericRCDATAElement(token);
    339             return;
    340         }
    341         if (token.name() == noscriptTag) {
    342             if (isScriptingFlagEnabled(m_document->frame())) {
    343                 insertGenericRawTextElement(token);
    344                 return;
    345             }
    346             insertElement(token);
    347             setInsertionMode(InHeadNoscriptMode);
    348             return;
    349         }
    350         if (token.name() == noframesTag || token.name() == styleTag) {
    351             insertGenericRawTextElement(token);
    352             return;
    353         }
    354         if (token.name() == scriptTag) {
    355             insertScriptElement(token);
    356             return;
    357         }
    358         if (token.name() == headTag) {
    359             notImplemented();
    360             return;
    361         }
     320        if (processStartTagForInHead(token))
     321            return;
    362322        processDefaultForInHeadMode(token);
    363323        // Fall through.
     
    403363        }
    404364        if (token.name() == linkTag || token.name() == metaTag || token.name() == noframesTag || token.name() == styleTag) {
    405             notImplemented();
     365            bool didProcess = processStartTagForInHead(token);
     366            ASSERT_UNUSED(didProcess, didProcess);
    406367            return;
    407368        }
     
    594555}
    595556
     557bool HTMLTreeBuilder::processStartTagForInHead(AtomicHTMLToken& token)
     558{
     559    if (token.name() == htmlTag) {
     560        insertHTMLStartTagInBody(token);
     561        return true;
     562    }
     563    // FIXME: Atomize "command".
     564    if (token.name() == baseTag || token.name() == "command" || token.name() == linkTag || token.name() == metaTag) {
     565        insertSelfClosingElement(token);
     566        // Note: The custom processing for the <meta> tag is done in HTMLMetaElement::process().
     567        return true;
     568    }
     569    if (token.name() == titleTag) {
     570        insertGenericRCDATAElement(token);
     571        return true;
     572    }
     573    if (token.name() == noscriptTag) {
     574        if (isScriptingFlagEnabled(m_document->frame())) {
     575            insertGenericRawTextElement(token);
     576            return true;
     577        }
     578        insertElement(token);
     579        setInsertionMode(InHeadNoscriptMode);
     580        return true;
     581    }
     582    if (token.name() == noframesTag || token.name() == styleTag) {
     583        insertGenericRawTextElement(token);
     584        return true;
     585    }
     586    if (token.name() == scriptTag) {
     587        insertScriptElement(token);
     588        return true;
     589    }
     590    if (token.name() == headTag) {
     591        parseError(token);
     592        return true;
     593    }
     594    return false;
     595}
     596
    596597void HTMLTreeBuilder::insertDoctype(AtomicHTMLToken& token)
    597598{
     
    617618    currentElement()->addChild(element);
    618619    m_openElements.push(element.release());
     620}
     621
     622void HTMLTreeBuilder::insertSelfClosingElement(AtomicHTMLToken& token)
     623{
     624    ASSERT(token.type() == HTMLToken::StartTag);
     625    insertElement(token);
     626    m_openElements.pop();
     627    // FIXME: Do we want to acknowledge the token's self-closing flag?
     628    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#acknowledge-self-closing-flag
    619629}
    620630
  • trunk/WebCore/html/HTMLTreeBuilder.h

    r61966 r61973  
    174174    void processDefaultForAfterHeadMode(AtomicHTMLToken&);
    175175
     176    bool processStartTagForInHead(AtomicHTMLToken&);
     177
    176178    void insertDoctype(AtomicHTMLToken&);
    177179    void insertComment(AtomicHTMLToken&);
    178180    void insertElement(AtomicHTMLToken&);
     181    void insertSelfClosingElement(AtomicHTMLToken&);
    179182    void insertCharacter(UChar cc);
    180183    void insertGenericRCDATAElement(AtomicHTMLToken&);
Note: See TracChangeset for help on using the changeset viewer.