diff options
author | yaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 23:30:26 +0000 |
---|---|---|
committer | yaar@chromium.org <yaar@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-22 23:30:26 +0000 |
commit | 56cd2750cc06043a641db4aac177852491e6e019 (patch) | |
tree | 0d22f66aa6efcce70a1c1889191f9f627ca1face /webkit/glue | |
parent | 51f8f2563ac66f10abad32ee93cd48eec1eb6ed5 (diff) | |
download | chromium_src-56cd2750cc06043a641db4aac177852491e6e019.zip chromium_src-56cd2750cc06043a641db4aac177852491e6e019.tar.gz chromium_src-56cd2750cc06043a641db4aac177852491e6e019.tar.bz2 |
Moved castToHTMLXXXElement and getNameForInputElement to DOMUtilitiesPrivate.
Review URL: http://codereview.chromium.org/304013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29834 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r-- | webkit/glue/dom_operations.cc | 34 | ||||
-rw-r--r-- | webkit/glue/dom_operations_private.h | 9 | ||||
-rw-r--r-- | webkit/glue/editor_client_impl.cc | 10 | ||||
-rw-r--r-- | webkit/glue/form_field_values.cc | 22 | ||||
-rw-r--r-- | webkit/glue/form_field_values.h | 10 | ||||
-rw-r--r-- | webkit/glue/webframe_impl.cc | 5 | ||||
-rw-r--r-- | webkit/glue/webview_impl.cc | 2 |
7 files changed, 16 insertions, 76 deletions
diff --git a/webkit/glue/dom_operations.cc b/webkit/glue/dom_operations.cc index 60c4199..1537e5c 100644 --- a/webkit/glue/dom_operations.cc +++ b/webkit/glue/dom_operations.cc @@ -165,16 +165,6 @@ void GetAllSavableResourceLinksForFrame(WebFrameImpl* current_frame, } } -template <class HTMLNodeType> -HTMLNodeType* CastHTMLElement(WebCore::Node* node, - const WebCore::QualifiedName& name) { - if (node->isHTMLElement() && - static_cast<typename WebCore::HTMLElement*>(node)->hasTagName(name)) { - return static_cast<HTMLNodeType*>(node); - } - return NULL; -} - } // namespace namespace webkit_glue { @@ -255,7 +245,7 @@ static bool FindFormInputElements(WebCore::HTMLFormElement* fe, // matching elements it can get at them through the FormElement*. // Note: This assignment adds a reference to the InputElement. result->input_elements[data.elements[j]] = - WebKit::nodeToHTMLInputElement(temp_elements[0].get()); + WebKit::toHTMLInputElement(temp_elements[0].get()); DCHECK(result->input_elements[data.elements[j]].get()); } return true; @@ -368,21 +358,6 @@ void FillPasswordForm(WebView* view, } } -WebCore::HTMLLinkElement* CastToHTMLLinkElement(WebCore::Node* node) { - return CastHTMLElement<WebCore::HTMLLinkElement>(node, - WebCore::HTMLNames::linkTag); -} - -WebCore::HTMLMetaElement* CastToHTMLMetaElement(WebCore::Node* node) { - return CastHTMLElement<WebCore::HTMLMetaElement>(node, - WebCore::HTMLNames::metaTag); -} - -WebCore::HTMLOptionElement* CastToHTMLOptionElement(WebCore::Node* node) { - return CastHTMLElement<WebCore::HTMLOptionElement>(node, - WebCore::HTMLNames::optionTag); -} - WebFrameImpl* GetWebFrameImplFromElement(WebCore::Element* element, bool* is_frame_element) { *is_frame_element = false; @@ -682,15 +657,12 @@ void GetApplicationInfo(WebView* view, WebApplicationInfo* app_info) { WTF::PassRefPtr<WebCore::HTMLCollection> children = head->children(); for (unsigned i = 0; i < children->length(); ++i) { WebCore::Node* child = children->item(i); - WebCore::HTMLLinkElement* link = CastHTMLElement<WebCore::HTMLLinkElement>( - child, WebCore::HTMLNames::linkTag); + WebCore::HTMLLinkElement* link = WebKit::toHTMLLinkElement(child); if (link) { if (link->isIcon()) AddInstallIcon(link, &app_info->icons); } else { - WebCore::HTMLMetaElement* meta = - CastHTMLElement<WebCore::HTMLMetaElement>( - child, WebCore::HTMLNames::metaTag); + WebCore::HTMLMetaElement* meta = WebKit::toHTMLMetaElement(child); if (meta) { if (meta->name() == String("application-name")) { app_info->title = webkit_glue::StringToString16(meta->content()); diff --git a/webkit/glue/dom_operations_private.h b/webkit/glue/dom_operations_private.h index f8ca7a6..69676f4 100644 --- a/webkit/glue/dom_operations_private.h +++ b/webkit/glue/dom_operations_private.h @@ -9,9 +9,6 @@ namespace WebCore { class AtomicString; class Document; class Element; -class HTMLLinkElement; -class HTMLMetaElement; -class HTMLOptionElement; class Node; class QualifiedName; class String; @@ -26,12 +23,6 @@ class WebFrameImpl; namespace webkit_glue { -// If node is an HTML node with a tag name of name it is casted and returned. -// If node is not an HTML node or the tag name is not name NULL is returned. -WebCore::HTMLLinkElement* CastToHTMLLinkElement(WebCore::Node* node); -WebCore::HTMLMetaElement* CastToHTMLMetaElement(WebCore::Node* node); -WebCore::HTMLOptionElement* CastToHTMLOptionElement(WebCore::Node* node); - // If element is HTML:IFrame or HTML:Frame, then return the WebFrameImpl // object corresponding to the content frame, otherwise return NULL. // The parameter is_frame_element indicates whether the input element diff --git a/webkit/glue/editor_client_impl.cc b/webkit/glue/editor_client_impl.cc index 683aa65..a09c9c8 100644 --- a/webkit/glue/editor_client_impl.cc +++ b/webkit/glue/editor_client_impl.cc @@ -661,7 +661,7 @@ void EditorClientImpl::textFieldDidEndEditing(WebCore::Element* element) { // Notify any password-listener of the focus change. WebCore::HTMLInputElement* input_element = - WebKit::elementToHTMLInputElement(element); + WebKit::toHTMLInputElement(element); if (!input_element) return; @@ -685,7 +685,7 @@ void EditorClientImpl::textDidChangeInTextField(WebCore::Element* element) { bool EditorClientImpl::ShowFormAutofillForNode(WebCore::Node* node) { WebCore::HTMLInputElement* input_element = - WebKit::nodeToHTMLInputElement(node); + WebKit::toHTMLInputElement(node); if (input_element) return Autofill(input_element, true, true, false); return false; @@ -705,7 +705,8 @@ bool EditorClientImpl::Autofill(WebCore::HTMLInputElement* input_element, return false; } - string16 name = FormFieldValues::GetNameForInputElement(input_element); + string16 name = webkit_glue::StringToString16( + WebKit::nameOfInputElement(input_element)); if (name.empty()) // If the field has no name, then we won't have values. return false; @@ -765,7 +766,8 @@ void EditorClientImpl::DoAutofill(WebCore::Timer<EditorClientImpl>* timer) { } // Then trigger form autofill. - string16 name = FormFieldValues::GetNameForInputElement(input_element); + string16 name = webkit_glue::StringToString16( + WebKit::nameOfInputElement(input_element)); ASSERT(static_cast<int>(name.length()) > 0); if (webview_->client()) { diff --git a/webkit/glue/form_field_values.cc b/webkit/glue/form_field_values.cc index 97ce119..3a57fad 100644 --- a/webkit/glue/form_field_values.cc +++ b/webkit/glue/form_field_values.cc @@ -15,6 +15,8 @@ #include "base/string_util.h" #include "webkit/api/public/WebForm.h" #include "webkit/glue/form_field_values.h" +// Can include from api/src because this file will eventually be there too. +#include "webkit/api/src/DOMUtilitiesPrivate.h" #include "webkit/glue/glue_util.h" using WebKit::WebForm; @@ -62,7 +64,8 @@ FormFieldValues* FormFieldValues::Create(const WebForm& webform) { if (value.length() == 0) continue; - string16 name = GetNameForInputElement(input_element); + string16 name = StringToString16( + WebKit::nameOfInputElement(input_element)); if (name.length() == 0) continue; // If we have no name, there is nothing to store. @@ -72,21 +75,4 @@ FormFieldValues* FormFieldValues::Create(const WebForm& webform) { return result; } -// static -string16 FormFieldValues::GetNameForInputElement(WebCore::HTMLInputElement* - element) { - string16 name = StringToString16(element->name()); - string16 trimmed_name; - TrimWhitespace(name, TRIM_LEADING, &trimmed_name); - if (trimmed_name.length() > 0) - return trimmed_name; - - name = StringToString16(element->getAttribute(WebCore::HTMLNames::idAttr)); - TrimWhitespace(name, TRIM_LEADING, &trimmed_name); - if (trimmed_name.length() > 0) - return trimmed_name; - - return string16(); -} - } // namespace webkit_glue diff --git a/webkit/glue/form_field_values.h b/webkit/glue/form_field_values.h index 6f50304..7b7ee69 100644 --- a/webkit/glue/form_field_values.h +++ b/webkit/glue/form_field_values.h @@ -8,10 +8,6 @@ #include <string> #include <vector> -namespace WebCore { -class HTMLInputElement; -} - namespace WebKit { class WebForm; } @@ -35,12 +31,6 @@ class FormFieldValues { static FormFieldValues* Create(const WebKit::WebForm& form); - // Returns the name that should be used for the specified |element| when - // storing autofill data. This is either the field name or its id, an empty - // string if it has no name and no id. - static string16 GetNameForInputElement(WebCore::HTMLInputElement* - element); - // A vector of all the input fields in the form. std::vector<Element> elements; }; diff --git a/webkit/glue/webframe_impl.cc b/webkit/glue/webframe_impl.cc index 08b7281..e3a0fd5 100644 --- a/webkit/glue/webframe_impl.cc +++ b/webkit/glue/webframe_impl.cc @@ -141,10 +141,9 @@ #include "webkit/api/public/WebSize.h" #include "webkit/api/public/WebURLError.h" #include "webkit/api/public/WebVector.h" +#include "webkit/api/src/DOMUtilitiesPrivate.h" #include "webkit/api/src/WebDataSourceImpl.h" #include "webkit/glue/chrome_client_impl.h" -#include "webkit/glue/dom_operations.h" -#include "webkit/glue/dom_operations_private.h" #include "webkit/glue/glue_util.h" #include "webkit/glue/password_autocomplete_listener.h" #include "webkit/glue/webframe_impl.h" @@ -399,7 +398,7 @@ WebURL WebFrameImpl::openSearchDescriptionURL() const { for (Node* child = children->firstItem(); child != NULL; child = children->nextItem()) { WebCore::HTMLLinkElement* link_element = - webkit_glue::CastToHTMLLinkElement(child); + WebKit::toHTMLLinkElement(child); if (link_element && link_element->type() == kOSDType && link_element->rel() == kOSDRel && !link_element->href().isEmpty()) { return webkit_glue::KURLToWebURL(link_element->href()); diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc index 373d67b..c479af1 100644 --- a/webkit/glue/webview_impl.cc +++ b/webkit/glue/webview_impl.cc @@ -476,7 +476,7 @@ void WebViewImpl::MouseDown(const WebMouseEvent& event) { if (event.button == WebMouseEvent::ButtonLeft) { RefPtr<Node> focused_node = GetFocusedNode(); if (focused_node.get() && - WebKit::nodeToHTMLInputElement(focused_node.get())) { + WebKit::toHTMLInputElement(focused_node.get())) { IntPoint point(event.x, event.y); point = page_->mainFrame()->view()->windowToContents(point); HitTestResult result(point); |