Changeset 62474 in webkit


Ignore:
Timestamp:
Jul 4, 2010 9:45:30 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-07-04 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Add basic "in table body" mode to support <tr> insertion
https://bugs.webkit.org/show_bug.cgi?id=41587

  • html5lib/runner-expected-html5.txt:
    • <tr> tags now show up, imagine that.

2010-07-04 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Add basic "in table body" mode to support <tr> insertion
https://bugs.webkit.org/show_bug.cgi?id=41587

This also adds a (currently untestable?)
popUntilTableBodyScopeMarker code path.
Any tags which would be between a tbody a <tr> would end up
foster parented outside the <table>. I think the spec was
just being over-cautious with popUntilTableBodyScopeMarker.

  • html/HTMLElementStack.cpp: (WebCore::HTMLNames::isTableScopeMarker): (WebCore::HTMLNames::isTableBodyScopeMarker): (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker):
  • html/HTMLElementStack.h:
  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processStartTag): (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r62473 r62474  
     12010-07-04  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add basic "in table body" mode to support <tr> insertion
     6        https://bugs.webkit.org/show_bug.cgi?id=41587
     7
     8        * html5lib/runner-expected-html5.txt:
     9         - <tr> tags now show up, imagine that.
     10
    1112010-07-04  Peter Kasting  <pkasting@google.com>
    212
  • trunk/LayoutTests/html5lib/runner-expected-html5.txt

    r62469 r62474  
    13461346|     <table>
    13471347|       <tbody>
     1348|         <tr>
    13481349Expected:
    13491350| <html>
     
    26022603|     <table>
    26032604|       <tbody>
     2605|         <tr>
    26042606Expected:
    26052607| <!DOCTYPE html>
     
    32323234|     <table>
    32333235|       <tbody>
     3236|         <tr>
    32343237Expected:
    32353238| <!DOCTYPE html>
     
    32553258|     <table>
    32563259|       <tbody>
     3260|         <tr>
    32573261Expected:
    32583262| <!DOCTYPE html>
     
    32793283|     <table>
    32803284|       <tbody>
     3285|         <tr>
    32813286Expected:
    32823287| <!DOCTYPE html>
     
    37423747|     <table>
    37433748|       <tbody>
     3749|         <tr>
    37443750Expected:
    37453751| <!DOCTYPE html>
     
    37653771|     <table>
    37663772|       <tbody>
     3773|         <tr>
    37673774Expected:
    37683775| <!DOCTYPE html>
     
    37893796|     <table>
    37903797|       <tbody>
     3798|         <tr>
    37913799Expected:
    37923800| <!DOCTYPE html>
  • trunk/WebCore/ChangeLog

    r62472 r62474  
     12010-07-04  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Add basic "in table body" mode to support <tr> insertion
     6        https://bugs.webkit.org/show_bug.cgi?id=41587
     7
     8        This also adds a (currently untestable?)
     9        popUntilTableBodyScopeMarker code path.
     10        Any tags which would be between a tbody a <tr> would end up
     11        foster parented outside the <table>.  I think the spec was
     12        just being over-cautious with popUntilTableBodyScopeMarker.
     13
     14        * html/HTMLElementStack.cpp:
     15        (WebCore::HTMLNames::isTableScopeMarker):
     16        (WebCore::HTMLNames::isTableBodyScopeMarker):
     17        (WebCore::HTMLElementStack::popUntilTableBodyScopeMarker):
     18        * html/HTMLElementStack.h:
     19        * html/HTMLTreeBuilder.cpp:
     20        (WebCore::HTMLTreeBuilder::processStartTag):
     21        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
     22
    1232010-07-04  Anders Carlsson  <andersca@apple.com>
    224
  • trunk/WebCore/html/HTMLElementStack.cpp

    r62469 r62474  
    6565inline bool isTableScopeMarker(Element* element)
    6666{
    67     return element->hasTagName(htmlTag)
    68         || element->hasTagName(tableTag);
     67    return element->hasTagName(tableTag)
     68        || element->hasTagName(htmlTag);
     69}
     70
     71inline bool isTableBodyScopeMarker(Element* element)
     72{
     73    return element->hasTagName(tbodyTag)
     74        || element->hasTagName(tfootTag)
     75        || element->hasTagName(theadTag)
     76        || element->hasTagName(htmlTag);
    6977}
    7078
     
    148156    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-context
    149157    while (!isTableScopeMarker(top()))
     158        pop();
     159}
     160
     161void HTMLElementStack::popUntilTableBodyScopeMarker()
     162{
     163    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tokenization.html#clear-the-stack-back-to-a-table-body-context
     164    while (!isTableBodyScopeMarker(top()))
    150165        pop();
    151166}
  • trunk/WebCore/html/HTMLElementStack.h

    r62469 r62474  
    8484    void popUntil(Element*);
    8585    void popUntilTableScopeMarker(); // "clear the stack back to a table context" in the spec.
     86    void popUntilTableBodyScopeMarker(); // "clear the stack back to a table body context" in the spec.
    8687    void popHTMLHeadElement();
    8788    void popHTMLBodyElement();
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r62470 r62474  
    7676        || tagName == h5Tag
    7777        || tagName == h6Tag;
     78}
     79
     80bool isTableBodyContextTag(const AtomicString& tagName)
     81{
     82    return tagName == tbodyTag
     83        || tagName == tfootTag
     84        || tagName == theadTag;
    7885}
    7986
     
    135142        || tagName == selectTag
    136143        || tagName == styleTag
    137         || tagName == tbodyTag
     144        || isTableBodyContextTag(tagName)
    138145        || tagName == textareaTag
    139         || tagName == tfootTag
    140         || tagName == theadTag
    141146        || tagName == titleTag
    142147        || tagName == trTag
     
    745750            return;
    746751        }
    747         if (token.name() == tbodyTag || token.name() == tfootTag || token.name() == theadTag) {
     752        if (isTableBodyContextTag(token.name())) {
    748753            m_openElements.popUntilTableScopeMarker();
    749754            insertElement(token);
     
    776781        parseError(token);
    777782        notImplemented();
     783        break;
     784    case InTableBodyMode:
     785        ASSERT(insertionMode() == InTableBodyMode);
     786        if (token.name() == trTag) {
     787            m_openElements.popUntilTableBodyScopeMarker(); // How is there ever anything to pop?
     788            insertElement(token);
     789            m_insertionMode = InRowMode;
     790            return;
     791        }
     792        if (token.name() == thTag || token.name() == tdTag) {
     793            parseError(token);
     794            AtomicHTMLToken fakeToken(HTMLToken::StartTag, trTag.localName());
     795            processStartTag(fakeToken);
     796            ASSERT(insertionMode() == InRowMode);
     797            processStartTag(token);
     798            return;
     799        }
     800        if (token.name() == captionTag || token.name() == colTag || token.name() == colgroupTag || isTableBodyContextTag(token.name())) {
     801            // FIXME: The spec is unclear as to what is supposed to happen here.
     802            notImplemented();
     803            return;
     804        }
     805        notImplemented(); // process using "in table" rules
    778806        break;
    779807    case AfterBodyMode:
     
    9811009        const AtomicString& commonAncestorTag = commonAncestor->localName();
    9821010        if (commonAncestorTag == tableTag
    983             || commonAncestorTag == tbodyTag
    984             || commonAncestorTag == tfootTag
    985             || commonAncestorTag == theadTag
    986             || commonAncestorTag == trTag)
     1011            || commonAncestorTag == trTag
     1012            || isTableBodyContextTag(commonAncestorTag))
    9871013            findFosterParentFor(lastNode->element());
    9881014        else {
Note: See TracChangeset for help on using the changeset viewer.