Changeset 62272 in webkit


Ignore:
Timestamp:
Jul 1, 2010 10:14:53 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-07-01 David Holloway <dhollowa@chromium.org>

Reviewed by Darin Fisher.

[chromium] Consolidates AutoFill and Autocomplete popup menus into a single popup menu.

This change combines SuggestionsPopupMenuClient, AutoFillPopupMenuClient, and
AutocompletePopupMenuClient classes into a single consolidated AutoFillPopupMenuClient class.
Prior to this change the contents of the AutoFill popup menu only included AutoFill
suggestions and similarly the Autocomplete popup menu only included Autocomplete
suggestions. With this consolidation, both AutoFill and Autocomplete suggestions can
now be displayed in a single menu.

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

  • WebKit.gyp:
  • public/WebFrame.h:
  • public/WebView.h:
  • src/AutoFillPopupMenuClient.cpp: (WebKit::AutoFillPopupMenuClient::AutoFillPopupMenuClient): (WebKit::AutoFillPopupMenuClient::~AutoFillPopupMenuClient): (WebKit::AutoFillPopupMenuClient::valueChanged): (WebKit::AutoFillPopupMenuClient::selectionCleared): (WebKit::AutoFillPopupMenuClient::itemText): (WebKit::AutoFillPopupMenuClient::itemStyle): (WebKit::AutoFillPopupMenuClient::menuStyle): (WebKit::AutoFillPopupMenuClient::clientPaddingLeft): (WebKit::AutoFillPopupMenuClient::clientPaddingRight): (WebKit::AutoFillPopupMenuClient::popupDidHide): (WebKit::AutoFillPopupMenuClient::setTextFromItem): (WebKit::AutoFillPopupMenuClient::fontSelector): (WebKit::AutoFillPopupMenuClient::hostWindow): (WebKit::AutoFillPopupMenuClient::createScrollbar): (WebKit::AutoFillPopupMenuClient::initialize): (WebKit::AutoFillPopupMenuClient::getWebView): (WebKit::AutoFillPopupMenuClient::textFieldStyle):
  • src/AutoFillPopupMenuClient.h: (WebKit::AutoFillPopupMenuClient::itemToolTip): (WebKit::AutoFillPopupMenuClient::itemAccessibilityText): (WebKit::AutoFillPopupMenuClient::itemIsEnabled): (WebKit::AutoFillPopupMenuClient::clientInsetLeft): (WebKit::AutoFillPopupMenuClient::clientInsetRight): (WebKit::AutoFillPopupMenuClient::listSize): (WebKit::AutoFillPopupMenuClient::selectedIndex): (WebKit::AutoFillPopupMenuClient::itemIsLabel): (WebKit::AutoFillPopupMenuClient::itemIsSelected): (WebKit::AutoFillPopupMenuClient::shouldPopOver): (WebKit::AutoFillPopupMenuClient::valueShouldChangeOnHotTrack): (WebKit::AutoFillPopupMenuClient::setAutocompleteMode): (WebKit::AutoFillPopupMenuClient::getTextField): (WebKit::AutoFillPopupMenuClient::getSelectedIndex): (WebKit::AutoFillPopupMenuClient::setSelectedIndex):
  • src/AutocompletePopupMenuClient.cpp: Removed.
  • src/AutocompletePopupMenuClient.h: Removed.
  • src/EditorClientImpl.cpp: (WebKit::EditorClientImpl::textFieldDidEndEditing): (WebKit::EditorClientImpl::doAutofill): (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted):
  • src/SuggestionsPopupMenuClient.cpp: Removed.
  • src/SuggestionsPopupMenuClient.h: Removed.
  • src/WebFrameImpl.cpp: (WebKit::WebFrameImpl::currentHistoryItem): (WebKit::WebFrameImpl::notifiyPasswordListenerOfAutocomplete):
  • src/WebFrameImpl.h:
  • src/WebViewImpl.cpp: (WebKit::): (WebKit::WebViewImpl::WebViewImpl): (WebKit::WebViewImpl::mouseDown): (WebKit::WebViewImpl::mouseUp): (WebKit::WebViewImpl::selectPopupHandleKeyEvent): (WebKit::WebViewImpl::autocompleteHandleKeyEvent): (WebKit::WebViewImpl::hideAutoFillPopup): (WebKit::WebViewImpl::setFocus): (WebKit::WebViewImpl::applyAutoFillSuggestions): (WebKit::WebViewImpl::applyAutocompleteSuggestions): (WebKit::WebViewImpl::hidePopups): (WebKit::WebViewImpl::refreshAutoFillPopup):
  • src/WebViewImpl.h: (WebKit::WebViewImpl::autoFillPopupDidHide):
