[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.21-584-g1e41756
eric at webkit.org
eric at webkit.org
Fri Feb 26 22:16:36 UTC 2010
The following commit has been merged in the webkit-1.1 branch:
commit 38da78c16a25c507d23ecb14e00cf4ebec2070af
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Wed Feb 10 04:48:49 2010 +0000
2010-02-09 James Hawkins <jhawkins at chromium.org>
Reviewed by Darin Fisher.
[Chromium] Refactor AutocompletePopupMenuClient into a base class,
SuggestionsPopupMenuClient, and two derived classes,
AutocompletePopupMenuClient and AutoFillPopupMenuClient. Currently
the behavior of suggestions popups has not changed.
https://bugs.webkit.org/show_bug.cgi?id=34721
* WebKit.gyp:
* public/WebView.h:
* src/AutoFillPopupMenuClient.cpp: Added.
* src/AutoFillPopupMenuClient.h: Added.
* src/AutocompletePopupMenuClient.cpp:
(WebKit::AutocompletePopupMenuClient::getSuggestionsCount):
(WebKit::AutocompletePopupMenuClient::getSuggestion):
(WebKit::AutocompletePopupMenuClient::removeSuggestionAtIndex):
(WebKit::AutocompletePopupMenuClient::initialize):
(WebKit::AutocompletePopupMenuClient::setSuggestions):
* src/AutocompletePopupMenuClient.h:
* src/SuggestionsPopupMenuClient.cpp: Added.
* src/SuggestionsPopupMenuClient.h: Added.
* src/WebViewImpl.cpp:
(WebKit::WebViewImpl::WebViewImpl):
(WebKit::WebViewImpl::keyEvent):
(WebKit::WebViewImpl::autocompleteHandleKeyEvent):
(WebKit::WebViewImpl::applyAutofillSuggestions):
(WebKit::WebViewImpl::applyAutoFillSuggestions):
(WebKit::WebViewImpl::applyAutocompleteSuggestions):
* src/WebViewImpl.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@54586 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKit/chromium/ChangeLog b/WebKit/chromium/ChangeLog
index 552e1e6..59eabd0 100644
--- a/WebKit/chromium/ChangeLog
+++ b/WebKit/chromium/ChangeLog
@@ -1,3 +1,36 @@
+2010-02-09 James Hawkins <jhawkins at chromium.org>
+
+ Reviewed by Darin Fisher.
+
+ [Chromium] Refactor AutocompletePopupMenuClient into a base class,
+ SuggestionsPopupMenuClient, and two derived classes,
+ AutocompletePopupMenuClient and AutoFillPopupMenuClient. Currently
+ the behavior of suggestions popups has not changed.
+
+ https://bugs.webkit.org/show_bug.cgi?id=34721
+
+ * WebKit.gyp:
+ * public/WebView.h:
+ * src/AutoFillPopupMenuClient.cpp: Added.
+ * src/AutoFillPopupMenuClient.h: Added.
+ * src/AutocompletePopupMenuClient.cpp:
+ (WebKit::AutocompletePopupMenuClient::getSuggestionsCount):
+ (WebKit::AutocompletePopupMenuClient::getSuggestion):
+ (WebKit::AutocompletePopupMenuClient::removeSuggestionAtIndex):
+ (WebKit::AutocompletePopupMenuClient::initialize):
+ (WebKit::AutocompletePopupMenuClient::setSuggestions):
+ * src/AutocompletePopupMenuClient.h:
+ * src/SuggestionsPopupMenuClient.cpp: Added.
+ * src/SuggestionsPopupMenuClient.h: Added.
+ * src/WebViewImpl.cpp:
+ (WebKit::WebViewImpl::WebViewImpl):
+ (WebKit::WebViewImpl::keyEvent):
+ (WebKit::WebViewImpl::autocompleteHandleKeyEvent):
+ (WebKit::WebViewImpl::applyAutofillSuggestions):
+ (WebKit::WebViewImpl::applyAutoFillSuggestions):
+ (WebKit::WebViewImpl::applyAutocompleteSuggestions):
+ * src/WebViewImpl.h:
+
2010-02-09 Chris Guillory <ctguil at google.com>
Reviewed by Darin Fisher.
diff --git a/WebKit/chromium/WebKit.gyp b/WebKit/chromium/WebKit.gyp
index 1ed26ec..4b0ad2b 100644
--- a/WebKit/chromium/WebKit.gyp
+++ b/WebKit/chromium/WebKit.gyp
@@ -200,6 +200,8 @@
'src/AssertMatchingEnums.cpp',
'src/AutocompletePopupMenuClient.cpp',
'src/AutocompletePopupMenuClient.h',
+ 'src/AutoFillPopupMenuClient.cpp',
+ 'src/AutoFillPopupMenuClient.h',
'src/BackForwardListClientImpl.cpp',
'src/BackForwardListClientImpl.h',
'src/BoundObject.cpp',
@@ -258,6 +260,8 @@
'src/StorageEventDispatcherImpl.h',
'src/StorageNamespaceProxy.cpp',
'src/StorageNamespaceProxy.h',
+ 'src/SuggestionsPopupMenuClient.cpp',
+ 'src/SuggestionsPopupMenuClient.h',
'src/TemporaryGlue.h',
'src/ToolsAgent.h',
'src/WebAccessibilityCache.cpp',
diff --git a/WebKit/chromium/public/WebView.h b/WebKit/chromium/public/WebView.h
index 8a4b977..99125d4 100644
--- a/WebKit/chromium/public/WebView.h
+++ b/WebKit/chromium/public/WebView.h
@@ -223,14 +223,29 @@ public:
virtual WebAccessibilityObject accessibilityObject() = 0;
- // Autofill ------------------------------------------------------------
+ // AutoFill / Autocomplete ---------------------------------------------
- // Notifies the WebView that autofill suggestions are available for a node.
+ // DEPRECATED: WebView::applyAutocompleteSuggestions is the new way to
+ // access this.
virtual void applyAutofillSuggestions(
const WebNode&,
const WebVector<WebString>& suggestions,
int defaultSuggestionIndex) = 0;
+ // Notifies the WebView that AutoFill suggestions are available for a node.
+ virtual void applyAutoFillSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ int defaultSuggestionIndex) = 0;
+
+ // Notifies the WebView that Autocomplete suggestions are available for a
+ // node.
+ virtual void applyAutocompleteSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& suggestions,
+ int defaultSuggestionIndex) = 0;
+
// DEPRECATED: WebView::hideSuggestionsPopup is the new way to access this.
virtual void hideAutofillPopup() = 0;
diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.cpp b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
new file mode 100644
index 0000000..ad3aec1
--- /dev/null
+++ b/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "AutoFillPopupMenuClient.h"
+
+#include "HTMLInputElement.h"
+#include "WebString.h"
+#include "WebVector.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+unsigned AutoFillPopupMenuClient::getSuggestionsCount() const
+{
+ return m_names.size();
+}
+
+WebString AutoFillPopupMenuClient::getSuggestion(unsigned listIndex) const
+{
+ // FIXME: Modify the PopupMenu to add the label in gray right-justified.
+ ASSERT(listIndex >= 0 && listIndex < m_names.size());
+ return m_names[listIndex] + String(" (") + m_labels[listIndex] + String(")");
+}
+
+void AutoFillPopupMenuClient::removeSuggestionAtIndex(unsigned listIndex)
+{
+ // FIXME: Do we want to remove AutoFill suggestions?
+ ASSERT(listIndex >= 0 && listIndex < static_cast<int>(m_names.size()));
+ m_names.remove(listIndex);
+ m_labels.remove(listIndex);
+}
+
+void AutoFillPopupMenuClient:: selectionChanged(unsigned listIndex,
+ bool fireEvents) {
+ if (listIndex == static_cast<unsigned>(-1)) {
+ SuggestionsPopupMenuClient::selectionChanged(listIndex, fireEvents);
+ return;
+ }
+
+ ASSERT(listIndex >= 0 && listIndex < m_names.size());
+ setSuggestedValue(m_names[listIndex]);
+}
+
+void AutoFillPopupMenuClient::initialize(
+ HTMLInputElement* textField,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ int defaultSuggestionIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(defaultSuggestionIndex < static_cast<int>(names.size()));
+
+ // The suggestions must be set before initializing the
+ // SuggestionsPopupMenuClient.
+ setSuggestions(names, labels);
+
+ SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex);
+}
+
+void AutoFillPopupMenuClient::setSuggestions(const WebVector<WebString>& names,
+ const WebVector<WebString>& labels)
+{
+ ASSERT(names.size() == labels.size());
+
+ m_names.clear();
+ m_labels.clear();
+ for (size_t i = 0; i < names.size(); ++i) {
+ m_names.append(names[i]);
+ m_labels.append(labels[i]);
+ }
+
+ // Try to preserve selection if possible.
+ if (getSelectedIndex() >= static_cast<int>(names.size()))
+ setSelectedIndex(-1);
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/AutoFillPopupMenuClient.h b/WebKit/chromium/src/AutoFillPopupMenuClient.h
new file mode 100644
index 0000000..e1fd100
--- /dev/null
+++ b/WebKit/chromium/src/AutoFillPopupMenuClient.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef AutoFillPopupMenuClient_h
+#define AutoFillPopupMenuClient_h
+
+#include "SuggestionsPopupMenuClient.h"
+
+namespace WebCore {
+class HTMLInputElement;
+}
+
+namespace WebKit {
+class WebString;
+template <typename T> class WebVector;
+
+// The AutoFill suggestions popup menu client, used to display name suggestions
+// with right-justified labels.
+class AutoFillPopupMenuClient : public SuggestionsPopupMenuClient {
+public:
+ // SuggestionsPopupMenuClient implementation:
+ virtual unsigned getSuggestionsCount() const;
+ virtual WebString getSuggestion(unsigned listIndex) const;
+ virtual void removeSuggestionAtIndex(unsigned listIndex);
+
+ // WebCore::PopupMenuClient implementation:
+ virtual void selectionChanged(unsigned listIndex, bool fireEvents);
+
+ void initialize(WebCore::HTMLInputElement*,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ int defaultSuggestionIndex);
+
+ void setSuggestions(const WebVector<WebString>& names,
+ const WebVector<WebString>& labels);
+
+private:
+ Vector<WebCore::String> m_names;
+ Vector<WebCore::String> m_labels;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/AutocompletePopupMenuClient.cpp b/WebKit/chromium/src/AutocompletePopupMenuClient.cpp
index fb9ad49..9620ffc 100644
--- a/WebKit/chromium/src/AutocompletePopupMenuClient.cpp
+++ b/WebKit/chromium/src/AutocompletePopupMenuClient.cpp
@@ -1,5 +1,5 @@
/*
- * 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
* modification, are permitted provided that the following conditions are
@@ -31,27 +31,29 @@
#include "config.h"
#include "AutocompletePopupMenuClient.h"
-#include "CSSStyleSelector.h"
-#include "CSSValueKeywords.h"
-#include "FrameView.h"
#include "HTMLInputElement.h"
-#include "RenderTheme.h"
+#include "WebString.h"
#include "WebVector.h"
-#include "WebViewImpl.h"
using namespace WebCore;
namespace WebKit {
-AutocompletePopupMenuClient::AutocompletePopupMenuClient(WebViewImpl* webView)
- : m_textField(0)
- , m_selectedIndex(0)
- , m_webView(webView)
+unsigned AutocompletePopupMenuClient::getSuggestionsCount() const
{
+ return m_suggestions.size();
}
-AutocompletePopupMenuClient::~AutocompletePopupMenuClient()
+WebString AutocompletePopupMenuClient::getSuggestion(unsigned listIndex) const
{
+ ASSERT(listIndex >= 0 && listIndex < m_suggestions.size());
+ return m_suggestions[listIndex];
+}
+
+void AutocompletePopupMenuClient::removeSuggestionAtIndex(unsigned listIndex)
+{
+ ASSERT(listIndex >= 0 && listIndex < m_suggestions.size());
+ m_suggestions.remove(listIndex);
}
void AutocompletePopupMenuClient::initialize(
@@ -60,90 +62,12 @@ void AutocompletePopupMenuClient::initialize(
int defaultSuggestionIndex)
{
ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size()));
- m_textField = textField;
- m_selectedIndex = defaultSuggestionIndex;
- setSuggestions(suggestions);
-
- FontDescription fontDescription;
- m_webView->theme()->systemFont(CSSValueWebkitControl, fontDescription);
- // Use a smaller font size to match IE/Firefox.
- // FIXME: http://crbug.com/7376 use the system size instead of a
- // fixed font size value.
- fontDescription.setComputedSize(12.0);
- Font font(fontDescription, 0, 0);
- font.update(textField->document()->styleSelector()->fontSelector());
- // The direction of text in popup menu is set the same as the direction of
- // the input element: textField.
- m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true,
- Length(WebCore::Fixed),
- textField->renderer()->style()->direction()));
-}
-
-void AutocompletePopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
-{
- m_textField->setValue(m_suggestions[listIndex]);
- EditorClientImpl* editor =
- static_cast<EditorClientImpl*>(m_webView->page()->editorClient());
- ASSERT(editor);
- editor->onAutofillSuggestionAccepted(
- static_cast<HTMLInputElement*>(m_textField.get()));
-}
-
-String AutocompletePopupMenuClient::itemText(unsigned listIndex) const
-{
- return m_suggestions[listIndex];
-}
-
-PopupMenuStyle AutocompletePopupMenuClient::itemStyle(unsigned listIndex) const
-{
- return *m_style;
-}
-
-PopupMenuStyle AutocompletePopupMenuClient::menuStyle() const
-{
- return *m_style;
-}
-
-int AutocompletePopupMenuClient::clientPaddingLeft() const
-{
- // Bug http://crbug.com/7708 seems to indicate the style can be 0.
- RenderStyle* style = textFieldStyle();
- return style ? m_webView->theme()->popupInternalPaddingLeft(style) : 0;
-}
-int AutocompletePopupMenuClient::clientPaddingRight() const
-{
- // Bug http://crbug.com/7708 seems to indicate the style can be 0.
- RenderStyle* style = textFieldStyle();
- return style ? m_webView->theme()->popupInternalPaddingRight(style) : 0;
-}
-
-void AutocompletePopupMenuClient::popupDidHide()
-{
- m_webView->suggestionsPopupDidHide();
-}
-
-void AutocompletePopupMenuClient::setTextFromItem(unsigned listIndex)
-{
- m_textField->setValue(m_suggestions[listIndex]);
-}
-
-FontSelector* AutocompletePopupMenuClient::fontSelector() const
-{
- return m_textField->document()->styleSelector()->fontSelector();
-}
-
-HostWindow* AutocompletePopupMenuClient::hostWindow() const
-{
- return m_textField->document()->view()->hostWindow();
-}
+ // The suggestions must be set before initializing the
+ // SuggestionsPopupMenuClient.
+ setSuggestions(suggestions);
-PassRefPtr<Scrollbar> AutocompletePopupMenuClient::createScrollbar(
- ScrollbarClient* client,
- ScrollbarOrientation orientation,
- ScrollbarControlSize size)
-{
- return Scrollbar::createNativeScrollbar(client, orientation, size);
+ SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex);
}
void AutocompletePopupMenuClient::setSuggestions(const WebVector<WebString>& suggestions)
@@ -151,28 +75,10 @@ void AutocompletePopupMenuClient::setSuggestions(const WebVector<WebString>& sug
m_suggestions.clear();
for (size_t i = 0; i < suggestions.size(); ++i)
m_suggestions.append(suggestions[i]);
- // Try to preserve selection if possible.
- if (m_selectedIndex >= static_cast<int>(suggestions.size()))
- m_selectedIndex = -1;
-}
-void AutocompletePopupMenuClient::removeItemAtIndex(int index)
-{
- ASSERT(index >= 0 && index < static_cast<int>(m_suggestions.size()));
- m_suggestions.remove(index);
-}
-
-RenderStyle* AutocompletePopupMenuClient::textFieldStyle() const
-{
- RenderStyle* style = m_textField->computedStyle();
- if (!style) {
- // It seems we can only have a 0 style in a TextField if the
- // node is detached, in which case we the popup shoud not be
- // showing. Please report this in http://crbug.com/7708 and
- // include the page you were visiting.
- ASSERT_NOT_REACHED();
- }
- return style;
+ // Try to preserve selection if possible.
+ if (getSelectedIndex() >= static_cast<int>(suggestions.size()))
+ setSelectedIndex(-1);
}
} // namespace WebKit
diff --git a/WebKit/chromium/src/AutocompletePopupMenuClient.h b/WebKit/chromium/src/AutocompletePopupMenuClient.h
index ad24e54..16a3771 100644
--- a/WebKit/chromium/src/AutocompletePopupMenuClient.h
+++ b/WebKit/chromium/src/AutocompletePopupMenuClient.h
@@ -1,5 +1,5 @@
/*
- * 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
* modification, are permitted provided that the following conditions are
@@ -28,69 +28,38 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "PopupMenuClient.h"
+#ifndef AutocompletePopupMenuClient_h
+#define AutocompletePopupMenuClient_h
+
+#include "SuggestionsPopupMenuClient.h"
namespace WebCore {
class HTMLInputElement;
-class PopupMenuStyle;
-class RenderStyle;
}
namespace WebKit {
class WebString;
-class WebViewImpl;
template <typename T> class WebVector;
-// AutocompletePopupMenuClient
-class AutocompletePopupMenuClient : public WebCore::PopupMenuClient {
+// The Autocomplete suggestions popup menu client, used to display a list of
+// autocomplete suggestions.
+class AutocompletePopupMenuClient : public SuggestionsPopupMenuClient {
public:
- AutocompletePopupMenuClient(WebViewImpl* webview);
- ~AutocompletePopupMenuClient();
+ // SuggestionsPopupMenuClient implementation:
+ virtual unsigned getSuggestionsCount() const;
+ virtual WebString getSuggestion(unsigned listIndex) const;
+ virtual void removeSuggestionAtIndex(unsigned listIndex);
void initialize(WebCore::HTMLInputElement*,
const WebVector<WebString>& suggestions,
int defaultSuggestionIndex);
- WebCore::HTMLInputElement* textField() const { return m_textField.get(); }
-
void setSuggestions(const WebVector<WebString>&);
- void removeItemAtIndex(int index);
-
- // WebCore::PopupMenuClient methods:
- virtual void valueChanged(unsigned listIndex, bool fireEvents = true);
- virtual WebCore::String itemText(unsigned listIndex) const;
- virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); }
- virtual bool itemIsEnabled(unsigned listIndex) const { return true; }
- virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const;
- virtual WebCore::PopupMenuStyle menuStyle() const;
- virtual int clientInsetLeft() const { return 0; }
- virtual int clientInsetRight() const { return 0; }
- virtual int clientPaddingLeft() const;
- virtual int clientPaddingRight() const;
- virtual int listSize() const { return m_suggestions.size(); }
- virtual int selectedIndex() const { return m_selectedIndex; }
- virtual void popupDidHide();
- virtual bool itemIsSeparator(unsigned listIndex) const { return false; }
- virtual bool itemIsLabel(unsigned listIndex) const { return false; }
- virtual bool itemIsSelected(unsigned listIndex) const { return false; }
- virtual bool shouldPopOver() const { return false; }
- virtual bool valueShouldChangeOnHotTrack() const { return false; }
- virtual void setTextFromItem(unsigned listIndex);
- virtual WebCore::FontSelector* fontSelector() const;
- virtual WebCore::HostWindow* hostWindow() const;
- virtual PassRefPtr<WebCore::Scrollbar> createScrollbar(
- WebCore::ScrollbarClient* client,
- WebCore::ScrollbarOrientation orientation,
- WebCore::ScrollbarControlSize size);
private:
- WebCore::RenderStyle* textFieldStyle() const;
-
- RefPtr<WebCore::HTMLInputElement> m_textField;
Vector<WebCore::String> m_suggestions;
- int m_selectedIndex;
- WebViewImpl* m_webView;
- OwnPtr<WebCore::PopupMenuStyle> m_style;
};
} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/SuggestionsPopupMenuClient.cpp b/WebKit/chromium/src/SuggestionsPopupMenuClient.cpp
new file mode 100644
index 0000000..32679ae
--- /dev/null
+++ b/WebKit/chromium/src/SuggestionsPopupMenuClient.cpp
@@ -0,0 +1,262 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SuggestionsPopupMenuClient.h"
+
+#include "CSSStyleSelector.h"
+#include "CSSValueKeywords.h"
+#include "Chrome.h"
+#include "FrameView.h"
+#include "HTMLInputElement.h"
+#include "RenderTheme.h"
+#include "WebViewImpl.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+SuggestionsPopupMenuClient::SuggestionsPopupMenuClient()
+ : m_textField(0)
+ , m_selectedIndex(0)
+{
+}
+
+SuggestionsPopupMenuClient::~SuggestionsPopupMenuClient()
+{
+}
+
+// FIXME: Implement this per-derived class?
+void SuggestionsPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents)
+{
+ m_textField->setValue(getSuggestion(listIndex));
+
+ WebViewImpl* webView = getWebView();
+ if (!webView)
+ return;
+
+ EditorClientImpl* editor =
+ static_cast<EditorClientImpl*>(webView->page()->editorClient());
+ ASSERT(editor);
+ editor->onAutofillSuggestionAccepted(
+ static_cast<HTMLInputElement*>(m_textField.get()));
+}
+
+void SuggestionsPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents)
+{
+ if (listIndex != static_cast<unsigned>(-1)) {
+ const WebString& suggestion = getSuggestion(listIndex);
+ setSuggestedValue(suggestion);
+ } else {
+ m_textField->setValue(m_typedFieldValue);
+ if (m_lastFieldValues->contains(m_textField->name()))
+ m_lastFieldValues->set(m_textField->name(), m_typedFieldValue);
+ else
+ m_lastFieldValues->add(m_textField->name(), m_typedFieldValue);
+ }
+}
+
+String SuggestionsPopupMenuClient::itemText(unsigned listIndex) const
+{
+ return getSuggestion(listIndex);
+}
+
+PopupMenuStyle SuggestionsPopupMenuClient::itemStyle(unsigned listIndex) const
+{
+ return *m_style;
+}
+
+PopupMenuStyle SuggestionsPopupMenuClient::menuStyle() const
+{
+ return *m_style;
+}
+
+int SuggestionsPopupMenuClient::clientPaddingLeft() const
+{
+ // Bug http://crbug.com/7708 seems to indicate the style can be 0.
+ RenderStyle* style = textFieldStyle();
+ if (!style)
+ return 0;
+
+ return RenderTheme::defaultTheme()->popupInternalPaddingLeft(style);
+}
+
+int SuggestionsPopupMenuClient::clientPaddingRight() const
+{
+ // Bug http://crbug.com/7708 seems to indicate the style can be 0.
+ RenderStyle* style = textFieldStyle();
+ if (!style)
+ return 0;
+
+ return RenderTheme::defaultTheme()->popupInternalPaddingRight(style);
+}
+
+void SuggestionsPopupMenuClient::popupDidHide()
+{
+ m_textField->setValue(m_typedFieldValue);
+ resetLastSuggestion();
+ WebViewImpl* webView = getWebView();
+ if (webView)
+ webView->suggestionsPopupDidHide();
+}
+
+void SuggestionsPopupMenuClient::setTextFromItem(unsigned listIndex)
+{
+ m_textField->setValue(getSuggestion(listIndex));
+ resetLastSuggestion();
+}
+
+void SuggestionsPopupMenuClient::resetLastSuggestion()
+{
+ if (m_lastFieldValues->contains(m_textField->name()))
+ m_lastFieldValues->set(m_textField->name(), m_textField->value());
+ else
+ m_lastFieldValues->add(m_textField->name(), m_textField->value());
+}
+
+FontSelector* SuggestionsPopupMenuClient::fontSelector() const
+{
+ return m_textField->document()->styleSelector()->fontSelector();
+}
+
+HostWindow* SuggestionsPopupMenuClient::hostWindow() const
+{
+ return m_textField->document()->view()->hostWindow();
+}
+
+PassRefPtr<Scrollbar> SuggestionsPopupMenuClient::createScrollbar(
+ ScrollbarClient* client,
+ ScrollbarOrientation orientation,
+ ScrollbarControlSize size)
+{
+ return Scrollbar::createNativeScrollbar(client, orientation, size);
+}
+
+RenderStyle* SuggestionsPopupMenuClient::textFieldStyle() const
+{
+ RenderStyle* style = m_textField->computedStyle();
+ if (!style) {
+ // It seems we can only have a 0 style in a TextField if the
+ // node is detached, in which case we the popup shoud not be
+ // showing. Please report this in http://crbug.com/7708 and
+ // include the page you were visiting.
+ ASSERT_NOT_REACHED();
+ }
+ return style;
+}
+
+void SuggestionsPopupMenuClient::initialize(HTMLInputElement* textField,
+ int defaultSuggestionIndex)
+{
+ if (!m_lastFieldValues)
+ m_lastFieldValues.set(new FieldValuesMap);
+
+ m_textField = textField;
+ m_typedFieldValue = textField->value();
+ m_selectedIndex = defaultSuggestionIndex;
+
+ setInitialSuggestion();
+
+ FontDescription fontDescription;
+ RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl,
+ fontDescription);
+
+ // Use a smaller font size to match IE/Firefox.
+ // FIXME: http://crbug.com/7376 use the system size instead of a
+ // fixed font size value.
+ fontDescription.setComputedSize(12.0);
+ Font font(fontDescription, 0, 0);
+ font.update(textField->document()->styleSelector()->fontSelector());
+ // The direction of text in popup menu is set the same as the direction of
+ // the input element: textField.
+ m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true,
+ Length(WebCore::Fixed),
+ textField->renderer()->style()->direction()));
+}
+
+void SuggestionsPopupMenuClient::setInitialSuggestion()
+{
+ if (!getSuggestionsCount() || !m_textField->name().length() || !m_typedFieldValue.length())
+ return;
+
+ int newIndex = m_selectedIndex >= 0 ? m_selectedIndex : 0;
+ const String& suggestion = getSuggestion(newIndex);
+ bool hasPreviousValue = m_lastFieldValues->contains(m_textField->name());
+
+ String prevValue;
+ if (hasPreviousValue)
+ prevValue = m_lastFieldValues->get(m_textField->name());
+
+ if (!hasPreviousValue || m_typedFieldValue.length() > m_lastFieldValues->get(m_textField->name()).length()) {
+ if (suggestion.startsWith(m_typedFieldValue))
+ m_selectedIndex = newIndex;
+
+ int start = 0;
+ String newSuggestion = suggestion;
+ if (suggestion.startsWith(m_typedFieldValue, false)) {
+ newSuggestion = m_typedFieldValue;
+ if (suggestion.length() > m_typedFieldValue.length()) {
+ newSuggestion.append(suggestion.substring(m_typedFieldValue.length(),
+ suggestion.length() - m_typedFieldValue.length()));
+ }
+ start = m_typedFieldValue.length();
+ }
+
+ m_textField->setSuggestedValue(newSuggestion);
+ m_textField->setSelectionRange(start, newSuggestion.length());
+ }
+
+ if (hasPreviousValue)
+ m_lastFieldValues->set(m_textField->name(), m_typedFieldValue);
+ else
+ m_lastFieldValues->add(m_textField->name(), m_typedFieldValue);
+}
+
+void SuggestionsPopupMenuClient::setSuggestedValue(const WebString& suggestion)
+{
+ m_textField->setSuggestedValue(suggestion);
+ m_textField->setSelectionRange(m_typedFieldValue.length(),
+ suggestion.length());
+}
+
+WebViewImpl* SuggestionsPopupMenuClient::getWebView() const
+{
+ Frame* frame = m_textField->document()->frame();
+ if (!frame)
+ return 0;
+
+ Page* page = frame->page();
+ if (!page)
+ return 0;
+
+ return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView();
+}
+
+} // namespace WebKit
diff --git a/WebKit/chromium/src/SuggestionsPopupMenuClient.h b/WebKit/chromium/src/SuggestionsPopupMenuClient.h
new file mode 100644
index 0000000..811eee1
--- /dev/null
+++ b/WebKit/chromium/src/SuggestionsPopupMenuClient.h
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2010 Google Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PopupMenuClient.h"
+
+#ifndef SuggestionsPopupMenuClient_h
+#define SuggestionsPopupMenuClient_h
+
+namespace WebCore {
+class HTMLInputElement;
+class PopupMenuStyle;
+class RenderStyle;
+}
+
+namespace WebKit {
+class WebString;
+class WebViewImpl;
+template <typename T> class WebVector;
+
+// The Suggestions popup menu client, used to display a list of suggestions.
+class SuggestionsPopupMenuClient : public WebCore::PopupMenuClient {
+public:
+ SuggestionsPopupMenuClient();
+ virtual ~SuggestionsPopupMenuClient();
+
+ // Returns the number of suggestions available.
+ virtual unsigned getSuggestionsCount() const = 0;
+
+ // Returns the suggestion at |listIndex|.
+ virtual WebString getSuggestion(unsigned listIndex) const = 0;
+
+ // Removes the suggestion at |listIndex| from the list of suggestions.
+ virtual void removeSuggestionAtIndex(unsigned listIndex) = 0;
+
+ // WebCore::PopupMenuClient methods:
+ virtual void valueChanged(unsigned listIndex, bool fireEvents = true);
+ virtual void selectionChanged(unsigned listIndex, bool fireEvents = true);
+ virtual WebCore::String itemText(unsigned listIndex) const;
+ virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); }
+ virtual bool itemIsEnabled(unsigned listIndex) const { return true; }
+ virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const;
+ virtual WebCore::PopupMenuStyle menuStyle() const;
+ virtual int clientInsetLeft() const { return 0; }
+ virtual int clientInsetRight() const { return 0; }
+ virtual int clientPaddingLeft() const;
+ virtual int clientPaddingRight() const;
+ virtual int listSize() const { return getSuggestionsCount(); }
+ virtual int selectedIndex() const { return m_selectedIndex; }
+ virtual void popupDidHide();
+ virtual bool itemIsSeparator(unsigned listIndex) const { return false; }
+ virtual bool itemIsLabel(unsigned listIndex) const { return false; }
+ virtual bool itemIsSelected(unsigned listIndex) const { return false; }
+ virtual bool shouldPopOver() const { return false; }
+ virtual bool valueShouldChangeOnHotTrack() const { return false; }
+ virtual void setTextFromItem(unsigned listIndex);
+ virtual WebCore::FontSelector* fontSelector() const;
+ virtual WebCore::HostWindow* hostWindow() const;
+ virtual PassRefPtr<WebCore::Scrollbar> createScrollbar(
+ WebCore::ScrollbarClient* client,
+ WebCore::ScrollbarOrientation orientation,
+ WebCore::ScrollbarControlSize size);
+
+protected:
+ void initialize(WebCore::HTMLInputElement* textField,
+ int defaultSuggestionIndex);
+ void setInitialSuggestion();
+
+ int getSelectedIndex() const { return m_selectedIndex; }
+ void setSelectedIndex(int index) { m_selectedIndex = index; }
+
+ void setSuggestedValue(const WebString& suggestion);
+
+ WebViewImpl* getWebView() const;
+ WebCore::HTMLInputElement* getTextField() const { return m_textField.get(); }
+
+private:
+ WebCore::RenderStyle* textFieldStyle() const;
+ void resetLastSuggestion();
+
+ RefPtr<WebCore::HTMLInputElement> m_textField;
+ int m_selectedIndex;
+ WebCore::String m_typedFieldValue;
+ OwnPtr<WebCore::PopupMenuStyle> m_style;
+ typedef HashMap<WebCore::String, WebCore::String> FieldValuesMap;
+ OwnPtr<FieldValuesMap> m_lastFieldValues;
+};
+
+} // namespace WebKit
+
+#endif
diff --git a/WebKit/chromium/src/WebViewImpl.cpp b/WebKit/chromium/src/WebViewImpl.cpp
index 32b3f2c..ce03523 100644
--- a/WebKit/chromium/src/WebViewImpl.cpp
+++ b/WebKit/chromium/src/WebViewImpl.cpp
@@ -31,6 +31,7 @@
#include "config.h"
#include "WebViewImpl.h"
+#include "AutoFillPopupMenuClient.h"
#include "AutocompletePopupMenuClient.h"
#include "AXObjectCache.h"
#include "Chrome.h"
@@ -240,6 +241,8 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_operationsAllowed(WebDragOperationNone)
, m_dragOperation(WebDragOperationNone)
, m_suggestionsPopupShowing(false)
+ , m_suggestionsPopupClient(0)
+ , m_suggestionsPopup(0)
, m_isTransparent(false)
, m_tabsToLinks(false)
{
@@ -468,7 +471,7 @@ bool WebViewImpl::keyEvent(const WebKeyboardEvent& event)
// event.
m_suppressNextKeypressEvent = false;
- // Give autocomplete a chance to consume the key events it is interested in.
+ // Give Autocomplete a chance to consume the key events it is interested in.
if (autocompleteHandleKeyEvent(event))
return true;
@@ -541,7 +544,7 @@ bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event)
m_client->removeAutofillSuggestions(name, value);
// Update the entries in the currently showing popup to reflect the
// deletion.
- m_autocompletePopupClient->removeItemAtIndex(selectedIndex);
+ m_autocompletePopupClient->removeSuggestionAtIndex(selectedIndex);
refreshSuggestionsPopup();
return false;
}
@@ -1560,58 +1563,118 @@ void WebViewImpl::applyAutofillSuggestions(
const WebVector<WebString>& suggestions,
int defaultSuggestionIndex)
{
- if (!m_page.get() || suggestions.isEmpty()) {
+ applyAutocompleteSuggestions(node, suggestions, defaultSuggestionIndex);
+}
+
+void WebViewImpl::applyAutoFillSuggestions(
+ const WebNode& node,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ int defaultSuggestionIndex)
+{
+ ASSERT(names.size() == labels.size());
+ ASSERT(defaultSuggestionIndex < static_cast<int>(names.size()));
+
+ if (names.isEmpty()) {
hideSuggestionsPopup();
return;
}
+ RefPtr<Node> focusedNode = focusedWebCoreNode();
+ // If the node for which we queried the AutoFill suggestions is not the
+ // focused node, then we have nothing to do. FIXME: also check the
+ // caret is at the end and that the text has not changed.
+ if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) {
+ hideSuggestionsPopup();
+ return;
+ }
+
+ HTMLInputElement* inputElem =
+ static_cast<HTMLInputElement*>(focusedNode.get());
+
+ // The first time the AutoFill popup is shown we'll create the client and
+ // the popup.
+ if (!m_autoFillPopupClient.get())
+ m_autoFillPopupClient.set(new AutoFillPopupMenuClient);
+
+ m_autoFillPopupClient->initialize(inputElem, names, labels,
+ defaultSuggestionIndex);
+
+ if (m_suggestionsPopupClient != m_autoFillPopupClient.get()) {
+ hideSuggestionsPopup();
+ m_suggestionsPopupClient = m_autoFillPopupClient.get();
+ }
+
+ if (!m_autoFillPopup.get()) {
+ m_autoFillPopup = PopupContainer::create(m_suggestionsPopupClient,
+ suggestionsPopupSettings);
+ }
+
+ if (m_suggestionsPopup != m_autoFillPopup.get())
+ m_suggestionsPopup = m_autoFillPopup.get();
+
+ if (m_suggestionsPopupShowing) {
+ m_autoFillPopupClient->setSuggestions(names, labels);
+ refreshSuggestionsPopup();
+ } else {
+ m_suggestionsPopup->show(focusedNode->getRect(),
+ focusedNode->ownerDocument()->view(), 0);
+ m_suggestionsPopupShowing = true;
+ }
+}
+
+void WebViewImpl::applyAutocompleteSuggestions(
+ const WebNode& node,
+ const WebVector<WebString>& suggestions,
+ int defaultSuggestionIndex)
+{
ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size()));
- if (RefPtr<Frame> focused = m_page->focusController()->focusedFrame()) {
- RefPtr<Document> document = focused->document();
- if (!document.get()) {
- hideSuggestionsPopup();
- return;
- }
+ if (!m_page.get() || suggestions.isEmpty()) {
+ hideSuggestionsPopup();
+ return;
+ }
- RefPtr<Node> focusedNode = document->focusedNode();
- // If the node for which we queried the autofill suggestions is not 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.
- if (!focusedNode.get() || focusedNode != PassRefPtr<Node>(node)) {
- hideSuggestionsPopup();
- return;
- }
+ RefPtr<Node> focusedNode = focusedWebCoreNode();
+ // If the node for which we queried the Autocomplete suggestions is not the
+ // focused node, then we have nothing to do. FIXME: also check the
+ // caret is at the end and that the text has not changed.
+ if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) {
+ hideSuggestionsPopup();
+ return;
+ }
- if (!focusedNode->hasTagName(HTMLNames::inputTag)) {
- ASSERT_NOT_REACHED();
- return;
- }
+ HTMLInputElement* inputElem =
+ static_cast<HTMLInputElement*>(focusedNode.get());
- HTMLInputElement* inputElem =
- static_cast<HTMLInputElement*>(focusedNode.get());
-
- // The first time the suggestions popup is shown we'll create the client
- // and the popup.
- if (!m_autocompletePopupClient.get())
- m_autocompletePopupClient.set(new AutocompletePopupMenuClient(this));
- m_autocompletePopupClient->initialize(inputElem,
- suggestions,
- defaultSuggestionIndex);
- if (!m_suggestionsPopup.get()) {
- m_suggestionsPopup =
- PopupContainer::create(m_autocompletePopupClient.get(),
- suggestionsPopupSettings);
- }
+ // The first time the Autocomplete is shown we'll create the client and the
+ // popup.
+ if (!m_autocompletePopupClient.get())
+ m_autocompletePopupClient.set(new AutocompletePopupMenuClient);
- if (m_suggestionsPopupShowing) {
- m_autocompletePopupClient->setSuggestions(suggestions);
- refreshSuggestionsPopup();
- } else {
- m_suggestionsPopup->show(focusedNode->getRect(),
- focusedNode->ownerDocument()->view(), 0);
- m_suggestionsPopupShowing = true;
- }
+ m_autocompletePopupClient->initialize(inputElem, suggestions,
+ defaultSuggestionIndex);
+
+ if (m_suggestionsPopupClient != m_autocompletePopupClient.get()) {
+ hideSuggestionsPopup();
+ m_suggestionsPopupClient = m_autocompletePopupClient.get();
+ }
+
+ if (!m_autocompletePopup.get()) {
+ m_autocompletePopup = PopupContainer::create(m_suggestionsPopupClient,
+ suggestionsPopupSettings);
+ }
+
+ if (m_suggestionsPopup != m_autocompletePopup.get())
+ m_suggestionsPopup = m_autocompletePopup.get();
+
+ if (m_suggestionsPopupShowing) {
+ m_autocompletePopupClient->setSuggestions(suggestions);
+ refreshSuggestionsPopup();
+ } else {
+ m_suggestionsPopup->show(focusedNode->getRect(),
+ focusedNode->ownerDocument()->view(), 0);
+ m_suggestionsPopupShowing = true;
}
}
diff --git a/WebKit/chromium/src/WebViewImpl.h b/WebKit/chromium/src/WebViewImpl.h
index 0b7cb73..286ac43 100644
--- a/WebKit/chromium/src/WebViewImpl.h
+++ b/WebKit/chromium/src/WebViewImpl.h
@@ -58,6 +58,7 @@ class KeyboardEvent;
class Page;
class PlatformKeyboardEvent;
class PopupContainer;
+class PopupMenuClient;
class Range;
class RenderTheme;
class Widget;
@@ -65,7 +66,9 @@ class Widget;
namespace WebKit {
class AutocompletePopupMenuClient;
+class AutoFillPopupMenuClient;
class ContextMenuClientImpl;
+class SuggestionsPopupMenuClient;
class WebAccessibilityObject;
class WebDevToolsAgentPrivate;
class WebFrameImpl;
@@ -153,6 +156,15 @@ public:
const WebNode&,
const WebVector<WebString>& suggestions,
int defaultSuggestionIndex);
+ virtual void applyAutoFillSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& names,
+ const WebVector<WebString>& labels,
+ int defaultSuggestionIndex);
+ virtual void applyAutocompleteSuggestions(
+ const WebNode&,
+ const WebVector<WebString>& suggestions,
+ int defaultSuggestionIndex);
virtual void hideAutofillPopup();
virtual void hideSuggestionsPopup();
virtual void setScrollbarColors(unsigned inactiveColor,
@@ -395,16 +407,29 @@ private:
// current drop target in this WebView (the drop target can accept the drop).
WebDragOperation m_dragOperation;
- // The suggestions popup. Kept around and reused every-time new suggestions
- // should be shown.
- RefPtr<WebCore::PopupContainer> m_suggestionsPopup;
-
- // Whether the suggestions popup is currently showing.
+ // Whether a suggestions popup is currently showing.
bool m_suggestionsPopupShowing;
- // The autocomplete client.
+ // A pointer to the current suggestions popup menu client. This can be
+ // either an AutoFillPopupMenuClient or an AutocompletePopupMenuClient. We
+ // do not own this pointer.
+ SuggestionsPopupMenuClient* m_suggestionsPopupClient;
+
+ // The AutoFill popup client.
+ OwnPtr<AutoFillPopupMenuClient> m_autoFillPopupClient;
+
+ // The Autocomplete popup client.
OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient;
+ // A pointer to the current suggestions popup. We do not own this pointer.
+ WebCore::PopupContainer* m_suggestionsPopup;
+
+ // The AutoFill suggestions popup.
+ RefPtr<WebCore::PopupContainer> m_autoFillPopup;
+
+ // The AutoComplete suggestions popup.
+ RefPtr<WebCore::PopupContainer> m_autocompletePopup;
+
OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
// Whether the webview is rendering transparently.
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list