From 658c53e87c6374ba1af2e3602f7034acf4b5a2a0 Mon Sep 17 00:00:00 2001 From: Marshall Greenblatt Date: Thu, 24 Mar 2011 15:49:41 +0000 Subject: [PATCH] Add support for retrieving values from DOM form elements. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@207 5089003a-bbd8-11dd-ad1f-f1f9622dbc98 --- libcef/dom_node_impl.cc | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/libcef/dom_node_impl.cc b/libcef/dom_node_impl.cc index 5ddaa97c2..3bb4184c8 100644 --- a/libcef/dom_node_impl.cc +++ b/libcef/dom_node_impl.cc @@ -16,9 +16,11 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebDOMEventListener.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" +#include "third_party/WebKit/Source/WebKit/chromium/public/WebFormControlElement.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNamedNodeMap.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebNode.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" +#include "webkit/glue/form_field.h" using WebKit::WebAttribute; using WebKit::WebDocument; @@ -26,6 +28,7 @@ using WebKit::WebDOMEvent; using WebKit::WebDOMEventListener; using WebKit::WebElement; using WebKit::WebFrame; +using WebKit::WebFormControlElement; using WebKit::WebNamedNodeMap; using WebKit::WebNode; using WebKit::WebString; @@ -170,9 +173,23 @@ CefString CefDOMNodeImpl::GetValue() if (!VerifyContext()) return str; - const WebString& value = node_.nodeValue(); - if (!value.isNull()) - str = value; + if (node_.isElementNode()) { + const WebElement& element = node_.to(); + if (element.isFormControlElement()) { + // Retrieve the value from the form control element. + const WebFormControlElement& formElement = + node_.to(); + + webkit_glue::FormField formField(formElement); + str = formField.value(); + } + } + + if (str.empty()) { + const WebString& value = node_.nodeValue(); + if (!value.isNull()) + str = value; + } return str; }