Changeset 159618 in webkit


Ignore:
Timestamp:
Nov 21, 2013 5:43:34 AM (10 years ago)
Author:
rniwa@webkit.org
Message:

HTML parser should not associate elements inside templates with forms
https://bugs.webkit.org/show_bug.cgi?id=117779

Reviewed by Antti Koivisto.

Source/WebCore:

Merge https://chromium.googlesource.com/chromium/blink/+/45aadf7ee7ee010327eb692066cf013315ef3ed7

When parsing <form><template><input>, the previous behavior was to associate the <input> with the <form>,
even though they're not in the same tree (or even the same document).

This patch changes that by checking, prior to creating a form control element, whether the element to be
created lives in a document with a browsing context.

We don't update m_form as needed to faithfully match the HTML5 specification's form element pointer
http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#form-element-pointer
and its algorithm for creating and inserting nodes:
http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#creating-and-inserting-nodes

While this leaves isindex's reference to form element pointer stale:
http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#isindex
The HTML5 specification matches the behaviors of Chrome and Firefox so we leave it as is.

Test: fast/dom/HTMLTemplateElement/no-form-association.html

  • html/parser/HTMLConstructionSite.cpp:

(WebCore::HTMLConstructionSite::createHTMLElement):

LayoutTests:

  • fast/dom/HTMLTemplateElement/no-form-association-expected.txt: Added.
  • fast/dom/HTMLTemplateElement/no-form-association.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r159610 r159618  
     12013-11-21  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        HTML parser should not associate elements inside templates with forms
     4        https://bugs.webkit.org/show_bug.cgi?id=117779
     5
     6        Reviewed by Antti Koivisto.
     7
     8        * fast/dom/HTMLTemplateElement/no-form-association-expected.txt: Added.
     9        * fast/dom/HTMLTemplateElement/no-form-association.html: Added.
     10
    1112013-11-20  Ryosuke Niwa  <rniwa@webkit.org>
    212
  • trunk/Source/WebCore/ChangeLog

    r159615 r159618  
     12013-11-21  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        HTML parser should not associate elements inside templates with forms
     4        https://bugs.webkit.org/show_bug.cgi?id=117779
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Merge https://chromium.googlesource.com/chromium/blink/+/45aadf7ee7ee010327eb692066cf013315ef3ed7
     9
     10        When parsing <form><template><input>, the previous behavior was to associate the <input> with the <form>,
     11        even though they're not in the same tree (or even the same document).
     12
     13        This patch changes that by checking, prior to creating a form control element, whether the element to be
     14        created lives in a document with a browsing context.
     15
     16        We don't update m_form as needed to faithfully match the HTML5 specification's form element pointer
     17        http://www.whatwg.org/specs/web-apps/current-work/multipage/parsing.html#form-element-pointer
     18        and its algorithm for creating and inserting nodes:
     19        http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#creating-and-inserting-nodes
     20
     21        While this leaves isindex's reference to form element pointer stale:
     22        http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#isindex
     23        The HTML5 specification matches the behaviors of Chrome and Firefox so we leave it as is.
     24
     25        Test: fast/dom/HTMLTemplateElement/no-form-association.html
     26
     27        * html/parser/HTMLConstructionSite.cpp:
     28        (WebCore::HTMLConstructionSite::createHTMLElement):
     29
    1302013-11-21  Carlos Garcia Campos  <cgarcia@igalia.com>
    231
  • trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp

    r158650 r159618  
    544544    // have to pass the current form element.  We should rework form association
    545545    // to occur after construction to allow better code sharing here.
    546     RefPtr<Element> element = HTMLElementFactory::createElement(tagName, ownerDocumentForCurrentNode(), form(), true);
     546    // http://www.whatwg.org/specs/web-apps/current-work/multipage/tree-construction.html#create-an-element-for-the-token
     547    Document& ownerDocument = ownerDocumentForCurrentNode();
     548    bool openElementsContainTemplateElement = !ownerDocument.frame();
     549    RefPtr<Element> element = HTMLElementFactory::createElement(tagName, ownerDocument, openElementsContainTemplateElement ? nullptr : form(), true);
    547550    setAttributes(element.get(), token, m_parserContentPolicy);
    548551    ASSERT(element->isHTMLElement());
Note: See TracChangeset for help on using the changeset viewer.