Changeset 62272 in webkit
- Timestamp:
- Jul 1, 2010 10:14:53 AM (14 years ago)
- Location:
- trunk/WebKit/chromium
- Files:
-
- 4 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKit/chromium/ChangeLog
r62246 r62272 1 2010-07-01 David Holloway <dhollowa@chromium.org> 2 3 Reviewed by Darin Fisher. 4 5 [chromium] Consolidates AutoFill and Autocomplete popup menus into a single popup menu. 6 7 This change combines SuggestionsPopupMenuClient, AutoFillPopupMenuClient, and 8 AutocompletePopupMenuClient classes into a single consolidated AutoFillPopupMenuClient class. 9 Prior to this change the contents of the AutoFill popup menu only included AutoFill 10 suggestions and similarly the Autocomplete popup menu only included Autocomplete 11 suggestions. With this consolidation, both AutoFill and Autocomplete suggestions can 12 now be displayed in a single menu. 13 14 https://bugs.webkit.org/show_bug.cgi?id=41236 15 16 * WebKit.gyp: 17 * public/WebFrame.h: 18 * public/WebView.h: 19 * src/AutoFillPopupMenuClient.cpp: 20 (WebKit::AutoFillPopupMenuClient::AutoFillPopupMenuClient): 21 (WebKit::AutoFillPopupMenuClient::~AutoFillPopupMenuClient): 22 (WebKit::AutoFillPopupMenuClient::valueChanged): 23 (WebKit::AutoFillPopupMenuClient::selectionCleared): 24 (WebKit::AutoFillPopupMenuClient::itemText): 25 (WebKit::AutoFillPopupMenuClient::itemStyle): 26 (WebKit::AutoFillPopupMenuClient::menuStyle): 27 (WebKit::AutoFillPopupMenuClient::clientPaddingLeft): 28 (WebKit::AutoFillPopupMenuClient::clientPaddingRight): 29 (WebKit::AutoFillPopupMenuClient::popupDidHide): 30 (WebKit::AutoFillPopupMenuClient::setTextFromItem): 31 (WebKit::AutoFillPopupMenuClient::fontSelector): 32 (WebKit::AutoFillPopupMenuClient::hostWindow): 33 (WebKit::AutoFillPopupMenuClient::createScrollbar): 34 (WebKit::AutoFillPopupMenuClient::initialize): 35 (WebKit::AutoFillPopupMenuClient::getWebView): 36 (WebKit::AutoFillPopupMenuClient::textFieldStyle): 37 * src/AutoFillPopupMenuClient.h: 38 (WebKit::AutoFillPopupMenuClient::itemToolTip): 39 (WebKit::AutoFillPopupMenuClient::itemAccessibilityText): 40 (WebKit::AutoFillPopupMenuClient::itemIsEnabled): 41 (WebKit::AutoFillPopupMenuClient::clientInsetLeft): 42 (WebKit::AutoFillPopupMenuClient::clientInsetRight): 43 (WebKit::AutoFillPopupMenuClient::listSize): 44 (WebKit::AutoFillPopupMenuClient::selectedIndex): 45 (WebKit::AutoFillPopupMenuClient::itemIsLabel): 46 (WebKit::AutoFillPopupMenuClient::itemIsSelected): 47 (WebKit::AutoFillPopupMenuClient::shouldPopOver): 48 (WebKit::AutoFillPopupMenuClient::valueShouldChangeOnHotTrack): 49 (WebKit::AutoFillPopupMenuClient::setAutocompleteMode): 50 (WebKit::AutoFillPopupMenuClient::getTextField): 51 (WebKit::AutoFillPopupMenuClient::getSelectedIndex): 52 (WebKit::AutoFillPopupMenuClient::setSelectedIndex): 53 * src/AutocompletePopupMenuClient.cpp: Removed. 54 * src/AutocompletePopupMenuClient.h: Removed. 55 * src/EditorClientImpl.cpp: 56 (WebKit::EditorClientImpl::textFieldDidEndEditing): 57 (WebKit::EditorClientImpl::doAutofill): 58 (WebKit::EditorClientImpl::onAutocompleteSuggestionAccepted): 59 * src/SuggestionsPopupMenuClient.cpp: Removed. 60 * src/SuggestionsPopupMenuClient.h: Removed. 61 * src/WebFrameImpl.cpp: 62 (WebKit::WebFrameImpl::currentHistoryItem): 63 (WebKit::WebFrameImpl::notifiyPasswordListenerOfAutocomplete): 64 * src/WebFrameImpl.h: 65 * src/WebViewImpl.cpp: 66 (WebKit::): 67 (WebKit::WebViewImpl::WebViewImpl): 68 (WebKit::WebViewImpl::mouseDown): 69 (WebKit::WebViewImpl::mouseUp): 70 (WebKit::WebViewImpl::selectPopupHandleKeyEvent): 71 (WebKit::WebViewImpl::autocompleteHandleKeyEvent): 72 (WebKit::WebViewImpl::hideAutoFillPopup): 73 (WebKit::WebViewImpl::setFocus): 74 (WebKit::WebViewImpl::applyAutoFillSuggestions): 75 (WebKit::WebViewImpl::applyAutocompleteSuggestions): 76 (WebKit::WebViewImpl::hidePopups): 77 (WebKit::WebViewImpl::refreshAutoFillPopup): 78 * src/WebViewImpl.h: 79 (WebKit::WebViewImpl::autoFillPopupDidHide): 80 1 81 2010-07-01 Yury Semikhatsky <yurys@chromium.org> 2 82 -
trunk/WebKit/chromium/WebKit.gyp
r62133 r62272 230 230 'src/ApplicationCacheHostInternal.h', 231 231 'src/AssertMatchingEnums.cpp', 232 'src/AutocompletePopupMenuClient.cpp',233 'src/AutocompletePopupMenuClient.h',234 232 'src/AutoFillPopupMenuClient.cpp', 235 233 'src/AutoFillPopupMenuClient.h', … … 311 309 'src/StorageNamespaceProxy.cpp', 312 310 'src/StorageNamespaceProxy.h', 313 'src/SuggestionsPopupMenuClient.cpp',314 'src/SuggestionsPopupMenuClient.h',315 311 'src/TemporaryGlue.h', 316 312 'src/ToolsAgent.h', -
trunk/WebKit/chromium/public/WebFrame.h
r61975 r62272 489 489 WebPasswordAutocompleteListener*) = 0; 490 490 491 // Dispatches an Autocompletion notification to registered listener if one 492 // exists that is registered against the WebInputElement specified. 493 virtual void notifiyPasswordListenerOfAutocomplete( 494 const WebInputElement&) = 0; 495 491 496 492 497 // Utility ------------------------------------------------------------- -
trunk/WebKit/chromium/public/WebView.h
r62234 r62272 235 235 236 236 237 // AutoFill / Autocomplete---------------------------------------------237 // AutoFill ----------------------------------------------------------- 238 238 239 239 // Notifies the WebView that AutoFill suggestions are available for a node. … … 242 242 const WebVector<WebString>& names, 243 243 const WebVector<WebString>& labels, 244 int defaultSuggestionIndex) = 0;244 int separatorIndex) = 0; 245 245 246 246 // Notifies the WebView that Autocomplete suggestions are available for a 247 247 // node. 248 // DEPRECATED: merging with applyAutoFillSuggestions. 248 249 virtual void applyAutocompleteSuggestions( 249 250 const WebNode&, -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.cpp
r61486 r62272 32 32 #include "AutoFillPopupMenuClient.h" 33 33 34 #include "CSSStyleSelector.h" 35 #include "CSSValueKeywords.h" 36 #include "Chrome.h" 37 #include "FrameView.h" 34 38 #include "HTMLInputElement.h" 39 #include "RenderTheme.h" 35 40 #include "WebNode.h" 36 41 #include "WebString.h" … … 43 48 namespace WebKit { 44 49 50 AutoFillPopupMenuClient::AutoFillPopupMenuClient() 51 : m_separatorIndex(-1) 52 , m_selectedIndex(-1) 53 , m_textField(0) 54 , m_AutocompleteModeEnabled(false) 55 { 56 } 57 58 AutoFillPopupMenuClient::~AutoFillPopupMenuClient() 59 { 60 } 61 45 62 unsigned AutoFillPopupMenuClient::getSuggestionsCount() const 46 63 { … … 76 93 void AutoFillPopupMenuClient::valueChanged(unsigned listIndex, bool fireEvents) 77 94 { 95 // DEPRECATED: Will be removed once AutoFill and Autocomplete merge is 96 // completed. 97 if (m_AutocompleteModeEnabled) { 98 m_textField->setValue(getSuggestion(listIndex)); 99 100 WebViewImpl* webView = getWebView(); 101 if (!webView) 102 return; 103 104 EditorClientImpl* editor = 105 static_cast<EditorClientImpl*>(webView->page()->editorClient()); 106 ASSERT(editor); 107 editor->onAutocompleteSuggestionAccepted( 108 static_cast<HTMLInputElement*>(m_textField.get())); 109 } else { 110 WebViewImpl* webView = getWebView(); 111 if (!webView) 112 return; 113 114 if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex)) 115 --listIndex; 116 117 ASSERT(listIndex < m_names.size()); 118 119 webView->client()->didAcceptAutoFillSuggestion(WebNode(getTextField()), 120 m_names[listIndex], 121 m_labels[listIndex], 122 listIndex); 123 } 124 } 125 126 void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents) 127 { 78 128 WebViewImpl* webView = getWebView(); 79 129 if (!webView) … … 85 135 ASSERT(listIndex < m_names.size()); 86 136 87 webView->client()->did AcceptAutoFillSuggestion(WebNode(getTextField()),137 webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()), 88 138 m_names[listIndex], 89 m_labels[listIndex], 90 listIndex); 91 } 92 93 void AutoFillPopupMenuClient::selectionChanged(unsigned listIndex, bool fireEvents) 139 m_labels[listIndex]); 140 } 141 142 void AutoFillPopupMenuClient::selectionCleared() 143 { 144 // Same effect desired as popupDidHide, so call through. 145 popupDidHide(); 146 } 147 148 String AutoFillPopupMenuClient::itemText(unsigned listIndex) const 149 { 150 return getSuggestion(listIndex); 151 } 152 153 PopupMenuStyle AutoFillPopupMenuClient::itemStyle(unsigned listIndex) const 154 { 155 return *m_style; 156 } 157 158 PopupMenuStyle AutoFillPopupMenuClient::menuStyle() const 159 { 160 return *m_style; 161 } 162 163 int AutoFillPopupMenuClient::clientPaddingLeft() const 164 { 165 // Bug http://crbug.com/7708 seems to indicate the style can be 0. 166 RenderStyle* style = textFieldStyle(); 167 if (!style) 168 return 0; 169 170 return RenderTheme::defaultTheme()->popupInternalPaddingLeft(style); 171 } 172 173 int AutoFillPopupMenuClient::clientPaddingRight() const 174 { 175 // Bug http://crbug.com/7708 seems to indicate the style can be 0. 176 RenderStyle* style = textFieldStyle(); 177 if (!style) 178 return 0; 179 180 return RenderTheme::defaultTheme()->popupInternalPaddingRight(style); 181 } 182 183 void AutoFillPopupMenuClient::popupDidHide() 94 184 { 95 185 WebViewImpl* webView = getWebView(); … … 97 187 return; 98 188 99 if (m_separatorIndex != -1 && listIndex > static_cast<unsigned>(m_separatorIndex)) 100 --listIndex; 101 102 ASSERT(listIndex < m_names.size()); 103 104 webView->client()->didSelectAutoFillSuggestion(WebNode(getTextField()), 105 m_names[listIndex], 106 m_labels[listIndex]); 107 } 108 109 void AutoFillPopupMenuClient::selectionCleared() 110 { 111 WebViewImpl* webView = getWebView(); 112 if (!webView) 113 return; 114 115 webView->suggestionsPopupDidHide(); 189 webView->autoFillPopupDidHide(); 116 190 webView->client()->didClearAutoFillSelection(WebNode(getTextField())); 117 191 } 118 192 119 void AutoFillPopupMenuClient::popupDidHide()120 {121 // FIXME: Refactor this method, as selectionCleared() and popupDidHide()122 // share the exact same functionality.123 WebViewImpl* webView = getWebView();124 if (!webView)125 return;126 127 webView->client()->didClearAutoFillSelection(WebNode(getTextField()));128 }129 130 193 bool AutoFillPopupMenuClient::itemIsSeparator(unsigned listIndex) const 131 194 { 132 195 return (m_separatorIndex != -1 && static_cast<unsigned>(m_separatorIndex) == listIndex); 196 } 197 198 void AutoFillPopupMenuClient::setTextFromItem(unsigned listIndex) 199 { 200 m_textField->setValue(getSuggestion(listIndex)); 201 } 202 203 FontSelector* AutoFillPopupMenuClient::fontSelector() const 204 { 205 return m_textField->document()->styleSelector()->fontSelector(); 206 } 207 208 HostWindow* AutoFillPopupMenuClient::hostWindow() const 209 { 210 return m_textField->document()->view()->hostWindow(); 211 } 212 213 PassRefPtr<Scrollbar> AutoFillPopupMenuClient::createScrollbar( 214 ScrollbarClient* client, 215 ScrollbarOrientation orientation, 216 ScrollbarControlSize size) 217 { 218 return Scrollbar::createNativeScrollbar(client, orientation, size); 133 219 } 134 220 … … 142 228 ASSERT(separatorIndex < static_cast<int>(names.size())); 143 229 230 m_selectedIndex = -1; 231 m_textField = textField; 232 144 233 // The suggestions must be set before initializing the 145 // SuggestionsPopupMenuClient.234 // AutoFillPopupMenuClient. 146 235 setSuggestions(names, labels, separatorIndex); 147 236 148 SuggestionsPopupMenuClient::initialize(textField, -1); 237 FontDescription fontDescription; 238 RenderTheme::defaultTheme()->systemFont(CSSValueWebkitControl, 239 fontDescription); 240 RenderStyle* style = m_textField->computedStyle(); 241 fontDescription.setComputedSize(style->fontDescription().computedSize()); 242 243 Font font(fontDescription, 0, 0); 244 font.update(textField->document()->styleSelector()->fontSelector()); 245 // The direction of text in popup menu is set the same as the direction of 246 // the input element: textField. 247 m_style.set(new PopupMenuStyle(Color::black, Color::white, font, true, 248 Length(WebCore::Fixed), 249 textField->renderer()->style()->direction())); 149 250 } 150 251 … … 170 271 } 171 272 273 WebViewImpl* AutoFillPopupMenuClient::getWebView() const 274 { 275 Frame* frame = m_textField->document()->frame(); 276 if (!frame) 277 return 0; 278 279 Page* page = frame->page(); 280 if (!page) 281 return 0; 282 283 return static_cast<ChromeClientImpl*>(page->chrome()->client())->webView(); 284 } 285 286 RenderStyle* AutoFillPopupMenuClient::textFieldStyle() const 287 { 288 RenderStyle* style = m_textField->computedStyle(); 289 if (!style) { 290 // It seems we can only have a 0 style in a TextField if the 291 // node is detached, in which case we the popup shoud not be 292 // showing. Please report this in http://crbug.com/7708 and 293 // include the page you were visiting. 294 ASSERT_NOT_REACHED(); 295 } 296 return style; 297 } 298 172 299 } // namespace WebKit -
trunk/WebKit/chromium/src/AutoFillPopupMenuClient.h
r60985 r62272 32 32 #define AutoFillPopupMenuClient_h 33 33 34 #include " SuggestionsPopupMenuClient.h"34 #include "PopupMenuClient.h" 35 35 36 36 namespace WebCore { 37 37 class HTMLInputElement; 38 class PopupMenuStyle; 39 class RenderStyle; 38 40 } 39 41 40 42 namespace WebKit { 41 43 class WebString; 44 class WebViewImpl; 42 45 template <typename T> class WebVector; 43 46 44 47 // The AutoFill suggestions popup menu client, used to display name suggestions 45 48 // with right-justified labels. 46 class AutoFillPopupMenuClient : public SuggestionsPopupMenuClient {49 class AutoFillPopupMenuClient : public WebCore::PopupMenuClient { 47 50 public: 48 // SuggestionsPopupMenuClient implementation: 51 AutoFillPopupMenuClient(); 52 virtual ~AutoFillPopupMenuClient(); 53 54 // Returns the number of suggestions available. 49 55 virtual unsigned getSuggestionsCount() const; 56 57 // Returns the suggestion at |listIndex|. 50 58 virtual WebString getSuggestion(unsigned listIndex) const; 59 60 // Removes the suggestion at |listIndex| from the list of suggestions. 51 61 virtual void removeSuggestionAtIndex(unsigned listIndex); 52 62 53 // WebCore::PopupMenuClient implementation:63 // WebCore::PopupMenuClient methods: 54 64 virtual void valueChanged(unsigned listIndex, bool fireEvents = true); 55 virtual void selectionChanged(unsigned listIndex, bool fireEvents = true);65 virtual void selectionChanged(unsigned, bool); 56 66 virtual void selectionCleared(); 67 virtual WebCore::String itemText(unsigned listIndex) const; 68 virtual WebCore::String itemToolTip(unsigned lastIndex) const { return WebCore::String(); } 69 virtual WebCore::String itemAccessibilityText(unsigned lastIndex) const { return WebCore::String(); } 70 virtual bool itemIsEnabled(unsigned listIndex) const { return true; } 71 virtual WebCore::PopupMenuStyle itemStyle(unsigned listIndex) const; 72 virtual WebCore::PopupMenuStyle menuStyle() const; 73 virtual int clientInsetLeft() const { return 0; } 74 virtual int clientInsetRight() const { return 0; } 75 virtual int clientPaddingLeft() const; 76 virtual int clientPaddingRight() const; 77 virtual int listSize() const { return getSuggestionsCount(); } 78 virtual int selectedIndex() const { return m_selectedIndex; } 57 79 virtual void popupDidHide(); 58 80 virtual bool itemIsSeparator(unsigned listIndex) const; 81 virtual bool itemIsLabel(unsigned listIndex) const { return false; } 82 virtual bool itemIsSelected(unsigned listIndex) const { return false; } 83 virtual bool shouldPopOver() const { return false; } 84 virtual bool valueShouldChangeOnHotTrack() const { return false; } 85 virtual void setTextFromItem(unsigned listIndex); 86 virtual WebCore::FontSelector* fontSelector() const; 87 virtual WebCore::HostWindow* hostWindow() const; 88 virtual PassRefPtr<WebCore::Scrollbar> createScrollbar( 89 WebCore::ScrollbarClient* client, 90 WebCore::ScrollbarOrientation orientation, 91 WebCore::ScrollbarControlSize size); 59 92 60 93 void initialize(WebCore::HTMLInputElement*, … … 67 100 int separatorIndex); 68 101 102 // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is 103 // complete. 104 void setAutocompleteMode(bool enabled) { m_AutocompleteModeEnabled = enabled; } 105 69 106 private: 107 WebViewImpl* getWebView() const; 108 WebCore::HTMLInputElement* getTextField() const { return m_textField.get(); } 109 WebCore::RenderStyle* textFieldStyle() const; 110 111 int getSelectedIndex() const { return m_selectedIndex; } 112 void setSelectedIndex(int index) { m_selectedIndex = index; } 113 114 // The names and labels that make up the text of the menu items. 70 115 Vector<WebCore::String> m_names; 71 116 Vector<WebCore::String> m_labels; … … 73 118 // The index of the separator. -1 if there is no separator. 74 119 int m_separatorIndex; 120 121 // The index of the selected item. -1 if there is no selected item. 122 int m_selectedIndex; 123 124 RefPtr<WebCore::HTMLInputElement> m_textField; 125 OwnPtr<WebCore::PopupMenuStyle> m_style; 126 127 // DEPRECATED: Will be removed once Autocomplete and AutoFill merge is 128 // complete. 129 bool m_AutocompleteModeEnabled; 75 130 }; 76 131 -
trunk/WebKit/chromium/src/EditorClientImpl.cpp
r62039 r62272 659 659 660 660 // Hide any showing popup. 661 m_webView->hide SuggestionsPopup();661 m_webView->hideAutoFillPopup(); 662 662 663 663 if (!m_webView->client()) … … 755 755 756 756 if ((!args->autofillOnEmptyValue && value.isEmpty()) || !isCaretAtEnd) { 757 m_webView->hide SuggestionsPopup();757 m_webView->hideAutoFillPopup(); 758 758 return; 759 759 } … … 797 797 return; 798 798 799 WebPasswordAutocompleteListener* listener = webframe->getPasswordListener(textField); 800 // Password listeners need to autocomplete other fields that depend on the 801 // input element with autofill suggestions. 802 if (listener) 803 listener->performInlineAutocomplete(textField->value(), false, false); 799 webframe->notifiyPasswordListenerOfAutocomplete(WebInputElement(textField)); 804 800 } 805 801 -
trunk/WebKit/chromium/src/WebFrameImpl.cpp
r61975 r62272 963 963 { 964 964 // If we are still loading, then we don't want to clobber the current 965 // history item as this could cause us to lose the scroll position and 965 // history item as this could cause us to lose the scroll position and 966 966 // document state. However, it is OK for new navigations. 967 967 if (m_frame->loader()->loadType() == FrameLoadTypeStandard … … 1969 1969 } 1970 1970 1971 void WebFrameImpl::notifiyPasswordListenerOfAutocomplete( 1972 const WebInputElement& inputElement) 1973 { 1974 RefPtr<HTMLInputElement> element = inputElement.operator PassRefPtr<HTMLInputElement>(); 1975 WebPasswordAutocompleteListener* listener = getPasswordListener(element.get()); 1976 // Password listeners need to autocomplete other fields that depend on the 1977 // input element with autofill suggestions. 1978 if (listener) 1979 listener->performInlineAutocomplete(element->value(), false, false); 1980 } 1981 1971 1982 WebPasswordAutocompleteListener* WebFrameImpl::getPasswordListener( 1972 1983 HTMLInputElement* inputElement) -
trunk/WebKit/chromium/src/WebFrameImpl.h
r61975 r62272 169 169 virtual bool registerPasswordListener( 170 170 WebInputElement, WebPasswordAutocompleteListener*); 171 virtual void notifiyPasswordListenerOfAutocomplete( 172 const WebInputElement&); 171 173 172 174 virtual WebString contentAsText(size_t maxChars) const; -
trunk/WebKit/chromium/src/WebViewImpl.cpp
r62234 r62272 33 33 34 34 #include "AutoFillPopupMenuClient.h" 35 #include "AutocompletePopupMenuClient.h"36 35 #include "AXObjectCache.h" 37 36 #include "Chrome.h" … … 155 154 COMPILE_ASSERT_MATCHING_ENUM(DragOperationEvery); 156 155 157 static const PopupContainerSettings suggestionsPopupSettings = {156 static const PopupContainerSettings autoFillPopupSettings = { 158 157 false, // setTextOnIndexChange 159 158 false, // acceptOnAbandon … … 241 240 , m_operationsAllowed(WebDragOperationNone) 242 241 , m_dragOperation(WebDragOperationNone) 243 , m_ suggestionsPopupShowing(false)244 , m_ suggestionsPopupClient(0)245 , m_ suggestionsPopup(0)242 , m_autoFillPopupShowing(false) 243 , m_autoFillPopupClient(0) 244 , m_autoFillPopup(0) 246 245 , m_isTransparent(false) 247 246 , m_tabsToLinks(false) … … 358 357 359 358 // If a text field that has focus is clicked again, we should display the 360 // suggestionspopup.359 // AutoFill popup. 361 360 RefPtr<Node> focusedNode = focusedWebCoreNode(); 362 361 if (focusedNode.get() && toHTMLInputElement(focusedNode.get())) { … … 376 375 377 376 if (clickedNode.get() && clickedNode == focusedWebCoreNode()) { 378 // Focus has not changed, show the suggestionspopup.377 // Focus has not changed, show the AutoFill popup. 379 378 static_cast<EditorClientImpl*>(m_page->editorClient())-> 380 379 showFormAutofillForNode(clickedNode.get()); … … 458 457 HitTestResult hitTestResult = focused->eventHandler()->hitTestResultAtPoint(contentPoint, false, false, ShouldHitTestScrollbars); 459 458 // We don't want to send a paste when middle clicking a scroll bar or a 460 // link (which will navigate later in the code). The main scrollbars 459 // link (which will navigate later in the code). The main scrollbars 461 460 // have to be handled separately. 462 461 if (!hitTestResult.scrollbar() && !hitTestResult.isLiveLink() && focused && !view->scrollbarAtPoint(clickPoint)) { … … 559 558 if (!m_selectPopup) 560 559 return false; 561 560 562 561 return m_selectPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event)); 563 562 } … … 565 564 bool WebViewImpl::autocompleteHandleKeyEvent(const WebKeyboardEvent& event) 566 565 { 567 if (!m_ suggestionsPopupShowing566 if (!m_autoFillPopupShowing 568 567 // Home and End should be left to the text field to process. 569 568 || event.windowsKeyCode == VKEY_HOME … … 573 572 // Pressing delete triggers the removal of the selected suggestion from the DB. 574 573 if (event.windowsKeyCode == VKEY_DELETE 575 && m_ suggestionsPopup->selectedIndex() != -1) {574 && m_autoFillPopup->selectedIndex() != -1) { 576 575 Node* node = focusedWebCoreNode(); 577 576 if (!node || (node->nodeType() != Node::ELEMENT_NODE)) { … … 585 584 } 586 585 587 int selectedIndex = m_ suggestionsPopup->selectedIndex();586 int selectedIndex = m_autoFillPopup->selectedIndex(); 588 587 HTMLInputElement* inputElement = static_cast<HTMLInputElement*>(element); 589 588 WebString name = inputElement->name(); 590 WebString value = m_ suggestionsPopupClient->itemText(selectedIndex);589 WebString value = m_autoFillPopupClient->itemText(selectedIndex); 591 590 m_client->removeAutofillSuggestions(name, value); 592 591 // Update the entries in the currently showing popup to reflect the 593 592 // deletion. 594 m_ suggestionsPopupClient->removeSuggestionAtIndex(selectedIndex);595 refresh SuggestionsPopup();593 m_autoFillPopupClient->removeSuggestionAtIndex(selectedIndex); 594 refreshAutoFillPopup(); 596 595 return false; 597 596 } 598 597 599 if (!m_ suggestionsPopup->isInterestedInEventForKey(event.windowsKeyCode))598 if (!m_autoFillPopup->isInterestedInEventForKey(event.windowsKeyCode)) 600 599 return false; 601 600 602 if (m_ suggestionsPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) {601 if (m_autoFillPopup->handleKeyEvent(PlatformKeyboardEventBuilder(event))) { 603 602 // We need to ignore the next Char event after this otherwise pressing 604 603 // enter when selecting an item in the menu will go to the page. … … 882 881 } 883 882 884 void WebViewImpl::hide SuggestionsPopup()885 { 886 if (m_ suggestionsPopupShowing) {887 m_ suggestionsPopup->hidePopup();888 m_ suggestionsPopupShowing = false;883 void WebViewImpl::hideAutoFillPopup() 884 { 885 if (m_autoFillPopupShowing) { 886 m_autoFillPopup->hidePopup(); 887 m_autoFillPopupShowing = false; 889 888 } 890 889 } … … 1144 1143 m_imeAcceptEvents = true; 1145 1144 } else { 1146 hide SuggestionsPopup();1145 hideAutoFillPopup(); 1147 1146 hideSelectPopup(); 1148 1147 … … 1781 1780 1782 1781 if (names.isEmpty()) { 1783 hide SuggestionsPopup();1782 hideAutoFillPopup(); 1784 1783 return; 1785 1784 } … … 1790 1789 // caret is at the end and that the text has not changed. 1791 1790 if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) { 1792 hide SuggestionsPopup();1791 hideAutoFillPopup(); 1793 1792 return; 1794 1793 } … … 1802 1801 m_autoFillPopupClient.set(new AutoFillPopupMenuClient); 1803 1802 1804 m_autoFillPopupClient->initialize(inputElem, names, labels, 1805 separatorIndex); 1806 1807 if (m_suggestionsPopupClient != m_autoFillPopupClient.get()) { 1808 hideSuggestionsPopup(); 1809 m_suggestionsPopupClient = m_autoFillPopupClient.get(); 1810 } 1803 m_autoFillPopupClient->initialize(inputElem, names, labels, separatorIndex); 1811 1804 1812 1805 if (!m_autoFillPopup.get()) { 1813 m_autoFillPopup = PopupContainer::create(m_ suggestionsPopupClient,1806 m_autoFillPopup = PopupContainer::create(m_autoFillPopupClient.get(), 1814 1807 PopupContainer::Suggestion, 1815 suggestionsPopupSettings); 1816 } 1817 1818 if (m_suggestionsPopup != m_autoFillPopup.get()) 1819 m_suggestionsPopup = m_autoFillPopup.get(); 1820 1821 if (m_suggestionsPopupShowing) { 1808 autoFillPopupSettings); 1809 } 1810 1811 if (m_autoFillPopupShowing) { 1822 1812 m_autoFillPopupClient->setSuggestions(names, labels, separatorIndex); 1823 refresh SuggestionsPopup();1813 refreshAutoFillPopup(); 1824 1814 } else { 1825 m_ suggestionsPopup->show(focusedNode->getRect(),1815 m_autoFillPopup->show(focusedNode->getRect(), 1826 1816 focusedNode->ownerDocument()->view(), 0); 1827 m_suggestionsPopupShowing = true; 1828 } 1829 } 1830 1817 m_autoFillPopupShowing = true; 1818 } 1819 1820 // DEPRECATED: This special mode will go away once AutoFill and Autocomplete 1821 // merge is complete. 1822 if (m_autoFillPopupClient) 1823 m_autoFillPopupClient->setAutocompleteMode(false); 1824 } 1825 1826 // DEPRECATED: replacing with applyAutoFillSuggestions. 1831 1827 void WebViewImpl::applyAutocompleteSuggestions( 1832 1828 const WebNode& node, … … 1834 1830 int defaultSuggestionIndex) 1835 1831 { 1836 ASSERT(defaultSuggestionIndex < static_cast<int>(suggestions.size())); 1837 1838 if (!m_page.get() || suggestions.isEmpty()) { 1839 hideSuggestionsPopup(); 1840 return; 1841 } 1842 1843 RefPtr<Node> focusedNode = focusedWebCoreNode(); 1844 // If the node for which we queried the Autocomplete suggestions is not the 1845 // focused node, then we have nothing to do. FIXME: also check the 1846 // caret is at the end and that the text has not changed. 1847 if (!focusedNode || focusedNode != PassRefPtr<Node>(node)) { 1848 hideSuggestionsPopup(); 1849 return; 1850 } 1851 1852 HTMLInputElement* inputElem = 1853 static_cast<HTMLInputElement*>(focusedNode.get()); 1854 1855 // The first time the Autocomplete is shown we'll create the client and the 1856 // popup. 1857 if (!m_autocompletePopupClient.get()) 1858 m_autocompletePopupClient.set(new AutocompletePopupMenuClient); 1859 1860 m_autocompletePopupClient->initialize(inputElem, suggestions, 1861 defaultSuggestionIndex); 1862 1863 if (m_suggestionsPopupClient != m_autocompletePopupClient.get()) { 1864 hideSuggestionsPopup(); 1865 m_suggestionsPopupClient = m_autocompletePopupClient.get(); 1866 } 1867 1868 if (!m_autocompletePopup.get()) { 1869 m_autocompletePopup = PopupContainer::create(m_suggestionsPopupClient, 1870 PopupContainer::Suggestion, 1871 suggestionsPopupSettings); 1872 } 1873 1874 if (m_suggestionsPopup != m_autocompletePopup.get()) 1875 m_suggestionsPopup = m_autocompletePopup.get(); 1876 1877 if (m_suggestionsPopupShowing) { 1878 m_autocompletePopupClient->setSuggestions(suggestions); 1879 refreshSuggestionsPopup(); 1880 } else { 1881 m_suggestionsPopup->show(focusedNode->getRect(), 1882 focusedNode->ownerDocument()->view(), 0); 1883 m_suggestionsPopupShowing = true; 1884 } 1832 WebVector<WebString> names(suggestions.size()); 1833 WebVector<WebString> labels(suggestions.size()); 1834 1835 for (size_t i = 0; i < suggestions.size(); ++i) { 1836 names[i] = suggestions[i]; 1837 labels[i] = WebString(); 1838 } 1839 1840 applyAutoFillSuggestions(node, names, labels, -1); 1841 if (m_autoFillPopupClient) 1842 m_autoFillPopupClient->setAutocompleteMode(true); 1885 1843 } 1886 1844 … … 1888 1846 { 1889 1847 hideSelectPopup(); 1890 hide SuggestionsPopup();1848 hideAutoFillPopup(); 1891 1849 } 1892 1850 … … 2082 2040 #endif 2083 2041 2084 void WebViewImpl::refresh SuggestionsPopup()2085 { 2086 ASSERT(m_ suggestionsPopupShowing);2042 void WebViewImpl::refreshAutoFillPopup() 2043 { 2044 ASSERT(m_autoFillPopupShowing); 2087 2045 2088 2046 // Hide the popup if it has become empty. 2089 if (!m_ suggestionsPopupClient->listSize()) {2090 hide SuggestionsPopup();2091 return; 2092 } 2093 2094 IntRect oldBounds = m_ suggestionsPopup->boundsRect();2095 m_ suggestionsPopup->refresh();2096 IntRect newBounds = m_ suggestionsPopup->boundsRect();2047 if (!m_autoFillPopupClient->listSize()) { 2048 hideAutoFillPopup(); 2049 return; 2050 } 2051 2052 IntRect oldBounds = m_autoFillPopup->boundsRect(); 2053 m_autoFillPopup->refresh(); 2054 IntRect newBounds = m_autoFillPopup->boundsRect(); 2097 2055 // Let's resize the backing window if necessary. 2098 2056 if (oldBounds != newBounds) { 2099 2057 WebPopupMenuImpl* popupMenu = 2100 static_cast<WebPopupMenuImpl*>(m_suggestionsPopup->client()); 2101 popupMenu->client()->setWindowRect(newBounds); 2058 static_cast<WebPopupMenuImpl*>(m_autoFillPopup->client()); 2059 if (popupMenu) 2060 popupMenu->client()->setWindowRect(newBounds); 2102 2061 } 2103 2062 } -
trunk/WebKit/chromium/src/WebViewImpl.h
r62234 r62272 71 71 class ContextMenuClientImpl; 72 72 class DragScrollTimer; 73 class SuggestionsPopupMenuClient;74 73 class WebAccessibilityObject; 75 74 class WebDevToolsAgentClient; … … 138 137 WebDragOperation operation); 139 138 virtual void dragSourceMovedTo( 140 const WebPoint& clientPoint, 141 const WebPoint& screenPoint, 139 const WebPoint& clientPoint, 140 const WebPoint& screenPoint, 142 141 WebDragOperation operation); 143 142 virtual void dragSourceSystemDragEnded(); … … 171 170 const WebVector<WebString>& labels, 172 171 int separatorIndex); 172 // DEPRECATED: replacing with applyAutoFillSuggestions. 173 173 virtual void applyAutocompleteSuggestions( 174 174 const WebNode&, … … 283 283 const WebPoint& dragImageOffset); 284 284 285 void suggestionsPopupDidHide()286 { 287 m_ suggestionsPopupShowing = false;285 void autoFillPopupDidHide() 286 { 287 m_autoFillPopupShowing = false; 288 288 } 289 289 … … 301 301 void popupClosed(WebCore::PopupContainer* popupContainer); 302 302 303 void hide SuggestionsPopup();303 void hideAutoFillPopup(); 304 304 305 305 // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can … … 344 344 bool autocompleteHandleKeyEvent(const WebKeyboardEvent&); 345 345 346 // Repaints the suggestionspopup. Should be called when the suggestions347 // have changed. Note that this should only be called when the suggestions346 // Repaints the AutoFill popup. Should be called when the suggestions 347 // have changed. Note that this should only be called when the AutoFill 348 348 // popup is showing. 349 void refresh SuggestionsPopup();349 void refreshAutoFillPopup(); 350 350 351 351 // Returns true if the view was scrolled. … … 456 456 WebDragOperation m_dragOperation; 457 457 458 // Whether a suggestions popup is currently showing. 459 bool m_suggestionsPopupShowing; 460 461 // A pointer to the current suggestions popup menu client. This can be 462 // either an AutoFillPopupMenuClient or an AutocompletePopupMenuClient. We 463 // do not own this pointer. 464 SuggestionsPopupMenuClient* m_suggestionsPopupClient; 458 // Whether an AutoFill popup is currently showing. 459 bool m_autoFillPopupShowing; 465 460 466 461 // The AutoFill popup client. 467 462 OwnPtr<AutoFillPopupMenuClient> m_autoFillPopupClient; 468 463 469 // The Autocomplete popup client. 470 OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient; 471 472 // A pointer to the current suggestions popup. We do not own this pointer. 473 WebCore::PopupContainer* m_suggestionsPopup; 464 // The AutoFill popup. 465 RefPtr<WebCore::PopupContainer> m_autoFillPopup; 474 466 475 467 // The popup associated with a select element. 476 468 RefPtr<WebCore::PopupContainer> m_selectPopup; 477 478 // The AutoFill suggestions popup.479 RefPtr<WebCore::PopupContainer> m_autoFillPopup;480 481 // The AutoComplete suggestions popup.482 RefPtr<WebCore::PopupContainer> m_autocompletePopup;483 469 484 470 OwnPtr<WebDevToolsAgentPrivate> m_devToolsAgent;
Note: See TracChangeset
for help on using the changeset viewer.