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

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

Issue 2179273003: Implement spec-compliant HTMLElement.prototype.isContentEditable (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
Index: third_party/WebKit/Source/core/editing/EditingUtilities.cpp
diff --git a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
index 742755960833b21ed25818d812686d968695b74c..8d9b53bbbf6681c6186799ae0721e7e2347f8176 100644
--- a/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
+++ b/third_party/WebKit/Source/core/editing/EditingUtilities.cpp
@@ -27,6 +27,7 @@
#include "core/HTMLElementFactory.h"
#include "core/HTMLNames.h"
+#include "core/MathMLNames.h"
#include "core/dom/Document.h"
#include "core/dom/ElementTraversal.h"
#include "core/dom/NodeComputedStyle.h"
@@ -57,6 +58,7 @@
#include "core/html/HTMLUListElement.h"
#include "core/layout/LayoutObject.h"
#include "core/layout/LayoutTableCell.h"
+#include "core/svg/SVGSVGElement.h"
#include "wtf/Assertions.h"
#include "wtf/StdLibExtras.h"
#include "wtf/text/StringBuilder.h"
@@ -299,6 +301,39 @@ static bool isEditableToAccessibility(const Node& node, EditableLevel editableLe
return false;
}
+bool isEditingHost(const Node& node)
+{
+ if (!node.isHTMLElement())
+ return false;
+ String ceValue = toHTMLElement(node).contentEditable();
+ if (ceValue == "true" || ceValue == "plaintext-only")
+ return true;
+ if (node.document().inDesignMode() && node.document().documentElement() == &node)
+ return true;
+ return false;
+}
yoichio 2016/07/27 01:29:35 If these functions are just for HTMLEelement::isCo
+
+bool isEditable(const Node& node)
+{
+ if (isEditingHost(node))
+ return false;
+ if (node.isHTMLElement() && toHTMLElement(node).contentEditable() == "false")
+ return false;
+ if (!node.parentNode())
+ return false;
+ if (!isEditingHost(*node.parentNode()) && !isEditable(*node.parentNode()))
+ return false;
+ if (node.isHTMLElement())
+ return true;
+ if (isSVGSVGElement(node))
+ return true;
+ if (node.isElementNode() && toElement(node).hasTagName(MathMLNames::mathTag))
+ return true;
+ if (!node.isElementNode() && node.parentNode()->isHTMLElement())
+ return true;
+ return false;
+}
+
bool isContentEditable(const Node& node)
{
node.document().updateStyleAndLayoutTree();

Powered by Google App Engine
This is Rietveld 408576698