TEST_F(WebPluginContainerTest, LocalToWindowPointTest) { URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html")); TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper. FrameTestHelpers::WebViewHelper webViewHelper; WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_container.html", true, &pluginWebFrameClient); ASSERT(webView); webView->settings()->setPluginsEnabled(true); webView->resize(WebSize(300, 300)); webView->updateAllLifecyclePhases(); runPendingTasks(); WebPluginContainer* pluginContainerOne = getWebPluginContainer(webView, WebString::fromUTF8("translated-plugin")); ASSERT(pluginContainerOne); WebPoint point1 = pluginContainerOne->localToRootFramePoint(WebPoint(0, 0)); ASSERT_EQ(10, point1.x); ASSERT_EQ(10, point1.y); WebPoint point2 = pluginContainerOne->localToRootFramePoint(WebPoint(90, 90)); ASSERT_EQ(100, point2.x); ASSERT_EQ(100, point2.y); WebPluginContainer* pluginContainerTwo = getWebPluginContainer(webView, WebString::fromUTF8("rotated-plugin")); ASSERT(pluginContainerTwo); WebPoint point3 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 0)); ASSERT_EQ(0, point3.x); ASSERT_EQ(10, point3.y); WebPoint point4 = pluginContainerTwo->localToRootFramePoint(WebPoint(10, 10)); ASSERT_EQ(-10, point4.x); ASSERT_EQ(10, point4.y); }
WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::handleGestureFling(const WebGestureEvent& gestureEvent) { WebInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(WebPoint(gestureEvent.x, gestureEvent.y), WebInputHandlerClient::ScrollInputTypeGesture); switch (scrollStatus) { case WebInputHandlerClient::ScrollStatusStarted: { m_inputHandlerClient->scrollEnd(); m_wheelFlingCurve = PlatformGestureCurveFactory::get()->createCurve(gestureEvent.data.flingStart.sourceDevice, FloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY)); TRACE_EVENT_ASYNC_BEGIN1("cc", "WebCompositorInputHandlerImpl::handleGestureFling::started", this, "curve", m_wheelFlingCurve->debugName()); m_wheelFlingParameters.delta = WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY); m_wheelFlingParameters.point = WebPoint(gestureEvent.x, gestureEvent.y); m_wheelFlingParameters.globalPoint = WebPoint(gestureEvent.globalX, gestureEvent.globalY); m_wheelFlingParameters.modifiers = gestureEvent.modifiers; m_wheelFlingParameters.sourceDevice = gestureEvent.data.flingStart.sourceDevice; m_inputHandlerClient->scheduleAnimation(); return DidHandle; } case WebInputHandlerClient::ScrollStatusOnMainThread: { TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread"); return DidNotHandle; } case WebInputHandlerClient::ScrollStatusIgnored: { TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::ignored"); // We still pass the curve to the main thread if there's nothing scrollable, in case something // registers a handler before the curve is over. return DidNotHandle; } } return DidNotHandle; }
WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::handleGestureFling(const WebGestureEvent& gestureEvent) { WebInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(WebPoint(gestureEvent.x, gestureEvent.y), WebInputHandlerClient::ScrollInputTypeGesture); switch (scrollStatus) { case WebInputHandlerClient::ScrollStatusStarted: { if (gestureEvent.data.flingStart.sourceDevice == WebGestureEvent::Touchpad) m_inputHandlerClient->scrollEnd(); m_flingCurve = adoptPtr(Platform::current()->createFlingAnimationCurve(gestureEvent.data.flingStart.sourceDevice, WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY), WebSize())); TRACE_EVENT_ASYNC_BEGIN0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::started", this); m_flingParameters.delta = WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY); m_flingParameters.point = WebPoint(gestureEvent.x, gestureEvent.y); m_flingParameters.globalPoint = WebPoint(gestureEvent.globalX, gestureEvent.globalY); m_flingParameters.modifiers = gestureEvent.modifiers; m_flingParameters.sourceDevice = gestureEvent.data.flingStart.sourceDevice; m_inputHandlerClient->scheduleAnimation(); return DidHandle; } case WebInputHandlerClient::ScrollStatusOnMainThread: { TRACE_EVENT_INSTANT0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread"); m_flingActiveOnMainThread = true; return DidNotHandle; } case WebInputHandlerClient::ScrollStatusIgnored: { TRACE_EVENT_INSTANT0("webkit", "WebCompositorInputHandlerImpl::handleGestureFling::ignored"); if (gestureEvent.data.flingStart.sourceDevice == WebGestureEvent::Touchpad) { // We still pass the curve to the main thread if there's nothing scrollable, in case something // registers a handler before the curve is over. return DidNotHandle; } return DropEvent; } } return DidNotHandle; }
WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::handleGestureFling(const WebGestureEvent& gestureEvent) { CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y), CCInputHandlerClient::Gesture); switch (scrollStatus) { case CCInputHandlerClient::ScrollStarted: { TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::started"); OwnPtr<PlatformGestureCurve> flingCurve = TouchpadFlingPlatformGestureCurve::create(FloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY)); m_wheelFlingAnimation = CCActiveGestureAnimation::create(PlatformGestureToCCGestureAdapter::create(flingCurve.release()), this); m_wheelFlingParameters.delta = WebFloatPoint(gestureEvent.data.flingStart.velocityX, gestureEvent.data.flingStart.velocityY); m_wheelFlingParameters.point = WebPoint(gestureEvent.x, gestureEvent.y); m_wheelFlingParameters.globalPoint = WebPoint(gestureEvent.globalX, gestureEvent.globalY); m_wheelFlingParameters.modifiers = gestureEvent.modifiers; m_inputHandlerClient->scheduleAnimation(); return DidHandle; } case CCInputHandlerClient::ScrollOnMainThread: { TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::scrollOnMainThread"); return DidNotHandle; } case CCInputHandlerClient::ScrollIgnored: { TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::handleGestureFling::ignored"); // We still pass the curve to the main thread if there's nothing scrollable, in case something // registers a handler before the curve is over. return DidNotHandle; } } return DidNotHandle; }
TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithoutScale) { registerMockedHttpURLLoad("long_scroll.html"); FrameTestHelpers::WebViewHelper webViewHelper; WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, 0); webView->resize(WebSize(1000, 1000)); webView->updateAllLifecyclePhases(); WebViewImpl* webViewImpl = toWebViewImpl(webView); FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); loader.setLoadType(FrameLoadTypeBackForward); webViewImpl->setPageScaleFactor(3.0f); webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); loader.documentLoader()->initialScrollState().wasScrolledByUser = false; loader.currentItem()->setPageScaleFactor(0); loader.currentItem()->setScrollPoint(WebPoint(0, 400)); // FrameLoader::restoreScrollPositionAndViewState flows differently if scale is zero. loader.restoreScrollPositionAndViewState(); // Expect that only the scroll position was restored. EXPECT_EQ(3.0f, webViewImpl->pageScaleFactor()); EXPECT_EQ(400, webViewImpl->mainFrameImpl()->scrollOffset().height); }
TEST_F(ProgrammaticScrollTest, RestoreScrollPositionAndViewStateWithScale) { registerMockedHttpURLLoad("long_scroll.html"); FrameTestHelpers::WebViewHelper webViewHelper; WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "long_scroll.html", true, 0, 0); webView->resize(WebSize(1000, 1000)); webView->updateAllLifecyclePhases(); WebViewImpl* webViewImpl = toWebViewImpl(webView); FrameLoader& loader = webViewImpl->mainFrameImpl()->frame()->loader(); loader.setLoadType(FrameLoadTypeBackForward); webViewImpl->setPageScaleFactor(3.0f); webViewImpl->mainFrame()->setScrollOffset(WebSize(0, 500)); loader.documentLoader()->initialScrollState().wasScrolledByUser = false; loader.currentItem()->setPageScaleFactor(2); loader.currentItem()->setScrollPoint(WebPoint(0, 200)); // Flip back the wasScrolledByUser flag which was set to true by setPageScaleFactor // because otherwise FrameLoader::restoreScrollPositionAndViewState does nothing. loader.documentLoader()->initialScrollState().wasScrolledByUser = false; loader.restoreScrollPositionAndViewState(); // Expect that both scroll and scale were restored. EXPECT_EQ(2.0f, webViewImpl->pageScaleFactor()); EXPECT_EQ(200, webViewImpl->mainFrameImpl()->scrollOffset().height); }
WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) : m_client(client) , m_widget(0) { // Set to impossible point so we always get the first mouse position. m_lastMousePosition = WebPoint(-1, -1); }
void ChromeClientImpl::showUnhandledTapUIIfNeeded( IntPoint tappedPositionInViewport, Node* tappedNode, bool pageChanged) { if (m_webView->client()) m_webView->client()->showUnhandledTapUIIfNeeded( WebPoint(tappedPositionInViewport), WebNode(tappedNode), pageChanged); }
WebPopupMenuImpl::WebPopupMenuImpl(WebWidgetClient* client) : m_client(client) , m_layerTreeView(0) , m_isAcceleratedCompositingActive(false) // Set to impossible point so we always get the first mouse position. , m_lastMousePosition(WebPoint(-1, -1)) , m_widget(0) { }
static void addTouchPoints(TouchList* touches, const IntPoint& offset, WebTouchPoint* touchPoints, unsigned* touchPointsLength) { unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); for (unsigned i = 0; i < numberOfTouches; ++i) { const Touch* touch = touches->item(i); WebTouchPoint point; point.id = touch->identifier(); point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); point.position = WebPoint(touch->pageX() - offset.x(), touch->pageY() - offset.y()); point.radiusX = touch->webkitRadiusX(); point.radiusY = touch->webkitRadiusY(); point.rotationAngle = touch->webkitRotationAngle(); point.force = touch->webkitForce(); touchPoints[i] = point; } *touchPointsLength = numberOfTouches; }
void ensureOriginalZoomFactor(FrameView* frameView) { if (m_originalZoomFactor) return; m_webView->setPageScaleFactor(1, WebPoint()); m_webView->setZoomLevel(false, 0); WebSize scaledEmulatedSize = scaledEmulatedFrameSize(frameView); m_originalZoomFactor = static_cast<double>(scaledEmulatedSize.width) / frameView->contentsWidth(); }
void WebPopupMenuImpl::handleMouseMove(const WebMouseEvent& event) { // Don't send mouse move messages if the mouse hasn't moved. if (event.x != m_lastMousePosition.x || event.y != m_lastMousePosition.y) { m_lastMousePosition = WebPoint(event.x, event.y); m_widget->handleMouseMoveEvent(PlatformMouseEventBuilder(m_widget, event)); // We cannot call setToolTipText() in PopupContainer, because PopupContainer is in WebCore, and we cannot refer to WebKit from Webcore. PopupContainer* container = static_cast<PopupContainer*>(m_widget); client()->setToolTipText(container->getSelectedItemToolTip(), toWebTextDirection(container->menuStyle().textDirection())); } }
void AccessibilityUIElement::scrollToGlobalPointCallback(const CppArgumentList& arguments, CppVariant* result) { result->setNull(); if (arguments.size() != 2 || !arguments[0].isNumber() || !arguments[1].isNumber()) return; int x = arguments[0].toInt32(); int y = arguments[1].toInt32(); accessibilityObject().scrollToGlobalPoint(WebPoint(x, y)); result->setNull(); }
static void addTouchPoints(const Widget* widget, const AtomicString& touchType, TouchList* touches, WebTouchPoint* touchPoints, unsigned* touchPointsLength, const WebCore::RenderObject* renderObject) { unsigned numberOfTouches = std::min(touches->length(), static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); for (unsigned i = 0; i < numberOfTouches; ++i) { const Touch* touch = touches->item(i); WebTouchPoint point; point.id = touch->identifier(); point.screenPosition = WebPoint(touch->screenX(), touch->screenY()); point.position = convertAbsoluteLocationForRenderObject(touch->absoluteLocation(), *renderObject); point.radiusX = touch->webkitRadiusX(); point.radiusY = touch->webkitRadiusY(); point.rotationAngle = touch->webkitRotationAngle(); point.force = touch->webkitForce(); point.state = toWebTouchPointState(touchType); touchPoints[i] = point; } *touchPointsLength = numberOfTouches; }
void FullscreenController::didExitFullScreen() { if (!m_fullScreenFrame) return; if (Document* doc = m_fullScreenFrame->document()) { if (FullscreenElementStack* fullscreen = FullscreenElementStack::fromIfExists(doc)) { if (fullscreen->webkitIsFullScreen()) { if (m_exitFullscreenPageScaleFactor) { m_webViewImpl->setPageScaleFactor(m_exitFullscreenPageScaleFactor, WebPoint(m_exitFullscreenScrollOffset.width(), m_exitFullscreenScrollOffset.height())); m_exitFullscreenPageScaleFactor = 0; m_exitFullscreenScrollOffset = IntSize(); } fullscreen->webkitDidExitFullScreenForElement(0); } } } m_fullScreenFrame.clear(); }
void WebCompositorInputHandlerImpl::scrollBy(const WebPoint& increment) { if (increment == WebPoint()) return; TRACE_EVENT2("webkit", "WebCompositorInputHandlerImpl::scrollBy", "x", increment.x, "y", increment.y); bool didScroll = false; switch (m_flingParameters.sourceDevice) { case WebGestureEvent::Touchpad: didScroll = touchpadFlingScroll(increment); break; case WebGestureEvent::Touchscreen: didScroll = m_inputHandlerClient->scrollByIfPossible(m_flingParameters.point, IntSize(-increment.x, -increment.y)); break; } if (didScroll) { m_flingParameters.cumulativeScroll.width += increment.x; m_flingParameters.cumulativeScroll.height += increment.y; } }
void WebCompositorInputHandlerImpl::scrollBy(const WebPoint& increment) { if (increment == WebPoint()) return; TRACE_EVENT2("cc", "WebCompositorInputHandlerImpl::scrollBy", "x", increment.x, "y", increment.y); WebMouseWheelEvent syntheticWheel; syntheticWheel.type = WebInputEvent::MouseWheel; syntheticWheel.deltaX = increment.x; syntheticWheel.deltaY = increment.y; syntheticWheel.hasPreciseScrollingDeltas = true; syntheticWheel.x = m_wheelFlingParameters.point.x; syntheticWheel.y = m_wheelFlingParameters.point.y; syntheticWheel.globalX = m_wheelFlingParameters.globalPoint.x; syntheticWheel.globalY = m_wheelFlingParameters.globalPoint.y; syntheticWheel.modifiers = m_wheelFlingParameters.modifiers; WebCompositorInputHandlerImpl::EventDisposition disposition = handleInputEventInternal(syntheticWheel); switch (disposition) { case DidHandle: m_wheelFlingParameters.cumulativeScroll.width += increment.x; m_wheelFlingParameters.cumulativeScroll.height += increment.y; case DropEvent: break; case DidNotHandle: TRACE_EVENT_INSTANT0("cc", "WebCompositorInputHandlerImpl::scrollBy::AbortFling"); // If we got a DidNotHandle, that means we need to deliver wheels on the main thread. // In this case we need to schedule a commit and transfer the fling curve over to the main // thread and run the rest of the wheels from there. // This can happen when flinging a page that contains a scrollable subarea that we can't // scroll on the thread if the fling starts outside the subarea but then is flung "under" the // pointer. m_client->transferActiveWheelFlingAnimation(m_wheelFlingParameters); cancelCurrentFling(); break; } }
static bool copyWebCoreFilterOperationsToWebFilterOperations(const FilterOperations& filters, WebFilterOperations& webFilters) { for (size_t i = 0; i < filters.size(); ++i) { const FilterOperation& op = *filters.at(i); switch (op.getOperationType()) { case FilterOperation::REFERENCE: return false; // Not supported. case FilterOperation::GRAYSCALE: case FilterOperation::SEPIA: case FilterOperation::SATURATE: case FilterOperation::HUE_ROTATE: { float amount = static_cast<const BasicColorMatrixFilterOperation*>(&op)->amount(); switch (op.getOperationType()) { case FilterOperation::GRAYSCALE: webFilters.append(WebFilterOperation::createGrayscaleFilter(amount)); break; case FilterOperation::SEPIA: webFilters.append(WebFilterOperation::createSepiaFilter(amount)); break; case FilterOperation::SATURATE: webFilters.append(WebFilterOperation::createSaturateFilter(amount)); break; case FilterOperation::HUE_ROTATE: webFilters.append(WebFilterOperation::createHueRotateFilter(amount)); break; default: ASSERT_NOT_REACHED(); } break; } case FilterOperation::INVERT: case FilterOperation::OPACITY: case FilterOperation::BRIGHTNESS: case FilterOperation::CONTRAST: { float amount = static_cast<const BasicComponentTransferFilterOperation*>(&op)->amount(); switch (op.getOperationType()) { case FilterOperation::INVERT: webFilters.append(WebFilterOperation::createInvertFilter(amount)); break; case FilterOperation::OPACITY: webFilters.append(WebFilterOperation::createOpacityFilter(amount)); break; case FilterOperation::BRIGHTNESS: webFilters.append(WebFilterOperation::createBrightnessFilter(amount)); break; case FilterOperation::CONTRAST: webFilters.append(WebFilterOperation::createContrastFilter(amount)); break; default: ASSERT_NOT_REACHED(); } break; } case FilterOperation::BLUR: { float pixelRadius = static_cast<const BlurFilterOperation*>(&op)->stdDeviation().getFloatValue(); webFilters.append(WebFilterOperation::createBlurFilter(pixelRadius)); break; } case FilterOperation::DROP_SHADOW: { const DropShadowFilterOperation& dropShadowOp = *static_cast<const DropShadowFilterOperation*>(&op); webFilters.append(WebFilterOperation::createDropShadowFilter(WebPoint(dropShadowOp.x(), dropShadowOp.y()), dropShadowOp.stdDeviation(), dropShadowOp.color().rgb())); break; } #if ENABLE(CSS_SHADERS) case FilterOperation::CUSTOM: case FilterOperation::VALIDATED_CUSTOM: return false; // Not supported. #endif case FilterOperation::PASSTHROUGH: case FilterOperation::NONE: break; } } return true; }
WebPoint WebPagePopupImpl::positionRelativeToOwner() { WebRect windowRect = m_webView->client()->rootWindowRect(); return WebPoint(m_windowRectInScreen.x - windowRect.x, m_windowRectInScreen.y - windowRect.y); }
void SkiaImageFilterBuilder::buildFilterOperations(const FilterOperations& operations, WebFilterOperations* filters) { ColorSpace currentColorSpace = ColorSpaceDeviceRGB; SkImageFilter* const nullFilter = 0; for (size_t i = 0; i < operations.size(); ++i) { const FilterOperation& op = *operations.at(i); switch (op.type()) { case FilterOperation::REFERENCE: { RefPtr<SkImageFilter> filter; ReferenceFilter* referenceFilter = toReferenceFilterOperation(op).filter(); if (referenceFilter && referenceFilter->lastEffect()) { FilterEffect* filterEffect = referenceFilter->lastEffect(); // Prepopulate SourceGraphic with two image filters: one with a null image // filter, and the other with a colorspace conversion filter. // We don't know what color space the interior nodes will request, so we have to // initialize SourceGraphic with both options. // Since we know SourceGraphic is always PM-valid, we also use // these for the PM-validated options. RefPtr<SkImageFilter> deviceFilter = transformColorSpace(nullFilter, currentColorSpace, ColorSpaceDeviceRGB); RefPtr<SkImageFilter> linearFilter = transformColorSpace(nullFilter, currentColorSpace, ColorSpaceLinearRGB); FilterEffect* sourceGraphic = referenceFilter->sourceGraphic(); sourceGraphic->setImageFilter(ColorSpaceDeviceRGB, false, deviceFilter.get()); sourceGraphic->setImageFilter(ColorSpaceLinearRGB, false, linearFilter.get()); sourceGraphic->setImageFilter(ColorSpaceDeviceRGB, true, deviceFilter.get()); sourceGraphic->setImageFilter(ColorSpaceLinearRGB, true, linearFilter.get()); currentColorSpace = filterEffect->operatingColorSpace(); filter = SkiaImageFilterBuilder::build(filterEffect, currentColorSpace); filters->appendReferenceFilter(filter.get()); } break; } case FilterOperation::GRAYSCALE: case FilterOperation::SEPIA: case FilterOperation::SATURATE: case FilterOperation::HUE_ROTATE: { float amount = toBasicColorMatrixFilterOperation(op).amount(); switch (op.type()) { case FilterOperation::GRAYSCALE: filters->appendGrayscaleFilter(amount); break; case FilterOperation::SEPIA: filters->appendSepiaFilter(amount); break; case FilterOperation::SATURATE: filters->appendSaturateFilter(amount); break; case FilterOperation::HUE_ROTATE: filters->appendHueRotateFilter(amount); break; default: ASSERT_NOT_REACHED(); } break; } case FilterOperation::INVERT: case FilterOperation::OPACITY: case FilterOperation::BRIGHTNESS: case FilterOperation::CONTRAST: { float amount = toBasicComponentTransferFilterOperation(op).amount(); switch (op.type()) { case FilterOperation::INVERT: filters->appendInvertFilter(amount); break; case FilterOperation::OPACITY: filters->appendOpacityFilter(amount); break; case FilterOperation::BRIGHTNESS: filters->appendBrightnessFilter(amount); break; case FilterOperation::CONTRAST: filters->appendContrastFilter(amount); break; default: ASSERT_NOT_REACHED(); } break; } case FilterOperation::BLUR: { float pixelRadius = toBlurFilterOperation(op).stdDeviation().getFloatValue(); filters->appendBlurFilter(pixelRadius); break; } case FilterOperation::DROP_SHADOW: { const DropShadowFilterOperation& drop = toDropShadowFilterOperation(op); filters->appendDropShadowFilter(WebPoint(drop.x(), drop.y()), drop.stdDeviation(), drop.color().rgb()); break; } case FilterOperation::NONE: break; } } if (currentColorSpace != ColorSpaceDeviceRGB) { // Transform to device color space at the end of processing, if required RefPtr<SkImageFilter> filter = transformColorSpace(nullFilter, currentColorSpace, ColorSpaceDeviceRGB); filters->appendReferenceFilter(filter.get()); } }
WebCompositorInputHandlerImpl::EventDisposition WebCompositorInputHandlerImpl::handleInputEventInternal(const WebInputEvent& event) { if (event.type == WebInputEvent::MouseWheel) { const WebMouseWheelEvent& wheelEvent = *static_cast<const WebMouseWheelEvent*>(&event); WebInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(WebPoint(wheelEvent.x, wheelEvent.y), WebInputHandlerClient::ScrollInputTypeWheel); switch (scrollStatus) { case WebInputHandlerClient::ScrollStatusStarted: { TRACE_EVENT_INSTANT2("webkit", "WebCompositorInputHandlerImpl::handleInput wheel scroll", "deltaX", -wheelEvent.deltaX, "deltaY", -wheelEvent.deltaY); bool didScroll = m_inputHandlerClient->scrollByIfPossible(WebPoint(wheelEvent.x, wheelEvent.y), IntSize(-wheelEvent.deltaX, -wheelEvent.deltaY)); m_inputHandlerClient->scrollEnd(); return didScroll ? DidHandle : DropEvent; } case WebInputHandlerClient::ScrollStatusIgnored: // FIXME: This should be DropEvent, but in cases where we fail to properly sync scrollability it's safer to send the // event to the main thread. Change back to DropEvent once we have synchronization bugs sorted out. return DidNotHandle; case WebInputHandlerClient::ScrollStatusOnMainThread: return DidNotHandle; } } else if (event.type == WebInputEvent::GestureScrollBegin) { ASSERT(!m_gestureScrollOnImplThread); ASSERT(!m_expectScrollUpdateEnd); #ifndef NDEBUG m_expectScrollUpdateEnd = true; #endif const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); WebInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(WebPoint(gestureEvent.x, gestureEvent.y), WebInputHandlerClient::ScrollInputTypeGesture); switch (scrollStatus) { case WebInputHandlerClient::ScrollStatusStarted: m_gestureScrollOnImplThread = true; return DidHandle; case WebInputHandlerClient::ScrollStatusOnMainThread: return DidNotHandle; case WebInputHandlerClient::ScrollStatusIgnored: return DropEvent; } } else if (event.type == WebInputEvent::GestureScrollUpdate) { ASSERT(m_expectScrollUpdateEnd); if (!m_gestureScrollOnImplThread && !m_gesturePinchOnImplThread) return DidNotHandle; const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); bool didScroll = m_inputHandlerClient->scrollByIfPossible(WebPoint(gestureEvent.x, gestureEvent.y), IntSize(-gestureEvent.data.scrollUpdate.deltaX, -gestureEvent.data.scrollUpdate.deltaY)); return didScroll ? DidHandle : DropEvent; } else if (event.type == WebInputEvent::GestureScrollEnd) { ASSERT(m_expectScrollUpdateEnd); #ifndef NDEBUG m_expectScrollUpdateEnd = false; #endif if (!m_gestureScrollOnImplThread) return DidNotHandle; m_inputHandlerClient->scrollEnd(); m_gestureScrollOnImplThread = false; return DidHandle; } else if (event.type == WebInputEvent::GesturePinchBegin) { ASSERT(!m_expectPinchUpdateEnd); #ifndef NDEBUG m_expectPinchUpdateEnd = true; #endif m_inputHandlerClient->pinchGestureBegin(); m_gesturePinchOnImplThread = true; return DidHandle; } else if (event.type == WebInputEvent::GesturePinchEnd) { ASSERT(m_expectPinchUpdateEnd); #ifndef NDEBUG m_expectPinchUpdateEnd = false; #endif m_gesturePinchOnImplThread = false; m_inputHandlerClient->pinchGestureEnd(); return DidHandle; } else if (event.type == WebInputEvent::GesturePinchUpdate) { ASSERT(m_expectPinchUpdateEnd); const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); m_inputHandlerClient->pinchGestureUpdate(gestureEvent.data.pinchUpdate.scale, WebPoint(gestureEvent.x, gestureEvent.y)); return DidHandle; } else if (event.type == WebInputEvent::GestureFlingStart) { const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); return handleGestureFling(gestureEvent); } else if (event.type == WebInputEvent::GestureFlingCancel) { if (cancelCurrentFling()) return DidHandle; else if (!m_flingActiveOnMainThread) return DropEvent; #if ENABLE(TOUCH_EVENT_TRACKING) } else if (event.type == WebInputEvent::TouchStart) { const WebTouchEvent& touchEvent = *static_cast<const WebTouchEvent*>(&event); if (!m_inputHandlerClient->haveTouchEventHandlersAt(touchEvent.touches[0].position)) return DropEvent; #endif } else if (WebInputEvent::isKeyboardEventType(event.type)) { cancelCurrentFling(); } return DidNotHandle; }
WebPoint WebHistoryItem::scrollOffset() const { ScrollOffset offset = m_private->scrollOffset(); return WebPoint(offset.width(), offset.height()); }