OLD | NEW |
| (Empty) |
1 /* | |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | |
3 * | |
4 * Redistribution and use in source and binary forms, with or without | |
5 * modification, are permitted provided that the following conditions are | |
6 * met: | |
7 * | |
8 * * Redistributions of source code must retain the above copyright | |
9 * notice, this list of conditions and the following disclaimer. | |
10 * * Redistributions in binary form must reproduce the above | |
11 * copyright notice, this list of conditions and the following disclaimer | |
12 * in the documentation and/or other materials provided with the | |
13 * distribution. | |
14 * * Neither the name of Google Inc. nor the names of its | |
15 * contributors may be used to endorse or promote products derived from | |
16 * this software without specific prior written permission. | |
17 * | |
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | |
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 */ | |
30 | |
31 #include "PopupMenuClient.h" | |
32 | |
33 namespace WebCore { | |
34 class HTMLInputElement; | |
35 class PopupMenuStyle; | |
36 class RenderStyle; | |
37 } | |
38 | |
39 namespace WebKit { | |
40 class WebString; | |
41 class WebViewImpl; | |
42 template <typename T> class WebVector; | |
43 | |
44 // AutocompletePopupMenuClient | |
45 class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { | |
46 public: | |
47 AutocompletePopupMenuClient(WebViewImpl* webview); | |
48 ~AutocompletePopupMenuClient(); | |
49 | |
50 void initialize(WebCore::HTMLInputElement*, | |
51 const WebVector<WebString>& suggestions, | |
52 int defaultSuggestionIndex); | |
53 | |
54 WebCore::HTMLInputElement* textField() const { return m_textField.get(); } | |
55 | |
56 void setSuggestions(const WebVector<WebString>&); | |
57 void removeItemAtIndex(int index); | |
58 | |
59 // WebCore::PopupMenuClient methods: | |
60 virtual void valueChanged(unsigned listIndex, bool fireEvents = true); | |
61 virtual WebCore::String itemText(unsigned listIndex) const; | |
62 virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); } | |
63 virtual bool itemIsEnabled(unsigned listIndex) const { return true; } | |
64 virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const; | |
65 virtual WebCore::PopupMenuStyle menuStyle() const; | |
66 virtual int clientInsetLeft() const { return 0; } | |
67 virtual int clientInsetRight() const { return 0; } | |
68 virtual int clientPaddingLeft() const; | |
69 virtual int clientPaddingRight() const; | |
70 virtual int listSize() const { return m_suggestions.size(); } | |
71 virtual int selectedIndex() const { return m_selectedIndex; } | |
72 virtual void popupDidHide(); | |
73 virtual bool itemIsSeparator(unsigned listIndex) const { return false; } | |
74 virtual bool itemIsLabel(unsigned listIndex) const { return false; } | |
75 virtual bool itemIsSelected(unsigned listIndex) const { return false; } | |
76 virtual bool shouldPopOver() const { return false; } | |
77 virtual bool valueShouldChangeOnHotTrack() const { return false; } | |
78 virtual void setTextFromItem(unsigned listIndex); | |
79 virtual WebCore::FontSelector* fontSelector() const; | |
80 virtual WebCore::HostWindow* hostWindow() const; | |
81 virtual PassRefPtr<WebCore::Scrollbar> createScrollbar( | |
82 WebCore::ScrollbarClient* client, | |
83 WebCore::ScrollbarOrientation orientation, | |
84 WebCore::ScrollbarControlSize size); | |
85 | |
86 private: | |
87 WebCore::RenderStyle* textFieldStyle() const; | |
88 | |
89 RefPtr<WebCore::HTMLInputElement> m_textField; | |
90 Vector<WebCore::String> m_suggestions; | |
91 int m_selectedIndex; | |
92 WebViewImpl* m_webView; | |
93 OwnPtr<WebCore::PopupMenuStyle> m_style; | |
94 }; | |
95 | |
96 } // namespace WebKit | |
OLD | NEW |