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

Unified Diff: third_party/WebKit/Source/core/dom/Node.cpp

Issue 2021793002: [Editing][CSS] Drag from a -webkit-user-select:none element should not start selection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update comment Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/selection/mouse/select_user_select_in_shadow.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Node.cpp
diff --git a/third_party/WebKit/Source/core/dom/Node.cpp b/third_party/WebKit/Source/core/dom/Node.cpp
index eac5a1ca94a4456e3e673a3779c998f8b71beb00..a834c8b5463ed24fa606b1d574f35798798572cf 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -938,15 +938,21 @@ bool Node::canStartSelection() const
if (hasEditableStyle(*this))
return true;
- if (layoutObject()) {
- const ComputedStyle& style = layoutObject()->styleRef();
- // We allow selections to begin within an element that has -webkit-user-select: none set,
- // but if the element is draggable then dragging should take priority over selection.
- if (style.userDrag() == DRAG_ELEMENT && style.userSelect() == SELECT_NONE)
+ // We don't allow selections to begin within an element that has
+ // -webkit-user-select: none set,
+ // https://drafts.csswg.org/css-ui-4/#valdef-user-select-none
+ if (usedValueOfUserSelect(*this) == SELECT_NONE)
+ return false;
+
+ if (isHTMLElement() && toHTMLElement(this)->draggable())
+ return false;
+
+ // TODO(yoichio): Implement FlatTreeTraversal::ancestorsOf() and use it.
+ for (const Node* parent = FlatTreeTraversal::parent(*this); parent; parent = FlatTreeTraversal::parent(*parent)) {
+ if (!parent->canStartSelection() && usedValueOfUserSelect(*parent) != SELECT_NONE)
return false;
}
- ContainerNode* parent = FlatTreeTraversal::parent(*this);
- return parent ? parent->canStartSelection() : true;
+ return true;
}
// StyledElements allow inline style (style="border: 1px"), presentational attributes (ex. color),
« no previous file with comments | « third_party/WebKit/LayoutTests/editing/selection/mouse/select_user_select_in_shadow.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698