summaryrefslogtreecommitdiffstats
path: root/webkit/glue/form_field.cc
diff options
context:
space:
mode:
authoramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 17:11:07 +0000
committeramit@chromium.org <amit@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-26 17:11:07 +0000
commit2f6fc6d9b62e14b22de3cb489500a4cfb0b5f2fa (patch)
tree7f8c180a6183c7d8bd81c2553607c58dce23bf81 /webkit/glue/form_field.cc
parent59e301ff41fb72be4cc785428db9d88f7ae819f0 (diff)
downloadchromium_src-2f6fc6d9b62e14b22de3cb489500a4cfb0b5f2fa.zip
chromium_src-2f6fc6d9b62e14b22de3cb489500a4cfb0b5f2fa.tar.gz
chromium_src-2f6fc6d9b62e14b22de3cb489500a4cfb0b5f2fa.tar.bz2
Page Cycler Intl2 perf regression.
Revert 42730 - AutoFill: Copy FormManager::LabelForElement and the corresponding FormManager::InferLabelForElement to form_field.cc until the FormData/FormFieldValues consolidation is finished. BUG=33031 TEST=none Review URL: http://codereview.chromium.org/1394003 TBR=jhawkins@chromium.org Review URL: http://codereview.chromium.org/1420001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42774 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/form_field.cc')
-rw-r--r--webkit/glue/form_field.cc77
1 files changed, 4 insertions, 73 deletions
diff --git a/webkit/glue/form_field.cc b/webkit/glue/form_field.cc
index 7717dea..721b3a7 100644
--- a/webkit/glue/form_field.cc
+++ b/webkit/glue/form_field.cc
@@ -6,80 +6,8 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebElement.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebLabelElement.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebNode.h"
-#include "third_party/WebKit/WebKit/chromium/public/WebNodeList.h"
-using WebKit::WebElement;
-using WebKit::WebLabelElement;
using WebKit::WebInputElement;
-using WebKit::WebNode;
-using WebKit::WebNodeList;
-
-// TODO(jhawkins): Remove the following methods once AutoFill has been switched
-// over to using FormData.
-// WARNING: This code must stay in sync with the corresponding code in
-// FormManager until we can remove this.
-namespace {
-
-string16 InferLabelForElement(const WebInputElement& element) {
- string16 inferred_label;
- WebNode previous = element.previousSibling();
- if (!previous.isNull()) {
- if (previous.isTextNode()) {
- inferred_label = previous.nodeValue();
- TrimWhitespace(inferred_label, TRIM_ALL, &inferred_label);
- }
-
- // If we didn't find text, check for previous paragraph.
- // Eg. <p>Some Text</p><input ...>
- // Note the lack of whitespace between <p> and <input> elements.
- if (inferred_label.empty()) {
- if (previous.isElementNode()) {
- WebElement element = previous.toElement<WebElement>();
- if (element.hasTagName("p")) {
- inferred_label = element.innerText();
- TrimWhitespace(inferred_label, TRIM_ALL, &inferred_label);
- }
- }
- }
-
- // If we didn't find paragraph, check for previous paragraph to this.
- // Eg. <p>Some Text</p> <input ...>
- // Note the whitespace between <p> and <input> elements.
- if (inferred_label.empty()) {
- previous = previous.previousSibling();
- if (!previous.isNull() && previous.isElementNode()) {
- WebElement element = previous.toElement<WebElement>();
- if (element.hasTagName("p")) {
- inferred_label = element.innerText();
- TrimWhitespace(inferred_label, TRIM_ALL, &inferred_label);
- }
- }
- }
- }
-
- return inferred_label;
-}
-
-string16 LabelForElement(const WebInputElement& element) {
- WebNodeList labels = element.document().getElementsByTagName("label");
- for (unsigned i = 0; i < labels.length(); ++i) {
- WebElement e = labels.item(i).toElement<WebElement>();
- if (e.hasTagName("label")) {
- WebLabelElement label = e.toElement<WebLabelElement>();
- if (label.correspondingControl() == element)
- return label.innerText();
- }
- }
-
- // Infer the label from context if not found in label element.
- return InferLabelForElement(element);
-}
-
-} // namespace
namespace webkit_glue {
@@ -88,7 +16,10 @@ FormField::FormField() {
FormField::FormField(const WebInputElement& input_element) {
name_ = input_element.nameForAutofill();
- label_ = LabelForElement(input_element);
+
+ // TODO(jhawkins): Extract the field label. For now we just use the field
+ // name.
+ label_ = name_;
value_ = input_element.value();
TrimWhitespace(value_, TRIM_LEADING, &value_);