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

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

Issue 2121313003: [Editing][DOM][CodeHealth] Make Node::isContentEditable and Node::isRichEditable global functions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('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 84a8cea65e1140ef19992d5e3c884b1fd0ce5c1f..d539dc910819e8b10112b676cd312d3e198a6528 100644
--- a/third_party/WebKit/Source/core/dom/Node.cpp
+++ b/third_party/WebKit/Source/core/dom/Node.cpp
@@ -537,31 +537,32 @@ void Node::normalize()
bool Node::isContentEditable(UserSelectAllTreatment treatment) const
{
document().updateStyleAndLayoutTree();
- return hasEditableStyle(Editable, treatment);
+ return hasEditableStyle(this, Editable, treatment);
}
bool Node::isContentRichlyEditable() const
{
document().updateStyleAndLayoutTree();
- return hasEditableStyle(RichlyEditable, UserSelectAllIsAlwaysNonEditable);
+ return hasEditableStyle(this, RichlyEditable, UserSelectAllIsAlwaysNonEditable);
}
-bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment treatment) const
+// TODO(yoichio): Move this to core/editing
+bool Node::hasEditableStyle(const Node* node, EditableLevel editableLevel, UserSelectAllTreatment treatment)
yosin_UTC9 2016/07/07 09:34:54 s/const Node*/const Node&/
{
- if (isPseudoElement())
+ if (node->isPseudoElement())
return false;
// Ideally we'd call DCHECK(!needsStyleRecalc()) here, but
// ContainerNode::setFocus() calls setNeedsStyleRecalc(), so the assertion
// would fire in the middle of Document::setFocusedNode().
- for (const Node& node : NodeTraversal::inclusiveAncestorsOf(*this)) {
- if ((node.isHTMLElement() || node.isDocumentNode()) && node.layoutObject()) {
+ for (const Node& ancestor : NodeTraversal::inclusiveAncestorsOf(*node)) {
+ if ((ancestor.isHTMLElement() || ancestor.isDocumentNode()) && ancestor.layoutObject()) {
// Elements with user-select: all style are considered atomic
// therefore non editable.
- if (nodeIsUserSelectAll(&node) && treatment == UserSelectAllIsAlwaysNonEditable)
+ if (nodeIsUserSelectAll(&ancestor) && treatment == UserSelectAllIsAlwaysNonEditable)
return false;
- switch (node.layoutObject()->style()->userModify()) {
+ switch (ancestor.layoutObject()->style()->userModify()) {
case READ_ONLY:
return false;
case READ_WRITE:
@@ -577,9 +578,10 @@ bool Node::hasEditableStyle(EditableLevel editableLevel, UserSelectAllTreatment
return false;
}
-bool Node::isEditableToAccessibility(EditableLevel editableLevel) const
+// TODO(yoichio): Move this to core/editing
+bool Node::isEditableToAccessibility(const Node* node, EditableLevel editableLevel)
yosin_UTC9 2016/07/07 09:34:54 s/const Node*/const Node&/
{
- if (hasEditableStyle(editableLevel))
+ if (hasEditableStyle(node, editableLevel))
return true;
// FIXME: Respect editableLevel for ARIA editable elements.
@@ -587,8 +589,8 @@ bool Node::isEditableToAccessibility(EditableLevel editableLevel) const
return false;
// FIXME(dmazzoni): support ScopedAXObjectCache (crbug/489851).
- if (AXObjectCache* cache = document().existingAXObjectCache())
- return cache->rootAXEditableElement(this);
+ if (AXObjectCache* cache = node->document().existingAXObjectCache())
+ return cache->rootAXEditableElement(node);
return false;
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698