summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/ChromeClientImpl.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-05-07 11:21:11 +0200
commit2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 (patch)
tree988e8c5b116dd0466244ae2fe5af8ee9be926d76 /Source/WebKit/chromium/src/ChromeClientImpl.cpp
parentdd91e772430dc294e3bf478c119ef8d43c0a3358 (diff)
downloadqtwebkit-2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47.tar.gz
Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286)
Diffstat (limited to 'Source/WebKit/chromium/src/ChromeClientImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/ChromeClientImpl.cpp94
1 files changed, 69 insertions, 25 deletions
diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
index ad35382b9..fac80d993 100644
--- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp
+++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp
@@ -34,7 +34,7 @@
#include "AXObjectCache.h"
#include "AccessibilityObject.h"
-#if ENABLE(INPUT_COLOR)
+#if ENABLE(INPUT_TYPE_COLOR)
#include "ColorChooser.h"
#include "ColorChooserClient.h"
#include "ColorChooserProxy.h"
@@ -51,8 +51,8 @@
#include "FrameLoadRequest.h"
#include "FrameView.h"
#include "Geolocation.h"
-#include "GeolocationService.h"
#include "GraphicsLayer.h"
+#include "HTMLInputElement.h"
#include "HTMLNames.h"
#include "HitTestResult.h"
#include "Icon.h"
@@ -69,11 +69,12 @@
#include "SearchPopupMenuChromium.h"
#include "SecurityOrigin.h"
#include "Settings.h"
+#include "TextFieldDecorationElement.h"
#if USE(V8)
#include "V8Proxy.h"
#endif
#include "WebAccessibilityObject.h"
-#if ENABLE(INPUT_COLOR)
+#if ENABLE(INPUT_TYPE_COLOR)
#include "WebColorChooser.h"
#include "WebColorChooserClientImpl.h"
#endif
@@ -100,6 +101,7 @@
#include "WebWindowFeatures.h"
#include "WindowFeatures.h"
#include "WrappedResourceRequest.h"
+#include <public/Platform.h>
#include <wtf/text/StringBuilder.h>
#include <wtf/text/StringConcatenate.h>
#include <wtf/unicode/CharacterNames.h>
@@ -316,7 +318,7 @@ WebNavigationPolicy ChromeClientImpl::getNavigationPolicy()
policy = WebNavigationPolicyNewBackgroundTab;
return policy;
}
-
+
void ChromeClientImpl::show()
{
if (!m_webView->client())
@@ -640,14 +642,16 @@ void ChromeClientImpl::setToolTip(const String& tooltipText, TextDirection dir)
void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArguments& arguments) const
{
#if ENABLE(VIEWPORT)
- if (!m_webView->isFixedLayoutModeEnabled() || !m_webView->client() || !m_webView->page())
+ if (!m_webView->settings()->viewportEnabled() || !m_webView->isFixedLayoutModeEnabled() || !m_webView->client() || !m_webView->page())
return;
+ bool useDefaultDeviceScaleFactor = false;
ViewportArguments args;
- if (arguments == args)
+ if (arguments == args) {
// Default viewport arguments passed in. This is a signal to reset the viewport.
args.width = ViewportArguments::ValueDesktopWidth;
- else
+ useDefaultDeviceScaleFactor = true;
+ } else
args = arguments;
FrameView* frameView = m_webView->mainFrameImpl()->frameView();
@@ -672,7 +676,10 @@ void ChromeClientImpl::dispatchViewportPropertiesDidChange(const ViewportArgumen
// FIXME: Investigate the impact this has on layout/rendering if any.
// This exposes the correct device scale to javascript and media queries.
- m_webView->setDeviceScaleFactor(computed.devicePixelRatio);
+ if (useDefaultDeviceScaleFactor && settings->defaultDeviceScaleFactor())
+ m_webView->setDeviceScaleFactor(settings->defaultDeviceScaleFactor());
+ else
+ m_webView->setDeviceScaleFactor(computed.devicePixelRatio);
m_webView->setPageScaleFactorLimits(computed.minimumScale, computed.maximumScale);
m_webView->setPageScaleFactorPreservingScrollOffset(computed.initialScale * computed.devicePixelRatio);
#endif
@@ -699,7 +706,7 @@ void ChromeClientImpl::reachedApplicationCacheOriginQuota(SecurityOrigin*, int64
ASSERT_NOT_REACHED();
}
-#if ENABLE(INPUT_COLOR)
+#if ENABLE(INPUT_TYPE_COLOR)
PassOwnPtr<ColorChooser> ChromeClientImpl::createColorChooser(ColorChooserClient* chooserClient, const Color& initialColor)
{
WebViewClient* client = m_webView->client();
@@ -772,6 +779,22 @@ 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;
@@ -888,20 +911,6 @@ bool ChromeClientImpl::paintCustomOverhangArea(GraphicsContext* context, const I
return false;
}
-// FIXME: Remove ChromeClientImpl::requestGeolocationPermissionForFrame and ChromeClientImpl::cancelGeolocationPermissionRequestForFrame
-// once all ports have moved to client-based geolocation (see https://bugs.webkit.org/show_bug.cgi?id=40373 ).
-// For client-based geolocation, these methods are now implemented as WebGeolocationClient::requestPermission and WebGeolocationClient::cancelPermissionRequest.
-// (see https://bugs.webkit.org/show_bug.cgi?id=50061 ).
-void ChromeClientImpl::requestGeolocationPermissionForFrame(Frame* frame, Geolocation* geolocation)
-{
- ASSERT_NOT_REACHED();
-}
-
-void ChromeClientImpl::cancelGeolocationPermissionRequestForFrame(Frame* frame, Geolocation* geolocation)
-{
- ASSERT_NOT_REACHED();
-}
-
#if USE(ACCELERATED_COMPOSITING)
void ChromeClientImpl::attachRootGraphicsLayer(Frame* frame, GraphicsLayer* graphicsLayer)
{
@@ -984,7 +993,7 @@ bool ChromeClientImpl::selectItemAlignmentFollowsMenuWritingDirection()
bool ChromeClientImpl::hasOpenedPopup() const
{
- return !!m_webView->selectPopup();
+ return m_webView->hasOpenedPopup();
}
PassRefPtr<PopupMenu> ChromeClientImpl::createPopupMenu(PopupMenuClient* client) const
@@ -1000,6 +1009,41 @@ PassRefPtr<SearchPopupMenu> ChromeClientImpl::createSearchPopupMenu(PopupMenuCli
return adoptRef(new SearchPopupMenuChromium(client));
}
+#if ENABLE(PAGE_POPUP)
+PagePopup* ChromeClientImpl::openPagePopup(PagePopupClient* client, const IntRect& originBoundsInRootView)
+{
+ return m_webView->openPagePopup(client, originBoundsInRootView);
+}
+
+void ChromeClientImpl::closePagePopup(PagePopup* popup)
+{
+ m_webView->closePagePopup(popup);
+}
+#endif
+
+bool ChromeClientImpl::willAddTextFieldDecorationsTo(HTMLInputElement* input)
+{
+ ASSERT(input);
+ const Vector<OwnPtr<TextFieldDecorator> >& decorators = m_webView->textFieldDecorators();
+ for (unsigned i = 0; i < decorators.size(); ++i) {
+ if (decorators[i]->willAddDecorationTo(input))
+ return true;
+ }
+ return false;
+}
+
+void ChromeClientImpl::addTextFieldDecorationsTo(HTMLInputElement* input)
+{
+ ASSERT(willAddTextFieldDecorationsTo(input));
+ const Vector<OwnPtr<TextFieldDecorator> >& decorators = m_webView->textFieldDecorators();
+ for (unsigned i = 0; i < decorators.size(); ++i) {
+ if (!decorators[i]->willAddDecorationTo(input))
+ continue;
+ RefPtr<TextFieldDecorationElement> decoration = TextFieldDecorationElement::create(input->document(), decorators[i].get());
+ decoration->decorate(input);
+ }
+}
+
bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType& dialogType, const String& dialogMessage, FrameLoader::PageDismissalType dismissalType) const
{
const char* kDialogs[] = {"alert", "confirm", "prompt", "showModalDialog"};
@@ -1010,7 +1054,7 @@ bool ChromeClientImpl::shouldRunModalDialogDuringPageDismissal(const DialogType&
int dismissal = static_cast<int>(dismissalType) - 1; // Exclude NoDismissal.
ASSERT(0 <= dismissal && dismissal < static_cast<int>(arraysize(kDismissals)));
- PlatformSupport::histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arraysize(kDismissals));
+ WebKit::Platform::current()->histogramEnumeration("Renderer.ModalDialogsDuringPageDismissal", dismissal * arraysize(kDialogs) + dialog, arraysize(kDialogs) * arraysize(kDismissals));
m_webView->mainFrame()->addMessageToConsole(WebConsoleMessage(WebConsoleMessage::LevelError, makeString("Blocked ", kDialogs[dialog], "('", dialogMessage, "') during ", kDismissals[dismissal], ".")));