void ChromeClientImpl::popupOpened(PopupContainer* popupContainer, const IntRect& bounds, bool handleExternally) { if (!m_webView->client()) return; WebWidget* webwidget; if (handleExternally) { WebPopupMenuInfo popupInfo; getPopupMenuInfo(popupContainer, &popupInfo); webwidget = m_webView->client()->createPopupMenu(popupInfo); } else { webwidget = m_webView->client()->createPopupMenu( convertPopupType(popupContainer->popupType())); // We only notify when the WebView has to handle the popup, as when // the popup is handled externally, the fact that a popup is showing is // transparent to the WebView. m_webView->popupOpened(popupContainer); } static_cast<WebPopupMenuImpl*>(webwidget)->Init(popupContainer, bounds); }
void ChromeClientImpl::popupOpened(PopupContainer* popupContainer, const IntRect& bounds, bool handleExternally) { // For Autofill popups, if the popup will not be fully visible, we shouldn't // show it at all. Among other things, this prevents users from being able // to interact via the keyboard with an invisible popup. if (popupContainer->popupType() == PopupContainer::Suggestion) { FrameView* view = m_webView->page()->mainFrame()->view(); IntRect visibleRect = view->visibleContentRect(true /* include scrollbars */); // |bounds| is in screen coordinates, so make sure to convert it to // content coordinates prior to comparing to |visibleRect|. IntRect screenRect = bounds; screenRect.setLocation(view->screenToContents(bounds.location())); if (!visibleRect.contains(screenRect)) { m_webView->hideAutofillPopup(); return; } } if (!m_webView->client()) return; WebWidget* webwidget; if (handleExternally) { WebPopupMenuInfo popupInfo; getPopupMenuInfo(popupContainer, &popupInfo); webwidget = m_webView->client()->createPopupMenu(popupInfo); } else { webwidget = m_webView->client()->createPopupMenu( convertPopupType(popupContainer->popupType())); // We only notify when the WebView has to handle the popup, as when // the popup is handled externally, the fact that a popup is showing is // transparent to the WebView. m_webView->popupOpened(popupContainer); } static_cast<WebPopupMenuImpl*>(webwidget)->init(popupContainer, bounds); }