Changeset 128373 in webkit


Ignore:
Timestamp:
Sep 12, 2012 3:40:15 PM (12 years ago)
Author:
eric@webkit.org
Message:

HTML parser fails to propertly close 4 identical nested formatting elements
https://bugs.webkit.org/show_bug.cgi?id=96385

Reviewed by Adam Barth.

Add missing Adoption agency step 4.a to fix one of our two outlying Adoption Agency bugs.
This is the same step that Opera was missing (must have been recently added to the spec).

  • html/parser/HTMLTreeBuilder.cpp:

(WebCore::HTMLTreeBuilder::callTheAdoptionAgency):

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/html5lib/runner-expected.txt

    r128359 r128373  
    1010resources/adoption01.dat:
    111114
    12 16
    1312
    1413Test 14 of 17 in resources/adoption01.dat failed. Input:
     
    6665|                         <div>
    6766|                           <div>
    68 
    69 Test 16 of 17 in resources/adoption01.dat failed. Input:
    70 <b><b><b><b>x</b></b></b></b>y
    71 Got:
    72 | <html>
    73 |   <head>
    74 |   <body>
    75 |     <b>
    76 |       <b>
    77 |         <b>
    78 |           <b>
    79 |             "x"
    80 |       "y"
    81 Expected:
    82 | <html>
    83 |   <head>
    84 |   <body>
    85 |     <b>
    86 |       <b>
    87 |         <b>
    88 |           <b>
    89 |             "x"
    90 |     "y"
    9167resources/adoption02.dat: PASS
    9268
  • trunk/Source/WebCore/ChangeLog

    r128372 r128373  
     12012-09-12  Eric Seidel  <eric@webkit.org>
     2
     3        HTML parser fails to propertly close 4 identical nested formatting elements
     4        https://bugs.webkit.org/show_bug.cgi?id=96385
     5
     6        Reviewed by Adam Barth.
     7
     8        Add missing Adoption agency step 4.a to fix one of our two outlying Adoption Agency bugs.
     9        This is the same step that Opera was missing (must have been recently added to the spec).
     10
     11        * html/parser/HTMLTreeBuilder.cpp:
     12        (WebCore::HTMLTreeBuilder::callTheAdoptionAgency):
     13
    1142012-09-12  Siraj Razick  <siraj.razick@collabora.co.uk>
    215
  • trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp

    r126355 r128373  
    14211421    static const int innerIterationLimit = 3;
    14221422
     1423    // 1, 2, 3 and 16 are covered by the for() loop.
    14231424    for (int i = 0; i < outerIterationLimit; ++i) {
    1424         // 1.
     1425        // 4.
    14251426        Element* formattingElement = m_tree.activeFormattingElements()->closestElementInScopeWithName(token->name());
    1426         if (!formattingElement || ((m_tree.openElements()->contains(formattingElement)) && !m_tree.openElements()->inScope(formattingElement))) {
     1427        // 4.a
     1428        if (!formattingElement)
     1429            return processAnyOtherEndTagForInBody(token);
     1430        // 4.c
     1431        if ((m_tree.openElements()->contains(formattingElement)) && !m_tree.openElements()->inScope(formattingElement)) {
    14271432            parseError(token);
    14281433            notImplemented(); // Check the stack of open elements for a more specific parse error.
    14291434            return;
    14301435        }
     1436        // 4.b
    14311437        HTMLElementStack::ElementRecord* formattingElementRecord = m_tree.openElements()->find(formattingElement);
    14321438        if (!formattingElementRecord) {
     
    14351441            return;
    14361442        }
     1443        // 4.d
    14371444        if (formattingElement != m_tree.currentElement())
    14381445            parseError(token);
    1439         // 2.
     1446        // 5.
    14401447        HTMLElementStack::ElementRecord* furthestBlock = m_tree.openElements()->furthestBlockForFormattingElement(formattingElement);
    1441         // 3.
     1448        // 6.
    14421449        if (!furthestBlock) {
    14431450            m_tree.openElements()->popUntilPopped(formattingElement);
     
    14451452            return;
    14461453        }
    1447         // 4.
     1454        // 7.
    14481455        ASSERT(furthestBlock->isAbove(formattingElementRecord));
    14491456        RefPtr<HTMLStackItem> commonAncestor = formattingElementRecord->next()->stackItem();
    1450         // 5.
     1457        // 8.
    14511458        HTMLFormattingElementList::Bookmark bookmark = m_tree.activeFormattingElements()->bookmarkFor(formattingElement);
    1452         // 6.
     1459        // 9.
    14531460        HTMLElementStack::ElementRecord* node = furthestBlock;
    14541461        HTMLElementStack::ElementRecord* nextNode = node->next();
    14551462        HTMLElementStack::ElementRecord* lastNode = furthestBlock;
     1463        // 9.1, 9.2, 9.3 and 9.11 are covered by the for() loop.
    14561464        for (int i = 0; i < innerIterationLimit; ++i) {
    1457             // 6.1
     1465            // 9.4
    14581466            node = nextNode;
    14591467            ASSERT(node);
    1460             nextNode = node->next(); // Save node->next() for the next iteration in case node is deleted in 6.2.
    1461             // 6.2
     1468            nextNode = node->next(); // Save node->next() for the next iteration in case node is deleted in 9.5.
     1469            // 9.5
    14621470            if (!m_tree.activeFormattingElements()->contains(node->element())) {
    14631471                m_tree.openElements()->remove(node->element());
     
    14651473                continue;
    14661474            }
    1467             // 6.3
     1475            // 9.6
    14681476            if (node == formattingElementRecord)
    14691477                break;
    1470             // 6.5
     1478            // 9.7
    14711479            RefPtr<HTMLStackItem> newItem = m_tree.createElementFromSavedToken(node->stackItem().get());
    14721480
     
    14741482            nodeEntry->replaceElement(newItem);
    14751483            node->replaceElement(newItem.release());
    1476             // 6.4 -- Intentionally out of order to handle the case where node
    1477             // was replaced in 6.5.
    1478             // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10096
     1484
     1485            // 9.8
    14791486            if (lastNode == furthestBlock)
    14801487                bookmark.moveToAfter(nodeEntry);
    1481             // 6.6
     1488            // 9.9
    14821489            if (ContainerNode* parent = lastNode->element()->parentNode())
    14831490                parent->parserRemoveChild(lastNode->element());
     
    14851492            if (lastNode->element()->parentElement()->attached() && !lastNode->element()->attached())
    14861493                lastNode->element()->lazyAttach();
    1487             // 6.7
     1494            // 9.10
    14881495            lastNode = node;
    14891496        }
    1490         // 7
     1497        // 10.
    14911498        if (ContainerNode* parent = lastNode->element()->parentNode())
    14921499            parent->parserRemoveChild(lastNode->element());
     
    15001507                lastNode->element()->lazyAttach();
    15011508        }
    1502         // 8
     1509        // 11.
    15031510        RefPtr<HTMLStackItem> newItem = m_tree.createElementFromSavedToken(formattingElementRecord->stackItem().get());
    1504         // 9
     1511        // 12.
    15051512        newItem->element()->takeAllChildrenFrom(furthestBlock->element());
    1506         // 10
     1513        // 13.
    15071514        Element* furthestBlockElement = furthestBlock->element();
    15081515        // FIXME: All this creation / parserAddChild / attach business should
    1509         //        be in HTMLConstructionSite.  My guess is that steps 8--12
     1516        //        be in HTMLConstructionSite. My guess is that steps 11--15
    15101517        //        should all be in some HTMLConstructionSite function.
    15111518        furthestBlockElement->parserAddChild(newItem->element());
     1519        // FIXME: Why is this attach logic necessary? Style resolve should attach us if needed.
    15121520        if (furthestBlockElement->attached() && !newItem->element()->attached()) {
    15131521            // Notice that newItem->element() might already be attached if, for example, one of the reparented
     
    15151523            newItem->element()->attach();
    15161524        }
    1517         // 11
     1525        // 14.
    15181526        m_tree.activeFormattingElements()->swapTo(formattingElement, newItem, bookmark);
    1519         // 12
     1527        // 15.
    15201528        m_tree.openElements()->remove(formattingElement);
    15211529        m_tree.openElements()->insertAbove(newItem, furthestBlock);
Note: See TracChangeset for help on using the changeset viewer.