Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: third_party/WebKit/Source/core/editing/SelectionController.cpp

Issue 2151803003: [Editing][Regression] Contenteditable w/ "-webkit-user-select:all" should be editable for drag. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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())

Powered by Google App Engine
This is Rietveld 408576698