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

Unified Diff: Source/web/WebElement.cpp

Issue 1347893002: Add WebElement::isEditable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 3 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 | « Source/core/dom/Node.cpp ('k') | Source/web/WebElementTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebElement.cpp
diff --git a/Source/web/WebElement.cpp b/Source/web/WebElement.cpp
index f58bf11ad9c323cfa16d4825abc4144d0983c190..0a9668ee9266eace187c508674462091c4cc31b9 100644
--- a/Source/web/WebElement.cpp
+++ b/Source/web/WebElement.cpp
@@ -32,16 +32,21 @@
#include "public/web/WebElement.h"
#include "bindings/core/v8/ExceptionState.h"
+#include "core/HTMLNames.h"
#include "core/dom/Element.h"
#include "core/dom/Fullscreen.h"
-#include "core/dom/NamedNodeMap.h"
#include "core/dom/custom/CustomElementProcessingStack.h"
+#include "core/html/HTMLTextFormControlElement.h"
#include "platform/graphics/Image.h"
#include "public/platform/WebRect.h"
#include "wtf/PassRefPtr.h"
+#include "wtf/text/AtomicString.h"
+#include "wtf/text/WTFString.h"
namespace blink {
+using namespace HTMLNames;
+
bool WebElement::isFormControlElement() const
{
return constUnwrap<Element>()->isFormControlElement();
@@ -52,6 +57,22 @@ bool WebElement::isTextFormControlElement() const
return constUnwrap<Element>()->isTextFormControl();
}
+bool WebElement::isEditable() const
+{
+ const Element* element = constUnwrap<Element>();
+
+ if (element->isContentEditable())
+ return true;
+
+ if (element->isTextFormControl()) {
+ const HTMLTextFormControlElement* input = toHTMLTextFormControlElement(element);
+ if (!input->isDisabledOrReadOnly())
+ return true;
+ }
+
+ return equalIgnoringCase(element->getAttribute(roleAttr), "textbox");
+}
+
WebString WebElement::tagName() const
{
return constUnwrap<Element>()->tagName();
« no previous file with comments | « Source/core/dom/Node.cpp ('k') | Source/web/WebElementTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698