Changeset 54586 in webkit
- Timestamp:
- Feb 9, 2010 8:48:49 PM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 3 added
- 7 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r54584 r54586 1 2010-02-09 James Hawkins <jhawkins@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 [Chromium] Refactor AutocompletePopupMenuClient into a base class, 6 SuggestionsPopupMenuClient, and two derived classes, 7 AutocompletePopupMenuClient and AutoFillPopupMenuClient. Currently 8 the behavior of suggestions popups has not changed. 9 10 https://bugs.webkit.org/show_bug.cgi?id=34721 11 12 * WebKit.gyp: 13 * public/WebView.h: 14 * src/AutoFillPopupMenuClient.cpp: Added. 15 * src/AutoFillPopupMenuClient.h: Added. 16 * src/AutocompletePopupMenuClient.cpp: 17 (WebKit::AutocompletePopupMenuClient::getSuggestionsCount): 18 (WebKit::AutocompletePopupMenuClient::getSuggestion): 19 (WebKit::AutocompletePopupMenuClient::removeSuggestionAtIndex): 20 (WebKit::AutocompletePopupMenuClient::initialize): 21 (WebKit::AutocompletePopupMenuClient::setSuggestions): 22 * src/AutocompletePopupMenuClient.h: 23 * src/SuggestionsPopupMenuClient.cpp: Added. 24 * src/SuggestionsPopupMenuClient.h: Added. 25 * src/WebViewImpl.cpp: 26 (WebKit::WebViewImpl::WebViewImpl): 27 (WebKit::WebViewImpl::keyEvent): 28 (WebKit::WebViewImpl::autocompleteHandleKeyEvent): 29 (WebKit::WebViewImpl::applyAutofillSuggestions): 30 (WebKit::WebViewImpl::applyAutoFillSuggestions): 31 (WebKit::WebViewImpl::applyAutocompleteSuggestions): 32 * src/WebViewImpl.h: 33 1 34 2010-02-09 Chris Guillory <ctguil@google.com> 2 35 -
trunk/WebKit/chromium/WebKit.gyp
r54565 r54586 201 201 'src/AutocompletePopupMenuClient.cpp', 202 202 'src/AutocompletePopupMenuClient.h', 203 'src/AutoFillPopupMenuClient.cpp', 204 'src/AutoFillPopupMenuClient.h', 203 205 'src/BackForwardListClientImpl.cpp', 204 206 'src/BackForwardListClientImpl.h', … … 259 261 'src/StorageNamespaceProxy.cpp', 260 262 'src/StorageNamespaceProxy.h', 263 'src/SuggestionsPopupMenuClient.cpp', 264 'src/SuggestionsPopupMenuClient.h', 261 265 'src/TemporaryGlue.h', 262 266 'src/ToolsAgent.h', -
trunk/WebKit/chromium/public/WebView.h
r54458 r54586 224 224 225 225 226 // Autofill ------------------------------------------------------------ 227 228 // Notifies the WebView that autofill suggestions are available for a node. 226 // AutoFill / Autocomplete --------------------------------------------- 227 228 // DEPRECATED: WebView::applyAutocompleteSuggestions is the new way to 229 // access this. 229 230 virtual void applyAutofillSuggestions( 230 231 const WebNode&, … … 232 233 int defaultSuggestionIndex) = 0; 233 234 235 // Notifies the WebView that AutoFill suggestions are available for a node. 236 virtual void applyAutoFillSuggestions( 237 const WebNode&, 238 const WebVector<WebString>& names, 239 const WebVector<WebString>& labels, 240 int defaultSuggestionIndex) = 0; 241 242 // Notifies the WebView that Autocomplete suggestions are available for a 243 // node. 244 virtual void applyAutocompleteSuggestions( 245 const WebNode&, 246 const WebVector<WebString>& suggestions, 247 int defaultSuggestionIndex) = 0; 248 234 249 // DEPRECATED: WebView::hideSuggestionsPopup is the new way to access this. 235 250 virtual void hideAutofillPopup() = 0; -
trunk/WebKit/chromium/src/AutocompletePopupMenuClient.cpp
r54458 r54586 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 #include "AutocompletePopupMenuClient.h" 33 33 34 #include "CSSStyleSelector.h"35 #include "CSSValueKeywords.h"36 #include "FrameView.h"37 34 #include "HTMLInputElement.h" 38 #include " RenderTheme.h"35 #include "WebString.h" 39 36 #include "WebVector.h" 40 #include "WebViewImpl.h"41 37 42 38 using namespace WebCore; … … 44 40 namespace WebKit { 45 41 46 AutocompletePopupMenuClient::AutocompletePopupMenuClient(WebViewImpl* webView) 47 : m_textField(0) 48 , m_selectedIndex(0) 49 , m_webView(webView) 42 unsigned AutocompletePopupMenuClient::getSuggestionsCount() const 50 43 { 44 return m_suggestions.size(); 51 45 } 52 46 53 AutocompletePopupMenuClient::~AutocompletePopupMenuClient() 47 WebString AutocompletePopupMenuClient::getSuggestion(unsigned listIndex) const 54 48 { 49 ASSERT(listIndex >= 0 && listIndex < m_suggestions.size()); 50 return m_suggestions[listIndex]; 51 } 52 53 void AutocompletePopupMenuClient::removeSuggestionAtIndex(unsigned listIndex) 54 { 55 ASSERT(listIndex >= 0 && listIndex < m_suggestions.size()); 56 m_suggestions.remove(listIndex); 55 57 } 56 58 … … 61 63 { 62 64 ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); 63 m_textField = textField; 64 m_selectedIndex = defaultSuggestionIndex; 65 66 // The suggestions must be set before initializing the 67 // SuggestionsPopupMenuClient. 65 68 setSuggestions(suggestions); 66 69 67 FontDescription fontDescription; 68 m_webView->theme()->systemFont(CSSValueWebkitControl, fontDescription); 69 // Use a smaller font size to match IE/Firefox. 70 // FIXME: http://crbug.com/7376 use the system size instead of a 71 // fixed font size value. 72 fontDescription.setComputedSize(12.0); 73 Font font(fontDescription, 0, 0); 74 font.update(textField->document()->styleSelector()->fontSelector()); 75 // The direction of text in popup menu is set the same as the direction of 76 // the input element: textField. 77 m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true, 78 Length(WebCore::Fixed), 79 textField->renderer()->style()->direction())); 80 } 81 82 void AutocompletePopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) 83 { 84 m_textField->setValue(m_suggestions[listIndex]); 85 EditorClientImpl* editor = 86 static_cast<EditorClientImpl*>(m_webView->page()->editorClient()); 87 ASSERT(editor); 88 editor->onAutofillSuggestionAccepted( 89 static_cast<HTMLInputElement*>(m_textField.get())); 90 } 91 92 String AutocompletePopupMenuClient::itemText(unsigned listIndex) const 93 { 94 return m_suggestions[listIndex]; 95 } 96 97 PopupMenuStyle AutocompletePopupMenuClient::itemStyle(unsigned listIndex) const 98 { 99 return *m_style; 100 } 101 102 PopupMenuStyle AutocompletePopupMenuClient::menuStyle() const 103 { 104 return *m_style; 105 } 106 107 int AutocompletePopupMenuClient::clientPaddingLeft() const 108 { 109 // Bug http://crbug.com/7708 seems to indicate the style can be 0. 110 RenderStyle* style = textFieldStyle(); 111 return style ? m_webView->theme()->popupInternalPaddingLeft(style) : 0; 112 } 113 114 int AutocompletePopupMenuClient::clientPaddingRight() const 115 { 116 // Bug http://crbug.com/7708 seems to indicate the style can be 0. 117 RenderStyle* style = textFieldStyle(); 118 return style ? m_webView->theme()->popupInternalPaddingRight(style) : 0; 119 } 120 121 void AutocompletePopupMenuClient::popupDidHide() 122 { 123 m_webView->suggestionsPopupDidHide(); 124 } 125 126 void AutocompletePopupMenuClient::setTextFromItem(unsigned listIndex) 127 { 128 m_textField->setValue(m_suggestions[listIndex]); 129 } 130 131 FontSelector* AutocompletePopupMenuClient::fontSelector() const 132 { 133 return m_textField->document()->styleSelector()->fontSelector(); 134 } 135 136 HostWindow* AutocompletePopupMenuClient::hostWindow() const 137 { 138 return m_textField->document()->view()->hostWindow(); 139 } 140 141 PassRefPtr<Scrollbar> AutocompletePopupMenuClient::createScrollbar( 142 ScrollbarClient* client, 143 ScrollbarOrientation orientation, 144 ScrollbarControlSize size) 145 { 146 return Scrollbar::createNativeScrollbar(client, orientation, size); 70 SuggestionsPopupMenuClient::initialize(textField, defaultSuggestionIndex); 147 71 } 148 72 … … 152 76 for (size_t i = 0; i < suggestions.size(); ++i) 153 77 m_suggestions.append(suggestions[i]); 78 154 79 // Try to preserve selection if possible. 155 if (m_selectedIndex >= static_cast<int>(suggestions.size())) 156 m_selectedIndex = -1; 157 } 158 159 void AutocompletePopupMenuClient::removeItemAtIndex(int index) 160 { 161 ASSERT(index >= 0 && index < static_cast<int>(m_suggestions.size())); 162 m_suggestions.remove(index); 163 } 164 165 RenderStyle* AutocompletePopupMenuClient::textFieldStyle() const 166 { 167 RenderStyle* style = m_textField->computedStyle(); 168 if (!style) { 169 // It seems we can only have a 0 style in a TextField if the 170 // node is detached, in which case we the popup shoud not be 171 // showing. Please report this in http://crbug.com/7708 and 172 // include the page you were visiting. 173 ASSERT_NOT_REACHED(); 174 } 175 return style; 80 if (getSelectedIndex() >= static_cast<int>(suggestions.size())) 81 setSelectedIndex(-1); 176 82 } 177 83 -
trunk/WebKit/chromium/src/AutocompletePopupMenuClient.h
r53716 r54586 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 */ 30 30 31 #include "PopupMenuClient.h" 31 #ifndef AutocompletePopupMenuClient_h 32 #define AutocompletePopupMenuClient_h 33 34 #include "SuggestionsPopupMenuClient.h" 32 35 33 36 namespace WebCore { 34 37 class HTMLInputElement; 35 class PopupMenuStyle;36 class RenderStyle;37 38 } 38 39 39 40 namespace WebKit { 40 41 class WebString; 41 class WebViewImpl;42 42 template <typename T> class WebVector; 43 43 44 // AutocompletePopupMenuClient 45 class AutocompletePopupMenuClient : public WebCore::PopupMenuClient { 44 // The Autocomplete suggestions popup menu client, used to display a list of 45 // autocomplete suggestions. 46 class AutocompletePopupMenuClient : public SuggestionsPopupMenuClient { 46 47 public: 47 AutocompletePopupMenuClient(WebViewImpl* webview); 48 ~AutocompletePopupMenuClient(); 48 // SuggestionsPopupMenuClient implementation: 49 virtual unsigned getSuggestionsCount() const; 50 virtual WebString getSuggestion(unsigned listIndex) const; 51 virtual void removeSuggestionAtIndex(unsigned listIndex); 49 52 50 53 void initialize(WebCore::HTMLInputElement*, … … 52 55 int defaultSuggestionIndex); 53 56 54 WebCore::HTMLInputElement* textField() const { return m_textField.get(); }55 56 57 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 58 86 59 private: 87 WebCore::RenderStyle* textFieldStyle() const;88 89 RefPtr<WebCore::HTMLInputElement> m_textField;90 60 Vector<WebCore::String> m_suggestions; 91 int m_selectedIndex;92 WebViewImpl* m_webView;93 OwnPtr<WebCore::PopupMenuStyle> m_style;94 61 }; 95 62 96 63 } // namespace WebKit 64 65 #endif -
trunk/WebKit/chromium/src/SuggestionsPopupMenuClient.h
r54585 r54586 1 1 /* 2 * Copyright (C) 20 09Google Inc. All rights reserved.2 * Copyright (C) 2010 Google Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "PopupMenuClient.h" 32 32 33 #ifndef SuggestionsPopupMenuClient_h 34 #define SuggestionsPopupMenuClient_h 35 33 36 namespace WebCore { 34 37 class HTMLInputElement; … … 42 45 template <typename T> class WebVector; 43 46 44 // AutocompletePopupMenuClient45 class AutocompletePopupMenuClient : public WebCore::PopupMenuClient {47 // The Suggestions popup menu client, used to display a list of suggestions. 48 class SuggestionsPopupMenuClient : public WebCore::PopupMenuClient { 46 49 public: 47 AutocompletePopupMenuClient(WebViewImpl* webview);48 ~AutocompletePopupMenuClient();50 SuggestionsPopupMenuClient(); 51 virtual ~SuggestionsPopupMenuClient(); 49 52 50 void initialize(WebCore::HTMLInputElement*, 51 const WebVector<WebString>& suggestions, 52 int defaultSuggestionIndex); 53 // Returns the number of suggestions available. 54 virtual unsigned getSuggestionsCount() const = 0; 53 55 54 WebCore::HTMLInputElement* textField() const { return m_textField.get(); } 56 // Returns the suggestion at |listIndex|. 57 virtual WebString getSuggestion(unsigned listIndex) const = 0; 55 58 56 void setSuggestions(const WebVector<WebString>&);57 v oid removeItemAtIndex(int index);59 // Removes the suggestion at |listIndex| from the list of suggestions. 60 virtual void removeSuggestionAtIndex(unsigned listIndex) = 0; 58 61 59 62 // WebCore::PopupMenuClient methods: 60 63 virtual void valueChanged(unsigned listIndex, bool fireEvents = true); 64 virtual void selectionChanged(unsigned listIndex, bool fireEvents = true); 61 65 virtual WebCore::String itemText(unsigned listIndex) const; 62 66 virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); } … … 68 72 virtual int clientPaddingLeft() const; 69 73 virtual int clientPaddingRight() const; 70 virtual int listSize() const { return m_suggestions.size(); }74 virtual int listSize() const { return getSuggestionsCount(); } 71 75 virtual int selectedIndex() const { return m_selectedIndex; } 72 76 virtual void popupDidHide(); … … 84 88 WebCore::ScrollbarControlSize size); 85 89 90 protected: 91 void initialize(WebCore::HTMLInputElement* textField, 92 int defaultSuggestionIndex); 93 void setInitialSuggestion(); 94 95 int getSelectedIndex() const { return m_selectedIndex; } 96 void setSelectedIndex(int index) { m_selectedIndex = index; } 97 98 void setSuggestedValue(const WebString& suggestion); 99 100 WebViewImpl* getWebView() const; 101 WebCore::HTMLInputElement* getTextField() const { return m_textField.get(); } 102 86 103 private: 87 104 WebCore::RenderStyle* textFieldStyle() const; 105 void resetLastSuggestion(); 88 106 89 107 RefPtr<WebCore::HTMLInputElement> m_textField; 90 Vector<WebCore::String> m_suggestions;91 108 int m_selectedIndex; 92 Web ViewImpl* m_webView;109 WebCore::String m_typedFieldValue; 93 110 OwnPtr<WebCore::PopupMenuStyle> m_style; 111 typedef HashMap<WebCore::String, WebCore::String> FieldValuesMap; 112 OwnPtr<FieldValuesMap> m_lastFieldValues; 94 113 }; 95 114 96 115 } // namespace WebKit 116 117 #endif -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r54535 r54586 32 32 #include "WebViewImpl.h" 33 33 34 #include "AutoFillPopupMenuClient.h" 34 35 #include "AutocompletePopupMenuClient.h" 35 36 #include "AXObjectCache.h" … … 241 242 , m_dragOperation(WebDragOperationNone) 242 243 , m_suggestionsPopupShowing(false) 244 , m_suggestionsPopupClient(0) 245 , m_suggestionsPopup(0) 243 246 , m_isTransparent(false) 244 247 , m_tabsToLinks(false) … … 469 472 m_suppressNextKeypressEvent = false; 470 473 471 // Give autocomplete a chance to consume the key events it is interested in.474 // Give Autocomplete a chance to consume the key events it is interested in. 472 475 if (autocompleteHandleKeyEvent(event)) 473 476 return true; … … 542 545 // Update the entries in the currently showing popup to reflect the 543 546 // deletion. 544 m_autocompletePopupClient->remove ItemAtIndex(selectedIndex);547 m_autocompletePopupClient->removeSuggestionAtIndex(selectedIndex); 545 548 refreshSuggestionsPopup(); 546 549 return false; … … 1561 1564 int defaultSuggestionIndex) 1562 1565 { 1566 applyAutocompleteSuggestions(node, suggestions, defaultSuggestionIndex); 1567 } 1568 1569 void WebViewImpl::applyAutoFillSuggestions( 1570 const WebNode& node, 1571 const WebVector<WebString>& names, 1572 const WebVector<WebString>& labels, 1573 int defaultSuggestionIndex) 1574 { 1575 ASSERT(names.size() == labels.size()); 1576 ASSERT(defaultSuggestionIndex < static_cast<int>(names.size())); 1577 1578 if (names.isEmpty()) { 1579 hideSuggestionsPopup(); 1580 return; 1581 } 1582 1583 RefPtr<Node> focusedNode = focusedWebCoreNode(); 1584 // If the node for which we queried the AutoFill suggestions is not the 1585 // focused node, then we have nothing to do. FIXME: also check the 1586 // caret is at the end and that the text has not changed. 1587 if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) { 1588 hideSuggestionsPopup(); 1589 return; 1590 } 1591 1592 HTMLInputElement* inputElem = 1593 static_cast<HTMLInputElement*>(focusedNode.get()); 1594 1595 // The first time the AutoFill popup is shown we'll create the client and 1596 // the popup. 1597 if (!m_autoFillPopupClient.get()) 1598 m_autoFillPopupClient.set(new AutoFillPopupMenuClient); 1599 1600 m_autoFillPopupClient->initialize(inputElem, names, labels, 1601 defaultSuggestionIndex); 1602 1603 if (m_suggestionsPopupClient != m_autoFillPopupClient.get()) { 1604 hideSuggestionsPopup(); 1605 m_suggestionsPopupClient = m_autoFillPopupClient.get(); 1606 } 1607 1608 if (!m_autoFillPopup.get()) { 1609 m_autoFillPopup = PopupContainer::create(m_suggestionsPopupClient, 1610 suggestionsPopupSettings); 1611 } 1612 1613 if (m_suggestionsPopup != m_autoFillPopup.get()) 1614 m_suggestionsPopup = m_autoFillPopup.get(); 1615 1616 if (m_suggestionsPopupShowing) { 1617 m_autoFillPopupClient->setSuggestions(names, labels); 1618 refreshSuggestionsPopup(); 1619 } else { 1620 m_suggestionsPopup->show(focusedNode->getRect(), 1621 focusedNode->ownerDocument()->view(), 0); 1622 m_suggestionsPopupShowing = true; 1623 } 1624 } 1625 1626 void WebViewImpl::applyAutocompleteSuggestions( 1627 const WebNode& node, 1628 const WebVector<WebString>& suggestions, 1629 int defaultSuggestionIndex) 1630 { 1631 ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); 1632 1563 1633 if (!m_page.get() || suggestions.isEmpty()) { 1564 1634 hideSuggestionsPopup(); … … 1566 1636 } 1567 1637 1568 ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); 1569 1570 if (RefPtr<Frame> focused = m_page->focusController()->focusedFrame()) { 1571 RefPtr<Document> document = focused->document(); 1572 if (!document.get()) { 1573 hideSuggestionsPopup(); 1574 return; 1575 } 1576 1577 RefPtr<Node> focusedNode = document->focusedNode(); 1578 // If the node for which we queried the autofill suggestions is not the 1579 // focused node, then we have nothing to do. FIXME: also check the 1580 // carret is at the end and that the text has not changed. 1581 if (!focusedNode.get() || focusedNode != PassRefPtr<Node>(node)) { 1582 hideSuggestionsPopup(); 1583 return; 1584 } 1585 1586 if (!focusedNode->hasTagName(HTMLNames::inputTag)) { 1587 ASSERT_NOT_REACHED(); 1588 return; 1589 } 1590 1591 HTMLInputElement* inputElem = 1592 static_cast<HTMLInputElement*>(focusedNode.get()); 1593 1594 // The first time the suggestions popup is shown we'll create the client 1595 // and the popup. 1596 if (!m_autocompletePopupClient.get()) 1597 m_autocompletePopupClient.set(new AutocompletePopupMenuClient(this)); 1598 m_autocompletePopupClient->initialize(inputElem, 1599 suggestions, 1600 defaultSuggestionIndex); 1601 if (!m_suggestionsPopup.get()) { 1602 m_suggestionsPopup = 1603 PopupContainer::create(m_autocompletePopupClient.get(), 1604 suggestionsPopupSettings); 1605 } 1606 1607 if (m_suggestionsPopupShowing) { 1608 m_autocompletePopupClient->setSuggestions(suggestions); 1609 refreshSuggestionsPopup(); 1610 } else { 1611 m_suggestionsPopup->show(focusedNode->getRect(), 1612 focusedNode->ownerDocument()->view(), 0); 1613 m_suggestionsPopupShowing = true; 1614 } 1638 RefPtr<Node> focusedNode = focusedWebCoreNode(); 1639 // If the node for which we queried the Autocomplete suggestions is not the 1640 // focused node, then we have nothing to do. FIXME: also check the 1641 // caret is at the end and that the text has not changed. 1642 if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) { 1643 hideSuggestionsPopup(); 1644 return; 1645 } 1646 1647 HTMLInputElement* inputElem = 1648 static_cast<HTMLInputElement*>(focusedNode.get()); 1649 1650 // The first time the Autocomplete is shown we'll create the client and the 1651 // popup. 1652 if (!m_autocompletePopupClient.get()) 1653 m_autocompletePopupClient.set(new AutocompletePopupMenuClient); 1654 1655 m_autocompletePopupClient->initialize(inputElem, suggestions, 1656 defaultSuggestionIndex); 1657 1658 if (m_suggestionsPopupClient != m_autocompletePopupClient.get()) { 1659 hideSuggestionsPopup(); 1660 m_suggestionsPopupClient = m_autocompletePopupClient.get(); 1661 } 1662 1663 if (!m_autocompletePopup.get()) { 1664 m_autocompletePopup = PopupContainer::create(m_suggestionsPopupClient, 1665 suggestionsPopupSettings); 1666 } 1667 1668 if (m_suggestionsPopup != m_autocompletePopup.get()) 1669 m_suggestionsPopup = m_autocompletePopup.get(); 1670 1671 if (m_suggestionsPopupShowing) { 1672 m_autocompletePopupClient->setSuggestions(suggestions); 1673 refreshSuggestionsPopup(); 1674 } else { 1675 m_suggestionsPopup->show(focusedNode->getRect(), 1676 focusedNode->ownerDocument()->view(), 0); 1677 m_suggestionsPopupShowing = true; 1615 1678 } 1616 1679 } -
trunk/WebKit/chromium/src/WebViewImpl.h
r54458 r54586 59 59 class PlatformKeyboardEvent; 60 60 class PopupContainer; 61 class PopupMenuClient; 61 62 class Range; 62 63 class RenderTheme; … … 66 67 namespace WebKit { 67 68 class AutocompletePopupMenuClient; 69 class AutoFillPopupMenuClient; 68 70 class ContextMenuClientImpl; 71 class SuggestionsPopupMenuClient; 69 72 class WebAccessibilityObject; 70 73 class WebDevToolsAgentPrivate; … … 154 157 const WebVector<WebString>& suggestions, 155 158 int defaultSuggestionIndex); 159 virtual void applyAutoFillSuggestions( 160 const WebNode&, 161 const WebVector<WebString>& names, 162 const WebVector<WebString>& labels, 163 int defaultSuggestionIndex); 164 virtual void applyAutocompleteSuggestions( 165 const WebNode&, 166 const WebVector<WebString>& suggestions, 167 int defaultSuggestionIndex); 156 168 virtual void hideAutofillPopup(); 157 169 virtual void hideSuggestionsPopup(); … … 396 408 WebDragOperation m_dragOperation; 397 409 398 // The suggestions popup. Kept around and reused every-time new suggestions 399 // should be shown. 400 RefPtr<WebCore::PopupContainer> m_suggestionsPopup; 401 402 // Whether the suggestions popup is currently showing. 410 // Whether a suggestions popup is currently showing. 403 411 bool m_suggestionsPopupShowing; 404 412 405 // The autocomplete client. 413 // A pointer to the current suggestions popup menu client. This can be 414 // either an AutoFillPopupMenuClient or an AutocompletePopupMenuClient. We 415 // do not own this pointer. 416 SuggestionsPopupMenuClient* m_suggestionsPopupClient; 417 418 // The AutoFill popup client. 419 OwnPtr<AutoFillPopupMenuClient> m_autoFillPopupClient; 420 421 // The Autocomplete popup client. 406 422 OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient; 423 424 // A pointer to the current suggestions popup. We do not own this pointer. 425 WebCore::PopupContainer* m_suggestionsPopup; 426 427 // The AutoFill suggestions popup. 428 RefPtr<WebCore::PopupContainer> m_autoFillPopup; 429 430 // The AutoComplete suggestions popup. 431 RefPtr<WebCore::PopupContainer> m_autocompletePopup; 407 432 408 433 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
Note: See TracChangeset
for help on using the changeset viewer.