Changeset 62893 in webkit


Ignore:
Timestamp:
Jul 8, 2010 10:25:47 PM (14 years ago)
Author:
jcivelli@chromium.org
Message:

2010-07-08 Jay Civelli <jcivelli@chromium.org>

Reviewed by Darin Fisher.

[chromium] Exposing the EditorClient text field related methods
to the WebViewClient. Also adding some more accessors methods
to the WebNode and WebInputElement.
This is needed to move the password autocomplete out of the
Chromium WebKit API to the Chromium code.
https://bugs.webkit.org/show_bug.cgi?id=41286

  • public/WebInputElement.h:
  • public/WebNode.h: (WebKit::operator!=): (WebKit::operator<):
  • public/WebViewClient.h: (WebKit::WebViewClient::textFieldDidBeginEditing): (WebKit::WebViewClient::textFieldDidEndEditing): (WebKit::WebViewClient::textDidChangeInTextField): (WebKit::WebViewClient::textFieldHandlingKeyDown): (WebKit::WebViewClient::didAcceptAutocompleteSuggestion):
  • src/EditorClientImpl.cpp: (WebKit::EditorClientImpl::textFieldDidBeginEditing): (WebKit::EditorClientImpl::textFieldDidEndEditing): (WebKit::EditorClientImpl::textDidChangeInTextField): (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted): (WebKit::EditorClientImpl::doTextFieldCommandFromEvent):
  • src/WebInputElement.cpp: (WebKit::WebInputElement::readOnly): (WebKit::WebInputElement::setSelectionRange): (WebKit::WebInputElement::selectionStart): (WebKit::WebInputElement::selectionEnd):
  • src/WebNode.cpp: (WebKit::WebNode::lessThan):
