HTMLTitleElement.text should only account for direct children Text nodes
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2016 01:15:48 +0000 (01:15 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 8 Jul 2016 01:15:48 +0000 (01:15 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159536

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline now that more checks are passing.

* web-platform-tests/html/semantics/document-metadata/the-title-element/title.text-01-expected.txt:
* web-platform-tests/html/semantics/document-metadata/the-title-element/title.text-02-expected.txt:

Source/WebCore:

HTMLTitleElement.text should only account for direct children Text nodes:
- https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text
- https://html.spec.whatwg.org/multipage/infrastructure.html#child-text-content

Firefox and Chrome match the specification. However, WebKit accounted for all
Text nodes that are descendants, not just children. This patch aligns our
behavior with the specification and other browsers.

No new tests, rebaselined existing tests.

* html/HTMLTitleElement.cpp:
(WebCore::HTMLTitleElement::text):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202951 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-title-element/title.text-01-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-title-element/title.text-02-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/html/HTMLTitleElement.cpp

index a678f6e..11b035e 100644 (file)
@@ -1,5 +1,17 @@
 2016-07-07  Chris Dumez  <cdumez@apple.com>
 
+        HTMLTitleElement.text should only account for direct children Text nodes
+        https://bugs.webkit.org/show_bug.cgi?id=159536
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline now that more checks are passing.
+
+        * web-platform-tests/html/semantics/document-metadata/the-title-element/title.text-01-expected.txt:
+        * web-platform-tests/html/semantics/document-metadata/the-title-element/title.text-02-expected.txt:
+
+2016-07-07  Chris Dumez  <cdumez@apple.com>
+
         td / th should be exposed as HTMLTableCellElement objects
         https://bugs.webkit.org/show_bug.cgi?id=159518
         <rdar://problem/27225436>
index 7fcbd24..1ca59cb 100644 (file)
@@ -1,3 +1,23 @@
+2016-07-07  Chris Dumez  <cdumez@apple.com>
+
+        HTMLTitleElement.text should only account for direct children Text nodes
+        https://bugs.webkit.org/show_bug.cgi?id=159536
+
+        Reviewed by Ryosuke Niwa.
+
+        HTMLTitleElement.text should only account for direct children Text nodes:
+        - https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text
+        - https://html.spec.whatwg.org/multipage/infrastructure.html#child-text-content
+
+        Firefox and Chrome match the specification. However, WebKit accounted for all
+        Text nodes that are descendants, not just children. This patch aligns our
+        behavior with the specification and other browsers.
+
+        No new tests, rebaselined existing tests.
+
+        * html/HTMLTitleElement.cpp:
+        (WebCore::HTMLTitleElement::text):
+
 2016-07-07  Dean Jackson  <dino@apple.com>
 
         REGRESSION(r200769): animations are no longer overridden
index b940336..0b310dc 100644 (file)
@@ -74,7 +74,10 @@ void HTMLTitleElement::childrenChanged(const ChildChange& change)
 
 String HTMLTitleElement::text() const
 {
-    return TextNodeTraversal::contentsAsString(*this);
+    StringBuilder result;
+    for (Text* text = TextNodeTraversal::firstChild(*this); text; text = TextNodeTraversal::nextSibling(*text))
+        result.append(text->data());
+    return result.toString();
 }
 
 StringWithDirection HTMLTitleElement::computedTextWithDirection()