Changeset 239190 in webkit


Ignore:
Timestamp:
Dec 13, 2018 5:45:24 PM (5 years ago)
Author:
rniwa@webkit.org
Message:

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.
Location:
trunk
Files:
21 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r239189 r239190  
     12018-12-13  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Make HTMLConverter work across shadow boundaries
     4        https://bugs.webkit.org/show_bug.cgi?id=192640
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Added tests for generating attributed string out across shadow boundaries based on the tests
     9        of respective names in editing/pasteboard.
     10
     11        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt: Added.
     12        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1.html: Added.
     13        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt: Added.
     14        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2.html: Added.
     15        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt: Added.
     16        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3.html: Added.
     17        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt: Added.
     18        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4.html: Added.
     19        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt: Added.
     20        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5.html: Added.
     21        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt: Added.
     22        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1.html: Added.
     23        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt: Added.
     24        * editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2.html: Added.
     25        * editing/mac/attributed-string/resources/dump-attributed-string.js:
     26        (window.dumpAttributedString): Now takes start and end containers and offsets.
     27        (serializeSubtreeWithShadow): Added. This function serializes the content of shadow roots along with
     28        start and end markers.
     29        (serializeSubtreeWithShadow.serializeCharacterData): Added.
     30        (serializeSubtreeWithShadow.serializeNode): Added.
     31        (serializeSubtreeWithShadow.serializeChildNodes): Added.
     32        (serializeSubtreeWithShadow.serializeShadowRootAndChildNodes): Added.
     33        (dumpAttributedString): Deleted.
     34        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1-expected.txt: Added.
     35        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2-expected.txt: Added.
     36        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3-expected.txt: Added.
     37        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4-expected.txt: Added.
     38        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5-expected.txt: Added.
     39        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1-expected.txt: Added.
     40        * platform/mac-sierra/editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2-expected.txt: Added.
     41
    1422018-12-13  Youenn Fablet  <youenn@apple.com>
    243
  • trunk/LayoutTests/editing/mac/attributed-string/resources/dump-attributed-string.js

    r239149 r239190  
    55        testRunner.dumpAsText();
    66
    7     function dumpAttributedString(container) {
     7    window.dumpAttributedString = function dumpAttributedString(root = document.body, startContainer, startOffset, endContainer, endOffset) {
    88        shouldAutoDump = false;
    99
    10         var body = document.body;
    11         if (!container)
    12             container = body;
     10        const markup = serializeSubtreeWithShadow(root, startContainer, startOffset, endContainer, endOffset).trim();
    1311
    14         var range = document.createRange();
    15         range.selectNodeContents(container);
     12        if (!startContainer)
     13            startContainer = root;
     14        if (startOffset == undefined)
     15            startOffset = 0;
     16        if (!endContainer)
     17            endContainer = root;
     18        if (endOffset == undefined)
     19            endOffset = endContainer.childNodes.length;
    1620
    17         var pre = document.createElement('pre');
    18         var result = serializeAttributedString(textInputController.legacyAttributedString(container, 0, container, container.childNodes.length));
    19         pre.textContent = 'Input:\n' + container.innerHTML.trim() + '\n\nOutput:\n' + result;
     21        const pre = document.createElement('pre');
     22        const result = serializeAttributedString(textInputController.legacyAttributedString(startContainer, startOffset, endContainer, endOffset));
     23        pre.textContent = 'Input:\n' + markup + '\n\nOutput:\n' + result;
    2024
    21         body.innerHTML = '';
    22         body.appendChild(pre);
     25        document.body.innerHTML = '';
     26        document.body.appendChild(pre);
     27    }
     28
     29    function serializeSubtreeWithShadow(parent, startContainer, startOffset, endContainer, endOffset) {
     30        function serializeCharacterData(node) {
     31            let data = node.data;
     32            let result = data;
     33            if (node == startContainer && node == endContainer) {
     34                result = data.substring(0, startOffset);
     35                result += '<#start>';
     36                result = data.substring(startOffset, endOffset);
     37                result += '<#end>';
     38                result += data.substring(endOffset);
     39            } else if (node == startContainer) {
     40                result = data.substring(0, startOffset);
     41                result += '<#start>';
     42                result += data.substring(startOffset);
     43            } else if (node == endContainer) {
     44                result = data.substring(0, endOffset);
     45                result += '<#end>';
     46                result += data.substring(endOffset);
     47            }
     48            return result;
     49        }
     50
     51        function serializeNode(node) {
     52            if (node.nodeType == Node.TEXT_NODE)
     53                return serializeCharacterData(node);
     54            if (node.nodeType == Node.COMMENT_NODE)
     55                return '<!--' + node.nodeValue + '-->';
     56            if (node.nodeType == Node.CDATA_SECTION_NODE)
     57                return '<!--[CDATA[' + node.nodeValue + '-->';
     58
     59            const elementTags = node.cloneNode(false).outerHTML;
     60            const endTagIndex = elementTags.lastIndexOf('</');
     61            const startTag = endTagIndex >= 0 ? elementTags.substring(0, endTagIndex) : elementTags;
     62            const endTag = endTagIndex >= 0 ? elementTags.substring(endTagIndex) : '';
     63            return startTag + serializeShadowRootAndChildNodes(node) + endTag;
     64        }
     65
     66        function serializeChildNodes(node) {
     67            let result = '';
     68            for (let i = 0; i < node.childNodes.length; i++) {
     69                if (node == startContainer && i == startOffset)
     70                    result += '<#start>';
     71                result += serializeNode(node.childNodes[i]);
     72                if (node == endContainer && i + 1 == endOffset)
     73                    result += '<#end>';
     74            }
     75            return result;
     76        }
     77
     78        function serializeShadowRootAndChildNodes(node) {
     79            const shadowRoot = node.nodeType == Node.ELEMENT_NODE ? internals.shadowRoot(node) : null;
     80            if (!shadowRoot)
     81                return serializeChildNodes(node);
     82            return `<#shadow-start>${serializeChildNodes(shadowRoot)}<#shadow-end>${serializeChildNodes(node)}`;
     83        }
     84
     85        return serializeShadowRootAndChildNodes(parent);
    2386    }
    2487
  • trunk/Source/WebCore/ChangeLog

    r239189 r239190  
     12018-12-13  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Make HTMLConverter work across shadow boundaries
     4        https://bugs.webkit.org/show_bug.cgi?id=192640
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        Made HTMLConverter work with shadow boundaries by replacing the various tree traversal functions.
     9
     10        Tests: editing/mac/attributed-string/attributed-string-across-shadow-boundaries-1.html
     11               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-2.html
     12               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-3.html
     13               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-4.html
     14               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-5.html
     15               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-1.html
     16               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-2.html
     17               editing/mac/attributed-string/attributed-string-across-shadow-boundaries-with-style-3.html
     18
     19        * dom/Position.cpp:
     20        (WebCore::commonShadowIncludingAncestor): Moved from markup.cpp to be shared between HTMLConverter
     21        and serializePreservingVisualAppearanceInternal.
     22        * dom/Position.h:
     23        * editing/cocoa/HTMLConverter.mm:
     24        (HTMLConverter::convert):
     25        (HTMLConverterCaches::propertyValueForNode):
     26        (HTMLConverterCaches::floatPropertyValueForNode):
     27        (HTMLConverter::_blockLevelElementForNode):
     28        (HTMLConverterCaches::colorPropertyValueForNode):
     29        (HTMLConverter::aggregatedAttributesForAncestors):
     30        (HTMLConverter::aggregatedAttributesForElementAndItsAncestors):
     31        (HTMLConverter::_processElement):
     32        (HTMLConverter::_traverseNode):
     33        (HTMLConverter::_traverseFooterNode):
     34        (HTMLConverterCaches::cacheAncestorsOfStartToBeConverted):
     35        (WebCore::attributedStringFromSelection):
     36        * editing/markup.cpp:
     37        (WebCore::commonShadowIncludingAncestor): Moved to Position.cpp.
     38
    1392018-12-13  Youenn Fablet  <youenn@apple.com>
    240
  • trunk/Source/WebCore/dom/Position.cpp

    r236649 r239190  
    16021602}
    16031603
     1604RefPtr<Node> commonShadowIncludingAncestor(const Position& a, const Position& b)
     1605{
     1606    auto* commonScope = commonTreeScope(a.containerNode(), b.containerNode());
     1607    if (!commonScope)
     1608        return nullptr;
     1609    auto* nodeA = commonScope->ancestorNodeInThisScope(a.containerNode());
     1610    ASSERT(nodeA);
     1611    auto* nodeB = commonScope->ancestorNodeInThisScope(b.containerNode());
     1612    ASSERT(nodeB);
     1613    return Range::commonAncestorContainer(nodeA, nodeB);
     1614}
     1615
    16041616} // namespace WebCore
    16051617
  • trunk/Source/WebCore/dom/Position.h

    r236785 r239190  
    334334}
    335335
     336RefPtr<Node> commonShadowIncludingAncestor(const Position&, const Position&);
     337
    336338WTF::TextStream& operator<<(WTF::TextStream&, const Position&);
    337339
  • trunk/Source/WebCore/editing/cocoa/HTMLConverter.mm

    r239149 r239190  
    3535#import "ColorCocoa.h"
    3636#import "ColorMac.h"
     37#import "ComposedTreeIterator.h"
    3738#import "Document.h"
    3839#import "DocumentLoader.h"
     
    495496    if (!m_dataSource)
    496497        return nil;
    497    
     498
    498499    _domRangeStartIndex = 0;
    499500    _traverseNode(*commonAncestorContainer, 0, false /* embedded */);
    500501    if (_domRangeStartIndex > 0 && _domRangeStartIndex <= [_attrStr length])
    501502        [_attrStr deleteCharactersInRange:NSMakeRange(0, _domRangeStartIndex)];
    502    
     503
    503504    return [[_attrStr retain] autorelease];
    504505}
     
    666667{
    667668    if (!is<Element>(node)) {
    668         if (Node* parent = node.parentNode())
     669        if (Node* parent = node.parentInComposedTree())
    669670            return propertyValueForNode(*parent, propertyId);
    670671        return String();
     
    774775
    775776    if (inherit) {
    776         if (Node* parent = node.parentNode())
     777        if (Node* parent = node.parentInComposedTree())
    777778            return propertyValueForNode(*parent, propertyId);
    778779    }
     
    811812{
    812813    if (!is<Element>(node)) {
    813         if (ContainerNode* parent = node.parentNode())
     814        if (ContainerNode* parent = node.parentInComposedTree())
    814815            return floatPropertyValueForNode(*parent, propertyId, result);
    815816        return false;
     
    844845
    845846    if (inherit) {
    846         if (ContainerNode* parent = node.parentNode())
     847        if (ContainerNode* parent = node.parentInComposedTree())
    847848            return floatPropertyValueForNode(*parent, propertyId, result);
    848849    }
     
    951952    Element* element = node->parentElement();
    952953    if (element && !_caches->isBlockElement(*element))
    953         element = _blockLevelElementForNode(element->parentNode());
     954        element = _blockLevelElementForNode(element->parentInComposedTree());
    954955    return element;
    955956}
     
    970971{
    971972    if (!is<Element>(node)) {
    972         if (Node* parent = node.parentNode())
     973        if (Node* parent = node.parentInComposedTree())
    973974            return colorPropertyValueForNode(*parent, propertyId);
    974975        return Color();
     
    10061007
    10071008    if (inherit) {
    1008         if (Node* parent = node.parentNode())
     1009        if (Node* parent = node.parentInComposedTree())
    10091010            return colorPropertyValueForNode(*parent, propertyId);
    10101011    }
     
    12621263NSDictionary* HTMLConverter::aggregatedAttributesForAncestors(CharacterData& node)
    12631264{
    1264     Node* ancestor = node.parentNode();
     1265    Node* ancestor = node.parentInComposedTree();
    12651266    while (ancestor && !is<Element>(*ancestor))
    1266         ancestor = ancestor->parentNode();
     1267        ancestor = ancestor->parentInComposedTree();
    12671268    if (!ancestor)
    12681269        return nullptr;
     
    12791280    ASSERT(attributesForCurrentElement);
    12801281
    1281     Node* ancestor = element.parentNode();
     1282    Node* ancestor = element.parentInComposedTree();
    12821283    while (ancestor && !is<Element>(*ancestor))
    1283         ancestor = ancestor->parentNode();
     1284        ancestor = ancestor->parentInComposedTree();
    12841285
    12851286    if (!ancestor) {
     
    18531854        if (displayValue == "table-row-group") {
    18541855            // If we are starting in medias res, the first thing we see may be the tbody, so go up to the table
    1855             tableElement = _blockLevelElementForNode(element.parentNode());
     1856            tableElement = _blockLevelElementForNode(element.parentInComposedTree());
    18561857            if (!tableElement || _caches->propertyValueForNode(*tableElement, CSSPropertyDisplay) != "table")
    18571858                tableElement = &element;
     
    19241925        }
    19251926    } else if (element.hasTagName(brTag)) {
    1926         Element* blockElement = _blockLevelElementForNode(element.parentNode());
     1927        Element* blockElement = _blockLevelElementForNode(element.parentInComposedTree());
    19271928        NSString *breakClass = element.getAttribute(classAttr);
    19281929        NSString *blockTag = blockElement ? (NSString *)blockElement->tagName() : nil;
     
    22862287    bool isEnd = false;
    22872288    if (&node == m_start.containerNode()) {
    2288         startOffset = m_start.offsetInContainerNode();
     2289        startOffset = m_start.computeOffsetInContainerNode();
    22892290        isStart = true;
    22902291        _flags.reachedStart = YES;
    22912292    }
    22922293    if (&node == m_end.containerNode()) {
    2293         endOffset = m_end.offsetInContainerNode();
     2294        endOffset = m_end.computeOffsetInContainerNode();
    22942295        isEnd = true;
    22952296    }
     
    22972298    if (node.isDocumentNode() || node.isDocumentFragment()) {
    22982299        Node* child = node.firstChild();
     2300        ASSERT(child == firstChildInComposedTreeIgnoringUserAgentShadow(node));
    22992301        for (NSUInteger i = 0; child; i++) {
    23002302            if (isStart && i == startOffset)
     
    23062308            if (_flags.reachedEnd)
    23072309                break;
     2310            ASSERT(child->nextSibling() == nextSiblingInComposedTreeIgnoringUserAgentShadow(*child));
    23082311            child = child->nextSibling();
    23092312        }
     
    23132316            NSUInteger startIndex = [_attrStr length];
    23142317            if (_processElement(element, depth)) {
    2315                 Node* child = node.firstChild();
    2316                 for (NSUInteger i = 0; child; i++) {
    2317                     if (isStart && i == startOffset)
    2318                         _domRangeStartIndex = [_attrStr length];
    2319                     if ((!isStart || startOffset <= i) && (!isEnd || endOffset > i))
    2320                         _traverseNode(*child, depth + 1, embedded);
    2321                     if (isEnd && i + 1 >= endOffset)
    2322                         _flags.reachedEnd = YES;
    2323                     if (_flags.reachedEnd)
    2324                         break;
    2325                     child = child->nextSibling();
     2318                if (auto* shadowRoot = shadowRootIgnoringUserAgentShadow(element)) // Traverse through shadow root to detect start and end.
     2319                    _traverseNode(*shadowRoot, depth + 1, embedded);
     2320                else {
     2321                    auto* child = firstChildInComposedTreeIgnoringUserAgentShadow(node);
     2322                    for (NSUInteger i = 0; child; i++) {
     2323                        if (isStart && i == startOffset)
     2324                            _domRangeStartIndex = [_attrStr length];
     2325                        if ((!isStart || startOffset <= i) && (!isEnd || endOffset > i))
     2326                            _traverseNode(*child, depth + 1, embedded);
     2327                        if (isEnd && i + 1 >= endOffset)
     2328                            _flags.reachedEnd = YES;
     2329                        if (_flags.reachedEnd)
     2330                            break;
     2331                        child = nextSiblingInComposedTreeIgnoringUserAgentShadow(*child);
     2332                    }
    23262333                }
    23272334                _exitElement(element, depth, startIndex);
     
    23472354    bool isEnd = false;
    23482355    if (&element == m_start.containerNode()) {
    2349         startOffset = m_start.offsetInContainerNode();
     2356        startOffset = m_start.computeOffsetInContainerNode();
    23502357        isStart = true;
    23512358        _flags.reachedStart = YES;
    23522359    }
    23532360    if (&element == m_end.containerNode()) {
    2354         endOffset = m_end.offsetInContainerNode();
     2361        endOffset = m_end.computeOffsetInContainerNode();
    23552362        isEnd = true;
    23562363    }
     
    23592366        NSUInteger startIndex = [_attrStr length];
    23602367        if (_processElement(element, depth)) {
    2361             Node* child = element.firstChild();
     2368            auto* child = firstChildInComposedTreeIgnoringUserAgentShadow(element);
    23622369            for (NSUInteger i = 0; child; i++) {
    23632370                if (isStart && i == startOffset)
     
    23692376                if (_flags.reachedEnd)
    23702377                    break;
    2371                 child = child->nextSibling();
     2378                child = nextSiblingInComposedTreeIgnoringUserAgentShadow(*child);
    23722379            }
    23732380            _exitElement(element, depth, startIndex);
     
    23892396Node* HTMLConverterCaches::cacheAncestorsOfStartToBeConverted(const Position& start, const Position& end)
    23902397{
    2391     Node* commonAncestor = Range::commonAncestorContainer(start.containerNode(), end.containerNode());
     2398    auto commonAncestor = commonShadowIncludingAncestor(start, end);
    23922399    Node* ancestor = start.containerNode();
    23932400
     
    23962403        if (ancestor == commonAncestor)
    23972404            break;
    2398         ancestor = ancestor->parentNode();
    2399     }
    2400 
    2401     return commonAncestor;
     2405        ancestor = ancestor->parentInComposedTree();
     2406    }
     2407
     2408    return commonAncestor.get();
    24022409}
    24032410
     
    24662473NSAttributedString *attributedStringFromSelection(const VisibleSelection& selection)
    24672474{
    2468     auto range = selection.toNormalizedRange();
    2469     ASSERT(range);
    2470     return attributedStringBetweenStartAndEnd(range->startPosition(), range->endPosition());
     2475    return attributedStringBetweenStartAndEnd(selection.start(), selection.end());
    24712476}
    24722477
  • trunk/Source/WebCore/editing/markup.cpp

    r238771 r239190  
    819819}
    820820
    821 static RefPtr<Node> commonShadowIncludingAncestor(const Position& a, const Position& b)
    822 {
    823     TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode());
    824     if (!commonScope)
    825         return nullptr;
    826     auto* nodeA = commonScope->ancestorNodeInThisScope(a.containerNode());
    827     ASSERT(nodeA);
    828     auto* nodeB = commonScope->ancestorNodeInThisScope(b.containerNode());
    829     ASSERT(nodeB);
    830     return Range::commonAncestorContainer(nodeA, nodeB);
    831 }
    832 
    833821static String serializePreservingVisualAppearanceInternal(const Position& start, const Position& end, Vector<Node*>* nodes, ResolveURLs urlsToResolve, SerializeComposedTree serializeComposedTree,
    834822    AnnotateForInterchange annotate, ConvertBlocksToInlines convertBlocksToInlines, MSOListMode msoListMode)
Note: See TracChangeset for help on using the changeset viewer.