Location:
trunk/WebKit/chromium
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r62876 r62893  
     12010-07-08  Jay Civelli  <jcivelli@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [chromium] Exposing the EditorClient text field related methods
     6        to the WebViewClient. Also adding some more accessors methods
     7        to the WebNode and WebInputElement.
     8        This is needed to move the password autocomplete out of the
     9        Chromium WebKit API to the Chromium code.
     10        https://bugs.webkit.org/show_bug.cgi?id=41286
     11
     12        * public/WebInputElement.h:
     13        * public/WebNode.h:
     14        (WebKit::operator!=):
     15        (WebKit::operator<):
     16        * public/WebViewClient.h:
     17        (WebKit::WebViewClient::textFieldDidBeginEditing):
     18        (WebKit::WebViewClient::textFieldDidEndEditing):
     19        (WebKit::WebViewClient::textDidChangeInTextField):
     20        (WebKit::WebViewClient::textFieldHandlingKeyDown):
     21        (WebKit::WebViewClient::didAcceptAutocompleteSuggestion):
     22        * src/EditorClientImpl.cpp:
     23        (WebKit::EditorClientImpl::textFieldDidBeginEditing):
     24        (WebKit::EditorClientImpl::textFieldDidEndEditing):
     25        (WebKit::EditorClientImpl::textDidChangeInTextField):
     26        (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted):
     27        (WebKit::EditorClientImpl::doTextFieldCommandFromEvent):
     28        * src/WebInputElement.cpp:
     29        (WebKit::WebInputElement::readOnly):
     30        (WebKit::WebInputElement::setSelectionRange):
     31        (WebKit::WebInputElement::selectionStart):
     32        (WebKit::WebInputElement::selectionEnd):
     33        * src/WebNode.cpp:
     34        (WebKit::WebNode::lessThan):
     35
    1362010-07-08  Aaron Boodman  <aa@chromium.org>
    237
  • trunk/WebKit/chromium/public/WebInputElement.h

    r62705 r62893  
    8181
    8282        WEBKIT_API bool autoComplete() const;
     83        WEBKIT_API bool isReadOnly() const;
    8384        WEBKIT_API bool isEnabledFormControl() const;
    8485        WEBKIT_API InputType inputType() const;
     
    9798        WEBKIT_API void dispatchFormControlChangeEvent();
    9899        WEBKIT_API void setSelectionRange(int, int);
     100        WEBKIT_API int selectionStart();
     101        WEBKIT_API int selectionEnd();
    99102
    100103#if WEBKIT_IMPLEMENTATION
  • trunk/WebKit/chromium/public/WebNode.h

    r62770 r62893  
    6262
    6363    WEBKIT_API bool equals(const WebNode&) const;
    64 
     64    // Required for using WebNodes in std maps.  Note the order used is
     65    // arbitrary and should not be expected to have any specific meaning.
     66    WEBKIT_API bool lessThan(const WebNode&) const;
     67   
    6568    bool isNull() const { return m_private.isNull(); }
    6669
     
    151154}
    152155
     156inline bool operator<(const WebNode& a, const WebNode& b)
     157{
     158    return a.lessThan(b);
     159}
     160
    153161} // namespace WebKit
    154162
  • trunk/WebKit/chromium/public/WebViewClient.h

    r62039 r62893  
    4646class WebAccessibilityObject;
    4747class WebDragData;
     48class WebElement;
    4849class WebFileChooserCompletion;
    4950class WebFrame;
    5051class WebGeolocationService;
    5152class WebImage;
     53class WebInputElement;
     54class WebKeyboardEvent;
    5255class WebNode;
    5356class WebNotificationPresenter;
     
    133136    virtual void didEndEditing() { }
    134137
     138    // These methods are called when the users edits a text-field.
     139    virtual void textFieldDidBeginEditing(const WebInputElement&) { }
     140    virtual void textFieldDidEndEditing(const WebInputElement&) { }
     141    virtual void textFieldDidChange(const WebInputElement&) { }
     142    virtual void textFieldDidReceiveKeyDown(const WebInputElement&, const WebKeyboardEvent&) { }
     143
    135144    // This method is called in response to WebView's handleInputEvent()
    136145    // when the default action for the current keyboard event is not
     
    313322    virtual void didClearAutoFillSelection(const WebNode&) { }
    314323
     324    // Informs the browser that the user has selected an autocomplete (password
     325    // or field) suggestion from the drop-down.  The input element text has
     326    // already been set to the selected suggestion.
     327    virtual void didAcceptAutocompleteSuggestion(const WebInputElement&) { }
     328
    315329    // Geolocation ---------------------------------------------------------
    316330
  • trunk/WebKit/chromium/src/EditorClientImpl.cpp

    r62272 r62893  
    4444#include "DOMUtilitiesPrivate.h"
    4545#include "WebEditingAction.h"
     46#include "WebElement.h"
    4647#include "WebFrameImpl.h"
    4748#include "WebKit.h"
    4849#include "WebInputElement.h"
     50#include "WebInputEventConversion.h"
    4951#include "WebNode.h"
    5052#include "WebPasswordAutocompleteListener.h"
     
    9193    // it if in testing mode and the test specifically requests it by using this
    9294    // magic class name.
    93     return WebKit::layoutTestMode()
     95    return layoutTestMode()
    9496           && elem->getAttribute(HTMLNames::classAttr) == "needsDeletionUI";
    9597}
     
    645647}
    646648
    647 void EditorClientImpl::textFieldDidBeginEditing(Element*)
    648 {
     649void EditorClientImpl::textFieldDidBeginEditing(Element* element)
     650{
     651    HTMLInputElement* inputElement = toHTMLInputElement(element);
     652    if (m_webView->client() && inputElement)
     653        m_webView->client()->textFieldDidBeginEditing(WebInputElement(inputElement));
    649654}
    650655
    651656void EditorClientImpl::textFieldDidEndEditing(Element* element)
    652657{
     658    HTMLInputElement* inputElement = toHTMLInputElement(element);
     659    if (m_webView->client() && inputElement)
     660        m_webView->client()->textFieldDidEndEditing(WebInputElement(inputElement));
     661
    653662    // Notification that focus was lost.  Be careful with this, it's also sent
    654663    // when the page is being closed.
     
    665674
    666675    // Notify any password-listener of the focus change.
    667     HTMLInputElement* inputElement = WebKit::toHTMLInputElement(element);
    668676    if (!inputElement)
    669677        return;
     
    683691{
    684692    ASSERT(element->hasLocalName(HTMLNames::inputTag));
     693    HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
     694    if (m_webView->client())
     695        m_webView->client()->textFieldDidChange(WebInputElement(inputElement));
     696
    685697    // Note that we only show the autofill popup in this case if the caret is at
    686698    // the end.  This matches FireFox and Safari but not IE.
    687     autofill(static_cast<HTMLInputElement*>(element), false, false,
    688              true);
     699    autofill(inputElement, false, false, true);
    689700}
    690701
    691702bool EditorClientImpl::showFormAutofillForNode(Node* node)
    692703{
    693     HTMLInputElement* inputElement = WebKit::toHTMLInputElement(node);
     704    HTMLInputElement* inputElement = toHTMLInputElement(node);
    694705    if (inputElement)
    695706        return autofill(inputElement, true, true, false);
     
    793804void EditorClientImpl::onAutocompleteSuggestionAccepted(HTMLInputElement* textField)
    794805{
     806    if (m_webView->client())
     807        m_webView->client()->didAcceptAutocompleteSuggestion(WebInputElement(textField));
     808
    795809    WebFrameImpl* webframe = WebFrameImpl::fromFrame(textField->document()->frame());
    796810    if (!webframe)
     
    803817                                                   KeyboardEvent* event)
    804818{
     819    HTMLInputElement* inputElement = toHTMLInputElement(element);
     820    if (m_webView->client() && inputElement) {
     821        m_webView->client()->textFieldDidReceiveKeyDown(WebInputElement(inputElement),
     822                                                        WebKeyboardEventBuilder(*event));
     823    }
     824
    805825    // Remember if backspace was pressed for the autofill.  It is not clear how to
    806826    // find if backspace was pressed from textFieldDidBeginEditing and
  • trunk/WebKit/chromium/src/WebInputElement.cpp

    r62705 r62893  
    4444{
    4545    return constUnwrap<HTMLInputElement>()->autoComplete();
     46}
     47
     48bool WebInputElement::isReadOnly() const
     49{
     50    return constUnwrap<HTMLInputElement>()->readOnly();
    4651}
    4752
     
    126131}
    127132
     133int WebInputElement::selectionStart()
     134{
     135    return unwrap<HTMLInputElement>()->selectionStart();
     136}
     137
     138int WebInputElement::selectionEnd()
     139{
     140    return unwrap<HTMLInputElement>()->selectionEnd();
     141}
     142
    128143WebInputElement::WebInputElement(const PassRefPtr<HTMLInputElement>& elem)
    129144    : WebFormControlElement(elem)
  • trunk/WebKit/chromium/src/WebNode.cpp

    r58967 r62893  
    6868}
    6969
     70bool WebNode::lessThan(const WebNode& n) const
     71{
     72    return (m_private.get() < n.m_private.get());
     73}
     74
    7075WebNode::NodeType WebNode::nodeType() const
    7176{
Note: See TracChangeset for help on using the changeset viewer.