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

Side by Side 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 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after
931 // FIXME: Shouldn't these functions be in the editing code? Code that asks ques tions about HTML in the core DOM class 931 // FIXME: Shouldn't these functions be in the editing code? Code that asks ques tions about HTML in the core DOM class
932 // is obviously misplaced. 932 // is obviously misplaced.
933 bool Node::canStartSelection() const 933 bool Node::canStartSelection() const
934 { 934 {
935 if (isDisabledFormControl(this)) 935 if (isDisabledFormControl(this))
936 return false; 936 return false;
937 937
938 if (hasEditableStyle(*this)) 938 if (hasEditableStyle(*this))
939 return true; 939 return true;
940 940
941 if (layoutObject()) { 941 // We don't allow selections to begin within an element that has
942 const ComputedStyle& style = layoutObject()->styleRef(); 942 // -webkit-user-select: none set,
943 // We allow selections to begin within an element that has -webkit-user- select: none set, 943 // https://drafts.csswg.org/css-ui-4/#valdef-user-select-none
944 // but if the element is draggable then dragging should take priority ov er selection. 944 if (usedValueOfUserSelect(*this) == SELECT_NONE)
945 if (style.userDrag() == DRAG_ELEMENT && style.userSelect() == SELECT_NON E) 945 return false;
946
947 if (isHTMLElement() && toHTMLElement(this)->draggable())
948 return false;
949
950 // TODO(yoichio): Use FlatTreeTraversal::ancestorsOf().
tkent 2016/08/17 02:34:20 Do you mean we don't have FlatTreeTraversal::ances
951 for (const Node* parent = FlatTreeTraversal::parent(*this); parent; parent = FlatTreeTraversal::parent(*parent)) {
952 if (!parent->canStartSelection() && usedValueOfUserSelect(*parent) != SE LECT_NONE)
946 return false; 953 return false;
947 } 954 }
948 ContainerNode* parent = FlatTreeTraversal::parent(*this); 955 return true;
949 return parent ? parent->canStartSelection() : true;
950 } 956 }
951 957
952 // StyledElements allow inline style (style="border: 1px"), presentational attri butes (ex. color), 958 // StyledElements allow inline style (style="border: 1px"), presentational attri butes (ex. color),
953 // class names (ex. class="foo bar") and other non-basic styling features. They also control 959 // class names (ex. class="foo bar") and other non-basic styling features. They also control
954 // if this element can participate in style sharing. 960 // if this element can participate in style sharing.
955 // 961 //
956 // FIXME: The only things that ever go through StyleResolver that aren't StyledE lements are 962 // FIXME: The only things that ever go through StyleResolver that aren't StyledE lements are
957 // PseudoElements and VTTElements. It's possible we can just eliminate all the c hecks 963 // PseudoElements and VTTElements. It's possible we can just eliminate all the c hecks
958 // since those elements will never have class names, inline style, or other thin gs that 964 // since those elements will never have class names, inline style, or other thin gs that
959 // this apparently guards against. 965 // this apparently guards against.
(...skipping 1452 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 2418
2413 void showNodePath(const blink::Node* node) 2419 void showNodePath(const blink::Node* node)
2414 { 2420 {
2415 if (node) 2421 if (node)
2416 node->showNodePathForThis(); 2422 node->showNodePathForThis();
2417 else 2423 else
2418 fprintf(stderr, "Cannot showNodePath for (nil)\n"); 2424 fprintf(stderr, "Cannot showNodePath for (nil)\n");
2419 } 2425 }
2420 2426
2421 #endif 2427 #endif
OLDNEW
« 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