Chromium Code Reviews| Index: third_party/WebKit/Source/core/editing/SelectionController.cpp |
| diff --git a/third_party/WebKit/Source/core/editing/SelectionController.cpp b/third_party/WebKit/Source/core/editing/SelectionController.cpp |
| index 425b435e967f5a104bc83d9f524fb73b2e5f1bcd..2fdc0254ca292344b5519e62dc6d45c709621e72 100644 |
| --- a/third_party/WebKit/Source/core/editing/SelectionController.cpp |
| +++ b/third_party/WebKit/Source/core/editing/SelectionController.cpp |
| @@ -82,14 +82,23 @@ DispatchEventResult dispatchSelectStart(Node* node) |
| return node->dispatchEvent(Event::createCancelableBubble(EventTypeNames::selectstart)); |
| } |
| -VisibleSelectionInFlatTree expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelectionInFlatTree& selection) |
| +static Node* rootUserSelectAllAndNotEditableNode(Node* const node) |
| { |
| - Node* rootUserSelectAll = EditingInFlatTreeStrategy::rootUserSelectAllForNode(targetNode); |
| + Node* const rootUserSelectAll = EditingInFlatTreeStrategy::rootUserSelectAllForNode(node); |
|
yosin_UTC9
2016/07/20 06:58:58
As talked offline, we should have a function, used
yoichio
2016/07/27 02:27:21
Created the function and use it in rootUserSelectA
|
| if (!rootUserSelectAll) |
| - return selection; |
| + return nullptr; |
| if (rootUserSelectAll->isHTMLElement() && toHTMLElement(rootUserSelectAll)->isTextFormControl()) |
| - return selection; |
| + return nullptr; |
| if (rootUserSelectAll->layoutObject()->style()->userModify() != READ_ONLY) |
| + return nullptr; |
| + |
| + return rootUserSelectAll; |
| +} |
| + |
| +VisibleSelectionInFlatTree expandSelectionToRespectUserSelectAll(Node* targetNode, const VisibleSelectionInFlatTree& selection) |
| +{ |
| + Node* const rootUserSelectAll = rootUserSelectAllAndNotEditableNode(targetNode); |
| + if (!rootUserSelectAll) |
| return selection; |
| VisibleSelectionInFlatTree newSelection(selection); |
| @@ -237,8 +246,9 @@ void SelectionController::updateSelectionForMouseDrag(const HitTestResult& hitTe |
| if (RuntimeEnabledFeatures::userSelectAllEnabled()) { |
| // TODO(yosin) Should we use |Strategy::rootUserSelectAllForNode()|? |
| - Node* rootUserSelectAllForMousePressNode = EditingInFlatTreeStrategy::rootUserSelectAllForNode(mousePressNode); |
| - if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode == EditingInFlatTreeStrategy::rootUserSelectAllForNode(target)) { |
| + Node* const rootUserSelectAllForMousePressNode = rootUserSelectAllAndNotEditableNode(mousePressNode); |
| + Node* const rootUserSelectAllForTarget = rootUserSelectAllAndNotEditableNode(target); |
| + if (rootUserSelectAllForMousePressNode && rootUserSelectAllForMousePressNode == rootUserSelectAllForTarget) { |
| newSelection.setBase(mostBackwardCaretPosition(PositionInFlatTree::beforeNode(rootUserSelectAllForMousePressNode), CanCrossEditingBoundary)); |
| newSelection.setExtent(mostForwardCaretPosition(PositionInFlatTree::afterNode(rootUserSelectAllForMousePressNode), CanCrossEditingBoundary)); |
| } else { |
| @@ -250,7 +260,6 @@ void SelectionController::updateSelectionForMouseDrag(const HitTestResult& hitTe |
| newSelection.setBase(mostForwardCaretPosition(PositionInFlatTree::afterNode(rootUserSelectAllForMousePressNode), CanCrossEditingBoundary)); |
| } |
| - Node* rootUserSelectAllForTarget = EditingInFlatTreeStrategy::rootUserSelectAllForNode(target); |
| if (rootUserSelectAllForTarget && mousePressNode->layoutObject() && toPositionInFlatTree(target->layoutObject()->positionForPoint(hitTestResult.localPoint()).position()).compareTo(toPositionInFlatTree(mousePressNode->layoutObject()->positionForPoint(dragStartPos).position())) < 0) |
| newSelection.setExtent(mostBackwardCaretPosition(PositionInFlatTree::beforeNode(rootUserSelectAllForTarget), CanCrossEditingBoundary)); |
| else if (rootUserSelectAllForTarget && mousePressNode->layoutObject()) |