summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/src/WebViewImpl.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2012-11-07 11:22:47 +0100
committerSimon Hausmann <simon.hausmann@digia.com>2012-11-07 11:22:47 +0100
commitcfd86b747d32ac22246a1aa908eaa720c63a88c1 (patch)
tree24d68c6f61c464ecba1e05670b80390ea3b0e50c /Source/WebKit/chromium/src/WebViewImpl.cpp
parent69d7c744c9de19d152dbe2d8e46eb7dfd4511d1a (diff)
downloadqtwebkit-cfd86b747d32ac22246a1aa908eaa720c63a88c1.tar.gz
Imported WebKit commit 20271caf2e2c016d5cef40184cddeefeac4f1876 (http://svn.webkit.org/repository/webkit/trunk@133733)
New snapshot that contains all previous fixes as well as build fix for latest QtMultimedia API changes.
Diffstat (limited to 'Source/WebKit/chromium/src/WebViewImpl.cpp')
-rw-r--r--Source/WebKit/chromium/src/WebViewImpl.cpp147
1 files changed, 102 insertions, 45 deletions
diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp
index 5277b7b34..3f83e4cbc 100644
--- a/Source/WebKit/chromium/src/WebViewImpl.cpp
+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp
@@ -419,6 +419,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client)
, m_rootLayer(0)
, m_rootGraphicsLayer(0)
, m_isAcceleratedCompositingActive(false)
+ , m_layerTreeViewCommitsDeferred(false)
, m_compositorCreationFailed(false)
, m_recreatingGraphicsContext(false)
, m_compositorSurfaceReady(false)
@@ -672,7 +673,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
// Queue a highlight animation, then hand off to regular handler.
#if OS(LINUX)
if (settingsImpl()->gestureTapHighlightEnabled())
- enableTouchHighlight(IntPoint(event.x, event.y));
+ enableTouchHighlight(event);
#endif
break;
case WebInputEvent::GestureTapCancel:
@@ -744,18 +745,7 @@ bool WebViewImpl::handleGestureEvent(const WebGestureEvent& event)
break;
}
- case WebInputEvent::GestureTwoFingerTap: {
- if (!mainFrameImpl() || !mainFrameImpl()->frameView())
- break;
-
- m_page->contextMenuController()->clearContextMenu();
- m_contextMenuAllowed = true;
- PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event);
- eventSwallowed = mainFrameImpl()->frame()->eventHandler()->sendContextMenuEventForGesture(platformEvent);
- m_contextMenuAllowed = false;
-
- break;
- }
+ case WebInputEvent::GestureTwoFingerTap:
case WebInputEvent::GestureLongPress: {
if (!mainFrameImpl() || !mainFrameImpl()->frameView())
break;
@@ -1179,15 +1169,17 @@ void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZo
scroll = clampOffsetAtScale(scroll, scale);
}
-static bool highlightConditions(Node* node)
+static bool invokesHandCursor(Node* node, bool shiftKey, Frame* frame)
{
- return node->supportsFocus()
- || node->hasEventListeners(eventNames().clickEvent)
- || node->hasEventListeners(eventNames().mousedownEvent)
- || node->hasEventListeners(eventNames().mouseupEvent);
+ if (!node || !node->renderer())
+ return false;
+
+ ECursor cursor = node->renderer()->style()->cursor();
+ return cursor == CURSOR_POINTER
+ || (cursor == CURSOR_AUTO && frame->eventHandler()->useHandCursor(node, node->isLink(), shiftKey));
}
-Node* WebViewImpl::bestTouchLinkNode(IntPoint touchEventLocation)
+Node* WebViewImpl::bestTouchLinkNode(const WebGestureEvent& touchEvent)
{
if (!m_page || !m_page->mainFrame())
return 0;
@@ -1196,27 +1188,23 @@ Node* WebViewImpl::bestTouchLinkNode(IntPoint touchEventLocation)
// FIXME: Should accept a search region from the caller instead of hard-coding the size.
IntSize touchEventSearchRegionSize(4, 2);
+ IntPoint touchEventLocation(touchEvent.x, touchEvent.y);
m_page->mainFrame()->eventHandler()->bestClickableNodeForTouchPoint(touchEventLocation, touchEventSearchRegionSize, touchEventLocation, bestTouchNode);
// bestClickableNodeForTouchPoint() doesn't always return a node that is a link, so let's try and find
// a link to highlight.
- while (bestTouchNode && !highlightConditions(bestTouchNode))
+ bool shiftKey = touchEvent.modifiers & WebGestureEvent::ShiftKey;
+ while (bestTouchNode && !invokesHandCursor(bestTouchNode, shiftKey, m_page->mainFrame()))
bestTouchNode = bestTouchNode->parentNode();
- // If the document/body have click handlers installed, we don't want to default to applying the highlight to the entire RenderView, or the
- // entire body.
- RenderObject* touchNodeRenderer = bestTouchNode ? bestTouchNode->renderer() : 0;
- if (bestTouchNode && (!touchNodeRenderer || touchNodeRenderer->isRenderView() || touchNodeRenderer->isBody()))
- return 0;
-
return bestTouchNode;
}
-void WebViewImpl::enableTouchHighlight(IntPoint touchEventLocation)
+void WebViewImpl::enableTouchHighlight(const WebGestureEvent& touchEvent)
{
// Always clear any existing highlight when this is invoked, even if we don't get a new target to highlight.
m_linkHighlight.clear();
- Node* touchNode = bestTouchLinkNode(touchEventLocation);
+ Node* touchNode = bestTouchLinkNode(touchEvent);
if (!touchNode || !touchNode->renderer() || !touchNode->renderer()->enclosingLayer())
return;
@@ -1448,9 +1436,6 @@ PagePopup* WebViewImpl::openPagePopup(PagePopupClient* client, const IntRect& or
m_pagePopup->closePopup();
m_pagePopup = 0;
}
-
- if (Frame* frame = focusedWebCoreFrame())
- frame->selection()->setCaretVisible(false);
return m_pagePopup.get();
}
@@ -1463,9 +1448,6 @@ void WebViewImpl::closePagePopup(PagePopup* popup)
return;
m_pagePopup->closePopup();
m_pagePopup = 0;
-
- if (Frame* frame = focusedWebCoreFrame())
- frame->selection()->pageActivationChanged();
}
#endif
@@ -1771,6 +1753,20 @@ void WebViewImpl::layout()
m_linkHighlight->updateGeometry();
}
+void WebViewImpl::enterForceCompositingMode(bool enter)
+{
+ TRACE_EVENT1("webkit", "WebViewImpl::enterForceCompositingMode", "enter", enter);
+ settingsImpl()->setForceCompositingMode(enter);
+ if (enter) {
+ if (!m_page)
+ return;
+ Frame* mainFrame = m_page->mainFrame();
+ if (!mainFrame)
+ return;
+ mainFrame->view()->updateCompositingLayersAfterStyleChange();
+ }
+}
+
#if USE(ACCELERATED_COMPOSITING)
void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect)
{
@@ -1780,6 +1776,14 @@ void WebViewImpl::doPixelReadbackToCanvas(WebCanvas* canvas, const IntRect& rect
target.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height(), rect.width() * 4);
target.allocPixels();
m_layerTreeView->compositeAndReadback(target.getPixels(), rect);
+#if (!SK_R32_SHIFT && SK_B32_SHIFT == 16)
+ // The compositor readback always gives back pixels in BGRA order, but for
+ // example Android's Skia uses RGBA ordering so the red and blue channels
+ // need to be swapped.
+ uint8_t* pixels = reinterpret_cast<uint8_t*>(target.getPixels());
+ for (size_t i = 0; i < target.getSize(); i += 4)
+ std::swap(pixels[i], pixels[i + 2]);
+#endif
canvas->writePixels(target, rect.x(), rect.y());
}
#endif
@@ -1825,6 +1829,14 @@ void WebViewImpl::paint(WebCanvas* canvas, const WebRect& rect, PaintOptions opt
}
}
+bool WebViewImpl::isTrackingRepaints() const
+{
+ if (!page())
+ return false;
+ FrameView* view = page()->mainFrame()->view();
+ return view->isTrackingRepaints();
+}
+
void WebViewImpl::themeChanged()
{
if (!page())
@@ -1988,7 +2000,29 @@ bool WebViewImpl::handleInputEvent(const WebInputEvent& inputEvent)
return true;
}
- bool handled = PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);
+ if (!m_layerTreeView)
+ return PageWidgetDelegate::handleInputEvent(m_page.get(), *this, inputEvent);
+
+ const WebInputEvent* inputEventTransformed = &inputEvent;
+ WebMouseEvent mouseEvent;
+ WebGestureEvent gestureEvent;
+ if (WebInputEvent::isMouseEventType(inputEvent.type)) {
+ mouseEvent = *static_cast<const WebMouseEvent*>(&inputEvent);
+
+ IntPoint transformedLocation = roundedIntPoint(m_layerTreeView->adjustEventPointForPinchZoom(WebFloatPoint(mouseEvent.x, mouseEvent.y)));
+ mouseEvent.x = transformedLocation.x();
+ mouseEvent.y = transformedLocation.y();
+ inputEventTransformed = static_cast<const WebInputEvent*>(&mouseEvent);
+ } else if (WebInputEvent::isGestureEventType(inputEvent.type)) {
+ gestureEvent = *static_cast<const WebGestureEvent*>(&inputEvent);
+
+ IntPoint transformedLocation = roundedIntPoint(m_layerTreeView->adjustEventPointForPinchZoom(WebFloatPoint(gestureEvent.x, gestureEvent.y)));
+ gestureEvent.x = transformedLocation.x();
+ gestureEvent.y = transformedLocation.y();
+ inputEventTransformed = static_cast<const WebInputEvent*>(&gestureEvent);
+ }
+
+ bool handled = PageWidgetDelegate::handleInputEvent(m_page.get(), *this, *inputEventTransformed);
return handled;
}
@@ -3117,6 +3151,11 @@ void WebViewImpl::performPluginAction(const WebPluginAction& action,
}
}
+WebHitTestResult WebViewImpl::hitTestResultAt(const WebPoint& point)
+{
+ return hitTestResultForWindowPos(point);
+}
+
void WebViewImpl::copyImageAt(const WebPoint& point)
{
if (!m_page)
@@ -3819,17 +3858,26 @@ void WebViewImpl::scrollRootLayerRect(const IntSize&, const IntRect&)
updateLayerTreeViewport();
}
-void WebViewImpl::invalidateRootLayerRect(const IntRect& rect)
+void WebViewImpl::invalidateRect(const IntRect& rect)
{
- ASSERT(m_layerTreeView);
+ if (m_layerTreeViewCommitsDeferred) {
+ // If we receive an invalidation from WebKit while in deferred commit mode,
+ // that means it's time to start producing frames again so un-defer.
+ m_layerTreeView->setDeferCommits(false);
+ m_layerTreeViewCommitsDeferred = false;
+ }
+ if (m_isAcceleratedCompositingActive) {
+ ASSERT(m_layerTreeView);
- if (!page())
- return;
+ if (!page())
+ return;
- FrameView* view = page()->mainFrame()->view();
- IntRect dirtyRect = view->windowToContents(rect);
- updateLayerTreeViewport();
- m_nonCompositedContentHost->invalidateRect(dirtyRect);
+ FrameView* view = page()->mainFrame()->view();
+ IntRect dirtyRect = view->windowToContents(rect);
+ updateLayerTreeViewport();
+ m_nonCompositedContentHost->invalidateRect(dirtyRect);
+ } else if (m_client)
+ m_client->didInvalidateRect(rect);
}
NonCompositedContentHost* WebViewImpl::nonCompositedContentHost()
@@ -3896,6 +3944,15 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
if (m_layerTreeView && !page()->settings()->forceCompositingMode())
m_layerTreeView->finishAllRendering();
m_client->didDeactivateCompositor();
+ if (!m_layerTreeViewCommitsDeferred
+ && WebKit::Platform::current()->compositorSupport()->isThreadingEnabled()) {
+ ASSERT(m_layerTreeView);
+ // In threaded compositing mode, force compositing mode is always on so setIsAcceleratedCompositingActive(false)
+ // means that we're transitioning to a new page. Suppress commits until WebKit generates invalidations so
+ // we don't attempt to paint too early in the next page load.
+ m_layerTreeView->setDeferCommits(true);
+ m_layerTreeViewCommitsDeferred = true;
+ }
} else if (m_layerTreeView) {
m_isAcceleratedCompositingActive = true;
updateLayerTreeViewport();
@@ -3946,7 +4003,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active)
WebRect asciiToRectTable[128];
int fontHeight;
SkBitmap bitmap = WebCore::CompositorHUDFontAtlas::generateFontAtlas(asciiToRectTable, fontHeight);
- m_layerTreeView->setFontAtlas(bitmap, asciiToRectTable, fontHeight);
+ m_layerTreeView->setFontAtlas(asciiToRectTable, bitmap, fontHeight);
}
} else {
m_nonCompositedContentHost.clear();
@@ -4105,7 +4162,7 @@ void WebViewImpl::didRecreateOutputSurface(bool success)
void WebViewImpl::scheduleComposite()
{
if (m_suppressInvalidations) {
- TRACE_EVENT0("webkit", "WebViewImpl invalidations suppressed");
+ TRACE_EVENT_INSTANT0("webkit", "WebViewImpl invalidations suppressed");
return;
}