summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/ChromeClientImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/chromium/src/ChromeClientImpl.cpp')
-rw-r--r--WebKit/chromium/src/ChromeClientImpl.cpp236
1 files changed, 176 insertions, 60 deletions
diff --git a/WebKit/chromium/src/ChromeClientImpl.cpp b/WebKit/chromium/src/ChromeClientImpl.cpp
index ce2f00c..405fbf6 100644
--- a/WebKit/chromium/src/ChromeClientImpl.cpp
+++ b/WebKit/chromium/src/ChromeClientImpl.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -31,8 +32,8 @@
#include "config.h"
#include "ChromeClientImpl.h"
-#include "AccessibilityObject.h"
#include "AXObjectCache.h"
+#include "AccessibilityObject.h"
#include "CharacterNames.h"
#include "Console.h"
#include "Cursor.h"
@@ -43,13 +44,22 @@
#include "FloatRect.h"
#include "FrameLoadRequest.h"
#include "FrameView.h"
+#include "GLES2Context.h"
+#include "Geolocation.h"
+#include "GeolocationService.h"
+#include "GeolocationServiceChromium.h"
+#include "GraphicsLayer.h"
+#include "HTMLNames.h"
#include "HitTestResult.h"
#include "IntRect.h"
#include "Node.h"
#include "NotificationPresenterImpl.h"
#include "Page.h"
#include "PopupMenuChromium.h"
+#include "SearchPopupMenuChromium.h"
#include "ScriptController.h"
+#include "SecurityOrigin.h"
+#include "WebGeolocationService.h"
#if USE(V8)
#include "V8Proxy.h"
#endif
@@ -61,13 +71,16 @@
#include "WebFrameImpl.h"
#include "WebInputEvent.h"
#include "WebKit.h"
+#include "WebNode.h"
#include "WebPopupMenuImpl.h"
#include "WebPopupMenuInfo.h"
+#include "WebPopupType.h"
#include "WebRect.h"
#include "WebTextDirection.h"
#include "WebURLRequest.h"
#include "WebViewClient.h"
#include "WebViewImpl.h"
+#include "WebWindowFeatures.h"
#include "WindowFeatures.h"
#include "WrappedResourceRequest.h"
@@ -75,6 +88,20 @@ using namespace WebCore;
namespace WebKit {
+// Converts a WebCore::PopupContainerType to a WebKit::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;
+ }
+}
+
ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
: m_webView(webView)
, m_toolbarsVisible(true)
@@ -82,7 +109,6 @@ ChromeClientImpl::ChromeClientImpl(WebViewImpl* webView)
, m_scrollbarsVisible(true)
, m_menubarVisible(true)
, m_resizable(true)
- , m_ignoreNextSetCursor(false)
{
}
@@ -138,35 +164,8 @@ float ChromeClientImpl::scaleFactor()
void ChromeClientImpl::focus()
{
- if (!m_webView->client())
- return;
-
- m_webView->client()->didFocus();
-
- // If accessibility is enabled, we should notify assistive technology that
- // the active AccessibilityObject changed.
- const Frame* frame = m_webView->focusedWebCoreFrame();
- if (!frame)
- return;
-
- Document* doc = frame->document();
-
- if (doc && doc->axObjectCache()->accessibilityEnabled()) {
- Node* focusedNode = m_webView->focusedWebCoreNode();
-
- if (!focusedNode) {
- // Could not retrieve focused Node.
- return;
- }
-
- // Retrieve the focused AccessibilityObject.
- AccessibilityObject* focusedAccObj =
- doc->axObjectCache()->getOrCreate(focusedNode->renderer());
-
- // Alert assistive technology that focus changed.
- if (focusedAccObj)
- m_webView->client()->focusAccessibilityObject(WebAccessibilityObject(focusedAccObj));
- }
+ if (m_webView->client())
+ m_webView->client()->didFocus();
}
void ChromeClientImpl::unfocus()
@@ -194,17 +193,39 @@ void ChromeClientImpl::takeFocus(FocusDirection direction)
void ChromeClientImpl::focusedNodeChanged(Node* node)
{
- WebURL focus_url;
+ m_webView->client()->focusedNodeChanged(WebNode(node));
+
+ WebURL focusURL;
if (node && node->isLink()) {
// This HitTestResult hack is the easiest way to get a link URL out of a
// WebCore::Node.
- HitTestResult hit_test(IntPoint(0, 0));
+ HitTestResult hitTest(IntPoint(0, 0));
// This cast must be valid because of the isLink() check.
- hit_test.setURLElement(reinterpret_cast<Element*>(node));
- if (hit_test.isLiveLink())
- focus_url = hit_test.absoluteLinkURL();
+ hitTest.setURLElement(static_cast<Element*>(node));
+ if (hitTest.isLiveLink())
+ focusURL = hitTest.absoluteLinkURL();
+ }
+ m_webView->client()->setKeyboardFocusURL(focusURL);
+
+ if (!node)
+ return;
+
+ // If accessibility is enabled, we should notify assistive technology that
+ // the active AccessibilityObject changed.
+ Document* document = node->document();
+ if (!document) {
+ ASSERT_NOT_REACHED();
+ return;
+ }
+ if (document && document->axObjectCache()->accessibilityEnabled()) {
+ // Retrieve the focused AccessibilityObject.
+ AccessibilityObject* focusedAccObj =
+ document->axObjectCache()->getOrCreate(node->renderer());
+
+ // Alert assistive technology that focus changed.
+ if (focusedAccObj)
+ m_webView->client()->focusAccessibilityObject(WebAccessibilityObject(focusedAccObj));
}
- m_webView->client()->setKeyboardFocusURL(focus_url);
}
Page* ChromeClientImpl::createWindow(
@@ -214,7 +235,7 @@ Page* ChromeClientImpl::createWindow(
return 0;
WebViewImpl* newView = static_cast<WebViewImpl*>(
- m_webView->client()->createView(WebFrameImpl::fromFrame(frame)));
+ m_webView->client()->createView(WebFrameImpl::fromFrame(frame), features, r.frameName()));
if (!newView)
return 0;
@@ -323,7 +344,7 @@ void ChromeClientImpl::setScrollbarsVisible(bool value)
m_scrollbarsVisible = value;
WebFrameImpl* web_frame = static_cast<WebFrameImpl*>(m_webView->mainFrame());
if (web_frame)
- web_frame->setAllowsScrolling(value);
+ web_frame->setCanHaveScrollbars(value);
}
bool ChromeClientImpl::scrollbarsVisible()
@@ -462,21 +483,30 @@ IntRect ChromeClientImpl::windowResizerRect() const
return result;
}
-void ChromeClientImpl::repaint(
- const IntRect& paintRect, bool contentChanged, bool immediate,
- bool repaintContentOnly)
+void ChromeClientImpl::invalidateWindow(const IntRect&, bool)
{
- // Ignore spurious calls.
- if (!contentChanged || paintRect.isEmpty())
+ notImplemented();
+}
+
+void ChromeClientImpl::invalidateContentsAndWindow(const IntRect& updateRect, bool /*immediate*/)
+{
+ if (updateRect.isEmpty())
return;
if (m_webView->client())
- m_webView->client()->didInvalidateRect(paintRect);
+ m_webView->client()->didInvalidateRect(updateRect);
+}
+
+void ChromeClientImpl::invalidateContentsForSlowScroll(const IntRect& updateRect, bool immediate)
+{
+ m_webView->hidePopups();
+ invalidateContentsAndWindow(updateRect, immediate);
}
void ChromeClientImpl::scroll(
const IntSize& scrollDelta, const IntRect& scrollRect,
const IntRect& clipRect)
{
+ m_webView->hidePopups();
if (m_webView->client()) {
int dx = scrollDelta.width();
int dy = scrollDelta.height();
@@ -552,6 +582,11 @@ void ChromeClientImpl::reachedMaxAppCacheSize(int64_t spaceNeeded)
{
ASSERT_NOT_REACHED();
}
+
+void ChromeClientImpl::reachedApplicationCacheOriginQuota(SecurityOrigin*)
+{
+ ASSERT_NOT_REACHED();
+}
#endif
void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileChooser)
@@ -562,6 +597,11 @@ void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileCh
WebFileChooserParams params;
params.multiSelect = fileChooser->allowsMultipleFiles();
+#if ENABLE(DIRECTORY_UPLOAD)
+ params.directory = fileChooser->allowsDirectoryUpload();
+#else
+ params.directory = false;
+#endif
params.acceptTypes = fileChooser->acceptTypes();
params.selectedFiles = fileChooser->filenames();
if (params.selectedFiles.size() > 0)
@@ -576,9 +616,13 @@ void ChromeClientImpl::runOpenPanel(Frame* frame, PassRefPtr<FileChooser> fileCh
chooserCompletion->didChooseFile(WebVector<WebString>());
}
+void ChromeClientImpl::chooseIconForFiles(const Vector<WTF::String>&, WebCore::FileChooser*)
+{
+ notImplemented();
+}
+
void ChromeClientImpl::popupOpened(PopupContainer* popupContainer,
const IntRect& bounds,
- bool activatable,
bool handleExternally)
{
if (!m_webView->client())
@@ -589,19 +633,24 @@ void ChromeClientImpl::popupOpened(PopupContainer* popupContainer,
WebPopupMenuInfo popupInfo;
getPopupMenuInfo(popupContainer, &popupInfo);
webwidget = m_webView->client()->createPopupMenu(popupInfo);
- } else
- webwidget = m_webView->client()->createPopupMenu(activatable);
-
+ } 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::setCursor(const WebCursorInfo& cursor)
+void ChromeClientImpl::popupClosed(WebCore::PopupContainer* popupContainer)
{
- if (m_ignoreNextSetCursor) {
- m_ignoreNextSetCursor = false;
- return;
- }
+ m_webView->popupClosed(popupContainer);
+}
+void ChromeClientImpl::setCursor(const WebCursorInfo& cursor)
+{
if (m_webView->client())
m_webView->client()->didChangeCursor(cursor);
}
@@ -609,11 +658,6 @@ void ChromeClientImpl::setCursor(const WebCursorInfo& 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.
- m_ignoreNextSetCursor = true;
}
void ChromeClientImpl::formStateDidChange(const Node* node)
@@ -655,8 +699,10 @@ void ChromeClientImpl::getPopupMenuInfo(PopupContainer* popupContainer,
}
info->itemHeight = popupContainer->menuItemHeight();
+ info->itemFontSize = popupContainer->menuItemFontSize();
info->selectedIndex = popupContainer->selectedIndex();
info->items.swap(outputItems);
+ info->rightAligned = popupContainer->menuStyle().textDirection() == RTL;
}
void ChromeClientImpl::didChangeAccessibilityObjectState(AccessibilityObject* obj)
@@ -666,7 +712,6 @@ void ChromeClientImpl::didChangeAccessibilityObjectState(AccessibilityObject* ob
m_webView->client()->didChangeAccessibilityObjectState(WebAccessibilityObject(obj));
}
-
#if ENABLE(NOTIFICATIONS)
NotificationPresenter* ChromeClientImpl::notificationPresenter() const
{
@@ -674,4 +719,75 @@ NotificationPresenter* ChromeClientImpl::notificationPresenter() const
}
#endif
+void ChromeClientImpl::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
+{
+ GeolocationServiceChromium* geolocationService = static_cast<GeolocationServiceChromium*>(geolocation->getGeolocationService());
+ geolocationService->geolocationServiceBridge()->attachBridgeIfNeeded();
+ m_webView->client()->geolocationService()->requestPermissionForFrame(geolocationService->geolocationServiceBridge()->getBridgeId(), frame->document()->url());
+}
+
+void ChromeClientImpl::cancelGeolocationPermissionRequestForFrame(Frame* frame, Geolocation* geolocation)
+{
+ GeolocationServiceChromium* geolocationService = static_cast<GeolocationServiceChromium*>(geolocation->getGeolocationService());
+ m_webView->client()->geolocationService()->cancelPermissionRequestForFrame(geolocationService->geolocationServiceBridge()->getBridgeId(), frame->document()->url());
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
+{
+ m_webView->setRootGraphicsLayer(graphicsLayer ? graphicsLayer->platformLayer() : 0);
+}
+
+void ChromeClientImpl::scheduleCompositingLayerSync()
+{
+ m_webView->setRootLayerNeedsDisplay();
+}
+#endif
+
+#if USE(GLES2_RENDERING)
+PassOwnPtr<GLES2Context> ChromeClientImpl::getOnscreenGLES2Context()
+{
+ return m_webView->getOnscreenGLES2Context();
+}
+
+PassOwnPtr<GLES2Context> ChromeClientImpl::getOffscreenGLES2Context()
+{
+ return m_webView->getOffscreenGLES2Context();
+}
+#endif
+
+bool ChromeClientImpl::supportsFullscreenForNode(const WebCore::Node* node)
+{
+ if (m_webView->client() && node->hasTagName(WebCore::HTMLNames::videoTag))
+ return m_webView->client()->supportsFullscreen();
+ return false;
+}
+
+void ChromeClientImpl::enterFullscreenForNode(WebCore::Node* node)
+{
+ if (m_webView->client())
+ m_webView->client()->enterFullscreenForNode(WebNode(node));
+}
+
+void ChromeClientImpl::exitFullscreenForNode(WebCore::Node* node)
+{
+ if (m_webView->client())
+ m_webView->client()->exitFullscreenForNode(WebNode(node));
+}
+
+bool ChromeClientImpl::selectItemWritingDirectionIsNatural()
+{
+ return false;
+}
+
+PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(PopupMenuClient* client) const
+{
+ return adoptRef(new PopupMenuChromium(client));
+}
+
+PassRefPtr<SearchPopupMenu> ChromeClientImpl::createSearchPopupMenu(PopupMenuClient* client) const
+{
+ return adoptRef(new SearchPopupMenuChromium(client));
+}
+
} // namespace WebKit