Commit 056a8496 authored by eric@webkit.org's avatar eric@webkit.org

2010-02-05 James Hawkins <jhawkins@chromium.org>

        Reviewed by David Levin.

        [Chromium] Rename autocomplete* to suggestions* to prepare for the
        refactoring of AutocompletePopupMenuClient.

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

        * public/WebView.h:
        * src/AutocompletePopupMenuClient.cpp:
        (WebKit::AutocompletePopupMenuClient::popupDidHide):
        * src/EditorClientImpl.cpp:
        (WebKit::EditorClientImpl::textFieldDidEndEditing):
        (WebKit::EditorClientImpl::doAutofill):
        * src/WebViewImpl.cpp:
        (WebKit::):
        (WebKit::WebViewImpl::WebViewImpl):
        (WebKit::WebViewImpl::mouseDown):
        (WebKit::WebViewImpl::autocompleteHandleKeyEvent):
        (WebKit::WebViewImpl::setFocus):
        (WebKit::WebViewImpl::applyAutofillSuggestions):
        (WebKit::WebViewImpl::hideAutofillPopup):
        (WebKit::WebViewImpl::hideSuggestionsPopup):
        (WebKit::WebViewImpl::refreshSuggestionsPopup):
        * src/WebViewImpl.h:
        (WebKit::WebViewImpl::suggestionsPopupDidHide):

