Changeset 65134 in webkit


Ignore:
Timestamp:
Aug 11, 2010 12:51:08 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-08-10 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
https://bugs.webkit.org/show_bug.cgi?id=43762

In fixing the insertAdjacentHTML I had to make small changes to
the error logic, which ended up bringing us closer to HTML5.

Test: fast/dom/HTMLElement/insertAdjacentHTML-errors.html

  • html/HTMLConstructionSite.cpp: (WebCore::HTMLConstructionSite::attach):
    • This ASSERT was just wrong, the child should not be attached in the case the parent is not attached.
  • html/HTMLElement.cpp: (WebCore::contextElementForInsertion):
    • This is part of HTML5, needed to know what to call the HTML or XML parsers with. The previous code always passed "this" which is wrong in the case of beforeBegin or afterEnd insertion.

(WebCore::HTMLElement::insertAdjacentHTML):

  • Use the right contextElement now that we know how to compute it.
  • html/HTMLTreeBuilder.cpp: (WebCore::HTMLTreeBuilder::processEndTagForInCell):
    • This ASSERT is direct from the spec, but it's wrong, so I've filed a spec bug.

2010-08-10 Eric Seidel <eric@webkit.org>

Reviewed by Adam Barth.

Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
https://bugs.webkit.org/show_bug.cgi?id=43762

In order to fix the insertAdjacentHTML I had to some behavior.
The behavior I changed brings us closer to the HTML5 spec,
but since it was not previously tested, I added tests.

  • fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt: Added.
  • fast/dom/HTMLElement/insertAdjacentHTML-errors.html: Added.
Location:
trunk
Files:
5 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65131 r65134  
     12010-08-10  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
     6        https://bugs.webkit.org/show_bug.cgi?id=43762
     7
     8        In order to fix the insertAdjacentHTML I had to some behavior.
     9        The behavior I changed brings us closer to the HTML5 spec,
     10        but since it was not previously tested, I added tests.
     11
     12        * fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt: Added.
     13        * fast/dom/HTMLElement/insertAdjacentHTML-errors.html: Added.
     14
    1152010-08-11  Yoshiki Hayashi  <yhayashi@google.com>
    216
     
    213227        * fast/dom/HTMLElement/insertAdjacentHTML-errors-expected.txt: Added.
    214228        * fast/dom/HTMLElement/insertAdjacentHTML-errors.html: Added.
     229        * fast/dom/HTMLElement/script-tests/TEMPLATE.html: Added.
     230        * fast/dom/HTMLElement/script-tests/insertAdjacentHTML-errors.js: Added.
     231        * fast/dynamic/insertAdjacentHTML-expected.txt:
     232         - Updated to match HTML5's expected exception on error.
    215233
    2162342010-08-10  MORITA Hajime  <morrita@google.com>
  • trunk/LayoutTests/fast/dynamic/insertAdjacentHTML-expected.txt

    r34543 r65134  
    1 Caught expected exception: Error: NOT_SUPPORTED_ERR: DOM Exception 9
     1Caught expected exception: Error: SYNTAX_ERR: DOM Exception 12
    221 (black) 2 (green) 3 (green) 4 (black)
    33
  • trunk/WebCore/ChangeLog

    r65133 r65134  
     12010-08-10  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by Adam Barth.
     4
     5        Fix three ASSERTs hit with the HTML5 TreeBuilder in fragment mode
     6        https://bugs.webkit.org/show_bug.cgi?id=43762
     7
     8        In fixing the insertAdjacentHTML I had to make small changes to
     9        the error logic, which ended up bringing us closer to HTML5.
     10
     11        Test: fast/dom/HTMLElement/insertAdjacentHTML-errors.html
     12
     13        * html/HTMLConstructionSite.cpp:
     14        (WebCore::HTMLConstructionSite::attach):
     15         - This ASSERT was just wrong, the child should not be attached
     16           in the case the parent is not attached.
     17        * html/HTMLElement.cpp:
     18        (WebCore::contextElementForInsertion):
     19         - This is part of HTML5, needed to know what to call the
     20           HTML or XML parsers with.  The previous code always passed
     21           "this" which is wrong in the case of beforeBegin or afterEnd insertion.
     22        (WebCore::HTMLElement::insertAdjacentHTML):
     23         - Use the right contextElement now that we know how to compute it.
     24        * html/HTMLTreeBuilder.cpp:
     25        (WebCore::HTMLTreeBuilder::processEndTagForInCell):
     26         - This ASSERT is direct from the spec, but it's wrong, so I've filed a spec bug.
     27
    1282010-08-11  Adam Barth  <abarth@webkit.org>
    229
  • trunk/WebCore/html/HTMLConstructionSite.cpp

    r65064 r65134  
    9494    if (shouldFosterParent()) {
    9595        fosterParent(child.get());
    96         ASSERT(child->attached());
     96        ASSERT(child->attached() || !child->parent()->attached());
    9797        return child.release();
    9898    }
  • trunk/WebCore/html/HTMLElement.cpp

    r65064 r65134  
    550550}
    551551
     552// Step 3 of http://www.whatwg.org/specs/web-apps/current-work/multipage/apis-in-html-documents.html#insertadjacenthtml()
     553static Element* contextElementForInsertion(const String& where, Element* element, ExceptionCode& ec)
     554{
     555    if (equalIgnoringCase(where, "beforeBegin") || equalIgnoringCase(where, "afterEnd")) {
     556        Node* parent = element->parentNode();
     557        if (parent && parent->isDocumentNode()) {
     558            ec = NO_MODIFICATION_ALLOWED_ERR;
     559            return 0;
     560        }
     561        ASSERT(!parent || parent->isElementNode());
     562        return static_cast<Element*>(parent);
     563    }
     564    if (equalIgnoringCase(where, "afterBegin") || equalIgnoringCase(where, "beforeEnd"))
     565        return element;
     566    ec =  SYNTAX_ERR;
     567    return 0;
     568}
     569
    552570void HTMLElement::insertAdjacentHTML(const String& where, const String& markup, ExceptionCode& ec)
    553571{
    554572    RefPtr<DocumentFragment> fragment = document()->createDocumentFragment();
     573    Element* contextElement = contextElementForInsertion(where, this, ec);
     574    if (!contextElement)
     575        return;
     576
    555577    if (document()->isHTMLDocument())
    556          fragment->parseHTML(markup, this);
     578         fragment->parseHTML(markup, contextElement);
    557579    else {
    558         if (!fragment->parseXML(markup, this))
     580        if (!fragment->parseXML(markup, contextElement))
    559581            // FIXME: We should propagate a syntax error exception out here.
    560582            return;
  • trunk/WebCore/html/HTMLTreeBuilder.cpp

    r65064 r65134  
    19981998        m_tree.activeFormattingElements()->clearToLastMarker();
    19991999        setInsertionMode(InRowMode);
    2000         ASSERT(m_tree.currentElement()->hasTagName(trTag));
     2000        // FIXME: The fragment case of this ASSERT is a spec bug:
     2001        // http://www.w3.org/Bugs/Public/show_bug.cgi?id=10338
     2002        ASSERT(m_tree.currentElement()->hasTagName(trTag) || (isParsingFragment() && m_fragmentContext.contextElement()->hasTagName(trTag)));
    20012003        return;
    20022004    }
Note: See TracChangeset for help on using the changeset viewer.