Changeset 51224 in webkit


Ignore:
Timestamp:
Nov 19, 2009 5:09:49 PM (14 years ago)
Author:
eric@webkit.org
Message:

2009-11-19 Yaar Schnitman <yaar@chromium.org>

Reviewed by Darin Fisher.

Make chromium/webkit/glue/FormFieldValues use the WebKit API

https://bugs.webkit.org/show_bug.cgi?id=31650

  • public/WebElement.h:
  • public/WebFormElement.h:
  • public/WebInputElement.h: (WebKit::WebInputElement::):
  • public/WebNode.h:
  • src/AssertMatchingEnums.cpp:
  • src/DOMUtilitiesPrivate.cpp: (WebKit::nameOfInputElement):
  • src/DOMUtilitiesPrivate.h:
  • src/EditorClientImpl.cpp: (WebKit::EditorClientImpl::autofill): (WebKit::EditorClientImpl::doAutofill):
  • src/WebFormElement.cpp: (WebKit::WebFormElement::name): (WebKit::WebFormElement::method): (WebKit::WebFormElement::getNamedElements): (WebKit::WebFormElement::getInputElements):
  • src/WebInputElement.cpp: (WebKit::WebInputElement::isEnabledFormControl): (WebKit::WebInputElement::inputType): (WebKit::WebInputElement::formControlType): (WebKit::WebInputElement::value): (WebKit::WebInputElement::dispatchFormControlChangeEvent): (WebKit::WebInputElement::setSelectionRange): (WebKit::WebInputElement::name): (WebKit::WebInputElement::nameForAutofill):
  • src/WebNode.cpp: (WebKit::WebNode::frame):
