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

Unified Diff: Source/web/WebFormControlElement.cpp

Issue 194923003: Move common methods to WebFormControlElement interface (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 | « no previous file | Source/web/WebInputElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/WebFormControlElement.cpp
diff --git a/Source/web/WebFormControlElement.cpp b/Source/web/WebFormControlElement.cpp
index 527db7713b3a61050cd5921cfee3971103d6ec93..585260f9128cf504a3271050c653b73089137eba 100644
--- a/Source/web/WebFormControlElement.cpp
+++ b/Source/web/WebFormControlElement.cpp
@@ -34,6 +34,7 @@
#include "core/html/HTMLFormControlElement.h"
#include "core/html/HTMLFormElement.h"
#include "core/html/HTMLInputElement.h"
+#include "core/html/HTMLSelectElement.h"
#include "core/html/HTMLTextAreaElement.h"
#include "wtf/PassRefPtr.h"
@@ -82,6 +83,53 @@ WebString WebFormControlElement::nameForAutofill() const
return constUnwrap<HTMLFormControlElement>()->nameForAutofill();
}
+bool WebFormControlElement::autoComplete() const
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ return constUnwrap<HTMLInputElement>()->shouldAutocomplete();
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ return constUnwrap<HTMLTextAreaElement>()->shouldAutocomplete();
+ return false;
+}
+
+void WebFormControlElement::setValue(const WebString& value, bool sendChangeEvent)
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent ? DispatchChangeEvent : DispatchNoEvent);
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ unwrap<HTMLTextAreaElement>()->setValue(value);
+ if (m_private->hasTagName(HTMLNames::selectTag))
+ unwrap<HTMLSelectElement>()->setValue(value);
+}
+
+WebString WebFormControlElement::value() const
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ return constUnwrap<HTMLInputElement>()->value();
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ return constUnwrap<HTMLTextAreaElement>()->value();
+ if (m_private->hasTagName(HTMLNames::selectTag))
+ return constUnwrap<HTMLSelectElement>()->value();
+ return WebString();
+}
+
+void WebFormControlElement::setSuggestedValue(const WebString& value)
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ unwrap<HTMLInputElement>()->setSuggestedValue(value);
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ unwrap<HTMLTextAreaElement>()->setSuggestedValue(value);
+}
+
+WebString WebFormControlElement::suggestedValue() const
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ return constUnwrap<HTMLInputElement>()->suggestedValue();
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ return constUnwrap<HTMLTextAreaElement>()->suggestedValue();
+ return WebString();
+}
+
WebString WebFormControlElement::editingValue() const
{
if (m_private->hasTagName(HTMLNames::inputTag))
@@ -91,6 +139,14 @@ WebString WebFormControlElement::editingValue() const
return WebString();
}
+void WebFormControlElement::setSelectionRange(int start, int end)
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ unwrap<HTMLInputElement>()->setSelectionRange(start, end);
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ unwrap<HTMLTextAreaElement>()->setSelectionRange(start, end);
+}
+
int WebFormControlElement::selectionStart() const
{
if (m_private->hasTagName(HTMLNames::inputTag))
@@ -109,6 +165,15 @@ int WebFormControlElement::selectionEnd() const
return 0;
}
+WebString WebFormControlElement::directionForFormData() const
+{
+ if (m_private->hasTagName(HTMLNames::inputTag))
+ return constUnwrap<HTMLInputElement>()->directionForFormData();
+ if (m_private->hasTagName(HTMLNames::textareaTag))
+ return constUnwrap<HTMLTextAreaElement>()->directionForFormData();
+ return WebString();
+}
+
WebFormElement WebFormControlElement::form() const
{
return WebFormElement(constUnwrap<HTMLFormControlElement>()->form());
« no previous file with comments | « no previous file | Source/web/WebInputElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698