Assert triggers VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries.
https://bugs.webkit.org/show_bug.cgi?id=83118
Reviewed by Hajime Morita.
Source/WebCore:
VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries did not work correctly.
There was a case that selection crosses shadow boundaries.
This patch introduces a class TreeScopeAdjuster, which enables us to adjust Node or Position
into a specified tree scope.
Test: fast/dom/shadow/selections-in-shadow.html
* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.ext.in:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
* dom/TreeScope.h:
(TreeScope):
* dom/TreeScopeAdjuster.cpp: Added.
(WebCore):
(WebCore::TreeScopeAdjuster::TreeScopeAdjuster):
(WebCore::TreeScopeAdjuster::ancestorInThisScope):
Returns the node itself if it's in the same tree scope.
Otherwise, this method checks the shadow ancestor of the node recursively.
If no corresponding node is found, 0 will be returned.
(WebCore::TreeScopeAdjuster::adjustPositionBefore):
(WebCore::TreeScopeAdjuster::adjustPositionAfter):
* dom/TreeScopeAdjuster.h: Added.
(WebCore):
(TreeScopeAdjuster):
(WebCore::TreeScopeAdjuster::treeScope):
* editing/VisibleSelection.cpp:
(WebCore::VisibleSelection::adjustSelectionToAvoidCrossingShadowBoundaries):
LayoutTests:
This tests checks all the combination of element not in a shadow tree, element in a shadow tree,
element in a nested shadow tree, element in a non-youngest shadow tree, element in a nested shadow tree
in non-youngest shadow treee.
* fast/dom/resources/event-sender-util.js: Added.
(mouseMoveToElem):
* fast/dom/shadow/selections-in-shadow-expected.txt: Added.
* fast/dom/shadow/selections-in-shadow.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113681
268f45cc-cd09-0410-ab3c-
d52691b4dbfc