Location:
trunk/WebKit/chromium
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r51172 r51224  
     12009-11-19  Yaar Schnitman  <yaar@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        Make chromium/webkit/glue/FormFieldValues use the WebKit API
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=31650
     8
     9        * public/WebElement.h:
     10        * public/WebFormElement.h:
     11        * public/WebInputElement.h:
     12        (WebKit::WebInputElement::):
     13        * public/WebNode.h:
     14        * src/AssertMatchingEnums.cpp:
     15        * src/DOMUtilitiesPrivate.cpp:
     16        (WebKit::nameOfInputElement):
     17        * src/DOMUtilitiesPrivate.h:
     18        * src/EditorClientImpl.cpp:
     19        (WebKit::EditorClientImpl::autofill):
     20        (WebKit::EditorClientImpl::doAutofill):
     21        * src/WebFormElement.cpp:
     22        (WebKit::WebFormElement::name):
     23        (WebKit::WebFormElement::method):
     24        (WebKit::WebFormElement::getNamedElements):
     25        (WebKit::WebFormElement::getInputElements):
     26        * src/WebInputElement.cpp:
     27        (WebKit::WebInputElement::isEnabledFormControl):
     28        (WebKit::WebInputElement::inputType):
     29        (WebKit::WebInputElement::formControlType):
     30        (WebKit::WebInputElement::value):
     31        (WebKit::WebInputElement::dispatchFormControlChangeEvent):
     32        (WebKit::WebInputElement::setSelectionRange):
     33        (WebKit::WebInputElement::name):
     34        (WebKit::WebInputElement::nameForAutofill):
     35        * src/WebNode.cpp:
     36        (WebKit::WebNode::frame):
     37
    1382009-11-18  Michelangelo De Simone  <micdesim@gmail.com>
    239
  • trunk/WebKit/chromium/public/WebElement.h

    r50669 r51224  
    5555        operator WTF::PassRefPtr<WebCore::Element>() const;
    5656#endif
    57 
    5857    };
    5958
  • trunk/WebKit/chromium/public/WebFormElement.h

    r51130 r51224  
    3333
    3434#include "WebElement.h"
     35#include "WebInputElement.h"
    3536#include "WebVector.h"
    3637
     
    6162        WEBKIT_API bool autoComplete() const;
    6263        WEBKIT_API WebString action() const;
     64        WEBKIT_API WebString name() const;
     65        WEBKIT_API WebString method() const;
    6366        WEBKIT_API void submit();
     67        // FIXME: Deprecate and replace with WebVector<WebElement>.
    6468        WEBKIT_API void getNamedElements(const WebString&, WebVector<WebNode>&);
     69        WEBKIT_API void getInputElements(WebVector<WebInputElement>&) const;
    6570    };
    6671
  • trunk/WebKit/chromium/public/WebInputElement.h

    r50669 r51224  
    5656#endif
    5757
    58         void setActivatedSubmit(bool);
    59         void setValue(const WebString& value);
    60         WebString value();
    61         void setAutofilled(bool);
    62         void dispatchFormControlChangeEvent();
    63         void setSelectionRange(size_t, size_t);
     58        enum InputType {
     59            Text = 0,
     60            Password,
     61            IsIndex,
     62            CheckBox,
     63            Radio,
     64            Submit,
     65            Reset,
     66            File,
     67            Hidden,
     68            Image,
     69            Button,
     70            Search,
     71            Range,
     72            Email,
     73            Number,
     74            Telephone,
     75            URL,
     76            Color,
     77            Date,
     78            DateTime,
     79            DateTimeLocal,
     80            Month,
     81            Time,
     82            Week
     83        };
     84       
     85        WEBKIT_API bool isEnabledFormControl() const;
     86        WEBKIT_API InputType inputType() const;
     87        WEBKIT_API WebString formControlType() const;
     88        WEBKIT_API void setActivatedSubmit(bool);
     89        WEBKIT_API void setValue(const WebString& value);
     90        WEBKIT_API WebString value() const;
     91        WEBKIT_API void setAutofilled(bool);
     92        WEBKIT_API void dispatchFormControlChangeEvent();
     93        WEBKIT_API void setSelectionRange(int, int);
     94        WEBKIT_API WebString name() const;
     95        // Returns the name that should be used for the specified |element| when
     96        // storing autofill data.  This is either the field name or its id, an empty
     97        // string if it has no name and no id.
     98        WEBKIT_API WebString nameForAutofill() const;
     99       
    64100    };
    65101
  • trunk/WebKit/chromium/public/WebNode.h

    r51130 r51224  
    6969    WEBKIT_API WebNode parentNode() const;
    7070    WEBKIT_API WebString nodeName() const;
    71     WEBKIT_API WebFrame* frame();
     71    WEBKIT_API WebFrame* frame() const;
    7272
    7373    template<typename T> T toElement()
  • trunk/WebKit/chromium/src/AssertMatchingEnums.cpp

    r51008 r51224  
    3737#include "ApplicationCacheHost.h"
    3838#include "EditorInsertAction.h"
     39#include "HTMLInputElement.h"
    3940#include "MediaPlayer.h"
    4041#include "NotificationPresenter.h"
     
    4748#include "WebCursorInfo.h"
    4849#include "WebEditingAction.h"
     50#include "WebInputElement.h"
    4951#include "WebMediaPlayer.h"
    5052#include "WebNotificationPresenter.h"
     
    216218COMPILE_ASSERT_MATCHING_ENUM(WebEditingActionDropped, EditorInsertActionDropped);
    217219
     220COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Text, HTMLInputElement::TEXT);
     221COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Password, HTMLInputElement::PASSWORD);
     222COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::IsIndex, HTMLInputElement::ISINDEX);
     223COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::CheckBox, HTMLInputElement::CHECKBOX);
     224COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Radio, HTMLInputElement::RADIO);
     225COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Submit, HTMLInputElement::SUBMIT);
     226COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Reset, HTMLInputElement::RESET);
     227COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::File, HTMLInputElement::FILE);
     228COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Hidden, HTMLInputElement::HIDDEN);
     229COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Image, HTMLInputElement::IMAGE);
     230COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Button, HTMLInputElement::BUTTON);
     231COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Search, HTMLInputElement::SEARCH);
     232COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Range, HTMLInputElement::RANGE);
     233COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Email, HTMLInputElement::EMAIL);
     234COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Number, HTMLInputElement::NUMBER);
     235COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Telephone, HTMLInputElement::TELEPHONE);
     236COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::URL, HTMLInputElement::URL);
     237COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Color, HTMLInputElement::COLOR);
     238COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Date, HTMLInputElement::DATE);
     239COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::DateTime, HTMLInputElement::DATETIME);
     240COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::DateTimeLocal, HTMLInputElement::DATETIMELOCAL);
     241COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Month, HTMLInputElement::MONTH);
     242COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Time, HTMLInputElement::TIME);
     243COMPILE_ASSERT_MATCHING_ENUM(WebInputElement::Week, HTMLInputElement::WEEK);
     244
    218245#if ENABLE(VIDEO)
    219246COMPILE_ASSERT_MATCHING_ENUM(WebMediaPlayer::Empty, MediaPlayer::Empty);
  • trunk/WebKit/chromium/src/DOMUtilitiesPrivate.cpp

    r50742 r51224  
    4040#include "Node.h"
    4141
     42#include "WebInputElement.h"
     43
    4244using namespace WebCore;
    4345
     
    8082String nameOfInputElement(HTMLInputElement* element)
    8183{
    82     String name = element->name();
    83     String trimmedName = name.stripWhiteSpace();
    84     if (!trimmedName.isEmpty())
    85         return trimmedName;
    86 
    87     name = element->getAttribute(HTMLNames::idAttr);
    88     trimmedName = name.stripWhiteSpace();
    89     if (!trimmedName.isEmpty())
    90         return trimmedName;
    91 
    92     return String();
     84    return WebInputElement(element).nameForAutofill();
    9385}
    9486
  • trunk/WebKit/chromium/src/DOMUtilitiesPrivate.h

    r50742 r51224  
    5151WebCore::HTMLOptionElement* toHTMLOptionElement(WebCore::Node*);
    5252
    53 // Returns the name that should be used for the specified |element| when
    54 // storing autofill data.  This is either the field name or its id, an empty
    55 // string if it has no name and no id.
     53// FIXME: Deprecate. Use WebInputElement::nameForAutofill instead.
    5654WebCore::String nameOfInputElement(WebCore::HTMLInputElement*);
    5755
  • trunk/WebKit/chromium/src/EditorClientImpl.cpp

    r50742 r51224  
    4646#include "WebFrameImpl.h"
    4747#include "WebKit.h"
     48#include "WebInputElement.h"
    4849#include "WebNode.h"
    4950#include "WebPasswordAutocompleteListener.h"
     
    707708        return false;
    708709
    709     WebString name = WebKit::nameOfInputElement(inputElement);
     710    WebString name = WebInputElement(inputElement).nameForAutofill();
    710711    if (name.isEmpty()) // If the field has no name, then we won't have values.
    711712        return false;
     
    770771
    771772    // Then trigger form autofill.
    772     WebString name = WebKit::nameOfInputElement(inputElement);
     773    WebString name = WebInputElement(inputElement).nameForAutofill();
    773774    ASSERT(static_cast<int>(name.length()) > 0);
    774775
  • trunk/WebKit/chromium/src/WebFormElement.cpp

    r51130 r51224  
    3232#include "WebFormElement.h"
    3333
     34#include "HTMLFormControlElement.h"
    3435#include "HTMLFormElement.h"
     36#include "HTMLInputElement.h"
     37#include "HTMLNames.h"
    3538#include "WebString.h"
    3639#include "WebURL.h"
     
    7073}
    7174
     75WebString WebFormElement::name() const
     76{
     77    return constUnwrap<HTMLFormElement>()->name();
     78}
     79
     80WebString WebFormElement::method() const
     81{
     82    return constUnwrap<HTMLFormElement>()->method();
     83}
     84   
    7285void WebFormElement::submit()
    7386{
     
    7891                                      WebVector<WebNode>& result)
    7992{
    80     Vector<RefPtr<Node> > temp_vector;
    81     unwrap<HTMLFormElement>()->getNamedElements(name, temp_vector);
    82     result.assign(temp_vector);
     93    Vector<RefPtr<Node> > tempVector;
     94    unwrap<HTMLFormElement>()->getNamedElements(name, tempVector);
     95    result.assign(tempVector);
     96}
     97   
     98void WebFormElement::getInputElements(WebVector<WebInputElement>& result) const
     99{
     100    const HTMLFormElement* form = constUnwrap<HTMLFormElement>();
     101    Vector<RefPtr<HTMLInputElement> > tempVector;
     102    for (size_t i = 0; i < form->formElements.size(); i++) {
     103        if (form->formElements[i]->hasLocalName(HTMLNames::inputTag))
     104            tempVector.append(static_cast<HTMLInputElement*>(
     105                form->formElements[i]));
     106    }
     107    result.assign(tempVector);
    83108}
    84109
  • trunk/WebKit/chromium/src/WebInputElement.cpp

    r50721 r51224  
    3333
    3434#include "HTMLInputElement.h"
     35#include "HTMLNames.h"
    3536#include "WebString.h"
    3637#include <wtf/PassRefPtr.h>
     
    5657}
    5758
     59bool WebInputElement::isEnabledFormControl() const
     60{
     61    return constUnwrap<HTMLInputElement>()->isEnabledFormControl();
     62}
     63
     64WebInputElement::InputType WebInputElement::inputType() const
     65{
     66    return static_cast<InputType>(constUnwrap<HTMLInputElement>()->inputType());
     67}
     68
     69WebString WebInputElement::formControlType() const
     70{
     71    return constUnwrap<HTMLInputElement>()->formControlType();
     72}
     73   
    5874void WebInputElement::setActivatedSubmit(bool activated)
    5975{
    6076    unwrap<HTMLInputElement>()->setActivatedSubmit(activated);
    6177}
    62 
    6378
    6479void WebInputElement::setValue(const WebString& value)
     
    6782}
    6883
    69 WebString WebInputElement::value()
     84WebString WebInputElement::value() const
    7085{
    71     return unwrap<HTMLInputElement>()->value();
     86    return constUnwrap<HTMLInputElement>()->value();
    7287}
    73 
    7488
    7589void WebInputElement::setAutofilled(bool autoFilled)
     
    8195{
    8296    unwrap<HTMLInputElement>()->dispatchFormControlChangeEvent();
    83 } // namespace WebKit
     97}
    8498
    85 void WebInputElement::setSelectionRange(size_t start, size_t end)
     99void WebInputElement::setSelectionRange(int start, int end)
    86100{
    87101    unwrap<HTMLInputElement>()->setSelectionRange(start, end);
    88102}
     103   
     104WebString WebInputElement::name() const
     105{
     106    return constUnwrap<HTMLInputElement>()->name();
     107}
     108   
     109WebString WebInputElement::nameForAutofill() const
     110{
     111    String name = constUnwrap<HTMLInputElement>()->name();
     112    String trimmedName = name.stripWhiteSpace();
     113    if (!trimmedName.isEmpty())
     114        return trimmedName;
     115    name = constUnwrap<HTMLInputElement>()->getAttribute(HTMLNames::idAttr);
     116    trimmedName = name.stripWhiteSpace();
     117    if (!trimmedName.isEmpty())
     118        return trimmedName;
     119    return String();
     120}
     121
    89122} // namespace WebKit
  • trunk/WebKit/chromium/src/WebNode.cpp

    r51130 r51224  
    9696}
    9797
    98 WebFrame* WebNode::frame()
     98WebFrame* WebNode::frame() const
    9999{
    100100    return WebFrameImpl::fromFrame(m_private->document()->frame());
Note: See TracChangeset for help on using the changeset viewer.