Location:
trunk/WebKit/chromium
Files:
4 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKit/chromium/ChangeLog

    r62246 r62272  
     12010-07-01  David Holloway  <dhollowa@chromium.org>
     2
     3        Reviewed by Darin Fisher.
     4
     5        [chromium] Consolidates AutoFill and Autocomplete popup menus into a single popup menu.
     6
     7        This change combines SuggestionsPopupMenuClient, AutoFillPopupMenuClient, and
     8        AutocompletePopupMenuClient classes into a single consolidated AutoFillPopupMenuClient class.
     9        Prior to this change the contents of the AutoFill popup menu only included AutoFill
     10        suggestions and similarly the Autocomplete popup menu only included Autocomplete
     11        suggestions.  With this consolidation, both AutoFill and Autocomplete suggestions can
     12        now be displayed in a single menu.
     13
     14        https://bugs.webkit.org/show_bug.cgi?id=41236
     15
     16        * WebKit.gyp:
     17        * public/WebFrame.h:
     18        * public/WebView.h:
     19        * src/AutoFillPopupMenuClient.cpp:
     20        (WebKit::AutoFillPopupMenuClient::AutoFillPopupMenuClient):
     21        (WebKit::AutoFillPopupMenuClient::~AutoFillPopupMenuClient):
     22        (WebKit::AutoFillPopupMenuClient::valueChanged):
     23        (WebKit::AutoFillPopupMenuClient::selectionCleared):
     24        (WebKit::AutoFillPopupMenuClient::itemText):
     25        (WebKit::AutoFillPopupMenuClient::itemStyle):
     26        (WebKit::AutoFillPopupMenuClient::menuStyle):
     27        (WebKit::AutoFillPopupMenuClient::clientPaddingLeft):
     28        (WebKit::AutoFillPopupMenuClient::clientPaddingRight):
     29        (WebKit::AutoFillPopupMenuClient::popupDidHide):
     30        (WebKit::AutoFillPopupMenuClient::setTextFromItem):
     31        (WebKit::AutoFillPopupMenuClient::fontSelector):
     32        (WebKit::AutoFillPopupMenuClient::hostWindow):
     33        (WebKit::AutoFillPopupMenuClient::createScrollbar):
     34        (WebKit::AutoFillPopupMenuClient::initialize):
     35        (WebKit::AutoFillPopupMenuClient::getWebView):
     36        (WebKit::AutoFillPopupMenuClient::textFieldStyle):
     37        * src/AutoFillPopupMenuClient.h:
     38        (WebKit::AutoFillPopupMenuClient::itemToolTip):
     39        (WebKit::AutoFillPopupMenuClient::itemAccessibilityText):
     40        (WebKit::AutoFillPopupMenuClient::itemIsEnabled):
     41        (WebKit::AutoFillPopupMenuClient::clientInsetLeft):
     42        (WebKit::AutoFillPopupMenuClient::clientInsetRight):
     43        (WebKit::AutoFillPopupMenuClient::listSize):
     44        (WebKit::AutoFillPopupMenuClient::selectedIndex):
     45        (WebKit::AutoFillPopupMenuClient::itemIsLabel):
     46        (WebKit::AutoFillPopupMenuClient::itemIsSelected):
     47        (WebKit::AutoFillPopupMenuClient::shouldPopOver):
     48        (WebKit::AutoFillPopupMenuClient::valueShouldChangeOnHotTrack):
     49        (WebKit::AutoFillPopupMenuClient::setAutocompleteMode):
     50        (WebKit::AutoFillPopupMenuClient::getTextField):
     51        (WebKit::AutoFillPopupMenuClient::getSelectedIndex):
     52        (WebKit::AutoFillPopupMenuClient::setSelectedIndex):
     53        * src/AutocompletePopupMenuClient.cpp: Removed.
     54        * src/AutocompletePopupMenuClient.h: Removed.
     55        * src/EditorClientImpl.cpp:
     56        (WebKit::EditorClientImpl::textFieldDidEndEditing):
     57        (WebKit::EditorClientImpl::doAutofill):
     58        (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted):
     59        * src/SuggestionsPopupMenuClient.cpp: Removed.
     60        * src/SuggestionsPopupMenuClient.h: Removed.
     61        * src/WebFrameImpl.cpp:
     62        (WebKit::WebFrameImpl::currentHistoryItem):
     63        (WebKit::WebFrameImpl::notifiyPasswordListenerOfAutocomplete):
     64        * src/WebFrameImpl.h:
     65        * src/WebViewImpl.cpp:
     66        (WebKit::):
     67        (WebKit::WebViewImpl::WebViewImpl):
     68        (WebKit::WebViewImpl::mouseDown):
     69        (WebKit::WebViewImpl::mouseUp):
     70        (WebKit::WebViewImpl::selectPopupHandleKeyEvent):
     71        (WebKit::WebViewImpl::autocompleteHandleKeyEvent):
     72        (WebKit::WebViewImpl::hideAutoFillPopup):
     73        (WebKit::WebViewImpl::setFocus):
     74        (WebKit::WebViewImpl::applyAutoFillSuggestions):
     75        (WebKit::WebViewImpl::applyAutocompleteSuggestions):
     76        (WebKit::WebViewImpl::hidePopups):
     77        (WebKit::WebViewImpl::refreshAutoFillPopup):
     78        * src/WebViewImpl.h:
     79        (WebKit::WebViewImpl::autoFillPopupDidHide):
     80
    1812010-07-01  Yury Semikhatsky  <yurys@chromium.org>
    282
  • trunk/WebKit/chromium/WebKit.gyp

    r62133 r62272  
    230230                'src/ApplicationCacheHostInternal.h',
    231231                'src/AssertMatchingEnums.cpp',
    232                 'src/AutocompletePopupMenuClient.cpp',
    233                 'src/AutocompletePopupMenuClient.h',
    234232                'src/AutoFillPopupMenuClient.cpp',
    235233                'src/AutoFillPopupMenuClient.h',
     
    311309                'src/StorageNamespaceProxy.cpp',
    312310                'src/StorageNamespaceProxy.h',
    313                 'src/SuggestionsPopupMenuClient.cpp',
    314                 'src/SuggestionsPopupMenuClient.h',
    315311                'src/TemporaryGlue.h',
    316312                'src/ToolsAgent.h',
  • trunk/WebKit/chromium/public/WebFrame.h

    r61975 r62272  
    489489        WebPasswordAutocompleteListener*) = 0;
    490490
     491    // Dispatches an Autocompletion notification to registered listener if one
     492    // exists that is registered against the WebInputElement specified.
     493    virtual void notifiyPasswordListenerOfAutocomplete(
     494        const WebInputElement&) = 0;
     495
    491496
    492497    // Utility -------------------------------------------------------------
  • trunk/WebKit/chromium/public/WebView.h

    r62234 r62272  
    235235
    236236
    237     // AutoFill / Autocomplete ---------------------------------------------
     237    // AutoFill  -----------------------------------------------------------
    238238
    239239    // Notifies the WebView that AutoFill suggestions are available for a node.
     
    242242        const WebVector<WebString>& names,
    243243        const WebVector<WebString>& labels,
    244         int defaultSuggestionIndex) = 0;
     244        int separatorIndex) = 0;
    245245
    246246    // Notifies the WebView that Autocomplete suggestions are available for a
    247247    // node.
     248    // DEPRECATED: merging with applyAutoFillSuggestions.
    248249    virtual void applyAutocompleteSuggestions(
    249250        const WebNode&,
  • trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp

    r61486 r62272  
    3232#include "AutoFillPopupMenuClient.h"
    3333
     34#include "CSSStyleSelector.h"
     35#include "CSSValueKeywords.h"
     36#include "Chrome.h"
     37#include "FrameView.h"
    3438#include "HTMLInputElement.h"
     39#include "RenderTheme.h"
    3540#include "WebNode.h"
    3641#include "WebString.h"
     
    4348namespace WebKit {
    4449
     50AutoFillPopupMenuClient::AutoFillPopupMenuClient()
     51    : m_separatorIndex(-1)
     52    , m_selectedIndex(-1)
     53    , m_textField(0)
     54    , m_AutocompleteModeEnabled(false)
     55{
     56}
     57
     58AutoFillPopupMenuClient::~AutoFillPopupMenuClient()
     59{
     60}
     61
    4562unsigned AutoFillPopupMenuClient::getSuggestionsCount() const
    4663{
     
    7693void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
    7794{
     95    // DEPRECATED: Will be removed once AutoFill and Autocomplete merge is
     96    // completed.
     97    if (m_AutocompleteModeEnabled) {
     98        m_textField->setValue(getSuggestion(listIndex));
     99
     100        WebViewImpl* webView = getWebView();
     101        if (!webView)
     102            return;
     103
     104        EditorClientImpl* editor =
     105            static_cast<EditorClientImpl*>(webView->page()->editorClient());
     106        ASSERT(editor);
     107        editor->onAutocompleteSuggestionAccepted(
     108            static_cast<HTMLInputElement*>(m_textField.get()));
     109    } else {
     110      WebViewImpl* webView = getWebView();
     111      if (!webView)
     112          return;
     113
     114      if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex))
     115          --listIndex;
     116
     117      ASSERT(listIndex < m_names.size());
     118
     119      webView->client()->didAcceptAutoFillSuggestion(WebNode(getTextField()),
     120                                                     m_names[listIndex],
     121                                                     m_labels[listIndex],
     122                                                     listIndex);
     123    }
     124}
     125
     126void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
     127{
    78128    WebViewImpl* webView = getWebView();
    79129    if (!webView)
     
    85135    ASSERT(listIndex < m_names.size());
    86136
    87     webView->client()->didAcceptAutoFillSuggestion(WebNode(getTextField()),
     137    webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()),
    88138                                                   m_names[listIndex],
    89                                                    m_labels[listIndex],
    90                                                    listIndex);
    91 }
    92 
    93 void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
     139                                                   m_labels[listIndex]);
     140}
     141
     142void AutoFillPopupMenuClient::selectionCleared()
     143{
     144    // Same effect desired as popupDidHide, so call through.
     145    popupDidHide();
     146}
     147
     148String AutoFillPopupMenuClient::itemText(unsigned listIndex) const
     149{
     150    return getSuggestion(listIndex);
     151}
     152
     153PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const
     154{
     155    return *m_style;
     156}
     157
     158PopupMenuStyle AutoFillPopupMenuClient::menuStyle() const
     159{
     160    return *m_style;
     161}
     162
     163int AutoFillPopupMenuClient::clientPaddingLeft() const
     164{
     165    // Bug http://crbug.com/7708 seems to indicate the style can be 0.
     166    RenderStyle* style = textFieldStyle();
     167    if (!style)
     168       return 0;
     169
     170    return RenderTheme::defaultTheme()->popupInternalPaddingLeft(style);
     171}
     172
     173int AutoFillPopupMenuClient::clientPaddingRight() const
     174{
     175    // Bug http://crbug.com/7708 seems to indicate the style can be 0.
     176    RenderStyle* style = textFieldStyle();
     177    if (!style)
     178        return 0;
     179
     180    return RenderTheme::defaultTheme()->popupInternalPaddingRight(style);
     181}
     182
     183void AutoFillPopupMenuClient::popupDidHide()
    94184{
    95185    WebViewImpl* webView = getWebView();
     
    97187        return;
    98188
    99     if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex))
    100         --listIndex;
    101 
    102     ASSERT(listIndex < m_names.size());
    103 
    104     webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()),
    105                                                    m_names[listIndex],
    106                                                    m_labels[listIndex]);
    107 }
    108 
    109 void AutoFillPopupMenuClient::selectionCleared()
    110 {
    111     WebViewImpl* webView = getWebView();
    112     if (!webView)
    113         return;
    114 
    115     webView->suggestionsPopupDidHide();
     189    webView->autoFillPopupDidHide();
    116190    webView->client()->didClearAutoFillSelection(WebNode(getTextField()));
    117191}
    118192
    119 void AutoFillPopupMenuClient::popupDidHide()
    120 {
    121     // FIXME: Refactor this method, as selectionCleared() and popupDidHide()
    122     // share the exact same functionality.
    123     WebViewImpl* webView = getWebView();
    124     if (!webView)
    125         return;
    126 
    127     webView->client()->didClearAutoFillSelection(WebNode(getTextField()));
    128 }
    129 
    130193bool AutoFillPopupMenuClient::itemIsSeparator(unsigned listIndex) const
    131194{
    132195    return (m_separatorIndex != -1 && static_cast<unsigned>(m_separatorIndex) == listIndex);
     196}
     197
     198void AutoFillPopupMenuClient::setTextFromItem(unsigned listIndex)
     199{
     200    m_textField->setValue(getSuggestion(listIndex));
     201}
     202
     203FontSelector* AutoFillPopupMenuClient::fontSelector() const
     204{
     205    return m_textField->document()->styleSelector()->fontSelector();
     206}
     207
     208HostWindow* AutoFillPopupMenuClient::hostWindow() const
     209{
     210    return m_textField->document()->view()->hostWindow();
     211}
     212
     213PassRefPtr<Scrollbar> AutoFillPopupMenuClient::createScrollbar(
     214    ScrollbarClient* client,
     215    ScrollbarOrientation orientation,
     216    ScrollbarControlSize size)
     217{
     218    return Scrollbar::createNativeScrollbar(client, orientation, size);
    133219}
    134220
     
    142228    ASSERT(separatorIndex < static_cast<int>(names.size()));
    143229
     230    m_selectedIndex = -1;
     231    m_textField = textField;
     232
    144233    // The suggestions must be set before initializing the
    145     // SuggestionsPopupMenuClient.
     234    // AutoFillPopupMenuClient.
    146235    setSuggestions(names, labels, separatorIndex);
    147236
    148     SuggestionsPopupMenuClient::initialize(textField, -1);
     237    FontDescription fontDescription;
     238    RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl,
     239                                            fontDescription);
     240    RenderStyle* style = m_textField->computedStyle();
     241    fontDescription.setComputedSize(style->fontDescription().computedSize());
     242
     243    Font font(fontDescription, 0, 0);
     244    font.update(textField->document()->styleSelector()->fontSelector());
     245    // The direction of text in popup menu is set the same as the direction of
     246    // the input element: textField.
     247    m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true,
     248                                   Length(WebCore::Fixed),
     249                                   textField->renderer()->style()->direction()));
    149250}
    150251
     
    170271}
    171272
     273WebViewImpl* AutoFillPopupMenuClient::getWebView() const
     274{
     275    Frame* frame = m_textField->document()->frame();
     276    if (!frame)
     277        return 0;
     278
     279    Page* page = frame->page();
     280    if (!page)
     281        return 0;
     282
     283    return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView();
     284}
     285
     286RenderStyle* AutoFillPopupMenuClient::textFieldStyle() const
     287{
     288    RenderStyle* style = m_textField->computedStyle();
     289    if (!style) {
     290        // It seems we can only have a 0 style in a TextField if the
     291        // node is detached, in which case we the popup shoud not be
     292        // showing.  Please report this in http://crbug.com/7708 and
     293        // include the page you were visiting.
     294        ASSERT_NOT_REACHED();
     295    }
     296    return style;
     297}
     298
    172299} // namespace WebKit
  • trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h

    r60985 r62272  
    3232#define AutoFillPopupMenuClient_h
    3333
    34 #include "SuggestionsPopupMenuClient.h"
     34#include "PopupMenuClient.h"
    3535
    3636namespace WebCore {
    3737class HTMLInputElement;
     38class PopupMenuStyle;
     39class RenderStyle;
    3840}
    3941
    4042namespace WebKit {
    4143class WebString;
     44class WebViewImpl;
    4245template <typename T> class WebVector;
    4346
    4447// The AutoFill suggestions popup menu client, used to display name suggestions
    4548// with right-justified labels.
    46 class AutoFillPopupMenuClient : public SuggestionsPopupMenuClient {
     49class AutoFillPopupMenuClient : public WebCore::PopupMenuClient {
    4750public:
    48     // SuggestionsPopupMenuClient implementation:
     51    AutoFillPopupMenuClient();
     52    virtual ~AutoFillPopupMenuClient();
     53
     54    // Returns the number of suggestions available.
    4955    virtual unsigned getSuggestionsCount() const;
     56
     57    // Returns the suggestion at |listIndex|.
    5058    virtual WebString getSuggestion(unsigned listIndex) const;
     59
     60    // Removes the suggestion at |listIndex| from the list of suggestions.
    5161    virtual void removeSuggestionAtIndex(unsigned listIndex);
    5262
    53     // WebCore::PopupMenuClient implementation:
     63    // WebCore::PopupMenuClient methods:
    5464    virtual void valueChanged(unsigned listIndex, bool fireEvents = true);
    55     virtual void selectionChanged(unsigned listIndex, bool fireEvents = true);
     65    virtual void selectionChanged(unsigned, bool);
    5666    virtual void selectionCleared();
     67    virtual WebCore::String itemText(unsigned listIndex) const;
     68    virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); }
     69    virtual WebCore::String itemAccessibilityText(unsigned lastIndex) const { return WebCore::String(); }
     70    virtual bool itemIsEnabled(unsigned listIndex) const { return true; }
     71    virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const;
     72    virtual WebCore::PopupMenuStyle menuStyle() const;
     73    virtual int clientInsetLeft() const { return 0; }
     74    virtual int clientInsetRight() const { return 0; }
     75    virtual int clientPaddingLeft() const;
     76    virtual int clientPaddingRight() const;
     77    virtual int listSize() const { return getSuggestionsCount(); }
     78    virtual int selectedIndex() const { return m_selectedIndex; }
    5779    virtual void popupDidHide();
    5880    virtual bool itemIsSeparator(unsigned listIndex) const;
     81    virtual bool itemIsLabel(unsigned listIndex) const { return false; }
     82    virtual bool itemIsSelected(unsigned listIndex) const { return false; }
     83    virtual bool shouldPopOver() const { return false; }
     84    virtual bool valueShouldChangeOnHotTrack() const { return false; }
     85    virtual void setTextFromItem(unsigned listIndex);
     86    virtual WebCore::FontSelector* fontSelector() const;
     87    virtual WebCore::HostWindow* hostWindow() const;
     88    virtual PassRefPtr<WebCore::Scrollbar> createScrollbar(
     89        WebCore::ScrollbarClient* client,
     90        WebCore::ScrollbarOrientation orientation,
     91        WebCore::ScrollbarControlSize size);
    5992
    6093    void initialize(WebCore::HTMLInputElement*,
     
    67100                        int separatorIndex);
    68101
     102    // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is
     103    // complete.
     104    void setAutocompleteMode(bool enabled) { m_AutocompleteModeEnabled = enabled; }
     105
    69106private:
     107    WebViewImpl* getWebView() const;
     108    WebCore::HTMLInputElement* getTextField() const { return m_textField.get(); }
     109    WebCore::RenderStyle* textFieldStyle() const;
     110
     111    int getSelectedIndex() const { return m_selectedIndex; }
     112    void setSelectedIndex(int index) { m_selectedIndex = index; }
     113
     114    // The names and labels that make up the text of the menu items.
    70115    Vector<WebCore::String> m_names;
    71116    Vector<WebCore::String> m_labels;
     
    73118    // The index of the separator.  -1 if there is no separator.
    74119    int m_separatorIndex;
     120
     121    // The index of the selected item.  -1 if there is no selected item.
     122    int m_selectedIndex;
     123
     124    RefPtr<WebCore::HTMLInputElement> m_textField;
     125    OwnPtr<WebCore::PopupMenuStyle> m_style;
     126
     127    // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is
     128    // complete.
     129    bool m_AutocompleteModeEnabled;
    75130};
    76131
  • trunk/WebKit/chromium/src/EditorClientImpl.cpp

    r62039 r62272  
    659659
    660660    // Hide any showing popup.
    661     m_webView->hideSuggestionsPopup();
     661    m_webView->hideAutoFillPopup();
    662662
    663663    if (!m_webView->client())
     
    755755
    756756    if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) {
    757         m_webView->hideSuggestionsPopup();
     757        m_webView->hideAutoFillPopup();
    758758        return;
    759759    }
     
    797797        return;
    798798
    799     WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(textField);
    800     // Password listeners need to autocomplete other fields that depend on the
    801     // input element with autofill suggestions.
    802     if (listener)
    803         listener->performInlineAutocomplete(textField->value(), false, false);
     799    webframe->notifiyPasswordListenerOfAutocomplete(WebInputElement(textField));
    804800}
    805801
  • trunk/WebKit/chromium/src/WebFrameImpl.cpp

    r61975 r62272  
    963963{
    964964    // If we are still loading, then we don't want to clobber the current
    965     // history item as this could cause us to lose the scroll position and 
     965    // history item as this could cause us to lose the scroll position and
    966966    // document state.  However, it is OK for new navigations.
    967967    if (m_frame->loader()->loadType() == FrameLoadTypeStandard
     
    19691969}
    19701970
     1971void WebFrameImpl::notifiyPasswordListenerOfAutocomplete(
     1972    const WebInputElement& inputElement)
     1973{
     1974    RefPtr<HTMLInputElement> element = inputElement.operator PassRefPtr<HTMLInputElement>();
     1975    WebPasswordAutocompleteListener* listener = getPasswordListener(element.get());
     1976    // Password listeners need to autocomplete other fields that depend on the
     1977    // input element with autofill suggestions.
     1978    if (listener)
     1979        listener->performInlineAutocomplete(element->value(), false, false);
     1980}
     1981
    19711982WebPasswordAutocompleteListener* WebFrameImpl::getPasswordListener(
    19721983    HTMLInputElement* inputElement)
  • trunk/WebKit/chromium/src/WebFrameImpl.h

    r61975 r62272  
    169169    virtual bool registerPasswordListener(
    170170        WebInputElement, WebPasswordAutocompleteListener*);
     171    virtual void notifiyPasswordListenerOfAutocomplete(
     172        const WebInputElement&);
    171173
    172174    virtual WebString contentAsText(size_t maxChars) const;
  • trunk/WebKit/chromium/src/WebViewImpl.cpp

    r62234 r62272  
    3333
    3434#include "AutoFillPopupMenuClient.h"
    35 #include "AutocompletePopupMenuClient.h"
    3635#include "AXObjectCache.h"
    3736#include "Chrome.h"
     
    155154COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
    156155
    157 static const PopupContainerSettings suggestionsPopupSettings = {
     156static const PopupContainerSettings autoFillPopupSettings = {
    158157    false,  // setTextOnIndexChange
    159158    false,  // acceptOnAbandon
     
    241240    , m_operationsAllowed(WebDragOperationNone)
    242241    , m_dragOperation(WebDragOperationNone)
    243     , m_suggestionsPopupShowing(false)
    244     , m_suggestionsPopupClient(0)
    245     , m_suggestionsPopup(0)
     242    , m_autoFillPopupShowing(false)
     243    , m_autoFillPopupClient(0)
     244    , m_autoFillPopup(0)
    246245    , m_isTransparent(false)
    247246    , m_tabsToLinks(false)
     
    358357
    359358        // If a text field that has focus is clicked again, we should display the
    360         // suggestions popup.
     359        // AutoFill popup.
    361360        RefPtr<Node> focusedNode = focusedWebCoreNode();
    362361        if (focusedNode.get() && toHTMLInputElement(focusedNode.get())) {
     
    376375
    377376    if (clickedNode.get() && clickedNode == focusedWebCoreNode()) {
    378         // Focus has not changed, show the suggestions popup.
     377        // Focus has not changed, show the AutoFill popup.
    379378        static_cast<EditorClientImpl*>(m_page->editorClient())->
    380379            showFormAutofillForNode(clickedNode.get());
     
    458457        HitTestResult hitTestResult = focused->eventHandler()->hitTestResultAtPoint(contentPoint, false, false, ShouldHitTestScrollbars);
    459458        // We don't want to send a paste when middle clicking a scroll bar or a
    460         // link (which will navigate later in the code).  The main scrollbars 
     459        // link (which will navigate later in the code).  The main scrollbars
    461460        // have to be handled separately.
    462461        if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused && !view->scrollbarAtPoint(clickPoint)) {
     
    559558    if (!m_selectPopup)
    560559        return false;
    561    
     560
    562561    return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event));
    563562}
     
    565564bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
    566565{
    567     if (!m_suggestionsPopupShowing
     566    if (!m_autoFillPopupShowing
    568567        // Home and End should be left to the text field to process.
    569568        || event.windowsKeyCode == VKEY_HOME
     
    573572    // Pressing delete triggers the removal of the selected suggestion from the DB.
    574573    if (event.windowsKeyCode == VKEY_DELETE
    575         && m_suggestionsPopup->selectedIndex() != -1) {
     574        && m_autoFillPopup->selectedIndex() != -1) {
    576575        Node* node = focusedWebCoreNode();
    577576        if (!node || (node->nodeType() != Node::ELEMENT_NODE)) {
     
    585584        }
    586585
    587         int selectedIndex = m_suggestionsPopup->selectedIndex();
     586        int selectedIndex = m_autoFillPopup->selectedIndex();
    588587        HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
    589588        WebString name = inputElement->name();
    590         WebString value = m_suggestionsPopupClient->itemText(selectedIndex);
     589        WebString value = m_autoFillPopupClient->itemText(selectedIndex);
    591590        m_client->removeAutofillSuggestions(name, value);
    592591        // Update the entries in the currently showing popup to reflect the
    593592        // deletion.
    594         m_suggestionsPopupClient->removeSuggestionAtIndex(selectedIndex);
    595         refreshSuggestionsPopup();
     593        m_autoFillPopupClient->removeSuggestionAtIndex(selectedIndex);
     594        refreshAutoFillPopup();
    596595        return false;
    597596    }
    598597
    599     if (!m_suggestionsPopup->isInterestedInEventForKey(event.windowsKeyCode))
     598    if (!m_autoFillPopup->isInterestedInEventForKey(event.windowsKeyCode))
    600599        return false;
    601600
    602     if (m_suggestionsPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) {
     601    if (m_autoFillPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) {
    603602        // We need to ignore the next Char event after this otherwise pressing
    604603        // enter when selecting an item in the menu will go to the page.
     
    882881}
    883882
    884 void WebViewImpl::hideSuggestionsPopup()
    885 {
    886     if (m_suggestionsPopupShowing) {
    887         m_suggestionsPopup->hidePopup();
    888         m_suggestionsPopupShowing = false;
     883void WebViewImpl::hideAutoFillPopup()
     884{
     885    if (m_autoFillPopupShowing) {
     886        m_autoFillPopup->hidePopup();
     887        m_autoFillPopupShowing = false;
    889888    }
    890889}
     
    11441143        m_imeAcceptEvents = true;
    11451144    } else {
    1146         hideSuggestionsPopup();
     1145        hideAutoFillPopup();
    11471146        hideSelectPopup();
    11481147
     
    17811780
    17821781    if (names.isEmpty()) {
    1783         hideSuggestionsPopup();
     1782        hideAutoFillPopup();
    17841783        return;
    17851784    }
     
    17901789    // caret is at the end and that the text has not changed.
    17911790    if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) {
    1792         hideSuggestionsPopup();
     1791        hideAutoFillPopup();
    17931792        return;
    17941793    }
     
    18021801        m_autoFillPopupClient.set(new AutoFillPopupMenuClient);
    18031802
    1804     m_autoFillPopupClient->initialize(inputElem, names, labels,
    1805                                       separatorIndex);
    1806 
    1807     if (m_suggestionsPopupClient != m_autoFillPopupClient.get()) {
    1808         hideSuggestionsPopup();
    1809         m_suggestionsPopupClient = m_autoFillPopupClient.get();
    1810     }
     1803    m_autoFillPopupClient->initialize(inputElem, names, labels, separatorIndex);
    18111804
    18121805    if (!m_autoFillPopup.get()) {
    1813         m_autoFillPopup = PopupContainer::create(m_suggestionsPopupClient,
     1806        m_autoFillPopup = PopupContainer::create(m_autoFillPopupClient.get(),
    18141807                                                 PopupContainer::Suggestion,
    1815                                                  suggestionsPopupSettings);
    1816     }
    1817 
    1818     if (m_suggestionsPopup != m_autoFillPopup.get())
    1819         m_suggestionsPopup = m_autoFillPopup.get();
    1820 
    1821     if (m_suggestionsPopupShowing) {
     1808                                                 autoFillPopupSettings);
     1809    }
     1810
     1811    if (m_autoFillPopupShowing) {
    18221812        m_autoFillPopupClient->setSuggestions(names, labels, separatorIndex);
    1823         refreshSuggestionsPopup();
     1813        refreshAutoFillPopup();
    18241814    } else {
    1825         m_suggestionsPopup->show(focusedNode->getRect(),
     1815        m_autoFillPopup->show(focusedNode->getRect(),
    18261816                                 focusedNode->ownerDocument()->view(), 0);
    1827         m_suggestionsPopupShowing = true;
    1828     }
    1829 }
    1830 
     1817        m_autoFillPopupShowing = true;
     1818    }
     1819
     1820    // DEPRECATED: This special mode will go away once AutoFill and Autocomplete
     1821    // merge is complete.
     1822    if (m_autoFillPopupClient)
     1823        m_autoFillPopupClient->setAutocompleteMode(false);
     1824}
     1825
     1826// DEPRECATED: replacing with applyAutoFillSuggestions.
    18311827void WebViewImpl::applyAutocompleteSuggestions(
    18321828    const WebNode& node,
     
    18341830    int defaultSuggestionIndex)
    18351831{
    1836     ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size()));
    1837 
    1838     if (!m_page.get() || suggestions.isEmpty()) {
    1839         hideSuggestionsPopup();
    1840         return;
    1841     }
    1842 
    1843     RefPtr<Node> focusedNode = focusedWebCoreNode();
    1844     // If the node for which we queried the Autocomplete suggestions is not the
    1845     // focused node, then we have nothing to do.  FIXME: also check the
    1846     // caret is at the end and that the text has not changed.
    1847     if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) {
    1848         hideSuggestionsPopup();
    1849         return;
    1850     }
    1851 
    1852     HTMLInputElement* inputElem =
    1853         static_cast<HTMLInputElement*>(focusedNode.get());
    1854 
    1855     // The first time the Autocomplete is shown we'll create the client and the
    1856     // popup.
    1857     if (!m_autocompletePopupClient.get())
    1858         m_autocompletePopupClient.set(new AutocompletePopupMenuClient);
    1859 
    1860     m_autocompletePopupClient->initialize(inputElem, suggestions,
    1861                                           defaultSuggestionIndex);
    1862 
    1863     if (m_suggestionsPopupClient != m_autocompletePopupClient.get()) {
    1864         hideSuggestionsPopup();
    1865         m_suggestionsPopupClient = m_autocompletePopupClient.get();
    1866     }
    1867 
    1868     if (!m_autocompletePopup.get()) {
    1869         m_autocompletePopup = PopupContainer::create(m_suggestionsPopupClient,
    1870                                                      PopupContainer::Suggestion,
    1871                                                      suggestionsPopupSettings);
    1872     }
    1873 
    1874     if (m_suggestionsPopup != m_autocompletePopup.get())
    1875         m_suggestionsPopup = m_autocompletePopup.get();
    1876 
    1877     if (m_suggestionsPopupShowing) {
    1878         m_autocompletePopupClient->setSuggestions(suggestions);
    1879         refreshSuggestionsPopup();
    1880     } else {
    1881         m_suggestionsPopup->show(focusedNode->getRect(),
    1882                                  focusedNode->ownerDocument()->view(), 0);
    1883         m_suggestionsPopupShowing = true;
    1884     }
     1832    WebVector<WebString> names(suggestions.size());
     1833    WebVector<WebString> labels(suggestions.size());
     1834
     1835    for (size_t i = 0; i < suggestions.size(); ++i) {
     1836        names[i] = suggestions[i];
     1837        labels[i] = WebString();
     1838    }
     1839
     1840    applyAutoFillSuggestions(node, names, labels, -1);
     1841    if (m_autoFillPopupClient)
     1842        m_autoFillPopupClient->setAutocompleteMode(true);
    18851843}
    18861844
     
    18881846{
    18891847    hideSelectPopup();
    1890     hideSuggestionsPopup();
     1848    hideAutoFillPopup();
    18911849}
    18921850
     
    20822040#endif
    20832041
    2084 void WebViewImpl::refreshSuggestionsPopup()
    2085 {
    2086     ASSERT(m_suggestionsPopupShowing);
     2042void WebViewImpl::refreshAutoFillPopup()
     2043{
     2044    ASSERT(m_autoFillPopupShowing);
    20872045
    20882046    // Hide the popup if it has become empty.
    2089     if (!m_suggestionsPopupClient->listSize()) {
    2090         hideSuggestionsPopup();
    2091         return;
    2092     }
    2093 
    2094     IntRect oldBounds = m_suggestionsPopup->boundsRect();
    2095     m_suggestionsPopup->refresh();
    2096     IntRect newBounds = m_suggestionsPopup->boundsRect();
     2047    if (!m_autoFillPopupClient->listSize()) {
     2048        hideAutoFillPopup();
     2049        return;
     2050    }
     2051
     2052    IntRect oldBounds = m_autoFillPopup->boundsRect();
     2053    m_autoFillPopup->refresh();
     2054    IntRect newBounds = m_autoFillPopup->boundsRect();
    20972055    // Let's resize the backing window if necessary.
    20982056    if (oldBounds != newBounds) {
    20992057        WebPopupMenuImpl* popupMenu =
    2100             static_cast<WebPopupMenuImpl*>(m_suggestionsPopup->client());
    2101         popupMenu->client()->setWindowRect(newBounds);
     2058            static_cast<WebPopupMenuImpl*>(m_autoFillPopup->client());
     2059        if (popupMenu)
     2060            popupMenu->client()->setWindowRect(newBounds);
    21022061    }
    21032062}
  • trunk/WebKit/chromium/src/WebViewImpl.h

    r62234 r62272  
    7171class ContextMenuClientImpl;
    7272class DragScrollTimer;
    73 class SuggestionsPopupMenuClient;
    7473class WebAccessibilityObject;
    7574class WebDevToolsAgentClient;
     
    138137        WebDragOperation operation);
    139138    virtual void dragSourceMovedTo(
    140         const WebPoint& clientPoint, 
    141         const WebPoint& screenPoint, 
     139        const WebPoint& clientPoint,
     140        const WebPoint& screenPoint,
    142141        WebDragOperation operation);
    143142    virtual void dragSourceSystemDragEnded();
     
    171170        const WebVector<WebString>& labels,
    172171        int separatorIndex);
     172    // DEPRECATED: replacing with applyAutoFillSuggestions.
    173173    virtual void applyAutocompleteSuggestions(
    174174        const WebNode&,
     
    283283        const WebPoint& dragImageOffset);
    284284
    285     void suggestionsPopupDidHide()
    286     {
    287         m_suggestionsPopupShowing = false;
     285    void autoFillPopupDidHide()
     286    {
     287        m_autoFillPopupShowing = false;
    288288    }
    289289
     
    301301    void popupClosed(WebCore::PopupContainer* popupContainer);
    302302
    303     void hideSuggestionsPopup();
     303    void hideAutoFillPopup();
    304304
    305305    // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can
     
    344344    bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
    345345
    346     // Repaints the suggestions popup. Should be called when the suggestions
    347     // have changed. Note that this should only be called when the suggestions
     346    // Repaints the AutoFill popup. Should be called when the suggestions
     347    // have changed. Note that this should only be called when the AutoFill
    348348    // popup is showing.
    349     void refreshSuggestionsPopup();
     349    void refreshAutoFillPopup();
    350350
    351351    // Returns true if the view was scrolled.
     
    456456    WebDragOperation m_dragOperation;
    457457
    458     // Whether a suggestions popup is currently showing.
    459     bool m_suggestionsPopupShowing;
    460 
    461     // A pointer to the current suggestions popup menu client. This can be
    462     // either an AutoFillPopupMenuClient or an AutocompletePopupMenuClient. We
    463     // do not own this pointer.
    464     SuggestionsPopupMenuClient* m_suggestionsPopupClient;
     458    // Whether an AutoFill popup is currently showing.
     459    bool m_autoFillPopupShowing;
    465460
    466461    // The AutoFill popup client.
    467462    OwnPtr<AutoFillPopupMenuClient> m_autoFillPopupClient;
    468463
    469     // The Autocomplete popup client.
    470     OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient;
    471 
    472     // A pointer to the current suggestions popup. We do not own this pointer.
    473     WebCore::PopupContainer* m_suggestionsPopup;
     464    // The AutoFill popup.
     465    RefPtr<WebCore::PopupContainer> m_autoFillPopup;
    474466
    475467    // The popup associated with a select element.
    476468    RefPtr<WebCore::PopupContainer> m_selectPopup;
    477 
    478     // The AutoFill suggestions popup.
    479     RefPtr<WebCore::PopupContainer> m_autoFillPopup;
    480 
    481     // The AutoComplete suggestions popup.
    482     RefPtr<WebCore::PopupContainer> m_autocompletePopup;
    483469
    484470    OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
Note: See TracChangeset for help on using the changeset viewer.