Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(807)

Side by Side Diff: webkit/glue/webview_impl.cc

Issue 17455: Autofill popup dismissed when page loses focus (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webview_delegate.h ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2007 Google Inc. All Rights Reserved. 2 * Copyright 2007 Google Inc. All Rights Reserved.
3 * 3 *
4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 4 * Portions Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
5 * 5 *
6 * ***** BEGIN LICENSE BLOCK ***** 6 * ***** BEGIN LICENSE BLOCK *****
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
(...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after
936 void WebViewImpl::StopLoading() { 936 void WebViewImpl::StopLoading() {
937 main_frame()->StopLoading(); 937 main_frame()->StopLoading();
938 } 938 }
939 939
940 void WebViewImpl::SetBackForwardListSize(int size) { 940 void WebViewImpl::SetBackForwardListSize(int size) {
941 page_->backForwardList()->setCapacity(size); 941 page_->backForwardList()->setCapacity(size);
942 } 942 }
943 943
944 void WebViewImpl::SetFocus(bool enable) { 944 void WebViewImpl::SetFocus(bool enable) {
945 if (enable) { 945 if (enable) {
946 // Hide the popup menu if any.
947 // TODO(jcampan): bug #3844: we should do that when we lose focus. The
948 // reason we are not doing it is because when clicking on the autofill
949 // popup, the page first loses focus before the mouse click is sent to the
950 // popup. So if we close when the focus is lost, the mouse click does not
951 // do anything.
952 HideAutoCompletePopup();
953
954 // Getting the focused frame will have the side-effect of setting the main 946 // Getting the focused frame will have the side-effect of setting the main
955 // frame as the focused frame if it is not already focused. Otherwise, if 947 // frame as the focused frame if it is not already focused. Otherwise, if
956 // there is already a focused frame, then this does nothing. 948 // there is already a focused frame, then this does nothing.
957 GetFocusedFrame(); 949 GetFocusedFrame();
958 if (page_.get() && page_->mainFrame()) { 950 if (page_.get() && page_->mainFrame()) {
959 Frame* frame = page_->mainFrame(); 951 Frame* frame = page_->mainFrame();
960 if (!frame->selection()->isFocusedAndActive()) { 952 if (!frame->selection()->isFocusedAndActive()) {
961 // No one has focus yet, try to restore focus. 953 // No one has focus yet, try to restore focus.
962 RestoreFocus(); 954 RestoreFocus();
963 page_->focusController()->setActive(true); 955 page_->focusController()->setActive(true);
964 } 956 }
965 Frame* focused_frame = page_->focusController()->focusedOrMainFrame(); 957 Frame* focused_frame = page_->focusController()->focusedOrMainFrame();
966 frame->selection()->setFocused(frame == focused_frame); 958 frame->selection()->setFocused(frame == focused_frame);
967 } 959 }
968 ime_accept_events_ = true; 960 ime_accept_events_ = true;
969 } else { 961 } else {
962 HideAutoCompletePopup();
963
970 // Clear out who last had focus. If someone has focus, the refs will be 964 // Clear out who last had focus. If someone has focus, the refs will be
971 // updated below. 965 // updated below.
972 ReleaseFocusReferences(); 966 ReleaseFocusReferences();
973 967
974 // Clear focus on the currently focused frame if any. 968 // Clear focus on the currently focused frame if any.
975 if (!page_.get()) 969 if (!page_.get())
976 return; 970 return;
977 971
978 Frame* frame = page_->mainFrame(); 972 Frame* frame = page_->mainFrame();
979 if (!frame) 973 if (!frame)
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
1502 } 1496 }
1503 1497
1504 WebCore::HTMLInputElement* input_elem = 1498 WebCore::HTMLInputElement* input_elem =
1505 static_cast<WebCore::HTMLInputElement*>(focused_node.get()); 1499 static_cast<WebCore::HTMLInputElement*>(focused_node.get());
1506 if (!autocomplete_popup_client_.get() || 1500 if (!autocomplete_popup_client_.get() ||
1507 autocomplete_popup_client_->text_field() != input_elem) { 1501 autocomplete_popup_client_->text_field() != input_elem) {
1508 autocomplete_popup_client_ = 1502 autocomplete_popup_client_ =
1509 adoptRef(new AutocompletePopupMenuClient(this, input_elem, 1503 adoptRef(new AutocompletePopupMenuClient(this, input_elem,
1510 suggestions, 1504 suggestions,
1511 default_suggestion_index)); 1505 default_suggestion_index));
1512 // Autocomplete popup does not get focused. We need the page to still 1506 // The autocomplete popup is not activated. We need the page to still
1513 // have focus so the user can keep typing when the popup is showing. 1507 // have focus so the user can keep typing when the popup is showing.
1514 autocomplete_popup_ = 1508 autocomplete_popup_ =
1515 WebCore::PopupContainer::create(autocomplete_popup_client_.get(), 1509 WebCore::PopupContainer::create(autocomplete_popup_client_.get(),
1516 false); 1510 false);
1517 autocomplete_popup_->setTextOnIndexChange(false); 1511 autocomplete_popup_->setTextOnIndexChange(false);
1518 autocomplete_popup_->setAcceptOnAbandon(false); 1512 autocomplete_popup_->setAcceptOnAbandon(false);
1519 autocomplete_popup_->show(focused_node->getRect(), 1513 autocomplete_popup_->show(focused_node->getRect(),
1520 page_->mainFrame()->view(), 0); 1514 page_->mainFrame()->view(), 0);
1521 } else { 1515 } else {
1522 // There is already a popup, reuse it. 1516 // There is already a popup, reuse it.
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 Frame* frame = page_->focusController()->focusedFrame(); 1630 Frame* frame = page_->focusController()->focusedFrame();
1637 if (!frame) 1631 if (!frame)
1638 return NULL; 1632 return NULL;
1639 1633
1640 Document* document = frame->document(); 1634 Document* document = frame->document();
1641 if (!document) 1635 if (!document)
1642 return NULL; 1636 return NULL;
1643 1637
1644 return document->focusedNode(); 1638 return document->focusedNode();
1645 } 1639 }
OLDNEW
« no previous file with comments | « webkit/glue/webview_delegate.h ('k') | webkit/tools/test_shell/test_webview_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698