Make HTMLConverter work across shadow boundaries
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2018 01:45:24 +0000 (01:45 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 14 Dec 2018 01:45:24 +0000 (01:45 +0000)
commitec72167dc80f17c41855310aa65c94c0397a30e1
tree0c7768dc23a635c3e70225085c8e49b1973495ce
parent989751bc3835928873aa020ea8317948e517692f
Make HTMLConverter work across shadow boundaries
https://bugs.webkit.org/show_bug.cgi?id=192640

Reviewed by Wenson Hsieh.

Source/WebCore:

Made HTMLConverter work with shadow boundaries by replacing the various tree traversal functions.

Tests: editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2.html
       editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-3.html

* dom/Position.cpp:
(WebCore::commonShadowIncludingAncestor): Moved from markup.cpp to be shared between HTMLConverter
and serializePreservingVisualAppearanceInternal.
* dom/Position.h:
* editing/cocoa/HTMLConverter.mm:
(HTMLConverter::convert):
(HTMLConverterCaches::propertyValueForNode):
(HTMLConverterCaches::floatPropertyValueForNode):
(HTMLConverter::_blockLevelElementForNode):
(HTMLConverterCaches::colorPropertyValueForNode):
(HTMLConverter::aggregatedAttributesForAncestors):
(HTMLConverter::aggregatedAttributesForElementAndItsAncestors):
(HTMLConverter::_processElement):
(HTMLConverter::_traverseNode):
(HTMLConverter::_traverseFooterNode):
(HTMLConverterCaches::cacheAncestorsOfStartToBeConverted):
(WebCore::attributedStringFromSelection):
* editing/markup.cpp:
(WebCore::commonShadowIncludingAncestor): Moved to Position.cpp.

LayoutTests:

Added tests for generating attributed string out across shadow boundaries based on the tests
of respective names in editing/pasteboard.

* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1.html: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2.html: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3.html: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4.html: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5.html: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1.html: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt: Added.
* editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2.html: Added.
* editing/mac/attributed-string/resources/dump-attributed-string.js:
(window.dumpAttributedString): Now takes start and end containers and offsets.
(serializeSubtreeWithShadow): Added. This function serializes the content of shadow roots along with
start and end markers.
(serializeSubtreeWithShadow.serializeCharacterData): Added.
(serializeSubtreeWithShadow.serializeNode): Added.
(serializeSubtreeWithShadow.serializeChildNodes): Added.
(serializeSubtreeWithShadow.serializeShadowRootAndChildNodes): Added.
(dumpAttributedString): Deleted.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt: Added.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt: Added.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt: Added.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt: Added.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt: Added.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt: Added.
* platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239190 268f45cc-cd09-0410-ab3c-d52691b4dbfc
28 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2.html [new file with mode: 0644]
LayoutTests/editing/mac/attributed-string/resources/dump-attributed-string.js
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/dom/Position.cpp
Source/WebCore/dom/Position.h
Source/WebCore/editing/cocoa/HTMLConverter.mm
Source/WebCore/editing/markup.cpp