git-svn-id: svn://svn.chromium.org/blink/trunk@54458 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e20529b5
2010-02-05 James Hawkins <jhawkins@chromium.org>
Reviewed by David Levin.
[Chromium] Rename autocomplete* to suggestions* to prepare for the
refactoring of AutocompletePopupMenuClient.
https://bugs.webkit.org/show_bug.cgi?id=34664
* public/WebView.h:
* src/AutocompletePopupMenuClient.cpp:
(WebKit::AutocompletePopupMenuClient::popupDidHide):
* src/EditorClientImpl.cpp:
(WebKit::EditorClientImpl::textFieldDidEndEditing):
(WebKit::EditorClientImpl::doAutofill):
* src/WebViewImpl.cpp:
(WebKit::):
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::mouseDown):
(WebKit::WebViewImpl::autocompleteHandleKeyEvent):
(WebKit::WebViewImpl::setFocus):
(WebKit::WebViewImpl::applyAutofillSuggestions):
(WebKit::WebViewImpl::hideAutofillPopup):
(WebKit::WebViewImpl::hideSuggestionsPopup):
(WebKit::WebViewImpl::refreshSuggestionsPopup):
* src/WebViewImpl.h:
(WebKit::WebViewImpl::suggestionsPopupDidHide):
2010-02-05 James Hawkins <jhawkins@chromium.org> 2010-02-05 James Hawkins <jhawkins@chromium.org>
Reviewed by David Levin. Reviewed by David Levin.
......
...@@ -231,9 +231,12 @@ public: ...@@ -231,9 +231,12 @@ public:
const WebVector<WebString>& suggestions, const WebVector<WebString>& suggestions,
int defaultSuggestionIndex) = 0; int defaultSuggestionIndex) = 0;
// Hides the autofill popup if any are showing. // DEPRECATED: WebView::hideSuggestionsPopup is the new way to access this.
virtual void hideAutofillPopup() = 0; virtual void hideAutofillPopup() = 0;
// Hides the suggestions popup if any are showing.
virtual void hideSuggestionsPopup() = 0;
// Context menu -------------------------------------------------------- // Context menu --------------------------------------------------------
......
...@@ -120,7 +120,7 @@ int AutocompletePopupMenuClient::clientPaddingRight() const ...@@ -120,7 +120,7 @@ int AutocompletePopupMenuClient::clientPaddingRight() const
void AutocompletePopupMenuClient::popupDidHide() void AutocompletePopupMenuClient::popupDidHide()
{ {
m_webView->autoCompletePopupDidHide(); m_webView->suggestionsPopupDidHide();
} }
void AutocompletePopupMenuClient::setTextFromItem(unsigned listIndex) void AutocompletePopupMenuClient::setTextFromItem(unsigned listIndex)
......
/* /*
* Copyright (C) 2006, 2007 Apple, Inc. All rights reserved. * Copyright (C) 2006, 2007 Apple, Inc. All rights reserved.
* Copyright (C) 2009 Google, Inc. All rights reserved. * Copyright (C) 2010 Google, Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
...@@ -654,7 +654,7 @@ void EditorClientImpl::textFieldDidEndEditing(Element* element) ...@@ -654,7 +654,7 @@ void EditorClientImpl::textFieldDidEndEditing(Element* element)
m_autofillTimer.stop(); m_autofillTimer.stop();
// Hide any showing popup. // Hide any showing popup.
m_webView->hideAutoCompletePopup(); m_webView->hideSuggestionsPopup();
if (!m_webView->client()) if (!m_webView->client())
return; // The page is getting closed, don't fill the password. return; // The page is getting closed, don't fill the password.
...@@ -748,7 +748,7 @@ void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer) ...@@ -748,7 +748,7 @@ void EditorClientImpl::doAutofill(Timer<EditorClientImpl>* timer)
&& inputElement->selectionEnd() == static_cast<int>(value.length()); && inputElement->selectionEnd() == static_cast<int>(value.length());
if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) { if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) {
m_webView->hideAutoCompletePopup(); m_webView->hideSuggestionsPopup();
return; return;
} }
......
/* /*
* Copyright (C) 2009 Google Inc. All rights reserved. * Copyright (C) 2010 Google Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
...@@ -148,16 +148,16 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove); ...@@ -148,16 +148,16 @@ COMPILE_ASSERT_MATCHING_ENUM(DragOperationMove);
COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete); COMPILE_ASSERT_MATCHING_ENUM(DragOperationDelete);
COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery);
// Note that focusOnShow is false so that the autocomplete popup is shown not // Note that focusOnShow is false so that the suggestions popup is shown not
// activated. We need the page to still have focus so the user can keep typing // activated. We need the page to still have focus so the user can keep typing
// while the popup is showing. // while the popup is showing.
static const PopupContainerSettings autocompletePopupSettings = { static const PopupContainerSettings suggestionsPopupSettings = {
false, // focusOnShow false, // focusOnShow
false, // setTextOnIndexChange false, // setTextOnIndexChange
false, // acceptOnAbandon false, // acceptOnAbandon
true, // loopSelectionNavigation true, // loopSelectionNavigation
true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari) true, // restrictWidthOfListBox. Same as other browser (Fx, IE, and safari)
// For autocomplete, we use the direction of the input field as the direction // For suggestions, we use the direction of the input field as the direction
// of the popup items. The main reason is to keep the display of items in // of the popup items. The main reason is to keep the display of items in
// drop-down the same as the items in the input field. // drop-down the same as the items in the input field.
PopupContainerSettings::DOMElementDirection, PopupContainerSettings::DOMElementDirection,
...@@ -239,7 +239,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) ...@@ -239,7 +239,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_dropEffect(DropEffectDefault) , m_dropEffect(DropEffectDefault)
, m_operationsAllowed(WebDragOperationNone) , m_operationsAllowed(WebDragOperationNone)
, m_dragOperation(WebDragOperationNone) , m_dragOperation(WebDragOperationNone)
, m_autocompletePopupShowing(false) , m_suggestionsPopupShowing(false)
, m_isTransparent(false) , m_isTransparent(false)
, m_tabsToLinks(false) , m_tabsToLinks(false)
{ {
...@@ -326,7 +326,7 @@ void WebViewImpl::mouseDown(const WebMouseEvent& event) ...@@ -326,7 +326,7 @@ void WebViewImpl::mouseDown(const WebMouseEvent& event)
m_lastMouseDownPoint = WebPoint(event.x, event.y); m_lastMouseDownPoint = WebPoint(event.x, event.y);
// If a text field that has focus is clicked again, we should display the // If a text field that has focus is clicked again, we should display the
// autocomplete popup. // suggestions popup.
RefPtr<Node> clickedNode; RefPtr<Node> clickedNode;
if (event.button == WebMouseEvent::ButtonLeft) { if (event.button == WebMouseEvent::ButtonLeft) {
RefPtr<Node> focusedNode = focusedWebCoreNode(); RefPtr<Node> focusedNode = focusedWebCoreNode();
...@@ -348,7 +348,7 @@ void WebViewImpl::mouseDown(const WebMouseEvent& event) ...@@ -348,7 +348,7 @@ void WebViewImpl::mouseDown(const WebMouseEvent& event)
PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event)); PlatformMouseEventBuilder(mainFrameImpl()->frameView(), event));
if (clickedNode.get() && clickedNode == focusedWebCoreNode()) { if (clickedNode.get() && clickedNode == focusedWebCoreNode()) {
// Focus has not changed, show the autocomplete popup. // Focus has not changed, show the suggestions popup.
static_cast<EditorClientImpl*>(m_page->editorClient())-> static_cast<EditorClientImpl*>(m_page->editorClient())->
showFormAutofillForNode(clickedNode.get()); showFormAutofillForNode(clickedNode.get());
} }
...@@ -514,7 +514,7 @@ bool WebViewImpl::keyEvent(const WebKeyboardEvent& event) ...@@ -514,7 +514,7 @@ bool WebViewImpl::keyEvent(const WebKeyboardEvent& event)
bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
{ {
if (!m_autocompletePopupShowing if (!m_suggestionsPopupShowing
// Home and End should be left to the text field to process. // Home and End should be left to the text field to process.
|| event.windowsKeyCode == VKEY_HOME || event.windowsKeyCode == VKEY_HOME
|| event.windowsKeyCode == VKEY_END) || event.windowsKeyCode == VKEY_END)
...@@ -522,7 +522,7 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) ...@@ -522,7 +522,7 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
// Pressing delete triggers the removal of the selected suggestion from the DB. // Pressing delete triggers the removal of the selected suggestion from the DB.
if (event.windowsKeyCode == VKEY_DELETE if (event.windowsKeyCode == VKEY_DELETE
&& m_autocompletePopup->selectedIndex() != -1) { && m_suggestionsPopup->selectedIndex() != -1) {
Node* node = focusedWebCoreNode(); Node* node = focusedWebCoreNode();
if (!node || (node->nodeType() != Node::ELEMENT_NODE)) { if (!node || (node->nodeType() != Node::ELEMENT_NODE)) {
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
...@@ -534,7 +534,7 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) ...@@ -534,7 +534,7 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
return false; return false;
} }
int selectedIndex = m_autocompletePopup->selectedIndex(); int selectedIndex = m_suggestionsPopup->selectedIndex();
HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element); HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element);
WebString name = inputElement->name(); WebString name = inputElement->name();
WebString value = m_autocompletePopupClient->itemText(selectedIndex); WebString value = m_autocompletePopupClient->itemText(selectedIndex);
...@@ -542,14 +542,14 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) ...@@ -542,14 +542,14 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
// Update the entries in the currently showing popup to reflect the // Update the entries in the currently showing popup to reflect the
// deletion. // deletion.
m_autocompletePopupClient->removeItemAtIndex(selectedIndex); m_autocompletePopupClient->removeItemAtIndex(selectedIndex);
refreshAutofillPopup(); refreshSuggestionsPopup();
return false; return false;
} }
if (!m_autocompletePopup->isInterestedInEventForKey(event.windowsKeyCode)) if (!m_suggestionsPopup->isInterestedInEventForKey(event.windowsKeyCode))
return false; return false;
if (m_autocompletePopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) { if (m_suggestionsPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) {
// We need to ignore the next Char event after this otherwise pressing // We need to ignore the next Char event after this otherwise pressing
// enter when selecting an item in the menu will go to the page. // enter when selecting an item in the menu will go to the page.
if (WebInputEvent::RawKeyDown == event.type) if (WebInputEvent::RawKeyDown == event.type)
...@@ -976,7 +976,7 @@ void WebViewImpl::setFocus(bool enable) ...@@ -976,7 +976,7 @@ void WebViewImpl::setFocus(bool enable)
} }
m_imeAcceptEvents = true; m_imeAcceptEvents = true;
} else { } else {
hideAutoCompletePopup(); hideSuggestionsPopup();
// Clear focus on the currently focused frame if any. // Clear focus on the currently focused frame if any.
if (!m_page.get()) if (!m_page.get())
...@@ -1559,7 +1559,7 @@ void WebViewImpl::applyAutofillSuggestions( ...@@ -1559,7 +1559,7 @@ void WebViewImpl::applyAutofillSuggestions(
int defaultSuggestionIndex) int defaultSuggestionIndex)
{ {
if (!m_page.get() || suggestions.isEmpty()) { if (!m_page.get() || suggestions.isEmpty()) {
hideAutoCompletePopup(); hideSuggestionsPopup();
return; return;
} }
...@@ -1568,7 +1568,7 @@ void WebViewImpl::applyAutofillSuggestions( ...@@ -1568,7 +1568,7 @@ void WebViewImpl::applyAutofillSuggestions(
if (RefPtr<Frame> focused = m_page->focusController()->focusedFrame()) { if (RefPtr<Frame> focused = m_page->focusController()->focusedFrame()) {
RefPtr<Document> document = focused->document(); RefPtr<Document> document = focused->document();
if (!document.get()) { if (!document.get()) {
hideAutoCompletePopup(); hideSuggestionsPopup();
return; return;
} }
...@@ -1577,7 +1577,7 @@ void WebViewImpl::applyAutofillSuggestions( ...@@ -1577,7 +1577,7 @@ void WebViewImpl::applyAutofillSuggestions(
// focused node, then we have nothing to do. FIXME: also check the // focused node, then we have nothing to do. FIXME: also check the
// carret is at the end and that the text has not changed. // carret is at the end and that the text has not changed.
if (!focusedNode.get() || focusedNode != PassRefPtr<Node>(node)) { if (!focusedNode.get() || focusedNode != PassRefPtr<Node>(node)) {
hideAutoCompletePopup(); hideSuggestionsPopup();
return; return;
} }
...@@ -1589,33 +1589,41 @@ void WebViewImpl::applyAutofillSuggestions( ...@@ -1589,33 +1589,41 @@ void WebViewImpl::applyAutofillSuggestions(
HTMLInputElement* inputElem = HTMLInputElement* inputElem =
static_cast<HTMLInputElement*>(focusedNode.get()); static_cast<HTMLInputElement*>(focusedNode.get());
// The first time the autocomplete is shown we'll create the client and the // The first time the suggestions popup is shown we'll create the client
// popup. // and the popup.
if (!m_autocompletePopupClient.get()) if (!m_autocompletePopupClient.get())
m_autocompletePopupClient.set(new AutocompletePopupMenuClient(this)); m_autocompletePopupClient.set(new AutocompletePopupMenuClient(this));
m_autocompletePopupClient->initialize(inputElem, m_autocompletePopupClient->initialize(inputElem,
suggestions, suggestions,
defaultSuggestionIndex); defaultSuggestionIndex);
if (!m_autocompletePopup.get()) { if (!m_suggestionsPopup.get()) {
m_autocompletePopup = m_suggestionsPopup =
PopupContainer::create(m_autocompletePopupClient.get(), PopupContainer::create(m_autocompletePopupClient.get(),
autocompletePopupSettings); suggestionsPopupSettings);
} }
if (m_autocompletePopupShowing) { if (m_suggestionsPopupShowing) {
m_autocompletePopupClient->setSuggestions(suggestions); m_autocompletePopupClient->setSuggestions(suggestions);
refreshAutofillPopup(); refreshSuggestionsPopup();
} else { } else {
m_autocompletePopup->show(focusedNode->getRect(), m_suggestionsPopup->show(focusedNode->getRect(),
focusedNode->ownerDocument()->view(), 0); focusedNode->ownerDocument()->view(), 0);
m_autocompletePopupShowing = true; m_suggestionsPopupShowing = true;
} }
} }
} }
void WebViewImpl::hideAutofillPopup() void WebViewImpl::hideAutofillPopup()
{ {
hideAutoCompletePopup(); hideSuggestionsPopup();
}
void WebViewImpl::hideSuggestionsPopup()
{
if (m_suggestionsPopupShowing) {
m_suggestionsPopup->hidePopup();
m_suggestionsPopupShowing = false;
}
} }
void WebViewImpl::performCustomContextMenuAction(unsigned action) void WebViewImpl::performCustomContextMenuAction(unsigned action)
...@@ -1778,19 +1786,6 @@ void WebViewImpl::observeNewNavigation() ...@@ -1778,19 +1786,6 @@ void WebViewImpl::observeNewNavigation()
#endif #endif
} }
void WebViewImpl::hideAutoCompletePopup()
{
if (m_autocompletePopupShowing) {
m_autocompletePopup->hidePopup();
autoCompletePopupDidHide();
}
}
void WebViewImpl::autoCompletePopupDidHide()
{
m_autocompletePopupShowing = false;
}
void WebViewImpl::setIgnoreInputEvents(bool newValue) void WebViewImpl::setIgnoreInputEvents(bool newValue)
{ {
ASSERT(m_ignoreInputEvents != newValue); ASSERT(m_ignoreInputEvents != newValue);
...@@ -1806,23 +1801,23 @@ NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl() ...@@ -1806,23 +1801,23 @@ NotificationPresenterImpl* WebViewImpl::notificationPresenterImpl()
} }
#endif #endif
void WebViewImpl::refreshAutofillPopup() void WebViewImpl::refreshSuggestionsPopup()
{ {
ASSERT(m_autocompletePopupShowing); ASSERT(m_suggestionsPopupShowing);
// Hide the popup if it has become empty. // Hide the popup if it has become empty.
if (!m_autocompletePopupClient->listSize()) { if (!m_autocompletePopupClient->listSize()) {
hideAutoCompletePopup(); hideSuggestionsPopup();
return; return;
} }
IntRect oldBounds = m_autocompletePopup->boundsRect(); IntRect oldBounds = m_suggestionsPopup->boundsRect();
m_autocompletePopup->refresh(); m_suggestionsPopup->refresh();
IntRect newBounds = m_autocompletePopup->boundsRect(); IntRect newBounds = m_suggestionsPopup->boundsRect();
// Let's resize the backing window if necessary. // Let's resize the backing window if necessary.
if (oldBounds != newBounds) { if (oldBounds != newBounds) {
WebPopupMenuImpl* popupMenu = WebPopupMenuImpl* popupMenu =
static_cast<WebPopupMenuImpl*>(m_autocompletePopup->client()); static_cast<WebPopupMenuImpl*>(m_suggestionsPopup->client());
popupMenu->client()->setWindowRect(newBounds); popupMenu->client()->setWindowRect(newBounds);
} }
} }
......
/* /*
* Copyright (C) 2009 Google Inc. All rights reserved. * Copyright (C) 2010 Google Inc. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are * modification, are permitted provided that the following conditions are
...@@ -154,6 +154,7 @@ public: ...@@ -154,6 +154,7 @@ public:
const WebVector<WebString>& suggestions, const WebVector<WebString>& suggestions,
int defaultSuggestionIndex); int defaultSuggestionIndex);
virtual void hideAutofillPopup(); virtual void hideAutofillPopup();
virtual void hideSuggestionsPopup();
virtual void setScrollbarColors(unsigned inactiveColor, virtual void setScrollbarColors(unsigned inactiveColor,
unsigned activeColor, unsigned activeColor,
unsigned trackColor); unsigned trackColor);
...@@ -261,9 +262,10 @@ public: ...@@ -261,9 +262,10 @@ public:
const WebDragData& dragData, const WebDragData& dragData,
WebDragOperationsMask dragSourceOperationMask); WebDragOperationsMask dragSourceOperationMask);
// Hides the autocomplete popup if it is showing. void suggestionsPopupDidHide()
void hideAutoCompletePopup(); {
void autoCompletePopupDidHide(); m_suggestionsPopupShowing = false;
}
#if ENABLE(NOTIFICATIONS) #if ENABLE(NOTIFICATIONS)
// Returns the provider of desktop notifications. // Returns the provider of desktop notifications.
...@@ -295,10 +297,10 @@ private: ...@@ -295,10 +297,10 @@ private:
// Returns true if the autocomple has consumed the event. // Returns true if the autocomple has consumed the event.
bool autocompleteHandleKeyEvent(const WebKeyboardEvent&); bool autocompleteHandleKeyEvent(const WebKeyboardEvent&);
// Repaints the autofill popup. Should be called when the suggestions have // Repaints the suggestions popup. Should be called when the suggestions
// changed. Note that this should only be called when the autofill popup is // have changed. Note that this should only be called when the suggestions
// showing. // popup is showing.
void refreshAutofillPopup(); void refreshSuggestionsPopup();
// Returns true if the view was scrolled. // Returns true if the view was scrolled.
bool scrollViewWithKeyboard(int keyCode, int modifiers); bool scrollViewWithKeyboard(int keyCode, int modifiers);
...@@ -393,12 +395,12 @@ private: ...@@ -393,12 +395,12 @@ private:
// current drop target in this WebView (the drop target can accept the drop). // current drop target in this WebView (the drop target can accept the drop).
WebDragOperation m_dragOperation; WebDragOperation m_dragOperation;
// The autocomplete popup. Kept around and reused every-time new suggestions // The suggestions popup. Kept around and reused every-time new suggestions
// should be shown. // should be shown.
RefPtr<WebCore::PopupContainer> m_autocompletePopup; RefPtr<WebCore::PopupContainer> m_suggestionsPopup;
// Whether the autocomplete popup is currently showing. // Whether the suggestions popup is currently showing.
bool m_autocompletePopupShowing; bool m_suggestionsPopupShowing;
// The autocomplete client. // The autocomplete client.
OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient; OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment