diff options
Diffstat (limited to 'chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp')
-rw-r--r-- | chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp | 485 |
1 files changed, 154 insertions, 331 deletions
diff --git a/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp b/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp index abd4ff415c3..6f570cc62bf 100644 --- a/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp +++ b/chromium/third_party/WebKit/Source/web/ChromeClientImpl.cpp @@ -30,68 +30,37 @@ */ #include "config.h" -#include "ChromeClientImpl.h" - -#include "ColorChooserPopupUIController.h" -#include "ColorChooserUIController.h" -#include "DateTimeChooserImpl.h" -#include "ExternalDateTimeChooser.h" -#include "ExternalPopupMenu.h" -#include "HTMLNames.h" -#include "PopupContainer.h" -#include "PopupMenuChromium.h" -#include "RuntimeEnabledFeatures.h" -#include "WebAXObject.h" -#include "WebAutofillClient.h" -#include "WebColorChooser.h" -#include "WebColorSuggestion.h" -#include "WebConsoleMessage.h" -#include "WebFileChooserCompletionImpl.h" -#include "WebFrameClient.h" -#include "WebFrameImpl.h" -#include "WebInputElement.h" -#include "WebInputEvent.h" -#include "WebInputEventConversion.h" -#include "WebKit.h" -#include "WebNode.h" -#include "WebPasswordGeneratorClient.h" -#include "WebPlugin.h" -#include "WebPluginContainerImpl.h" -#include "WebPopupMenuImpl.h" -#include "WebPopupMenuInfo.h" -#include "WebPopupType.h" -#include "WebSettings.h" -#include "WebSettingsImpl.h" -#include "WebTextDirection.h" -#include "WebUserGestureIndicator.h" -#include "WebUserGestureToken.h" -#include "WebViewClient.h" -#include "WebViewImpl.h" -#include "WebWindowFeatures.h" +#include "web/ChromeClientImpl.h" + #include "bindings/v8/ScriptController.h" +#include "core/HTMLNames.h" #include "core/accessibility/AXObject.h" #include "core/accessibility/AXObjectCache.h" #include "core/dom/Document.h" #include "core/dom/DocumentFullscreen.h" #include "core/dom/Node.h" +#include "core/events/KeyboardEvent.h" +#include "core/events/MouseEvent.h" +#include "core/events/WheelEvent.h" +#include "core/frame/Console.h" +#include "core/frame/FrameView.h" +#include "core/frame/Settings.h" #include "core/html/HTMLInputElement.h" #include "core/loader/DocumentLoader.h" #include "core/loader/FrameLoadRequest.h" -#include "core/frame/Console.h" -#include "core/frame/FrameView.h" #include "core/page/Page.h" #include "core/page/PagePopupDriver.h" -#include "core/frame/Settings.h" #include "core/page/WindowFeatures.h" #include "core/rendering/HitTestResult.h" #include "core/rendering/RenderWidget.h" -#include "modules/geolocation/Geolocation.h" #include "platform/ColorChooser.h" #include "platform/ColorChooserClient.h" #include "platform/Cursor.h" #include "platform/DateTimeChooser.h" #include "platform/FileChooser.h" +#include "platform/NotImplemented.h" #include "platform/PlatformScreen.h" +#include "platform/RuntimeEnabledFeatures.h" #include "platform/exported/WrappedResourceRequest.h" #include "platform/geometry/FloatRect.h" #include "platform/geometry/IntRect.h" @@ -101,7 +70,38 @@ #include "public/platform/WebCursorInfo.h" #include "public/platform/WebRect.h" #include "public/platform/WebURLRequest.h" +#include "public/web/WebAXObject.h" +#include "public/web/WebAutofillClient.h" +#include "public/web/WebColorChooser.h" +#include "public/web/WebColorSuggestion.h" +#include "public/web/WebConsoleMessage.h" +#include "public/web/WebFrameClient.h" +#include "public/web/WebInputElement.h" +#include "public/web/WebInputEvent.h" +#include "public/web/WebKit.h" +#include "public/web/WebNode.h" +#include "public/web/WebPlugin.h" +#include "public/web/WebPopupMenuInfo.h" +#include "public/web/WebSettings.h" +#include "public/web/WebTextDirection.h" #include "public/web/WebTouchAction.h" +#include "public/web/WebUserGestureIndicator.h" +#include "public/web/WebUserGestureToken.h" +#include "public/web/WebViewClient.h" +#include "public/web/WebWindowFeatures.h" +#include "web/ColorChooserPopupUIController.h" +#include "web/ColorChooserUIController.h" +#include "web/DateTimeChooserImpl.h" +#include "web/ExternalDateTimeChooser.h" +#include "web/ExternalPopupMenu.h" +#include "web/PopupMenuChromium.h" +#include "web/WebFileChooserCompletionImpl.h" +#include "web/WebInputEventConversion.h" +#include "web/WebLocalFrameImpl.h" +#include "web/WebPluginContainerImpl.h" +#include "web/WebPopupMenuImpl.h" +#include "web/WebSettingsImpl.h" +#include "web/WebViewImpl.h" #include "wtf/text/CString.h" #include "wtf/text/StringBuilder.h" #include "wtf/text/StringConcatenate.h" @@ -111,20 +111,6 @@ using namespace WebCore; namespace blink { -// Converts a WebCore::PopupContainerType to a blink::WebPopupType. -static WebPopupType convertPopupType(PopupContainer::PopupType type) -{ - switch (type) { - case PopupContainer::Select: - return WebPopupTypeSelect; - case PopupContainer::Suggestion: - return WebPopupTypeSuggestion; - default: - ASSERT_NOT_REACHED(); - return WebPopupTypeNone; - } -} - // Converts a WebCore::AXObjectCache::AXNotification to a blink::WebAXEvent static WebAXEvent toWebAXEvent(AXObjectCache::AXNotification notification) { @@ -192,24 +178,18 @@ void ChromeClientImpl::focus() m_webView->client()->didFocus(); } -void ChromeClientImpl::unfocus() -{ - if (m_webView->client()) - m_webView->client()->didBlur(); -} - -bool ChromeClientImpl::canTakeFocus(FocusDirection) +bool ChromeClientImpl::canTakeFocus(FocusType) { // For now the browser can always take focus if we're not running layout // tests. return !layoutTestMode(); } -void ChromeClientImpl::takeFocus(FocusDirection direction) +void ChromeClientImpl::takeFocus(FocusType type) { if (!m_webView->client()) return; - if (direction == FocusDirectionBackward) + if (type == FocusTypeBackward) m_webView->client()->focusPrevious(); else m_webView->client()->focusNext(); @@ -232,7 +212,14 @@ void ChromeClientImpl::focusedNodeChanged(Node* node) m_webView->client()->setKeyboardFocusURL(focusURL); } -Page* ChromeClientImpl::createWindow(Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features, +void ChromeClientImpl::focusedFrameChanged(WebCore::LocalFrame* frame) +{ + WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); + if (webframe && webframe->client()) + webframe->client()->frameFocused(); +} + +Page* ChromeClientImpl::createWindow(LocalFrame* frame, const FrameLoadRequest& r, const WindowFeatures& features, NavigationPolicy navigationPolicy, ShouldSendReferrer shouldSendReferrer) { if (!m_webView->client()) @@ -242,10 +229,11 @@ Page* ChromeClientImpl::createWindow(Frame* frame, const FrameLoadRequest& r, co if (policy == WebNavigationPolicyIgnore) policy = getNavigationPolicy(); - DocumentFullscreen::webkitCancelFullScreen(frame->document()); + ASSERT(frame->document()); + DocumentFullscreen::webkitCancelFullScreen(*frame->document()); WebViewImpl* newView = toWebViewImpl( - m_webView->client()->createView(WebFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSendReferrer == NeverSendReferrer)); + m_webView->client()->createView(WebLocalFrameImpl::fromFrame(frame), WrappedResourceRequest(r.resourceRequest()), features, r.frameName(), policy, shouldSendReferrer == NeverSendReferrer)); if (!newView) return 0; return newView->page(); @@ -349,7 +337,7 @@ bool ChromeClientImpl::statusbarVisible() void ChromeClientImpl::setScrollbarsVisible(bool value) { m_scrollbarsVisible = value; - WebFrameImpl* webFrame = toWebFrameImpl(m_webView->mainFrame()); + WebLocalFrameImpl* webFrame = toWebLocalFrameImpl(m_webView->mainFrame()); if (webFrame) webFrame->setCanHaveScrollbars(value); } @@ -376,13 +364,15 @@ void ChromeClientImpl::setResizable(bool value) bool ChromeClientImpl::shouldReportDetailedMessageForSource(const String& url) { - return m_webView->client() && m_webView->client()->shouldReportDetailedMessageForSource(url); + WebLocalFrameImpl* webframe = m_webView->mainFrameImpl(); + return webframe->client() && webframe->client()->shouldReportDetailedMessageForSource(url); } -void ChromeClientImpl::addMessageToConsole(MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) +void ChromeClientImpl::addMessageToConsole(LocalFrame* localFrame, MessageSource source, MessageLevel level, const String& message, unsigned lineNumber, const String& sourceID, const String& stackTrace) { - if (m_webView->client()) { - m_webView->client()->didAddMessageToConsole( + WebLocalFrameImpl* frame = WebLocalFrameImpl::fromFrame(localFrame); + if (frame && frame->client()) { + frame->client()->didAddMessageToConsole( WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message), sourceID, lineNumber, @@ -395,19 +385,24 @@ bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() return !!m_webView->client(); } -bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame) +bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, LocalFrame* frame) { - if (m_webView->client()) { - return m_webView->client()->runModalBeforeUnloadDialog( - WebFrameImpl::fromFrame(frame), message); - } + WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); + + bool isReload = false; + WebDataSource* ds = webframe->provisionalDataSource(); + if (ds) + isReload = (ds->navigationType() == blink::WebNavigationTypeReload); + + if (webframe->client()) + return webframe->client()->runModalBeforeUnloadDialog(isReload, message); return false; } void ChromeClientImpl::closeWindowSoon() { // Make sure this Page can no longer be found by JS. - m_webView->page()->clearPageGroup(); + Page::ordinaryPages().remove(m_webView->page()); // Make sure that all loading is stopped. Ensures that JS stops executing! m_webView->mainFrame()->stopLoading(); @@ -416,42 +411,42 @@ void ChromeClientImpl::closeWindowSoon() m_webView->client()->closeWidgetSoon(); } -// Although a Frame is passed in, we don't actually use it, since we +// Although a LocalFrame is passed in, we don't actually use it, since we // already know our own m_webView. -void ChromeClientImpl::runJavaScriptAlert(Frame* frame, const String& message) +void ChromeClientImpl::runJavaScriptAlert(LocalFrame* frame, const String& message) { - if (m_webView->client()) { + WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); + if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); - m_webView->client()->runModalAlertDialog( - WebFrameImpl::fromFrame(frame), message); + webframe->client()->runModalAlertDialog(message); } } // See comments for runJavaScriptAlert(). -bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message) +bool ChromeClientImpl::runJavaScriptConfirm(LocalFrame* frame, const String& message) { - if (m_webView->client()) { + WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); + if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); - return m_webView->client()->runModalConfirmDialog( - WebFrameImpl::fromFrame(frame), message); + return webframe->client()->runModalConfirmDialog(message); } return false; } // See comments for runJavaScriptAlert(). -bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame, +bool ChromeClientImpl::runJavaScriptPrompt(LocalFrame* frame, const String& message, const String& defaultValue, String& result) { - if (m_webView->client()) { + WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); + if (webframe->client()) { if (WebUserGestureIndicator::isProcessingUserGesture()) WebUserGestureIndicator::currentUserGestureToken().setJavascriptPrompt(); WebString actualValue; - bool ok = m_webView->client()->runModalPromptDialog( - WebFrameImpl::fromFrame(frame), + bool ok = webframe->client()->runModalPromptDialog( message, defaultValue, &actualValue); @@ -498,11 +493,6 @@ void ChromeClientImpl::scheduleAnimation() m_webView->scheduleAnimation(); } -bool ChromeClientImpl::isCompositorFramePending() const -{ - return m_webView->client()->isCompositorFramePending(); -} - void ChromeClientImpl::scroll( const IntSize& scrollDelta, const IntRect& scrollRect, const IntRect& clipRect) @@ -513,20 +503,9 @@ void ChromeClientImpl::scroll( int dy = scrollDelta.height(); m_webView->client()->didScrollRect(dx, dy, intersection(scrollRect, clipRect)); } - } else - m_webView->scrollRootLayerRect(scrollDelta, clipRect); -} - -IntPoint ChromeClientImpl::screenToRootView(const IntPoint& point) const -{ - IntPoint windowPoint(point); - - if (m_webView->client()) { - WebRect windowRect = m_webView->client()->windowRect(); - windowPoint.move(-windowRect.x, -windowRect.y); + } else { + m_webView->scrollRootLayer(); } - - return windowPoint; } IntRect ChromeClientImpl::rootViewToScreen(const IntRect& rect) const @@ -546,14 +525,14 @@ WebScreenInfo ChromeClientImpl::screenInfo() const return m_webView->client() ? m_webView->client()->screenInfo() : WebScreenInfo(); } -void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const +void ChromeClientImpl::contentsSizeChanged(LocalFrame* frame, const IntSize& size) const { m_webView->didChangeContentsSize(); - WebFrameImpl* webframe = WebFrameImpl::fromFrame(frame); + WebLocalFrameImpl* webframe = WebLocalFrameImpl::fromFrame(frame); webframe->didChangeContentsSize(size); - if (webframe->client()) - webframe->client()->didChangeContentsSize(webframe, size); + + frame->loader().restoreScrollPositionAndViewState(); } void ChromeClientImpl::deviceOrPageScaleFactorChanged() const @@ -561,9 +540,9 @@ void ChromeClientImpl::deviceOrPageScaleFactorChanged() const m_webView->deviceOrPageScaleFactorChanged(); } -void ChromeClientImpl::layoutUpdated(Frame* frame) const +void ChromeClientImpl::layoutUpdated(LocalFrame* frame) const { - m_webView->layoutUpdated(WebFrameImpl::fromFrame(frame)); + m_webView->layoutUpdated(WebLocalFrameImpl::fromFrame(frame)); } void ChromeClientImpl::mouseDidMoveOverElement( @@ -574,16 +553,16 @@ void ChromeClientImpl::mouseDidMoveOverElement( WebURL url; // Find out if the mouse is over a link, and if so, let our UI know... - if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) + if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) { url = result.absoluteLinkURL(); - else if (result.innerNonSharedNode() - && (result.innerNonSharedNode()->hasTagName(HTMLNames::objectTag) - || result.innerNonSharedNode()->hasTagName(HTMLNames::embedTag))) { + } else if (result.innerNonSharedNode() + && (isHTMLObjectElement(*result.innerNonSharedNode()) + || isHTMLEmbedElement(*result.innerNonSharedNode()))) { RenderObject* object = result.innerNonSharedNode()->renderer(); if (object && object->isWidget()) { Widget* widget = toRenderWidget(object)->widget(); if (widget && widget->isPluginContainer()) { - WebPluginContainerImpl* plugin = toPluginContainerImpl(widget); + WebPluginContainerImpl* plugin = toWebPluginContainerImpl(widget); url = plugin->plugin()->linkAtPosition(result.roundedPointInInnerNodeFrame()); } } @@ -608,24 +587,24 @@ void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportDescrip m_webView->updatePageDefinedViewportConstraints(description); } -void ChromeClientImpl::print(Frame* frame) +void ChromeClientImpl::print(LocalFrame* frame) { if (m_webView->client()) - m_webView->client()->printPage(WebFrameImpl::fromFrame(frame)); + m_webView->client()->printPage(WebLocalFrameImpl::fromFrame(frame)); } -PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(ColorChooserClient* chooserClient, const Color&) +PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(LocalFrame* frame, ColorChooserClient* chooserClient, const Color&) { OwnPtr<ColorChooserUIController> controller; if (RuntimeEnabledFeatures::pagePopupEnabled()) - controller = adoptPtr(new ColorChooserPopupUIController(this, chooserClient)); + controller = adoptPtr(new ColorChooserPopupUIController(frame, this, chooserClient)); else - controller = adoptPtr(new ColorChooserUIController(this, chooserClient)); + controller = adoptPtr(new ColorChooserUIController(frame, chooserClient)); controller->openUI(); return controller.release(); } -PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChooserClient* pickerClient, const DateTimeChooserParameters& parameters) +PassRefPtrWillBeRawPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChooserClient* pickerClient, const DateTimeChooserParameters& parameters) { #if ENABLE(INPUT_MULTIPLE_FIELDS_UI) return DateTimeChooserImpl::create(this, pickerClient, parameters); @@ -634,7 +613,7 @@ PassRefPtr<DateTimeChooser> ChromeClientImpl::openDateTimeChooser(DateTimeChoose #endif } -void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser) +void ChromeClientImpl::runOpenPanel(LocalFrame* frame, PassRefPtr<FileChooser> fileChooser) { WebViewClient* client = m_webView->client(); if (!client) @@ -676,50 +655,6 @@ void ChromeClientImpl::enumerateChosenDirectory(FileChooser* fileChooser) chooserCompletion->didChooseFile(WebVector<WebString>()); } -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(ScrollableArea::IncludeScrollbars); - // |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); - } - toWebPopupMenuImpl(webwidget)->initialize(popupContainer, bounds); -} - -void ChromeClientImpl::popupClosed(WebCore::PopupContainer* popupContainer) -{ - m_webView->popupClosed(popupContainer); -} - void ChromeClientImpl::setCursor(const WebCore::Cursor& cursor) { setCursor(WebCursorInfo(cursor)); @@ -742,63 +677,13 @@ void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor) setCursor(cursor); } -void ChromeClientImpl::formStateDidChange(const Node* node) -{ - // The current history item is not updated yet. That happens lazily when - // WebFrame::currentHistoryItem is requested. - WebFrameImpl* webframe = WebFrameImpl::fromFrame(node->document().frame()); - if (webframe->client()) - webframe->client()->didUpdateCurrentHistoryItem(webframe); -} - -void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer, - WebPopupMenuInfo* info) -{ - const Vector<PopupItem*>& inputItems = popupContainer->popupData(); - - WebVector<WebMenuItemInfo> outputItems(inputItems.size()); - - for (size_t i = 0; i < inputItems.size(); ++i) { - const PopupItem& inputItem = *inputItems[i]; - WebMenuItemInfo& outputItem = outputItems[i]; - - outputItem.label = inputItem.label; - outputItem.enabled = inputItem.enabled; - if (inputItem.textDirection == WebCore::RTL) - outputItem.textDirection = WebTextDirectionRightToLeft; - else - outputItem.textDirection = WebTextDirectionLeftToRight; - outputItem.hasTextDirectionOverride = inputItem.hasTextDirectionOverride; - - switch (inputItem.type) { - case PopupItem::TypeOption: - outputItem.type = WebMenuItemInfo::Option; - break; - case PopupItem::TypeGroup: - outputItem.type = WebMenuItemInfo::Group; - break; - case PopupItem::TypeSeparator: - outputItem.type = WebMenuItemInfo::Separator; - break; - default: - ASSERT_NOT_REACHED(); - } - } - - info->itemHeight = popupContainer->menuItemHeight(); - info->itemFontSize = popupContainer->menuItemFontSize(); - info->selectedIndex = popupContainer->selectedIndex(); - info->items.swap(outputItems); - info->rightAligned = popupContainer->menuStyle().textDirection() == RTL; -} - void ChromeClientImpl::postAccessibilityNotification(AXObject* obj, AXObjectCache::AXNotification notification) { // Alert assistive technology about the accessibility object notification. if (!obj) return; - - m_webView->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification)); + if (m_webView->client()) + m_webView->client()->postAccessibilityEvent(WebAXObject(obj), toWebAXEvent(notification)); } String ChromeClientImpl::acceptLanguages() @@ -808,8 +693,8 @@ String ChromeClientImpl::acceptLanguages() bool ChromeClientImpl::paintCustomOverhangArea(GraphicsContext* context, const IntRect& horizontalOverhangArea, const IntRect& verticalOverhangArea, const IntRect& dirtyRect) { - Frame* frame = m_webView->mainFrameImpl()->frame(); - WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame); + LocalFrame* frame = m_webView->mainFrameImpl()->frame(); + WebPluginContainerImpl* pluginContainer = WebLocalFrameImpl::pluginContainerFromFrame(frame); if (pluginContainer) return pluginContainer->paintCustomOverhangArea(context, horizontalOverhangArea, verticalOverhangArea, dirtyRect); return false; @@ -820,39 +705,9 @@ GraphicsLayerFactory* ChromeClientImpl::graphicsLayerFactory() const return m_webView->graphicsLayerFactory(); } -void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer) +void ChromeClientImpl::attachRootGraphicsLayer(GraphicsLayer* rootLayer) { - m_webView->setRootGraphicsLayer(graphicsLayer); -} - -void ChromeClientImpl::scheduleCompositingLayerFlush() -{ - m_webView->scheduleCompositingLayerSync(); -} - -ChromeClient::CompositingTriggerFlags ChromeClientImpl::allowedCompositingTriggers() const -{ - if (!m_webView->allowsAcceleratedCompositing()) - return 0; - - CompositingTriggerFlags flags = 0; - Settings& settings = m_webView->page()->settings(); - if (settings.acceleratedCompositingFor3DTransformsEnabled()) - flags |= ThreeDTransformTrigger; - if (settings.acceleratedCompositingForVideoEnabled()) - flags |= VideoTrigger; - if (settings.acceleratedCompositingForPluginsEnabled()) - flags |= PluginTrigger; - if (settings.acceleratedCompositingForAnimationEnabled()) - flags |= AnimationTrigger; - if (settings.acceleratedCompositingForCanvasEnabled()) - flags |= CanvasTrigger; - if (settings.acceleratedCompositingForScrollableFramesEnabled()) - flags |= ScrollableInnerFrameTrigger; - if (settings.acceleratedCompositingForFiltersEnabled()) - flags |= FilterTrigger; - - return flags; + m_webView->setRootGraphicsLayer(rootLayer); } void ChromeClientImpl::enterFullScreenForElement(Element* element) @@ -870,10 +725,10 @@ bool ChromeClientImpl::hasOpenedPopup() const return m_webView->hasOpenedPopup(); } -PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(Frame& frame, PopupMenuClient* client) const +PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(LocalFrame& frame, PopupMenuClient* client) const { if (WebViewImpl::useExternalPopupMenus()) - return adoptRef(new ExternalPopupMenu(frame, client, m_webView->client())); + return adoptRef(new ExternalPopupMenu(frame, client, *m_webView)); return adoptRef(new PopupMenuChromium(frame, client)); } @@ -901,18 +756,6 @@ void ChromeClientImpl::resetPagePopupDriver() m_pagePopupDriver = m_webView; } -bool ChromeClientImpl::isPasswordGenerationEnabled() const -{ - return m_webView->passwordGeneratorClient(); -} - -void ChromeClientImpl::openPasswordGenerator(HTMLInputElement* input) -{ - ASSERT(isPasswordGenerationEnabled()); - WebInputElement webInput(input); - m_webView->passwordGeneratorClient()->openPasswordGenerator(webInput); -} - bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType& dialogType, const String& dialogMessage, Document::PageDismissalType dismissalType) const { const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"}; @@ -931,27 +774,6 @@ bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType& return false; } -bool ChromeClientImpl::shouldRubberBandInDirection(WebCore::ScrollDirection direction) const -{ - ASSERT(direction != WebCore::ScrollUp && direction != WebCore::ScrollDown); - - if (!m_webView->client()) - return false; - - if (direction == WebCore::ScrollLeft) - return !m_webView->client()->historyBackListCount(); - if (direction == WebCore::ScrollRight) - return !m_webView->client()->historyForwardListCount(); - - ASSERT_NOT_REACHED(); - return true; -} - -void ChromeClientImpl::numWheelEventHandlersChanged(unsigned numberOfWheelHandlers) -{ - m_webView->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); -} - void ChromeClientImpl::needTouchEvents(bool needsTouchEvents) { m_webView->hasTouchEventHandlers(needsTouchEvents); @@ -975,11 +797,6 @@ void ChromeClientImpl::requestPointerUnlock() return m_webView->requestPointerUnlock(); } -bool ChromeClientImpl::isPointerLocked() -{ - return m_webView->isPointerLocked(); -} - void ChromeClientImpl::annotatedRegionsChanged() { WebViewClient* client = m_webView->client(); @@ -987,15 +804,10 @@ void ChromeClientImpl::annotatedRegionsChanged() client->draggableRegionsChanged(); } -void ChromeClientImpl::didAssociateFormControls(const Vector<RefPtr<Element> >& elements) +void ChromeClientImpl::didAssociateFormControls(const WillBeHeapVector<RefPtrWillBeMember<Element> >& elements) { - if (!m_webView->autofillClient()) - return; - WebVector<WebNode> elementVector(static_cast<size_t>(elements.size())); - size_t elementsCount = elements.size(); - for (size_t i = 0; i < elementsCount; ++i) - elementVector[i] = elements[i]; - m_webView->autofillClient()->didAssociateFormControls(elementVector); + if (m_webView->autofillClient()) + m_webView->autofillClient()->didAssociateFormControls(elements); } void ChromeClientImpl::didCancelCompositionOnSelectionChange() @@ -1010,6 +822,12 @@ void ChromeClientImpl::willSetInputMethodState() m_webView->client()->resetInputMethod(); } +void ChromeClientImpl::didUpdateTextOfFocusedElementByNonUserInput() +{ + if (m_webView->client()) + m_webView->client()->didUpdateTextOfFocusedElementByNonUserInput(); +} + void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputElement, KeyboardEvent& event) { if (!m_webView->autofillClient()) @@ -1017,23 +835,45 @@ void ChromeClientImpl::handleKeyboardEventOnTextField(HTMLInputElement& inputEle m_webView->autofillClient()->textFieldDidReceiveKeyDown(WebInputElement(&inputElement), WebKeyboardEventBuilder(event)); } -void ChromeClientImpl::didChangeValueInTextField(HTMLInputElement& inputElement) +// FIXME: Remove this code once we have input routing in the browser +// process. See http://crbug.com/339659. +void ChromeClientImpl::forwardInputEvent( + WebCore::Frame* frame, WebCore::Event* event) +{ + WebLocalFrameImpl* webFrame = WebLocalFrameImpl::fromFrame(toLocalFrameTemporary(frame)); + + // This is only called when we have out-of-process iframes, which + // need to forward input events across processes. + // FIXME: Add a check for out-of-process iframes enabled. + if (event->isKeyboardEvent()) { + WebKeyboardEventBuilder webEvent(*static_cast<WebCore::KeyboardEvent*>(event)); + webFrame->client()->forwardInputEvent(&webEvent); + } else if (event->isMouseEvent()) { + WebMouseEventBuilder webEvent(webFrame->frameView(), frame->ownerRenderer(), *static_cast<WebCore::MouseEvent*>(event)); + // Internal Blink events should not be forwarded. + if (webEvent.type == WebInputEvent::Undefined) + return; + + webFrame->client()->forwardInputEvent(&webEvent); + } else if (event->isWheelEvent()) { + WebMouseWheelEventBuilder webEvent(webFrame->frameView(), frame->ownerRenderer(), *static_cast<WebCore::WheelEvent*>(event)); + if (webEvent.type == WebInputEvent::Undefined) + return; + webFrame->client()->forwardInputEvent(&webEvent); + } +} + +void ChromeClientImpl::didChangeValueInTextField(HTMLFormControlElement& element) { if (!m_webView->autofillClient()) return; - m_webView->autofillClient()->textFieldDidChange(WebInputElement(&inputElement)); + m_webView->autofillClient()->textFieldDidChange(WebFormControlElement(&element)); } void ChromeClientImpl::didEndEditingOnTextField(HTMLInputElement& inputElement) { if (m_webView->autofillClient()) m_webView->autofillClient()->textFieldDidEndEditing(WebInputElement(&inputElement)); - - // Notification that focus was lost. Be careful with this, it's also sent - // when the page is being closed. - - // Hide any showing popup. - m_webView->hideAutofillPopup(); } void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input) @@ -1042,21 +882,4 @@ void ChromeClientImpl::openTextDataListChooser(HTMLInputElement& input) m_webView->autofillClient()->openTextDataListChooser(WebInputElement(&input)); } -#if ENABLE(NAVIGATOR_CONTENT_UTILS) -PassOwnPtr<NavigatorContentUtilsClientImpl> NavigatorContentUtilsClientImpl::create(WebViewImpl* webView) -{ - return adoptPtr(new NavigatorContentUtilsClientImpl(webView)); -} - -NavigatorContentUtilsClientImpl::NavigatorContentUtilsClientImpl(WebViewImpl* webView) - : m_webView(webView) -{ -} - -void NavigatorContentUtilsClientImpl::registerProtocolHandler(const String& scheme, const String& baseURL, const String& url, const String& title) -{ - m_webView->client()->registerProtocolHandler(scheme, baseURL, url, title); -} -#endif - } // namespace blink |