• shinyak@chromium.org's avatar
    ShadowRoot.selection should return the seleciton whose range is in a shadow tree. · 589b39fc
    shinyak@chromium.org authored
    Reviewed by Ryosuke Niwa.
    The selection object returned from shadowRoot.selection should be able to see
    the inner object of the shadowRoot.
    In the previous code, the node out of the shadow subtree was returned for
    anchorNode, focusNode, baseNode, and extentNode. This patch enables us to get
    the corresponding shadow ancestor in the specified TreeScope (m_treeScope).
    Tests: editing/shadow/selection-of-orphan-shadowroot.html
    * dom/ShadowRoot.cpp:
    * dom/ShadowRoot.h:
    * dom/TreeScope.cpp:
    (WebCore::TreeScope::getSelection): When shadow DOM feature is not enabled, we want to use the same
    instance of DOMSelection among Document and ShadowRoot.
    * dom/TreeScopeAdjuster.cpp:
    (WebCore::TreeScopeAdjuster::ancestorInThisScope): Since node could be null, I've added a node check code.
    * dom/TreeScopeAdjuster.h:
    * page/DOMSelection.cpp:
    (WebCore::DOMSelection::shadowAdjustedNode): Gets the corresponding node in the m_treeScope from the Position.
    (WebCore::DOMSelection::shadowAdjustedOffset): Gets the corresponding node offset in the m_treeScope from the Position.
    * page/DOMSelection.h:
    This patch contains 2 tests:
    - Generates a complex HTML tree having a ShadowRoot, an older ShadowRoot, a nested ShadowRoot,
    nested ShadowRoot in an older ShadowRoot, etc., and try to drag from a nested shadow root of
    older shadow root to a nested shadow root of younger shadow root. Then checks nodes of Shadowroot.selection
    are in the same tree scope or null.
    - Generates a ShadowDOM which is not inserted into a document, and confirms nodes taken from
    the selection are all null.
    Also, this patch deprecates old shadowRoot.selection tests, because they test to check
    window.getSelection() and shadowRoot.selection is the same. This behavior is changed by this patch.
    * editing/shadow/selection-of-orphan-shadowroot-expected.txt: Added.
    * editing/shadow/selection-of-orphan-shadowroot.html: Added.
    * editing/shadow/selection-of-shadowroot-expected.txt: Added.
    * editing/shadow/selection-of-shadowroot.html: Added.
    * fast/dom/resources/event-sender-util.js:
    * fast/dom/shadow/resources/shadow-dom-util.js: Added.
    * fast/dom/shadow/selection-in-shadow.html: Removed.
    * platform/chromium-mac-snowleopard/fast/dom/shadow/selection-in-shadow-expected.txt: Removed.
    * platform/chromium/fast/dom/shadow/selection-in-shadow-expected.txt: Removed.
    * platform/qt/Skipped:
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@117249 268f45cc-cd09-0410-ab3c-d52691b4dbfc
DOMSelection.h 4.31 KB