summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/WebViewImpl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/chromium/src/WebViewImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.cpp123
1 files changed, 83 insertions, 40 deletions
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index f6f9fc6fa..7aa12048f 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -32,7 +32,6 @@
#include "WebViewImpl.h"
#include "AXObjectCache.h"
-#include "ActivePlatformGestureAnimation.h"
#include "AutofillPopupMenuClient.h"
#include "BackForwardListChromium.h"
#include "BatteryClientImpl.h"
@@ -95,7 +94,6 @@
#include "PlatformContextSkia.h"
#include "PlatformKeyboardEvent.h"
#include "PlatformMouseEvent.h"
-#include "PlatformThemeChromiumLinux.h"
#include "PlatformWheelEvent.h"
#include "PointerLockController.h"
#include "PopupContainer.h"
@@ -146,6 +144,7 @@
#include "WebViewClient.h"
#include "WheelEvent.h"
#include "painting/GraphicsContextBuilder.h"
+#include "src/WebActiveGestureAnimation.h"
#include <public/Platform.h>
#include <public/WebCompositorOutputSurface.h>
#include <public/WebCompositorSupport.h>
@@ -165,16 +164,23 @@
#include <wtf/TemporaryChange.h>
#include <wtf/Uint8ClampedArray.h>
+#if ENABLE(DEFAULT_RENDER_THEME)
+#include "PlatformThemeChromiumDefault.h"
+#include "RenderThemeChromiumDefault.h"
+#endif
+
#if ENABLE(GESTURE_EVENTS)
-#include "PlatformGestureCurveFactory.h"
#include "PlatformGestureEvent.h"
#include "TouchDisambiguation.h"
#endif
#if OS(WINDOWS)
+#if !ENABLE(DEFAULT_RENDER_THEME)
#include "RenderThemeChromiumWin.h"
+#endif
#else
-#if OS(UNIX) && !OS(DARWIN)
+#if OS(UNIX) && !OS(DARWIN) && !ENABLE(DEFAULT_RENDER_THEME)
+#include "PlatformThemeChromiumLinux.h"
#include "RenderThemeChromiumLinux.h"
#endif
#include "RenderTheme.h"
@@ -425,6 +431,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_compositorSurfaceReady(false)
, m_deviceScaleInCompositor(1)
, m_inputHandlerIdentifier(-1)
+ , m_isFontAtlasLoaded(false)
#endif
#if ENABLE(INPUT_SPEECH)
, m_speechInputClient(SpeechInputClientImpl::create(client))
@@ -641,15 +648,15 @@ void WebViewImpl::handleMouseUp(Frame& mainFrame, const WebMouseEvent& event)
#endif
}
-void WebViewImpl::scrollBy(const WebCore::IntPoint& delta)
+void WebViewImpl::scrollBy(const WebPoint& delta)
{
WebMouseWheelEvent syntheticWheel;
const float tickDivisor = WebCore::WheelEvent::tickMultiplier;
- syntheticWheel.deltaX = delta.x();
- syntheticWheel.deltaY = delta.y();
- syntheticWheel.wheelTicksX = delta.x() / tickDivisor;
- syntheticWheel.wheelTicksY = delta.y() / tickDivisor;
+ syntheticWheel.deltaX = delta.x;
+ syntheticWheel.deltaY = delta.y;
+ syntheticWheel.wheelTicksX = delta.x / tickDivisor;
+ syntheticWheel.wheelTicksY = delta.y / tickDivisor;
syntheticWheel.hasPreciseScrollingDeltas = true;
syntheticWheel.x = m_lastWheelPosition.x;
syntheticWheel.y = m_lastWheelPosition.y;
@@ -677,13 +684,10 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
#endif
break;
case WebInputEvent::GestureTapCancel:
- if (m_linkHighlight)
- m_linkHighlight->startHighlightAnimationIfNeeded();
- break;
case WebInputEvent::GestureTap:
case WebInputEvent::GestureLongPress:
- // If a link highlight is active, kill it.
- m_linkHighlight.clear();
+ if (m_linkHighlight)
+ m_linkHighlight->startHighlightAnimationIfNeeded();
break;
default:
break;
@@ -691,13 +695,14 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
switch (event.type) {
case WebInputEvent::GestureFlingStart: {
+ if (mainFrameImpl()->frame()->eventHandler()->isScrollbarHandlingGestures())
+ break;
m_client->cancelScheduledContentIntents();
m_lastWheelPosition = WebPoint(event.x, event.y);
m_lastWheelGlobalPosition = WebPoint(event.globalX, event.globalY);
m_flingModifier = event.modifiers;
- // FIXME: Make the curve parametrizable from the browser.
- OwnPtr<PlatformGestureCurve> flingCurve = PlatformGestureCurveFactory::get()->createCurve(event.data.flingStart.sourceDevice, FloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY));
- m_gestureAnimation = ActivePlatformGestureAnimation::create(flingCurve.release(), this);
+ OwnPtr<WebGestureCurve> flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(event.data.flingStart.sourceDevice, WebFloatPoint(event.data.flingStart.velocityX, event.data.flingStart.velocityY), WebSize()));
+ m_gestureAnimation = WebActiveGestureAnimation::createAtAnimationStart(flingCurve.release(), this);
scheduleAnimation();
eventSwallowed = true;
break;
@@ -799,8 +804,8 @@ void WebViewImpl::transferActiveWheelFlingAnimation(const WebActiveWheelFlingPar
m_lastWheelPosition = parameters.point;
m_lastWheelGlobalPosition = parameters.globalPoint;
m_flingModifier = parameters.modifiers;
- OwnPtr<PlatformGestureCurve> curve = PlatformGestureCurveFactory::get()->createCurve(parameters.sourceDevice, parameters.delta, IntPoint(parameters.cumulativeScroll));
- m_gestureAnimation = ActivePlatformGestureAnimation::create(curve.release(), this, parameters.startTime);
+ OwnPtr<WebGestureCurve> curve = adoptPtr(Platform::current()->createFlingAnimationCurve(parameters.sourceDevice, WebFloatPoint(parameters.delta), parameters.cumulativeScroll));
+ m_gestureAnimation = WebActiveGestureAnimation::createWithTimeOffset(curve.release(), this, parameters.startTime);
scheduleAnimation();
}
@@ -831,6 +836,18 @@ WebViewBenchmarkSupport* WebViewImpl::benchmarkSupport()
return &m_benchmarkSupport;
}
+void WebViewImpl::setShowFPSCounter(bool show)
+{
+ if (isAcceleratedCompositingActive()) {
+ TRACE_EVENT0("webkit", "WebViewImpl::setShowFPSCounter");
+#if USE(ACCELERATED_COMPOSITING)
+ loadFontAtlasIfNecessary();
+#endif
+ m_layerTreeView->setShowFPSCounter(show);
+ }
+ settingsImpl()->setShowFPSCounter(show);
+}
+
bool WebViewImpl::handleKeyEvent(const WebKeyboardEvent& event)
{
ASSERT((event.type == WebInputEvent::RawKeyDown)
@@ -1817,7 +1834,7 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions opt
}
double paintStart = currentTime();
- PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque);
+ PageWidgetDelegate::paint(m_page.get(), pageOverlays(), canvas, rect, isTransparent() ? PageWidgetDelegate::Translucent : PageWidgetDelegate::Opaque, m_webSettings->applyDeviceScaleFactorInCompositor());
double paintEnd = currentTime();
double pixelsPerSec = (rect.width * rect.height) / (paintEnd - paintStart);
WebKit::Platform::current()->histogramCustomCounts("Renderer4.SoftwarePaintDurationMS", (paintEnd - paintStart) * 1000, 0, 120, 30);
@@ -2913,7 +2930,7 @@ void WebViewImpl::setDeviceScaleFactor(float scaleFactor)
page()->setDeviceScaleFactor(scaleFactor);
- if (m_layerTreeView && m_webSettings->applyDefaultDeviceScaleFactorInCompositor()) {
+ if (m_layerTreeView && m_webSettings->applyDeviceScaleFactorInCompositor()) {
m_deviceScaleInCompositor = page()->deviceScaleFactor();
m_layerTreeView->setDeviceScaleFactor(m_deviceScaleInCompositor);
}
@@ -2987,6 +3004,14 @@ void WebViewImpl::setIgnoreViewportTagMaximumScale(bool flag)
m_page->chrome()->client()->dispatchViewportPropertiesDidChange(page()->mainFrame()->document()->viewportArguments());
}
+static IntSize unscaledContentsSize(Frame* frame)
+{
+ RenderView* root = frame->contentRenderer();
+ if (!root)
+ return IntSize();
+ return root->unscaledDocumentRect().size();
+}
+
bool WebViewImpl::computePageScaleFactorLimits()
{
if (m_pageDefinedMinimumPageScaleFactor == -1 || m_pageDefinedMaximumPageScaleFactor == -1)
@@ -2999,11 +3024,10 @@ bool WebViewImpl::computePageScaleFactorLimits()
m_maximumPageScaleFactor = max(min(m_pageDefinedMaximumPageScaleFactor, maxPageScaleFactor), minPageScaleFactor) * (deviceScaleFactor() / m_deviceScaleInCompositor);
int viewWidthNotIncludingScrollbars = page()->mainFrame()->view()->visibleContentRect(false).width();
- int contentsWidth = mainFrame()->contentsSize().width;
- if (viewWidthNotIncludingScrollbars && contentsWidth) {
+ int unscaledContentsWidth = unscaledContentsSize(page()->mainFrame()).width();
+ if (viewWidthNotIncludingScrollbars && unscaledContentsWidth) {
// Limit page scaling down to the document width.
- int unscaledContentWidth = contentsWidth / pageScaleFactor();
- m_minimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<float>(viewWidthNotIncludingScrollbars) / unscaledContentWidth);
+ m_minimumPageScaleFactor = max(m_minimumPageScaleFactor, static_cast<float>(viewWidthNotIncludingScrollbars) / unscaledContentsWidth);
m_maximumPageScaleFactor = max(m_minimumPageScaleFactor, m_maximumPageScaleFactor);
}
ASSERT(m_minimumPageScaleFactor <= m_maximumPageScaleFactor);
@@ -3533,7 +3557,9 @@ void WebViewImpl::setDomainRelaxationForbidden(bool forbidden, const WebString&
void WebViewImpl::setScrollbarColors(unsigned inactiveColor,
unsigned activeColor,
unsigned trackColor) {
-#if OS(UNIX) && !OS(DARWIN) && !OS(ANDROID)
+#if ENABLE(DEFAULT_RENDER_THEME)
+ PlatformThemeChromiumDefault::setScrollbarColors(inactiveColor, activeColor, trackColor);
+#elif OS(UNIX) && !OS(DARWIN) && !OS(ANDROID)
PlatformThemeChromiumLinux::setScrollbarColors(inactiveColor, activeColor, trackColor);
#endif
}
@@ -3542,11 +3568,11 @@ void WebViewImpl::setSelectionColors(unsigned activeBackgroundColor,
unsigned activeForegroundColor,
unsigned inactiveBackgroundColor,
unsigned inactiveForegroundColor) {
-#if OS(UNIX) && !OS(DARWIN) && !OS(ANDROID)
- RenderThemeChromiumLinux::setSelectionColors(activeBackgroundColor,
- activeForegroundColor,
- inactiveBackgroundColor,
- inactiveForegroundColor);
+#if ENABLE(DEFAULT_RENDER_THEME)
+ RenderThemeChromiumDefault::setSelectionColors(activeBackgroundColor, activeForegroundColor, inactiveBackgroundColor, inactiveForegroundColor);
+ theme()->platformColorsDidChange();
+#elif OS(UNIX) && !OS(DARWIN) && !OS(ANDROID)
+ RenderThemeChromiumLinux::setSelectionColors(activeBackgroundColor, activeForegroundColor, inactiveBackgroundColor, inactiveForegroundColor);
theme()->platformColorsDidChange();
#endif
}
@@ -3964,10 +3990,14 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
WebLayerTreeView::Settings layerTreeViewSettings;
layerTreeViewSettings.acceleratePainting = page()->settings()->acceleratedDrawingEnabled();
+ layerTreeViewSettings.showDebugBorders = page()->settings()->showDebugBorders();
layerTreeViewSettings.showFPSCounter = settingsImpl()->showFPSCounter();
layerTreeViewSettings.showPlatformLayerTree = settingsImpl()->showPlatformLayerTree();
layerTreeViewSettings.showPaintRects = settingsImpl()->showPaintRects();
layerTreeViewSettings.renderVSyncEnabled = settingsImpl()->renderVSyncEnabled();
+ layerTreeViewSettings.perTilePaintingEnabled = settingsImpl()->perTilePaintingEnabled();
+ layerTreeViewSettings.acceleratedAnimationEnabled = settingsImpl()->acceleratedAnimationEnabled();
+ layerTreeViewSettings.pageScalePinchZoomEnabled = settingsImpl()->applyPageScaleFactorInCompositor();
layerTreeViewSettings.defaultTileSize = settingsImpl()->defaultTileSize();
layerTreeViewSettings.maxUntiledLayerSize = settingsImpl()->maxUntiledLayerSize();
@@ -3978,7 +4008,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
m_layerTreeView = adoptPtr(Platform::current()->compositorSupport()->createLayerTreeView(this, *m_rootLayer, layerTreeViewSettings));
if (m_layerTreeView) {
- if (m_webSettings->applyDefaultDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) {
+ if (m_webSettings->applyDeviceScaleFactorInCompositor() && page()->deviceScaleFactor() != 1) {
ASSERT(page()->deviceScaleFactor());
m_deviceScaleInCompositor = page()->deviceScaleFactor();
@@ -3995,17 +4025,15 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
m_client->didActivateCompositor(m_inputHandlerIdentifier);
m_isAcceleratedCompositingActive = true;
m_compositorCreationFailed = false;
+ m_isFontAtlasLoaded = false;
if (m_pageOverlays)
m_pageOverlays->update();
- // Only allocate the font atlas if we have reason to use the heads-up display.
- if (layerTreeViewSettings.showFPSCounter || layerTreeViewSettings.showPlatformLayerTree) {
- TRACE_EVENT0("cc", "WebViewImpl::setIsAcceleratedCompositingActive(true) initialize font atlas");
- WebRect asciiToRectTable[128];
- int fontHeight;
- SkBitmap bitmap = WebCore::CompositorHUDFontAtlas::generateFontAtlas(asciiToRectTable, fontHeight);
- m_layerTreeView->setFontAtlas(asciiToRectTable, bitmap, fontHeight);
- }
+ if (layerTreeViewSettings.showPlatformLayerTree)
+ loadFontAtlasIfNecessary();
+
+ if (settingsImpl()->showFPSCounter())
+ setShowFPSCounter(true);
} else {
m_nonCompositedContentHost.clear();
m_isAcceleratedCompositingActive = false;
@@ -4017,6 +4045,21 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
page()->mainFrame()->view()->setClipsRepaints(!m_isAcceleratedCompositingActive);
}
+void WebViewImpl::loadFontAtlasIfNecessary()
+{
+ ASSERT(m_layerTreeView);
+
+ if (m_isFontAtlasLoaded)
+ return;
+
+ TRACE_EVENT0("webkit", "WebViewImpl::loadFontAtlas");
+ WebRect asciiToRectTable[128];
+ int fontHeight;
+ SkBitmap bitmap = WebCore::CompositorHUDFontAtlas::generateFontAtlas(asciiToRectTable, fontHeight);
+ m_layerTreeView->setFontAtlas(asciiToRectTable, bitmap, fontHeight);
+ m_isFontAtlasLoaded = true;
+}
+
#endif
namespace {