Title: [208565] trunk
Revision
208565
Author
rn...@webkit.org
Date
2016-11-10 14:21:35 -0800 (Thu, 10 Nov 2016)

Log Message

Copied text would contain text inside CDATA sections and comments
https://bugs.webkit.org/show_bug.cgi?id=164578
Source/WebCore:

<rdar://problem/19834542>

Reviewed by Darin Adler.

The bug was caused by HTMLConverter::_traverseNode always including the content of a Text node.
Since Comment and CDataSection nodes are also Text nodes, we need to exclude them.

In the long term, we should check the visibility of the text as done in MarkupAccumulator.

Test: editing/mac/attributed-string/comment-cdata-section.html

* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::_traverseNode):

LayoutTests:

Reviewed by Darin Adler.

Added a regression test for creating an attributed string from different kinds of Text nodes.
Comment and CDataSection should not be included in the attributed string.

* editing/mac/attributed-string/comment-cdata-section-expected.txt: Added.
* editing/mac/attributed-string/comment-cdata-section.html: Added.
* platform/mac-yosemite/editing/mac/attributed-string/comment-cdata-section-expected.txt: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (208564 => 208565)


--- trunk/LayoutTests/ChangeLog	2016-11-10 22:03:24 UTC (rev 208564)
+++ trunk/LayoutTests/ChangeLog	2016-11-10 22:21:35 UTC (rev 208565)
@@ -1,3 +1,17 @@
+2016-11-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Copied text would contain text inside CDATA sections and comments
+        https://bugs.webkit.org/show_bug.cgi?id=164578
+
+        Reviewed by Darin Adler.
+
+        Added a regression test for creating an attributed string from different kinds of Text nodes.
+        Comment and CDataSection should not be included in the attributed string.
+
+        * editing/mac/attributed-string/comment-cdata-section-expected.txt: Added.
+        * editing/mac/attributed-string/comment-cdata-section.html: Added.
+        * platform/mac-yosemite/editing/mac/attributed-string/comment-cdata-section-expected.txt: Added.
+
 2016-11-10  Joseph Pecoraro  <pecor...@apple.com>
 
         test262: DataView / TypedArray methods should throw RangeErrors for negative numbers (ToIndex)

Added: trunk/LayoutTests/editing/mac/attributed-string/comment-cdata-section-expected.txt (0 => 208565)


--- trunk/LayoutTests/editing/mac/attributed-string/comment-cdata-section-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/mac/attributed-string/comment-cdata-section-expected.txt	2016-11-10 22:21:35 UTC (rev 208565)
@@ -0,0 +1,31 @@
+Input:
+hello <!-- FAIL1 --><!--[CDATA[ FAIL2 ]]--> world.
+
+Output:
+NSParagraphStyle:
+Alignment 4
+    LineSpacing: 0
+    ParagraphSpacing: 0
+    ParagraphSpacingBefore: 0
+    HeadIndent: 0
+    TailIndent: 0
+    FirstLineHeadIndent: 0
+    LineHeight: 0/0
+    LineHeightMultiple: 0
+    LineBreakMode: 0
+    Tabs: ()
+    DefaultTabInterval: 36
+    Blocks: (
+)
+    Lists: (
+)
+    BaseWritingDirection: 0
+    HyphenationFactor: 0
+    TighteningForTruncation: YES
+    HeaderLevel: 0
+[hello world. ]
+    NSFont: Times-Roman 16.00 pt.
+    NSKern: 0pt
+    NSStrokeColor: NSDeviceRGBColorSpace 0 0 0 1
+    NSStrokeWidth: 0
+

Added: trunk/LayoutTests/editing/mac/attributed-string/comment-cdata-section.html (0 => 208565)


--- trunk/LayoutTests/editing/mac/attributed-string/comment-cdata-section.html	                        (rev 0)
+++ trunk/LayoutTests/editing/mac/attributed-string/comment-cdata-section.html	2016-11-10 22:21:35 UTC (rev 208565)
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+hello <!-- FAIL1 --><![CDATA[ FAIL2 ]]> world.
+</body>
+</html>

Added: trunk/LayoutTests/platform/mac-yosemite/editing/mac/attributed-string/comment-cdata-section-expected.txt (0 => 208565)


--- trunk/LayoutTests/platform/mac-yosemite/editing/mac/attributed-string/comment-cdata-section-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/platform/mac-yosemite/editing/mac/attributed-string/comment-cdata-section-expected.txt	2016-11-10 22:21:35 UTC (rev 208565)
@@ -0,0 +1,29 @@
+Input:
+hello <!-- FAIL1 --><!--[CDATA[ FAIL2 ]]--> world.
+
+Output:
+NSParagraphStyle:
+Alignment 4
+    LineSpacing: 0
+    ParagraphSpacing: 0
+    ParagraphSpacingBefore: 0
+    HeadIndent: 0
+    TailIndent: 0
+    FirstLineHeadIndent: 0
+    LineHeight: 0/0
+    LineHeightMultiple: 0
+    LineBreakMode: 0
+    Tabs: ()
+    DefaultTabInterval: 36
+    Blocks: (null)
+    Lists: (null)
+    BaseWritingDirection: 0
+    HyphenationFactor: 0
+    TighteningFactor: 0.05
+    HeaderLevel: 0
+[hello world. ]
+    NSFont: Times-Roman 16.00 pt.
+    NSKern: 0pt
+    NSStrokeColor: NSDeviceRGBColorSpace 0 0 0 1
+    NSStrokeWidth: 0
+

Modified: trunk/Source/WebCore/ChangeLog (208564 => 208565)


--- trunk/Source/WebCore/ChangeLog	2016-11-10 22:03:24 UTC (rev 208564)
+++ trunk/Source/WebCore/ChangeLog	2016-11-10 22:21:35 UTC (rev 208565)
@@ -1,3 +1,21 @@
+2016-11-10  Ryosuke Niwa  <rn...@webkit.org>
+
+        Copied text would contain text inside CDATA sections and comments
+        https://bugs.webkit.org/show_bug.cgi?id=164578
+        <rdar://problem/19834542>
+
+        Reviewed by Darin Adler.
+
+        The bug was caused by HTMLConverter::_traverseNode always including the content of a Text node.
+        Since Comment and CDataSection nodes are also Text nodes, we need to exclude them.
+
+        In the long term, we should check the visibility of the text as done in MarkupAccumulator.
+
+        Test: editing/mac/attributed-string/comment-cdata-section.html
+
+        * editing/cocoa/HTMLConverter.mm:
+        (HTMLConverter::_traverseNode):
+
 2016-11-10  Eric Carlson  <eric.carl...@apple.com>
 
         [MediaStream] apply constraints passed to getUserMedia()

Modified: trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm (208564 => 208565)


--- trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2016-11-10 22:03:24 UTC (rev 208564)
+++ trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm	2016-11-10 22:21:35 UTC (rev 208565)
@@ -2327,7 +2327,7 @@
                 _exitElement(element, depth, startIndex);
             }
         }
-    } else if (is<CharacterData>(node))
+    } else if (node.nodeType() == Node::TEXT_NODE)
         _processText(downcast<CharacterData>(node));
 
     if (isEnd)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to