Chromium Code Reviews| Index: webkit/api/src/ChromeClientImpl.cpp |
| =================================================================== |
| --- webkit/api/src/ChromeClientImpl.cpp (revision 30163) |
| +++ webkit/api/src/ChromeClientImpl.cpp (working copy) |
| @@ -1,8 +1,35 @@ |
| -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| -// Use of this source code is governed by a BSD-style license that can be |
| -// found in the LICENSE file. |
| +/* |
| + * Copyright (C) 2009 Google Inc. All rights reserved. |
| + * |
| + * Redistribution and use in source and binary forms, with or without |
| + * modification, are permitted provided that the following conditions are |
| + * met: |
| + * |
| + * * Redistributions of source code must retain the above copyright |
| + * notice, this list of conditions and the following disclaimer. |
| + * * Redistributions in binary form must reproduce the above |
| + * copyright notice, this list of conditions and the following disclaimer |
| + * in the documentation and/or other materials provided with the |
| + * distribution. |
| + * * Neither the name of Google Inc. nor the names of its |
| + * contributors may be used to endorse or promote products derived from |
| + * this software without specific prior written permission. |
| + * |
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| + */ |
| #include "config.h" |
| +#include "ChromeClientImpl.h" |
| #include "AccessibilityObject.h" |
| #include "AXObjectCache.h" |
| @@ -19,614 +46,617 @@ |
| #include "HitTestResult.h" |
| #include "IntRect.h" |
| #include "Node.h" |
| +#include "NotificationPresenterImpl.h" |
| #include "Page.h" |
| #include "PopupMenuChromium.h" |
| #include "ScriptController.h" |
| -#include "WindowFeatures.h" |
| #if USE(V8) |
| #include "V8Proxy.h" |
| #endif |
| -#undef LOG |
| +#include "WebAccessibilityObject.h" |
| +#include "WebConsoleMessage.h" |
| +#include "WebCursorInfo.h" |
| +#include "WebFileChooserCompletion.h" |
| +#include "WebFrameClient.h" |
| +#include "WebInputEvent.h" |
| +#include "WebKit.h" |
| +#include "WebPopupMenuInfo.h" |
| +#include "WebRect.h" |
| +#include "WebTextDirection.h" |
| +#include "WebURLRequest.h" |
| +#include "WebViewClient.h" |
| +#include "WebFileChooserCompletionImpl.h" |
| +#include "WebPopupMenuImpl.h" |
| +#include "WindowFeatures.h" |
| +#include "WrappedResourceRequest.h" |
| -#include "webkit/api/public/WebAccessibilityObject.h" |
| -#include "webkit/api/public/WebConsoleMessage.h" |
| -#include "webkit/api/public/WebCursorInfo.h" |
| -#include "webkit/api/public/WebFileChooserCompletion.h" |
| -#include "webkit/api/public/WebFrameClient.h" |
| -#include "webkit/api/public/WebInputEvent.h" |
| -#include "webkit/api/public/WebKit.h" |
| -#include "webkit/api/public/WebPopupMenuInfo.h" |
| -#include "webkit/api/public/WebRect.h" |
| -#include "webkit/api/public/WebTextDirection.h" |
| -#include "webkit/api/public/WebURLRequest.h" |
| -#include "webkit/api/public/WebViewClient.h" |
| -#include "webkit/api/src/NotificationPresenterImpl.h" |
| -#include "webkit/api/src/WebFileChooserCompletionImpl.h" |
| -#include "webkit/api/src/WrappedResourceRequest.h" |
| -#include "webkit/glue/chrome_client_impl.h" |
| -#include "webkit/glue/glue_util.h" |
| +// FIXME: Remove these once they move out of glue/. |
| #include "webkit/glue/webframe_impl.h" |
| -#include "webkit/glue/webpopupmenu_impl.h" |
| #include "webkit/glue/webview_impl.h" |
| -using WebCore::PopupContainer; |
| -using WebCore::PopupItem; |
| +using namespace WebCore; |
| -using WebKit::WebAccessibilityObject; |
| -using WebKit::WebConsoleMessage; |
| -using WebKit::WebCursorInfo; |
| -using WebKit::WebFileChooserCompletionImpl; |
| -using WebKit::WebInputEvent; |
| -using WebKit::WebMouseEvent; |
| -using WebKit::WebNavigationPolicy; |
| -using WebKit::WebPopupMenuInfo; |
| -using WebKit::WebRect; |
| -using WebKit::WebString; |
| -using WebKit::WebTextDirection; |
| -using WebKit::WebURL; |
| -using WebKit::WebURLRequest; |
| -using WebKit::WebVector; |
| -using WebKit::WebViewClient; |
| -using WebKit::WebWidget; |
| -using WebKit::WrappedResourceRequest; |
| +namespace WebKit { |
| -using webkit_glue::AccessibilityObjectToWebAccessibilityObject; |
| - |
| -ChromeClientImpl::ChromeClientImpl(WebViewImpl* webview) |
| - : webview_(webview), |
| - toolbars_visible_(true), |
| - statusbar_visible_(true), |
| - scrollbars_visible_(true), |
| - menubar_visible_(true), |
| - resizable_(true), |
| - ignore_next_set_cursor_(false) { |
| +ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView) |
| + : m_webView(webView) |
| + , m_toolbarsVisible(true) |
| + , m_statusbarVisible(true) |
| + , m_scrollbarsVisible(true) |
| + , m_menubarVisible(true) |
| + , m_resizable(true) |
| + , m_ignoreNextSetCursor(false) |
| +{ |
| } |
| -ChromeClientImpl::~ChromeClientImpl() { |
| +ChromeClientImpl::~ChromeClientImpl() |
| +{ |
| } |
| -void ChromeClientImpl::chromeDestroyed() { |
| - // Our lifetime is bound to the WebViewImpl. |
| +void ChromeClientImpl::chromeDestroyed() |
| +{ |
| + // Our lifetime is bound to the WebViewImpl. |
| } |
| -void ChromeClientImpl::setWindowRect(const WebCore::FloatRect& r) { |
| - if (webview_->client()) { |
| - webview_->client()->setWindowRect( |
| - webkit_glue::IntRectToWebRect(WebCore::IntRect(r))); |
| - } |
| +void ChromeClientImpl::setWindowRect(const FloatRect& r) |
| +{ |
| + if (m_webView->client()) |
| + m_webView->client()->setWindowRect(IntRect(r)); |
| } |
| -WebCore::FloatRect ChromeClientImpl::windowRect() { |
| - WebRect rect; |
| - if (webview_->client()) { |
| - rect = webview_->client()->rootWindowRect(); |
| - } else { |
| - // These numbers will be fairly wrong. The window's x/y coordinates will |
| - // be the top left corner of the screen and the size will be the content |
| - // size instead of the window size. |
| - rect.width = webview_->size().width; |
| - rect.height = webview_->size().height; |
| - } |
| - return WebCore::FloatRect(webkit_glue::WebRectToIntRect(rect)); |
| +FloatRect ChromeClientImpl::windowRect() |
| +{ |
| + WebRect rect; |
| + if (m_webView->client()) |
| + rect = m_webView->client()->rootWindowRect(); |
| + else { |
| + // These numbers will be fairly wrong. The window's x/y coordinates will |
| + // be the top left corner of the screen and the size will be the content |
| + // size instead of the window size. |
| + rect.width = m_webView->size().width; |
| + rect.height = m_webView->size().height; |
| + } |
| + return FloatRect(rect); |
| } |
| -WebCore::FloatRect ChromeClientImpl::pageRect() { |
| - // We hide the details of the window's border thickness from the web page by |
| - // simple re-using the window position here. So, from the point-of-view of |
| - // the web page, the window has no border. |
| - return windowRect(); |
| +FloatRect ChromeClientImpl::pageRect() |
| +{ |
| + // We hide the details of the window's border thickness from the web page by |
| + // simple re-using the window position here. So, from the point-of-view of |
| + // the web page, the window has no border. |
| + return windowRect(); |
| } |
| -float ChromeClientImpl::scaleFactor() { |
| - // This is supposed to return the scale factor of the web page. It looks like |
| - // the implementor of the graphics layer is responsible for doing most of the |
| - // operations associated with scaling. However, this value is used ins some |
| - // cases by WebCore. For example, this is used as a scaling factor in canvas |
| - // so that things drawn in it are scaled just like the web page is. |
| - // |
| - // We don't currently implement scaling, so just return 1.0 (no scaling). |
| - return 1.0; |
| +float ChromeClientImpl::scaleFactor() |
| +{ |
| + // This is supposed to return the scale factor of the web page. It looks like |
| + // the implementor of the graphics layer is responsible for doing most of the |
| + // operations associated with scaling. However, this value is used ins some |
| + // cases by WebCore. For example, this is used as a scaling factor in canvas |
| + // so that things drawn in it are scaled just like the web page is. |
| + // |
| + // We don't currently implement scaling, so just return 1.0 (no scaling). |
| + return 1.0; |
| } |
| -void ChromeClientImpl::focus() { |
| - if (!webview_->client()) |
| - return; |
| +void ChromeClientImpl::focus() |
| +{ |
| + if (!m_webView->client()) |
| + return; |
| - webview_->client()->didFocus(); |
| + m_webView->client()->didFocus(); |
| - // If accessibility is enabled, we should notify assistive technology that |
| - // the active AccessibilityObject changed. |
| - const WebCore::Frame* frame = webview_->GetFocusedWebCoreFrame(); |
| - if (!frame) |
| - return; |
| + // If accessibility is enabled, we should notify assistive technology that |
| + // the active AccessibilityObject changed. |
| + const Frame* frame = m_webView->GetFocusedWebCoreFrame(); |
| + if (!frame) |
| + return; |
| - WebCore::Document* doc = frame->document(); |
| + Document* doc = frame->document(); |
| - if (doc && doc->axObjectCache()->accessibilityEnabled()) { |
| - WebCore::Node* focused_node = webview_->GetFocusedNode(); |
| + if (doc && doc->axObjectCache()->accessibilityEnabled()) { |
| + Node* focusedNode = m_webView->GetFocusedNode(); |
| - if (!focused_node) { |
| - // Could not retrieve focused Node. |
| - return; |
| - } |
| + if (!focusedNode) { |
| + // Could not retrieve focused Node. |
| + return; |
| + } |
| - // Retrieve the focused AccessibilityObject. |
| - WebCore::AccessibilityObject* focused_acc_obj = |
| - doc->axObjectCache()->getOrCreate(focused_node->renderer()); |
| + // Retrieve the focused AccessibilityObject. |
| + AccessibilityObject* focusedAccObj = |
| + doc->axObjectCache()->getOrCreate(focusedNode->renderer()); |
| - // Alert assistive technology that focus changed. |
| - if (focused_acc_obj) { |
| - webview_->client()->focusAccessibilityObject( |
| - AccessibilityObjectToWebAccessibilityObject(focused_acc_obj)); |
| + // Alert assistive technology that focus changed. |
| + if (focusedAccObj) |
| + m_webView->client()->focusAccessibilityObject(WebAccessibilityObject(focusedAccObj)); |
| } |
| - } |
| } |
| -void ChromeClientImpl::unfocus() { |
| - if (webview_->client()) |
| - webview_->client()->didBlur(); |
| +void ChromeClientImpl::unfocus() |
| +{ |
| + if (m_webView->client()) |
| + m_webView->client()->didBlur(); |
| } |
| -bool ChromeClientImpl::canTakeFocus(WebCore::FocusDirection) { |
| - // For now the browser can always take focus if we're not running layout |
| - // tests. |
| - return !WebKit::layoutTestMode(); |
| +bool ChromeClientImpl::canTakeFocus(FocusDirection) |
| +{ |
| + // For now the browser can always take focus if we're not running layout |
| + // tests. |
| + return !layoutTestMode(); |
| } |
| -void ChromeClientImpl::takeFocus(WebCore::FocusDirection direction) { |
| - if (!webview_->client()) |
| - return; |
| - if (direction == WebCore::FocusDirectionBackward) { |
| - webview_->client()->focusPrevious(); |
| - } else { |
| - webview_->client()->focusNext(); |
| - } |
| +void ChromeClientImpl::takeFocus(FocusDirection direction) |
| +{ |
| + if (!m_webView->client()) |
| + return; |
| + if (direction == FocusDirectionBackward) |
| + m_webView->client()->focusPrevious(); |
| + else |
| + m_webView->client()->focusNext(); |
| } |
| -WebCore::Page* ChromeClientImpl::createWindow( |
| - WebCore::Frame* frame, const WebCore::FrameLoadRequest& r, |
| - const WebCore::WindowFeatures& features) { |
| - if (!webview_->client()) |
| - return NULL; |
| +Page* ChromeClientImpl::createWindow( |
| + Frame* frame, const FrameLoadRequest& r, const WindowFeatures& features) |
| +{ |
| + if (!m_webView->client()) |
| + return 0; |
| - WebViewImpl* new_view = static_cast<WebViewImpl*>( |
| - webview_->client()->createView(WebFrameImpl::FromFrame(frame))); |
| - if (!new_view) |
| - return NULL; |
| + WebViewImpl* newView = static_cast<WebViewImpl*>( |
| + m_webView->client()->createView(WebFrameImpl::FromFrame(frame))); |
| + if (!newView) |
| + return 0; |
| - // The request is empty when we are just being asked to open a blank window. |
| - // This corresponds to window.open(""), for example. |
| - if (!r.resourceRequest().isEmpty()) { |
| - WrappedResourceRequest request(r.resourceRequest()); |
| - new_view->main_frame()->loadRequest(request); |
| - } |
| + // The request is empty when we are just being asked to open a blank window. |
| + // This corresponds to window.open(""), for example. |
| + if (!r.resourceRequest().isEmpty()) { |
| + WrappedResourceRequest request(r.resourceRequest()); |
| + newView->main_frame()->loadRequest(request); |
| + } |
| - return new_view->page(); |
| + return newView->page(); |
| } |
| -static inline bool CurrentEventShouldCauseBackgroundTab( |
| - const WebInputEvent* input_event) { |
| - if (!input_event) |
| - return false; |
| +static inline bool CurrentEventShouldCauseBackgroundTab(const WebInputEvent* inputEvent) |
| +{ |
| + if (!inputEvent) |
| + return false; |
| - if (input_event->type != WebInputEvent::MouseUp) |
| - return false; |
| + if (inputEvent->type != WebInputEvent::MouseUp) |
| + return false; |
| - const WebMouseEvent* mouse_event = |
| - static_cast<const WebMouseEvent*>(input_event); |
| + const WebMouseEvent* mouseEvent = static_cast<const WebMouseEvent*>(inputEvent); |
| - WebNavigationPolicy policy; |
| - unsigned short button_number; |
| - switch (mouse_event->button) { |
| + WebNavigationPolicy policy; |
| + unsigned short buttonNumber; |
| + switch (mouseEvent->button) { |
| case WebMouseEvent::ButtonLeft: |
| - button_number = 0; |
| - break; |
| + buttonNumber = 0; |
| + break; |
| case WebMouseEvent::ButtonMiddle: |
| - button_number = 1; |
| - break; |
| + buttonNumber = 1; |
| + break; |
| case WebMouseEvent::ButtonRight: |
| - button_number = 2; |
| - break; |
| + buttonNumber = 2; |
| + break; |
| default: |
| - return false; |
| - } |
| - bool ctrl = mouse_event->modifiers & WebMouseEvent::ControlKey; |
| - bool shift = mouse_event->modifiers & WebMouseEvent::ShiftKey; |
| - bool alt = mouse_event->modifiers & WebMouseEvent::AltKey; |
| - bool meta = mouse_event->modifiers & WebMouseEvent::MetaKey; |
| + return false; |
| + } |
| + bool ctrl = mouseEvent->modifiers & WebMouseEvent::ControlKey; |
| + bool shift = mouseEvent->modifiers & WebMouseEvent::ShiftKey; |
| + bool alt = mouseEvent->modifiers & WebMouseEvent::AltKey; |
| + bool meta = mouseEvent->modifiers & WebMouseEvent::MetaKey; |
| - if (!WebViewImpl::NavigationPolicyFromMouseEvent(button_number, ctrl, |
| - shift, alt, meta, &policy)) |
| - return false; |
| + if (!WebViewImpl::NavigationPolicyFromMouseEvent(buttonNumber, ctrl, shift, alt, meta, &policy)) |
| + return false; |
| - return policy == WebKit::WebNavigationPolicyNewBackgroundTab; |
| + return policy == WebNavigationPolicyNewBackgroundTab; |
| } |
| -void ChromeClientImpl::show() { |
| - if (!webview_->client()) |
| - return; |
| +void ChromeClientImpl::show() |
| +{ |
| + if (!m_webView->client()) |
| + return; |
| - // If our default configuration was modified by a script or wasn't |
| - // created by a user gesture, then show as a popup. Else, let this |
| - // new window be opened as a toplevel window. |
| - bool as_popup = |
| - !toolbars_visible_ || |
| - !statusbar_visible_ || |
| - !scrollbars_visible_ || |
| - !menubar_visible_ || |
| - !resizable_; |
| + // If our default configuration was modified by a script or wasn't |
| + // created by a user gesture, then show as a popup. Else, let this |
| + // new window be opened as a toplevel window. |
| + bool asPopup = |
| + !m_toolbarsVisible || |
| + !m_statusbarVisible || |
| + !m_scrollbarsVisible || |
| + !m_menubarVisible || |
| + !m_resizable; |
| - WebNavigationPolicy policy = WebKit::WebNavigationPolicyNewForegroundTab; |
| - if (as_popup) |
| - policy = WebKit::WebNavigationPolicyNewPopup; |
| - if (CurrentEventShouldCauseBackgroundTab( |
| - WebViewImpl::current_input_event())) |
| - policy = WebKit::WebNavigationPolicyNewBackgroundTab; |
| + WebNavigationPolicy policy = WebNavigationPolicyNewForegroundTab; |
| + if (asPopup) |
| + policy = WebNavigationPolicyNewPopup; |
| + if (CurrentEventShouldCauseBackgroundTab(WebViewImpl::current_input_event())) |
| + policy = WebNavigationPolicyNewBackgroundTab; |
| - webview_->client()->show(policy); |
| + m_webView->client()->show(policy); |
| } |
| -bool ChromeClientImpl::canRunModal() { |
| - return webview_->client() != NULL; |
| +bool ChromeClientImpl::canRunModal() |
| +{ |
| + return m_webView->client() != 0; |
| } |
| -void ChromeClientImpl::runModal() { |
| - if (webview_->client()) |
| - webview_->client()->runModal(); |
| +void ChromeClientImpl::runModal() |
| +{ |
| + if (m_webView->client()) |
| + m_webView->client()->runModal(); |
| } |
| -void ChromeClientImpl::setToolbarsVisible(bool value) { |
| - toolbars_visible_ = value; |
| +void ChromeClientImpl::setToolbarsVisible(bool value) |
| +{ |
| + m_toolbarsVisible = value; |
| } |
| -bool ChromeClientImpl::toolbarsVisible() { |
| - return toolbars_visible_; |
| +bool ChromeClientImpl::toolbarsVisible() |
| +{ |
| + return m_toolbarsVisible; |
| } |
| -void ChromeClientImpl::setStatusbarVisible(bool value) { |
| - statusbar_visible_ = value; |
| +void ChromeClientImpl::setStatusbarVisible(bool value) |
| +{ |
| + m_statusbarVisible = value; |
| } |
| -bool ChromeClientImpl::statusbarVisible() { |
| - return statusbar_visible_; |
| +bool ChromeClientImpl::statusbarVisible() |
| +{ |
| + return m_statusbarVisible; |
| } |
| -void ChromeClientImpl::setScrollbarsVisible(bool value) { |
| - scrollbars_visible_ = value; |
| - WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(webview_->mainFrame()); |
| - if (web_frame) |
| - web_frame->SetAllowsScrolling(value); |
| +void ChromeClientImpl::setScrollbarsVisible(bool value) |
| +{ |
| + m_scrollbarsVisible = value; |
| + WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(m_webView->mainFrame()); |
| + if (web_frame) |
| + web_frame->SetAllowsScrolling(value); |
| } |
| -bool ChromeClientImpl::scrollbarsVisible() { |
| - return scrollbars_visible_; |
| +bool ChromeClientImpl::scrollbarsVisible() |
| +{ |
| + return m_scrollbarsVisible; |
| } |
| -void ChromeClientImpl::setMenubarVisible(bool value) { |
| - menubar_visible_ = value; |
| +void ChromeClientImpl::setMenubarVisible(bool value) |
| +{ |
| + m_menubarVisible = value; |
| } |
| -bool ChromeClientImpl::menubarVisible() { |
| - return menubar_visible_; |
| +bool ChromeClientImpl::menubarVisible() |
| +{ |
| + return m_menubarVisible; |
| } |
| -void ChromeClientImpl::setResizable(bool value) { |
| - resizable_ = value; |
| +void ChromeClientImpl::setResizable(bool value) |
| +{ |
| + m_resizable = value; |
| } |
| -void ChromeClientImpl::addMessageToConsole(WebCore::MessageSource source, |
| - WebCore::MessageType type, |
| - WebCore::MessageLevel level, |
| - const WebCore::String& message, |
| - unsigned int line_no, |
| - const WebCore::String& source_id) { |
| - if (webview_->client()) { |
| - webview_->client()->didAddMessageToConsole( |
| - WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), |
| - webkit_glue::StringToWebString(message)), |
| - webkit_glue::StringToWebString(source_id), |
| - line_no); |
| - } |
| +void ChromeClientImpl::addMessageToConsole(MessageSource source, |
| + MessageType type, |
| + MessageLevel level, |
| + const String& message, |
| + unsigned lineNumber, |
| + const String& sourceID) |
| +{ |
| + if (m_webView->client()) { |
| + m_webView->client()->didAddMessageToConsole( |
| + WebConsoleMessage(static_cast<WebConsoleMessage::Level>(level), message), |
| + sourceID, |
| + lineNumber); |
| + } |
| } |
| -bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() { |
| - return webview_->client() != NULL; |
| +bool ChromeClientImpl::canRunBeforeUnloadConfirmPanel() |
| +{ |
| + return m_webView->client() != 0; |
| } |
| -bool ChromeClientImpl::runBeforeUnloadConfirmPanel( |
| - const WebCore::String& message, |
| - WebCore::Frame* frame) { |
| - if (webview_->client()) { |
| - return webview_->client()->runModalBeforeUnloadDialog( |
| - WebFrameImpl::FromFrame(frame), |
| - webkit_glue::StringToWebString(message)); |
| - } |
| - return false; |
| +bool ChromeClientImpl::runBeforeUnloadConfirmPanel(const String& message, Frame* frame) |
| +{ |
| + if (m_webView->client()) { |
| + return m_webView->client()->runModalBeforeUnloadDialog( |
| + WebFrameImpl::FromFrame(frame), message); |
| + } |
| + return false; |
| } |
| -void ChromeClientImpl::closeWindowSoon() { |
| - // Make sure this Page can no longer be found by JS. |
| - webview_->page()->setGroupName(WebCore::String()); |
| +void ChromeClientImpl::closeWindowSoon() |
| +{ |
| + // Make sure this Page can no longer be found by JS. |
| + m_webView->page()->setGroupName(String()); |
| - // Make sure that all loading is stopped. Ensures that JS stops executing! |
| - webview_->mainFrame()->stopLoading(); |
| + // Make sure that all loading is stopped. Ensures that JS stops executing! |
| + m_webView->mainFrame()->stopLoading(); |
| - if (webview_->client()) |
| - webview_->client()->closeWidgetSoon(); |
| + if (m_webView->client()) |
| + m_webView->client()->closeWidgetSoon(); |
| } |
| -// Although a WebCore::Frame is passed in, we don't actually use it, since we |
| -// already know our own webview_. |
| -void ChromeClientImpl::runJavaScriptAlert(WebCore::Frame* frame, |
| - const WebCore::String& message) { |
| - if (webview_->client()) { |
| +// Although a Frame 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) |
| +{ |
| + if (m_webView->client()) { |
| #if USE(V8) |
| - // Before showing the JavaScript dialog, we give the proxy implementation |
| - // a chance to process any pending console messages. |
| - WebCore::V8Proxy::processConsoleMessages(); |
| + // Before showing the JavaScript dialog, we give the proxy implementation |
| + // a chance to process any pending console messages. |
| + V8Proxy::processConsoleMessages(); |
| #endif |
| - webview_->client()->runModalAlertDialog( |
| - WebFrameImpl::FromFrame(frame), |
| - webkit_glue::StringToWebString(message)); |
| - } |
| + m_webView->client()->runModalAlertDialog( |
| + WebFrameImpl::FromFrame(frame), message); |
| + } |
| } |
| // See comments for runJavaScriptAlert(). |
| -bool ChromeClientImpl::runJavaScriptConfirm(WebCore::Frame* frame, |
| - const WebCore::String& message) { |
| - if (webview_->client()) { |
| - return webview_->client()->runModalConfirmDialog( |
| - WebFrameImpl::FromFrame(frame), |
| - webkit_glue::StringToWebString(message)); |
| - } |
| - return false; |
| +bool ChromeClientImpl::runJavaScriptConfirm(Frame* frame, const String& message) |
| +{ |
| + if (m_webView->client()) { |
| + return m_webView->client()->runModalConfirmDialog( |
| + WebFrameImpl::FromFrame(frame), message); |
| + } |
| + return false; |
| } |
| // See comments for runJavaScriptAlert(). |
| -bool ChromeClientImpl::runJavaScriptPrompt(WebCore::Frame* frame, |
| - const WebCore::String& message, |
| - const WebCore::String& default_value, |
| - WebCore::String& result) { |
| - if (webview_->client()) { |
| - WebString actual_value; |
| - bool ok = webview_->client()->runModalPromptDialog( |
| - WebFrameImpl::FromFrame(frame), |
| - webkit_glue::StringToWebString(message), |
| - webkit_glue::StringToWebString(default_value), |
| - &actual_value); |
| - if (ok) |
| - result = webkit_glue::WebStringToString(actual_value); |
| - return ok; |
| - } |
| - return false; |
| +bool ChromeClientImpl::runJavaScriptPrompt(Frame* frame, |
| + const String& message, |
| + const String& defaultValue, |
| + String& result) |
| +{ |
| + if (m_webView->client()) { |
| + WebString actualValue; |
| + bool ok = m_webView->client()->runModalPromptDialog( |
| + WebFrameImpl::FromFrame(frame), |
| + message, |
| + defaultValue, |
| + &actualValue); |
| + if (ok) |
| + result = actualValue; |
| + return ok; |
| + } |
| + return false; |
| } |
| -void ChromeClientImpl::setStatusbarText(const WebCore::String& message) { |
| - if (webview_->client()) { |
| - webview_->client()->setStatusText( |
| - webkit_glue::StringToWebString(message)); |
| - } |
| +void ChromeClientImpl::setStatusbarText(const String& message) |
| +{ |
| + if (m_webView->client()) |
| + m_webView->client()->setStatusText(message); |
| } |
| -bool ChromeClientImpl::shouldInterruptJavaScript() { |
| - // TODO(mbelshe): implement me |
| - return false; |
| +bool ChromeClientImpl::shouldInterruptJavaScript() |
| +{ |
| + // FIXME: implement me |
| + return false; |
| } |
| -bool ChromeClientImpl::tabsToLinks() const { |
| - return webview_->tabsToLinks(); |
| +bool ChromeClientImpl::tabsToLinks() const |
| +{ |
| + // Returns true if anchors should accept keyboard focus with the tab key. |
| + // This method is used in a convoluted fashion by EventHandler::tabsToLinks. |
| + // It's a twisted path (self-evident, but more complicated than seems |
| + // necessary), but the net result is that returning true from here, on a |
| + // platform other than MAC or QT, lets anchors get keyboard focus. |
| + return m_webView->tabsToLinks(); |
| } |
| -WebCore::IntRect ChromeClientImpl::windowResizerRect() const { |
| - WebCore::IntRect result; |
| - if (webview_->client()) { |
| - result = webkit_glue::WebRectToIntRect( |
| - webview_->client()->windowResizerRect()); |
| - } |
| - return result; |
| +IntRect ChromeClientImpl::windowResizerRect() const |
| +{ |
| + IntRect result; |
| + if (m_webView->client()) |
| + result = m_webView->client()->windowResizerRect(); |
| + return result; |
| } |
| void ChromeClientImpl::repaint( |
| - const WebCore::IntRect& paint_rect, bool content_changed, bool immediate, |
| - bool repaint_content_only) { |
| - // Ignore spurious calls. |
| - if (!content_changed || paint_rect.isEmpty()) |
| - return; |
| - if (webview_->client()) { |
| - webview_->client()->didInvalidateRect( |
| - webkit_glue::IntRectToWebRect(paint_rect)); |
| - } |
| + const IntRect& paintRect, bool contentChanged, bool immediate, |
| + bool repaintContentOnly) |
| +{ |
| + // Ignore spurious calls. |
| + if (!contentChanged || paintRect.isEmpty()) |
| + return; |
| + if (m_webView->client()) |
| + m_webView->client()->didInvalidateRect(paintRect); |
| } |
| void ChromeClientImpl::scroll( |
| - const WebCore::IntSize& scroll_delta, const WebCore::IntRect& scroll_rect, |
| - const WebCore::IntRect& clip_rect) { |
| - if (webview_->client()) { |
| - int dx = scroll_delta.width(); |
| - int dy = scroll_delta.height(); |
| - webview_->client()->didScrollRect( |
| - dx, dy, webkit_glue::IntRectToWebRect(clip_rect)); |
| - } |
| + const IntSize& scrollDelta, const IntRect& scrollRect, |
| + const IntRect& clipRect) |
| +{ |
| + if (m_webView->client()) { |
| + int dx = scrollDelta.width(); |
| + int dy = scrollDelta.height(); |
| + m_webView->client()->didScrollRect(dx, dy, clipRect); |
| + } |
| } |
| -WebCore::IntPoint ChromeClientImpl::screenToWindow( |
| - const WebCore::IntPoint&) const { |
| - notImplemented(); |
| - return WebCore::IntPoint(); |
| +IntPoint ChromeClientImpl::screenToWindow(const IntPoint&) const |
| +{ |
| + notImplemented(); |
| + return IntPoint(); |
| } |
| -WebCore::IntRect ChromeClientImpl::windowToScreen( |
| - const WebCore::IntRect& rect) const { |
| - WebCore::IntRect screen_rect(rect); |
| +IntRect ChromeClientImpl::windowToScreen(const IntRect& rect) const { |
| + IntRect screenRect(rect); |
| - if (webview_->client()) { |
| - WebRect window_rect = webview_->client()->windowRect(); |
| - screen_rect.move(window_rect.x, window_rect.y); |
| - } |
| + if (m_webView->client()) { |
| + WebRect windowRect = m_webView->client()->windowRect(); |
| + screenRect.move(windowRect.x, windowRect.y); |
| + } |
| - return screen_rect; |
| + return screenRect; |
| } |
| -void ChromeClientImpl::contentsSizeChanged(WebCore::Frame* frame, const |
| - WebCore::IntSize& size) const { |
| - WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); |
| - if (webframe->client()) { |
| - webframe->client()->didChangeContentsSize( |
| - webframe, webkit_glue::IntSizeToWebSize(size)); |
| - } |
| +void ChromeClientImpl::contentsSizeChanged(Frame* frame, const IntSize& size) const |
| +{ |
| + WebFrameImpl* webframe = WebFrameImpl::FromFrame(frame); |
| + if (webframe->client()) |
| + webframe->client()->didChangeContentsSize(webframe, size); |
| } |
| -void ChromeClientImpl::scrollbarsModeDidChange() const { |
| +void ChromeClientImpl::scrollbarsModeDidChange() const |
| +{ |
| } |
| void ChromeClientImpl::mouseDidMoveOverElement( |
| - const WebCore::HitTestResult& result, unsigned modifier_flags) { |
| - if (!webview_->client()) |
| - return; |
| - // Find out if the mouse is over a link, and if so, let our UI know... |
| - if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) { |
| - webview_->client()->setMouseOverURL( |
| - webkit_glue::KURLToWebURL(result.absoluteLinkURL())); |
| - } else { |
| - webview_->client()->setMouseOverURL(WebURL()); |
| - } |
| + const HitTestResult& result, unsigned modifierFlags) |
| +{ |
| + if (!m_webView->client()) |
| + return; |
| + // Find out if the mouse is over a link, and if so, let our UI know... |
| + if (result.isLiveLink() && !result.absoluteLinkURL().string().isEmpty()) |
| + m_webView->client()->setMouseOverURL(result.absoluteLinkURL()); |
| + else |
| + m_webView->client()->setMouseOverURL(WebURL()); |
| } |
| -void ChromeClientImpl::setToolTip(const WebCore::String& tooltip_text, |
| - WebCore::TextDirection dir) { |
| - if (!webview_->client()) |
| - return; |
| - WebTextDirection text_direction = (dir == WebCore::RTL) ? |
| - WebKit::WebTextDirectionRightToLeft : |
| - WebKit::WebTextDirectionLeftToRight; |
| - webview_->client()->setToolTipText( |
| - webkit_glue::StringToWebString(tooltip_text), text_direction); |
| +void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir) |
| +{ |
| + if (!m_webView->client()) |
| + return; |
| + WebTextDirection textDirection = (dir == RTL) ? |
| + WebTextDirectionRightToLeft : |
| + WebTextDirectionLeftToRight; |
| + m_webView->client()->setToolTipText( |
| + tooltipText, textDirection); |
| } |
| -void ChromeClientImpl::print(WebCore::Frame* frame) { |
| - if (webview_->client()) |
| - webview_->client()->printPage(WebFrameImpl::FromFrame(frame)); |
| +void ChromeClientImpl::print(Frame* frame) |
| +{ |
| + if (m_webView->client()) |
| + m_webView->client()->printPage(WebFrameImpl::FromFrame(frame)); |
| } |
| -void ChromeClientImpl::exceededDatabaseQuota(WebCore::Frame* frame, |
| - const WebCore::String& databaseName) { |
| - // set a reasonable quota for now -- 5Mb should be enough for anybody |
| - // TODO(dglazkov): this should be configurable |
| - WebCore::SecurityOrigin* origin = frame->document()->securityOrigin(); |
| - WebCore::DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5); |
| +void ChromeClientImpl::exceededDatabaseQuota(Frame* frame, const String& databaseName) |
| +{ |
| + // set a reasonable quota for now -- 5Mb should be enough for anybody |
| + // TODO(dglazkov): this should be configurable |
| + SecurityOrigin* origin = frame->document()->securityOrigin(); |
| + DatabaseTracker::tracker().setQuota(origin, 1024 * 1024 * 5); |
| } |
| #if ENABLE(OFFLINE_WEB_APPLICATIONS) |
| -void ChromeClientImpl::reachedMaxAppCacheSize(int64_t space_needed) { |
| - ASSERT_NOT_REACHED(); |
| +void ChromeClientImpl::reachedMaxAppCacheSize(int64_t spaceNeeded) |
| +{ |
| + ASSERT_NOT_REACHED(); |
| } |
| #endif |
| -void ChromeClientImpl::runOpenPanel(WebCore::Frame* frame, |
| - PassRefPtr<WebCore::FileChooser> file_chooser) { |
| - WebViewClient* client = webview_->client(); |
| - if (!client) |
| - return; |
| +void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser) |
| +{ |
| + WebViewClient* client = m_webView->client(); |
| + if (!client) |
| + return; |
| - bool multiple_files = file_chooser->allowsMultipleFiles(); |
| + bool multipleFiles = fileChooser->allowsMultipleFiles(); |
| - WebString suggestion; |
| - if (file_chooser->filenames().size() > 0) |
| - suggestion = webkit_glue::StringToWebString(file_chooser->filenames()[0]); |
| + WebString suggestion; |
| + if (fileChooser->filenames().size() > 0) |
| + suggestion = fileChooser->filenames()[0]; |
| - WebFileChooserCompletionImpl* chooser_completion = |
| - new WebFileChooserCompletionImpl(file_chooser); |
| - bool ok = client->runFileChooser(multiple_files, |
| - WebString(), |
| - suggestion, |
| - chooser_completion); |
| - if (!ok) { |
| - // Choosing failed, so do callback with an empty list. |
| - chooser_completion->didChooseFile(WebVector<WebString>()); |
| - } |
| + WebFileChooserCompletionImpl* chooserCompletion = |
| + new WebFileChooserCompletionImpl(fileChooser); |
| + bool ok = client->runFileChooser(multipleFiles, |
| + WebString(), |
| + suggestion, |
| + chooserCompletion); |
| + if (!ok) { |
| + // Choosing failed, so do callback with an empty list. |
| + chooserCompletion->didChooseFile(WebVector<WebString>()); |
|
yaar
2009/10/27 18:48:34
nit: 4 space indent
|
| + } |
| } |
| -void ChromeClientImpl::popupOpened(PopupContainer* popup_container, |
| - const WebCore::IntRect& bounds, |
| +void ChromeClientImpl::popupOpened(PopupContainer* popupContainer, |
| + const IntRect& bounds, |
| bool activatable, |
| - bool handle_externally) { |
| - if (!webview_->client()) |
| - return; |
| + bool handleExternally) |
| +{ |
| + if (!m_webView->client()) |
| + return; |
| - WebWidget* webwidget; |
| - if (handle_externally) { |
| - WebPopupMenuInfo popup_info; |
| - GetPopupMenuInfo(popup_container, &popup_info); |
| - webwidget = webview_->client()->createPopupMenu(popup_info); |
| - } else { |
| - webwidget = webview_->client()->createPopupMenu(activatable); |
| - } |
| + WebWidget* webwidget; |
| + if (handleExternally) { |
| + WebPopupMenuInfo popupInfo; |
| + getPopupMenuInfo(popupContainer, &popupInfo); |
| + webwidget = m_webView->client()->createPopupMenu(popupInfo); |
| + } else |
| + webwidget = m_webView->client()->createPopupMenu(activatable); |
| - static_cast<WebPopupMenuImpl*>(webwidget)->Init( |
| - popup_container, webkit_glue::IntRectToWebRect(bounds)); |
| + static_cast<WebPopupMenuImpl*>(webwidget)->Init(popupContainer, bounds); |
| } |
| -void ChromeClientImpl::SetCursor(const WebCursorInfo& cursor) { |
| - if (ignore_next_set_cursor_) { |
| - ignore_next_set_cursor_ = false; |
| - return; |
| - } |
| +void ChromeClientImpl::setCursor(const WebCursorInfo& cursor) |
| +{ |
| + if (m_ignoreNextSetCursor) { |
| + m_ignoreNextSetCursor = false; |
| + return; |
| + } |
| - if (webview_->client()) |
| - webview_->client()->didChangeCursor(cursor); |
| + if (m_webView->client()) |
| + m_webView->client()->didChangeCursor(cursor); |
| } |
| -void ChromeClientImpl::SetCursorForPlugin(const WebCursorInfo& cursor) { |
| - SetCursor(cursor); |
| - // Currently, Widget::setCursor is always called after this function in |
| - // EventHandler.cpp and since we don't want that we set a flag indicating |
| - // that the next SetCursor call is to be ignored. |
| - ignore_next_set_cursor_ = true; |
| +void ChromeClientImpl::setCursorForPlugin(const WebCursorInfo& cursor) |
| +{ |
| + setCursor(cursor); |
| + |
| + // Currently, Widget::setCursor is always called after this function in |
| + // EventHandler.cpp and since we don't want that we set a flag indicating |
| + // that the next SetCursor call is to be ignored. |
| + m_ignoreNextSetCursor = true; |
| } |
| -void ChromeClientImpl::formStateDidChange(const WebCore::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::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* popup_container, |
| - WebPopupMenuInfo* info) { |
| - const Vector<PopupItem*>& input_items = popup_container->popupData(); |
| +void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer, |
| + WebPopupMenuInfo* info) |
| +{ |
| + const Vector<PopupItem*>& inputItems = popupContainer->popupData(); |
| - WebVector<WebPopupMenuInfo::Item> output_items(input_items.size()); |
| + WebVector<WebPopupMenuInfo::Item> outputItems(inputItems.size()); |
| - for (size_t i = 0; i < input_items.size(); ++i) { |
| - const PopupItem& input_item = *input_items[i]; |
| - WebPopupMenuInfo::Item& output_item = output_items[i]; |
| + for (size_t i = 0; i < inputItems.size(); ++i) { |
| + const PopupItem& inputItem = *inputItems[i]; |
| + WebPopupMenuInfo::Item& outputItem = outputItems[i]; |
| - output_item.label = webkit_glue::StringToWebString(input_item.label); |
| - output_item.enabled = input_item.enabled; |
| + outputItem.label = inputItem.label; |
| + outputItem.enabled = inputItem.enabled; |
| - switch (input_item.type) { |
| - case PopupItem::TypeOption: |
| - output_item.type = WebPopupMenuInfo::Item::Option; |
| - break; |
| - case PopupItem::TypeGroup: |
| - output_item.type = WebPopupMenuInfo::Item::Group; |
| - break; |
| - case PopupItem::TypeSeparator: |
| - output_item.type = WebPopupMenuInfo::Item::Separator; |
| - break; |
| - default: |
| - ASSERT_NOT_REACHED(); |
| + switch (inputItem.type) { |
| + case PopupItem::TypeOption: |
| + outputItem.type = WebPopupMenuInfo::Item::Option; |
| + break; |
| + case PopupItem::TypeGroup: |
| + outputItem.type = WebPopupMenuInfo::Item::Group; |
| + break; |
| + case PopupItem::TypeSeparator: |
| + outputItem.type = WebPopupMenuInfo::Item::Separator; |
| + break; |
| + default: |
| + ASSERT_NOT_REACHED(); |
| + } |
| } |
| - } |
| - info->itemHeight = popup_container->menuItemHeight(); |
| - info->selectedIndex = popup_container->selectedIndex(); |
| - info->items.swap(output_items); |
| + info->itemHeight = popupContainer->menuItemHeight(); |
| + info->selectedIndex = popupContainer->selectedIndex(); |
| + info->items.swap(outputItems); |
| } |
| #if ENABLE(NOTIFICATIONS) |
| -WebCore::NotificationPresenter* ChromeClientImpl::notificationPresenter() const { |
| - return webview_->GetNotificationPresenter(); |
| +NotificationPresenter* ChromeClientImpl::notificationPresenter() const |
| +{ |
| + return m_webView->GetNotificationPresenter(); |
| } |
| #endif |
| + |
| +} // namespace WebKit |