diff options
Diffstat (limited to 'Source/WebKit/chromium')
102 files changed, 5724 insertions, 1090 deletions
diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog index c3837d1cf..797b31c6c 100644 --- a/Source/WebKit/chromium/ChangeLog +++ b/Source/WebKit/chromium/ChangeLog @@ -1,3 +1,1562 @@ +2012-02-24 Shinya Kawanaka <shinyak@chromium.org> + + SpellCheckRequest needs to know the context where the spellcheck happened. + https://bugs.webkit.org/show_bug.cgi?id=79320 + + Reviewed by Hajime Morita. + + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::requestCheckingOfString): + * src/EditorClientImpl.h: + (EditorClientImpl): + * src/WebFrameImpl.cpp: + (WebKit::WebFrameImpl::requestTextChecking): + +2012-02-23 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-23 Ian Vollick <vollick@chromium.org> + + [chromium] Implement keyframed animations for the cc thread. + https://bugs.webkit.org/show_bug.cgi?id=77229 + + Reviewed by James Robinson. + + * WebKit.gypi: + * tests/CCAnimationTestCommon.cpp: + (WebCore): + (WebCore::addOpacityTransition): + (WebKitTests::addOpacityTransitionToController): + (WebKitTests::addOpacityTransitionToLayer): + * tests/CCAnimationTestCommon.h: + (WebCore): + (WebKitTests): + * tests/CCKeyframedAnimationCurveTest.cpp: Added. + (WebCore): + (WebCore::expectTranslateX): + (WebCore::TEST): + * tests/CCLayerAnimationControllerTest.cpp: + (WebKitTests::expectTranslateX): + (WebKitTests): + (WebKitTests::TEST): + * tests/CCLayerTreeHostTest.cpp: + (WTF::CCLayerTreeHostTest::dispatchAddAnimation): + (WTF::CCLayerTreeHostTest::doBeginTest): + +2012-02-23 James Robinson <jamesr@chromium.org> + + [chromium] Clean up GraphicsContext3D initialization paths + https://bugs.webkit.org/show_bug.cgi?id=79321 + + Reviewed by Kenneth Russell. + + This simplifies the GraphicsContext3D initialization paths down to two simple codepaths, one for offscreen + contexts initialized from WebCore and one for onscreen (compositor) contexts initialized by WebViewImpl or + WebLayerTreeViewImpl. + + Offscreen initialization path: + 1) WebCore code calls WebCore::GraphicsContext3D::create(), implemented in GraphicsContext3DChromium.cpp + 2) GraphicsContext3D::create() instantiates a WebGraphicsContext3D via the static WebKitPlatformSupport interface + 3) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a + GraphicsContext3D's m_private pointer. + + Onscreen initialization path: + 1) WebViewImpl or WebLayerTreeViewImpl request an onscreen WebGraphicsContext3D from either their WebViewClient + or WebLayerTreeViewClient, respectively + 2) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a + GraphicsContext3D's m_private pointer. + + There are no other initialization paths. Specifically, we do not support instantiating onscreen contexts from + within WebCore. + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): + (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): + (WebCore): + (WebCore::GraphicsContext3DPrivate::platformTexture): + (WebCore::GraphicsContext3D::create): + * src/GraphicsContext3DPrivate.h: + (GraphicsContext3DPrivate): + * src/WebLayerTreeViewImpl.cpp: + (WebKit::WebLayerTreeViewImpl::createLayerTreeHostContext3D): + * src/WebViewImpl.cpp: + (std::getCompositorContextAttributes): + (WebKit::WebViewImpl::createCompositorGraphicsContext3D): + (WebKit): + (WebKit::WebViewImpl::createLayerTreeHostContext3D): + (WebKit::WebViewImpl::graphicsContext3D): + * src/WebViewImpl.h: + (WebViewImpl): + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::CCLayerTreeHostImplTest::createContext): + (CCLayerTreeHostImplTest): + (WebKit::TEST_F): + * tests/CCLayerTreeHostTest.cpp: + (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): + * tests/Canvas2DLayerChromiumTest.cpp: + (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): + * tests/CompositorFakeGraphicsContext3D.h: + (WebCore::createCompositorMockGraphicsContext3D): + * tests/FakeGraphicsContext3DTest.cpp: + (TEST): + +2012-02-23 Jonathan Backer <backer@chromium.org> + + [chromium] Plumb video damage to the damage tracker. + https://bugs.webkit.org/show_bug.cgi?id=79373 + + Reviewed by James Robinson. + + * src/WebMediaPlayerClientImpl.cpp: + (WebKit::WebMediaPlayerClientImpl::repaint): + +2012-02-21 James Robinson <jamesr@chromium.org> + + [chromium] Notify compositor of wheel event registration via ScrollingCoordinator + https://bugs.webkit.org/show_bug.cgi?id=79133 + + Reviewed by Dimitri Glazkov. + + Rips out old wheel event notification and adds unit tests for new LayerChromium property. + + * src/NonCompositedContentHost.cpp: + (WebKit::NonCompositedContentHost::setViewport): + * src/WebCompositorInputHandlerImpl.cpp: + (WebKit::WebCompositorInputHandlerImpl::handleInputEvent): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::numberOfWheelEventHandlersChanged): + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + * src/WebViewImpl.h: + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::TEST_F): + (WebKit): + * tests/LayerChromiumTest.cpp: + * tests/WebCompositorInputHandlerImplTest.cpp: + +2012-02-23 Adrienne Walker <enne@google.com> + + Unreviewed, rolling out r108666. + http://trac.webkit.org/changeset/108666 + https://bugs.webkit.org/show_bug.cgi?id=79321 + + Breaks webplugin tests: http://goo.gl/CoHIi + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): + (WebCore): + (WebCore::GraphicsContext3DPrivate::create): + (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): + (WebCore::GraphicsContext3DPrivate::createGraphicsContextForAnotherThread): + (WebCore::GraphicsContext3DPrivate::platformTexture): + (WebCore::GraphicsContext3D::create): + * src/GraphicsContext3DPrivate.h: + (WebKit): + (GraphicsContext3DPrivate): + * src/WebLayerTreeViewImpl.cpp: + (WebKit::WebLayerTreeViewImpl::createLayerTreeHostContext3D): + * src/WebViewImpl.cpp: + (std::getCompositorContextAttributes): + (WebKit::WebViewImpl::createLayerTreeHostContext3D): + (WebKit::WebViewImpl::graphicsContext3D): + * tests/CCLayerTreeHostImplTest.cpp: + (CCLayerTreeHostImplTest): + (WebKit::TEST_F): + * tests/CCLayerTreeHostTest.cpp: + (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): + * tests/Canvas2DLayerChromiumTest.cpp: + (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): + * tests/CompositorFakeGraphicsContext3D.h: + (WebCore::createCompositorMockGraphicsContext3D): + * tests/FakeGraphicsContext3DTest.cpp: + (TEST): + +2012-02-23 Daniel Sievers <sievers@chromium.org> + + [Chromium] Add video stream texture support + https://bugs.webkit.org/show_bug.cgi?id=78398 + + This upstreams the abstraction used on Android for + hardware video decoding with the compositor. + + Most of the interfaces are kept generic and the core + of this change is to allow texturing from an external + texture while receiving notifications (on the compositor + thread if we are running it) when there are new frames to + be displayed. + + Reviewed by James Robinson. + + * WebKit.gyp: + * public/WebMediaPlayer.h: + (WebKit): + (WebKit::WebMediaPlayer::setStreamTextureClient): + (WebMediaPlayer): + * public/WebStreamTextureClient.h: Copied from Source/WebKit/chromium/public/WebVideoFrame.h. + (WebKit): + (WebStreamTextureClient): + (WebKit::WebStreamTextureClient::~WebStreamTextureClient): + * public/WebVideoFrame.h: + * src/WebMediaPlayerClientImpl.cpp: + (WebKit::WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl): + (WebKit::WebMediaPlayerClientImpl::setVideoFrameProviderClient): + (WebKit::WebMediaPlayerClientImpl::didReceiveFrame): + (WebKit): + (WebKit::WebMediaPlayerClientImpl::didUpdateMatrix): + * src/WebMediaPlayerClientImpl.h: + (WebMediaPlayerClientImpl): + +2012-02-22 James Robinson <jamesr@chromium.org> + + [chromium] Clean up GraphicsContext3D initialization paths + https://bugs.webkit.org/show_bug.cgi?id=79321 + + Reviewed by Kenneth Russell. + + This simplifies the GraphicsContext3D initialization paths down to two simple codepaths, one for offscreen + contexts initialized from WebCore and one for onscreen (compositor) contexts initialized by WebViewImpl or + WebLayerTreeViewImpl. + + Offscreen initialization path: + 1) WebCore code calls WebCore::GraphicsContext3D::create(), implemented in GraphicsContext3DChromium.cpp + 2) GraphicsContext3D::create() instantiates a WebGraphicsContext3D via the static WebKitPlatformSupport interface + 3) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a + GraphicsContext3D's m_private pointer. + + Onscreen initialization path: + 1) WebViewImpl or WebLayerTreeViewImpl request an onscreen WebGraphicsContext3D from either their WebViewClient + or WebLayerTreeViewClient, respectively + 2) GraphicsContext3DPrivate::createGraphicsContextFromWebContext() wraps the WebGraphicsContext3D in a + GraphicsContext3D's m_private pointer. + + There are no other initialization paths. Specifically, we do not support instantiating onscreen contexts from + within WebCore. + + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): + (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromWebContext): + (WebCore): + (WebCore::GraphicsContext3DPrivate::platformTexture): + (WebCore::GraphicsContext3D::create): + * src/GraphicsContext3DPrivate.h: + (GraphicsContext3DPrivate): + * src/WebLayerTreeViewImpl.cpp: + (WebKit::WebLayerTreeViewImpl::createLayerTreeHostContext3D): + * src/WebViewImpl.cpp: + (std::getCompositorContextAttributes): + (WebKit::WebViewImpl::createLayerTreeHostContext3D): + (WebKit::WebViewImpl::graphicsContext3D): + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::CCLayerTreeHostImplTest::createContext): + (CCLayerTreeHostImplTest): + (WebKit::TEST_F): + * tests/CCLayerTreeHostTest.cpp: + (WTF::MockLayerTreeHostClient::createLayerTreeHostContext3D): + * tests/Canvas2DLayerChromiumTest.cpp: + (WebCore::Canvas2DLayerChromiumTest::fullLifecycleTest): + * tests/CompositorFakeGraphicsContext3D.h: + (WebCore::createCompositorMockGraphicsContext3D): + * tests/FakeGraphicsContext3DTest.cpp: + (TEST): + +2012-02-23 Greg Billock <gbillock@google.com> + + Add UserGestureIndicator capability to Chromium API. + https://bugs.webkit.org/show_bug.cgi?id=77690 + + Reviewed by Darin Fisher. + + * WebKit.gyp: + * public/WebScopedUserGesture.h: Added. + * src/WebScopedUserGesture.cpp: Added. + +2012-02-23 Peter Beverloo <peter@chromium.org> + + Unreviewed, rolling out r108627 and r108630. + https://bugs.webkit.org/show_bug.cgi?id=79367 + + ffmpeg is creating issues and was just reverted upstream as well. + + * DEPS: + +2012-02-23 Peter Beverloo <peter@chromium.org> + + Unreviewed build fix. Remove the ffmpeg binary directory from the + Chromium-Windows DEPS file, following the commit done in the + Chromium repository: + http://src.chromium.org/viewvc/chrome?view=rev&revision=123123 + + * DEPS: + +2012-02-23 Peter Beverloo <peter@chromium.org> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-22 Hajime Morrita <morrita@chromium.org> + + NOTIFICATIONS should be implemented as PageSupplement + https://bugs.webkit.org/show_bug.cgi?id=79052 + + Reviewed by Adam Barth. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + +2012-02-22 Dana Jansens <danakj@chromium.org> + + [chromium] Add unit test for surface occlusion + https://bugs.webkit.org/show_bug.cgi?id=79302 + + Reviewed by James Robinson. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::TEST): + (WebCore): + +2012-02-22 James Robinson <jamesr@chromium.org> + + Remove GraphicsContext3D::paintsIntoCanvasBuffer and unify WebGL and canvas 2d logic + https://bugs.webkit.org/show_bug.cgi?id=79317 + + Reviewed by Kenneth Russell. + + Remove paintsIntoCanvasBuffer() implementations. + + * src/GraphicsContext3DChromium.cpp: + (WebCore): + * src/GraphicsContext3DPrivate.h: + +2012-02-22 Yuta Kitamura <yutak@chromium.org> + + Unreviewed, rolling out r108590. + http://trac.webkit.org/changeset/108590 + + I mistakenly disabled tests even though the fix was already + in. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::TEST): + +2012-02-22 Yuta Kitamura <yutak@chromium.org> + + [Chromium] Unreviewed. Disable two tests from CCOcclusionTrackerTest + which cause assertion failures. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore): + (WebCore::TEST): + +2012-02-22 Dana Jansens <danakj@chromium.org> + + [chromium] Fix CCOcclusionTracker unit test assertion + https://bugs.webkit.org/show_bug.cgi?id=79275 + + Reviewed by James Robinson. + + * tests/CCOcclusionTrackerTest.cpp: + (WebCore::TEST): + +2012-02-22 Ian Vollick <vollick@chromium.org> + + [chromium] Plumb from GraphicsLayer to the cc thread animation code + https://bugs.webkit.org/show_bug.cgi?id=75874 + + Reviewed by James Robinson. + + * WebKit.gypi: + * public/WebSettings.h: + * public/platform/WebLayerTreeView.h: + (WebKit::WebLayerTreeView::Settings::Settings): + (Settings): + * src/WebLayerTreeView.cpp: + (WebKit::WebLayerTreeView::Settings::operator CCSettings): + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setThreadedAnimationEnabled): + (WebKit): + * src/WebSettingsImpl.h: + (WebSettingsImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + * tests/CCActiveAnimationTest.cpp: + (WebCore::createActiveAnimation): + * tests/CCAnimationTestCommon.cpp: Added. + (WebKitTests): + (WebKitTests::FakeFloatAnimationCurve::FakeFloatAnimationCurve): + (WebKitTests::FakeFloatAnimationCurve::~FakeFloatAnimationCurve): + (WebKitTests::FakeFloatAnimationCurve::clone): + (WebKitTests::FakeTransformTransition::FakeTransformTransition): + (WebKitTests::FakeTransformTransition::~FakeTransformTransition): + (WebKitTests::FakeTransformTransition::getValue): + (WebKitTests::FakeTransformTransition::clone): + (WebKitTests::FakeFloatTransition::FakeFloatTransition): + (WebKitTests::FakeFloatTransition::~FakeFloatTransition): + (WebKitTests::FakeFloatTransition::getValue): + (WebKitTests::FakeLayerAnimationControllerImplClient::FakeLayerAnimationControllerImplClient): + (WebKitTests::FakeLayerAnimationControllerImplClient::~FakeLayerAnimationControllerImplClient): + (WebKitTests::FakeFloatTransition::clone): + (WebKitTests::addOpacityTransition): + * tests/CCAnimationTestCommon.h: Added. + (WebCore): + (WebKitTests): + (FakeFloatAnimationCurve): + (WebKitTests::FakeFloatAnimationCurve::duration): + (WebKitTests::FakeFloatAnimationCurve::getValue): + (FakeTransformTransition): + (WebKitTests::FakeTransformTransition::duration): + (FakeFloatTransition): + (WebKitTests::FakeFloatTransition::duration): + (FakeLayerAnimationControllerImplClient): + (WebKitTests::FakeLayerAnimationControllerImplClient::id): + (WebKitTests::FakeLayerAnimationControllerImplClient::opacity): + (WebKitTests::FakeLayerAnimationControllerImplClient::setOpacity): + (WebKitTests::FakeLayerAnimationControllerImplClient::transform): + (WebKitTests::FakeLayerAnimationControllerImplClient::setTransform): + (WebKitTests::FakeLayerAnimationControllerImplClient::bounds): + * tests/CCLayerAnimationControllerImplTest.cpp: + (WebKitTests::createActiveAnimation): + (WebKitTests::TEST): + * tests/CCLayerAnimationControllerTest.cpp: Added. + (WebKitTests): + (WebKitTests::createActiveAnimation): + (WebKitTests::TEST): + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::CCLayerTreeHostImplTest::postAnimationEventsToMainThreadOnImplThread): + * tests/CCLayerTreeHostTest.cpp: + (WTF::TestHooks::animateLayers): + (MockLayerTreeHostImpl): + (WTF::MockLayerTreeHostImpl::animateLayers): + (WTF::MockLayerTreeHost::create): + (WTF::MockLayerTreeHost::createLayerTreeHostImpl): + (WTF): + (MockLayerAnimationController): + (WTF::MockLayerAnimationController::create): + (WTF::MockLayerAnimationController::addAnimation): + (WTF::MockLayerTreeHostClient::scheduleComposite): + (WTF::CCLayerTreeHostTest::postAddAnimationToMainThread): + (CCLayerTreeHostTest): + (WTF::CCLayerTreeHostTest::dispatchAddAnimation): + (WTF::CCLayerTreeHostTest::doBeginTest): + (CCLayerTreeHostTestAddAnimation): + (WTF::CCLayerTreeHostTestAddAnimation::CCLayerTreeHostTestAddAnimation): + (WTF::CCLayerTreeHostTestAddAnimation::beginTest): + (WTF::CCLayerTreeHostTestAddAnimation::animateLayers): + (WTF::CCLayerTreeHostTestAddAnimation::afterTest): + (WTF::TEST_F): + * tests/TreeSynchronizerTest.cpp: + (FakeLayerAnimationController): + (WebKitTests::FakeLayerAnimationController::create): + (WebKitTests::FakeLayerAnimationController::synchronizedAnimations): + (WebKitTests::FakeLayerAnimationController::FakeLayerAnimationController): + (WebKitTests::FakeLayerAnimationController::synchronizeAnimations): + (WebKitTests): + (WebKitTests::TEST): + +2012-02-21 Ryosuke Niwa <rniwa@webkit.org> + + Remove the remaining uses of CSSStyleDeclaration in Editor + https://bugs.webkit.org/show_bug.cgi?id=78939 + + Reviewed by Enrica Casucci. + + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::shouldApplyStyle): + * src/EditorClientImpl.h: + (EditorClientImpl): + +2012-02-22 Daniel Cheng <dcheng@chromium.org> + + [chromium] Cleanup unused WebDragData methods after r107846 + https://bugs.webkit.org/show_bug.cgi?id=78837 + + Reviewed by Tony Chang. + + The deleted methods have been replaced by items() and setItems(). + + * public/platform/WebDragData.h: + (WebDragData): + * src/WebDragData.cpp: + (WebKit::WebDragData::addItem): Add ensureMutable() call to verify preconditions for + mutating the item store. + +2012-02-22 Tim Dresser <tdresser@chromium.org> + + CCLayerTreeHostImpl calls didDraw more frequently than willDraw + https://bugs.webkit.org/show_bug.cgi?id=79139 + + Reviewed by James Robinson. + + * tests/CCLayerTreeHostImplTest.cpp: + (WebKit::DidDrawCheckLayer::willDraw): + (DidDrawCheckLayer): + (WebKit::DidDrawCheckLayer::willDrawCalled): + (WebKit::DidDrawCheckLayer::DidDrawCheckLayer): + (WebKit::TEST_F): + (WebKit): + +2012-02-22 Dana Jansens <danakj@chromium.org> + + [Chromium] New CCOcclusionTracker class with tests + https://bugs.webkit.org/show_bug.cgi?id=78549 + + Reviewed by James Robinson. + + * WebKit.gypi: + * tests/CCLayerTreeHostCommonTest.cpp: + (WebCore): + * tests/CCOcclusionTrackerTest.cpp: Added. + (WebCore): + (WebCore::setLayerPropertiesForTesting): + (LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::drawsContent): + (TestCCOcclusionTracker): + (WebCore::TestCCOcclusionTracker::occlusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::occlusionInTargetSurface): + (WebCore::TestCCOcclusionTracker::setOcclusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::setOcclusionInTargetSurface): + (WebCore::TEST): + +2012-02-22 Hao Zheng <zhenghao@chromium.org> + + [chromium] Build WebKit with MEDIA_STREAM disabled. + https://bugs.webkit.org/show_bug.cgi?id=79214 + + Reviewed by Kent Tamura. + + * src/UserMediaClientImpl.h: + +2012-02-20 Roland Steiner <rolandsteiner@chromium.org> + + <style scoped>: Add runtime-flag + https://bugs.webkit.org/show_bug.cgi?id=79074 + + Added a runtime-flag. + Enable default STYLE_SCOPED compile-time flag for Chromium. + + Reviewed by Dimitri Glazkov. + + * features.gypi: enable STYLE_SCOPED + * public/WebRuntimeFeatures.h: + (WebRuntimeFeatures): + * src/WebRuntimeFeatures.cpp: + (WebKit::WebRuntimeFeatures::enableStyleScoped): + (WebKit): + (WebKit::WebRuntimeFeatures::isStyleScopedEnabled): + +2012-02-22 Yuta Kitamura <yutak@chromium.org> + + Unreviewed, rolling out r108453. + http://trac.webkit.org/changeset/108453 + https://bugs.webkit.org/show_bug.cgi?id=78549 + + Broke Chromium's webkit_unit_tests. + + * WebKit.gypi: + * tests/CCLayerTreeHostCommonTest.cpp: + (WebCore::TEST): + (WebCore): + * tests/CCOcclusionTrackerTest.cpp: Removed. + +2012-02-22 Ryosuke Niwa <rniwa@webkit.org> + + Remove the remaining uses of CSSStyleDeclaration in Editor + https://bugs.webkit.org/show_bug.cgi?id=78939 + + Reviewed by Enrica Casucci. + + * src/EditorClientImpl.cpp: + (WebKit::EditorClientImpl::shouldApplyStyle): + * src/EditorClientImpl.h: + (EditorClientImpl): + +2012-02-22 Dana Jansens <danakj@chromium.org> + + [chromium] Cull quads outside of the scissoring damage rect + https://bugs.webkit.org/show_bug.cgi?id=79181 + + Reviewed by James Robinson. + + * tests/CCQuadCullerTest.cpp: + (WebCore::TEST): + (WebCore): + +2012-02-21 Dana Jansens <danakj@chromium.org> + + [Chromium] New CCOcclusionTracker class with tests + https://bugs.webkit.org/show_bug.cgi?id=78549 + + Reviewed by James Robinson. + + * WebKit.gypi: + * tests/CCLayerTreeHostCommonTest.cpp: + (WebCore): + * tests/CCOcclusionTrackerTest.cpp: Added. + (WebCore): + (WebCore::setLayerPropertiesForTesting): + (LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::LayerChromiumWithForcedDrawsContent): + (WebCore::LayerChromiumWithForcedDrawsContent::drawsContent): + (TestCCOcclusionTracker): + (WebCore::TestCCOcclusionTracker::occlusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::occlusionInTargetSurface): + (WebCore::TestCCOcclusionTracker::setOcclusionInScreenSpace): + (WebCore::TestCCOcclusionTracker::setOcclusionInTargetSurface): + (WebCore::TEST): + +2012-02-21 MORITA Hajime <morrita@google.com> + + INPUT_SPEECH should be implemented as a PageSupplement. + https://bugs.webkit.org/show_bug.cgi?id=79051 + + Reviewed by Adam Barth. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + +2012-02-20 MORITA Hajime <morrita@google.com> + + MEDIA_STREAM should be implemented as a PageSupplement. + https://bugs.webkit.org/show_bug.cgi?id=79050 + + Reviewed by Adam Barth. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + +2012-02-21 Dana Jansens <danakj@chromium.org> + + [chromium] Painting a layer clears opaque rect in untouched tiles + https://bugs.webkit.org/show_bug.cgi?id=79157 + + Reviewed by James Robinson. + + * tests/TiledLayerChromiumTest.cpp: + (WTF::TEST): + +2012-02-21 James Robinson <jamesr@chromium.org> + + Enable ScrollingCoordinator in chromium whenever compositing is enabled + https://bugs.webkit.org/show_bug.cgi?id=79165 + + Reviewed by Adam Barth. + + * src/NonCompositedContentHost.cpp: + (WebKit::NonCompositedContentHost::setViewport): + Whenever the ScrollingCoordinator is enabled the scroll layer's position is expected to be updated + externally to RenderLayerCompositor, so set it here. + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setAcceleratedCompositingEnabled): + +2012-02-21 Daniel Cheng <dcheng@chromium.org> + + [chromium] Fix image drag out on Chromium + https://bugs.webkit.org/show_bug.cgi?id=79158 + + Reviewed by Tony Chang. + + We constructed the WebDragData::Item for dragging out an image but never added it to the + item list. This is normally covered by the fast/events/drag-image-filename.html layout test, + but the bug wasn't caught in the original patch since the implementations in Chrome and DRT + had diverged. + + * src/WebDragData.cpp: + (WebKit::WebDragData::items): + +2012-02-21 David Grogan <dgrogan@chromium.org> + + IndexedDB: webFrame isn't threadsafe, don't use it from a worker thread + https://bugs.webkit.org/show_bug.cgi?id=78659 + + After crrev.com/121669, indexed db doesn't use the web frame for + anything if called from a web worker. + + No new tests - this check was defensive and possibly not ever + triggered. + + Reviewed by Tony Chang. + + * src/IDBFactoryBackendProxy.cpp: + (WebKit::IDBFactoryBackendProxy::openFromWorker): + +2012-02-21 Yury Semikhatsky <yurys@chromium.org> + + [V8] Web Inspector: set breakpoint/pause doesn't work when worker is in a tight loop + https://bugs.webkit.org/show_bug.cgi?id=79097 + + Worker script execution will be interrupted for dispatching inspector commands. + + Reviewed by Pavel Feldman. + + * src/WebSharedWorkerImpl.cpp: + (WebKit::WebSharedWorkerImpl::dispatchDevToolsMessage): + +2012-02-20 Peter Beverloo <peter@chromium.org> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-20 Kenichi Ishibashi <bashi@chromium.org> + + [WebSocket] Add deflater/inflater classes + https://bugs.webkit.org/show_bug.cgi?id=78449 + + Add tests which ensure WebSocketDeflater/WebSocketInflater can + compress/decompress data correctly. + + Reviewed by Kent Tamura. + + * WebKit.gypi: Added zlib dependency. + * WebKitUnitTests.gyp: Ditto. + * tests/WebSocketDeflaterTest.cpp: Added. + (WebCore): + (WebCore::TEST): + +2012-02-17 Yury Semikhatsky <yurys@chromium.org> + + [Chromium] Web Inspector: terminated workers are not removed from dedicated worker list + https://bugs.webkit.org/show_bug.cgi?id=78899 + + Pass original WorkerContextProxy object to the inspector instrumentation instead + of Chromium-specific one for consistency with WorkerMessagingProxy implementation + in WebCore. + + Reviewed by Pavel Feldman. + + * src/WebWorkerClientImpl.cpp: + (WebKit::WebWorkerClientImpl::startWorkerContext): + +2012-02-18 raman Tenneti <rtenneti@chromium.org> + + Track the NPN protocol version negotiated with the server + https://bugs.webkit.org/show_bug.cgi?id=77349 + + Reviewed by Darin Fisher. + + [chromium] Added ExtraData to WebURLResponse. + + * WebKit.gypi: + * public/platform/WebURLResponse.h: + (ExtraData): + (WebKit::WebURLResponse::ExtraData::~ExtraData): + (WebURLResponse): + * src/WebURLResponse.cpp: + (WebKit::WebURLResponse::extraData): + (WebKit): + (WebKit::WebURLResponse::setExtraData): + * tests/WebURLResponseTest.cpp: Added. + (WebKit): + (TestExtraData): + (WebKit::TestExtraData::TestExtraData): + (WebKit::TestExtraData::~TestExtraData): + (WebKit::TEST): + +2012-02-17 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Support overloaded methods that take IDBKey or IDBKeyRange + https://bugs.webkit.org/show_bug.cgi?id=78399 + + Implements the WebKit API for IDBObjectStore.delete(IDBKeyRange), + to exercise the overload capability. + + Reviewed by Tony Chang. + + * src/IDBObjectStoreBackendProxy.cpp: + (WebKit::IDBObjectStoreBackendProxy::deleteFunction): + (WebKit): + * src/IDBObjectStoreBackendProxy.h: + (IDBObjectStoreBackendProxy): + * src/WebIDBObjectStoreImpl.cpp: + (WebKit::WebIDBObjectStoreImpl::deleteFunction): + (WebKit): + * src/WebIDBObjectStoreImpl.h: + (WebIDBObjectStoreImpl): + +2012-02-17 Michal Mocny <mmocny@google.com> + + [chromium] GL_CHROMIUM_gpu_memory_manager extension + https://bugs.webkit.org/show_bug.cgi?id=77155 + + Reviewed by James Robinson. + + * public/platform/WebGraphicsContext3D.h: + (WebGraphicsMemoryAllocationChangedCallbackCHROMIUM): + (WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM::~WebGraphicsMemoryAllocationChangedCallbackCHROMIUM): + (WebGraphicsContext3D): + (WebKit::WebGraphicsContext3D::setMemoryAllocationChangedCallbackCHROMIUM): + * src/Extensions3DChromium.cpp: + (WebCore::Extensions3DChromium::setGpuMemoryAllocationChangedCallbackCHROMIUM): + (WebCore): + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3D::~GraphicsContext3D): + (GraphicsContext3DMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::GraphicsContext3DMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::~GraphicsContext3DMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::onMemoryAllocationChanged): + (WebCore): + (WebCore::GraphicsContext3DPrivate::setGpuMemoryAllocationChangedCallbackCHROMIUM): + * src/GraphicsContext3DPrivate.h: + (WebCore): + * tests/FakeWebGraphicsContext3D.h: + (WebKit::FakeWebGraphicsContext3D::setMemoryAllocationChangedCallbackCHROMIUM): + (FakeWebGraphicsContext3D): + +2012-02-17 Mihnea Ovidenie <mihnea@adobe.com> + + CSS regions enabled by default + https://bugs.webkit.org/show_bug.cgi?id=78525 + + Reviewed by David Hyatt. + + Add a runtime preference to enable/disable regions functionality at runtime(WebKitCSSRegionsEnabled). + CSSRegions are still enabled by default. + In DRT, use layoutTestController.overridePreference("WebKitCSSRegionsEnabled", "0") to disable the css regions functionality. + + * public/WebSettings.h: + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setExperimentalCSSRegionsEnabled): + (WebKit): + * src/WebSettingsImpl.h: + (WebSettingsImpl): + +2012-02-17 Scott Graham <scottmg@chromium.org> + + [Chromium] pack Gamepad shared memory structure + https://bugs.webkit.org/show_bug.cgi?id=78022 + + Reviewed by Darin Fisher. + + Add #pragma pack around definition of shared memory structures to + avoid differences across compilers and platforms. Add COMPILE_ASSERT + to verify expected size. + + * public/platform/WebGamepad.h: + (WebKit): + * public/platform/WebGamepads.h: + (WebKit): + +2012-02-17 Tim Dresser <tdresser@chromium.org> + + [chromium] Refactor video drawing to be more data driven + https://bugs.webkit.org/show_bug.cgi?id=76720 + + Reviewed by James Robinson. + + CCLayerTreeHostImplTest.didDrawCalledOnAllLayers ensures that + CCLayerImpl::didDraw() is called on all layers, including layers + on different render surfaces. + + * tests/CCLayerTreeHostImplTest.cpp: + (DidDrawCheckLayer): + (WebKit::DidDrawCheckLayer::create): + (WebKit::DidDrawCheckLayer::didDraw): + (WebKit::DidDrawCheckLayer::didDrawCalled): + (WebKit::DidDrawCheckLayer::DidDrawCheckLayer): + (WebKit): + (WebKit::TEST_F): + +2012-02-17 Ilya Tikhonovsky <loislo@chromium.org> + + Unreviewed, rolling out r108071. + http://trac.webkit.org/changeset/108071 + https://bugs.webkit.org/show_bug.cgi?id=77155 + + chromium-mac compilation failed + + * public/platform/WebGraphicsContext3D.h: + (WebGraphicsContext3D): + * src/Extensions3DChromium.cpp: + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3D::~GraphicsContext3D): + * src/GraphicsContext3DPrivate.h: + (WebCore): + * tests/FakeWebGraphicsContext3D.h: + +2012-02-17 Michal Mocny <mmocny@google.com> + + [chromium] GL_CHROMIUM_gpu_memory_manager extension + https://bugs.webkit.org/show_bug.cgi?id=77155 + + Reviewed by James Robinson. + + * public/platform/WebGraphicsContext3D.h: + (WebGraphicsMemoryAllocationChangedCallbackCHROMIUM): + (WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM::~WebGraphicsMemoryAllocationChangedCallbackCHROMIUM): + (WebGraphicsContext3D): + (WebKit::WebGraphicsContext3D::setMemoryAllocationChangedCallbackCHROMIUM): + * src/Extensions3DChromium.cpp: + (WebCore::Extensions3DChromium::setGpuMemoryAllocationChangedCallbackCHROMIUM): + (WebCore): + * src/GraphicsContext3DChromium.cpp: + (WebCore::GraphicsContext3D::~GraphicsContext3D): + (GraphicsContext3DMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::GraphicsContext3DMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::~GraphicsContext3DMemoryAllocationChangedCallbackAdapter): + (WebCore::GraphicsContext3DMemoryAllocationChangedCallbackAdapter::onMemoryAllocationChanged): + (WebCore): + (WebCore::GraphicsContext3DPrivate::setGpuMemoryAllocationChangedCallbackCHROMIUM): + * src/GraphicsContext3DPrivate.h: + (WebCore): + * tests/FakeWebGraphicsContext3D.h: + (WebKit::FakeWebGraphicsContext3D::setMemoryAllocationChangedCallbackCHROMIUM): + (FakeWebGraphicsContext3D): + +2012-02-17 Ilya Tikhonovsky <loislo@chromium.org> + + Unreviewed. Chromium DEPS roll + + * DEPS: from 122122 to 122498 + +2012-02-16 Alexandre Elias <aelias@google.com> + + [chromium] Bundle page scale factor and limits in CCLayerTreeHost + https://bugs.webkit.org/show_bug.cgi?id=78762 + + Setting page scale factor and its limits in separate methods + may cause clamping bugs if one of them makes it to the + impl thread before the other. Change the API to bundle them together, + which matches the existing impl-side interface. + + Reviewed by James Robinson. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::computePageScaleFactorLimits): + (WebKit::WebViewImpl::setIsAcceleratedCompositingActive): + (WebKit::WebViewImpl::updateLayerTreeViewport): + * tests/CCLayerTreeHostTest.cpp: + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::applyScrollAndScale): + +2012-02-16 Varun Jain <varunjain@google.com> + + [Chromium] Add method to WebViewImpl to extract zoom/scroll params for gesture events on touch devices + https://bugs.webkit.org/show_bug.cgi?id=72909 + + Reviewed by James Robinson. + + * src/WebViewImpl.cpp: + (std): + (WebKit): + (WebKit::WebViewImpl::computeBlockBounds): + (WebKit::WebViewImpl::widenRectWithinPageBounds): + (WebKit::WebViewImpl::computeScaleAndScrollForHitRect): + * src/WebViewImpl.h: + (WebViewImpl): + * tests/WebFrameTest.cpp: + (WebKit): + (WebKit::TEST_F): + * tests/data/get_scale_for_auto_zoom_into_div_test.html: Added. + +2012-02-16 Sami Kyostila <skyostil@chromium.org> + + [chromium] LayerChromium::setNeedsDisplay does not apply contents scale correctly + https://bugs.webkit.org/show_bug.cgi?id=77464 + + Added a new unit test for TiledLayerChromium to verify its invalidation behavior when + the contents scale changes. Also enhance and existing unit test for LayerChromium to + verify the paint rectangle dimensions instead just checking that it is not empty. + + Reviewed by James Robinson. + + * tests/LayerChromiumTest.cpp: + * tests/TiledLayerChromiumTest.cpp: + (WTF::FakeTiledLayerChromium::setNeedsDisplayRect): + (FakeTiledLayerChromium): + (WTF::FakeTiledLayerChromium::lastNeedsDisplayRect): + (WTF::TEST): + (WTF): + +2012-02-16 MORITA Hajime <morrita@google.com> + + https://bugs.webkit.org/show_bug.cgi?id=78065 + [Chromium] Should eliminate WebTextCheckingResult legacy APIs + + Reviewed by Kent Tamura. + + Removed unused legacy members. + + * public/WebTextCheckingResult.h: + (WebKit::WebTextCheckingResult::WebTextCheckingResult): + (WebTextCheckingResult): + * src/AssertMatchingEnums.cpp: + +2012-02-16 Evan Martin <evan@chromium.org> + + [chromium] pull third_party/gold to fix linux build + https://bugs.webkit.org/show_bug.cgi?id=78842 + + Reviewed by Tony Chang. + + The Chrome build now depends on third_party/gold also being checked out. + + * DEPS: + +2012-02-15 Michael Nordman <michaeln@google.com> + + Fix bugs in the implementation of WebDatabase::closeDatabaseImmediately. + https://bugs.webkit.org/show_bug.cgi?id=78841 + + WebDatabase now delegates this function entirely to DatabaseTracker. + This is part of resolving http://crbug.com/98939 + + Reviewed by David Levin. + + * src/WebDatabase.cpp: + (WebKit::WebDatabase::closeDatabaseImmediately): + +2012-02-16 Dana Jansens <danakj@chromium.org> + + [Chromium] Occlusion tracking with CSS filters + https://bugs.webkit.org/show_bug.cgi?id=77498 + + Reviewed by James Robinson. + + * tests/CCLayerTreeHostTest.cpp: + (CCLayerTreeHostTestLayerOcclusionWithFilters): + (WTF::CCLayerTreeHostTestLayerOcclusionWithFilters::CCLayerTreeHostTestLayerOcclusionWithFilters): + (WTF::CCLayerTreeHostTestLayerOcclusionWithFilters::beginTest): + (WTF::CCLayerTreeHostTestLayerOcclusionWithFilters::afterTest): + (WTF): + +2012-02-16 Joshua Bell <jsbell@chromium.org> + + IndexedDB: Chromium WebKit API support for IDBObjectStore.delete(IDBKeyRange) + https://bugs.webkit.org/show_bug.cgi?id=78619 + + Add an overload to WebIDBObjectStore::deleteFunction(). First part of a two-sided patch. + + Reviewed by Darin Fisher. + + * public/WebIDBObjectStore.h: + (WebKit::WebIDBObjectStore::deleteFunction): + +2012-02-16 Dana Jansens <danakj@chromium.org> + + [chromium] Clipping/Transforms applied in wrong order in opaque paint tracking + https://bugs.webkit.org/show_bug.cgi?id=78775 + + Reviewed by Stephen White. + + * tests/PlatformContextSkiaTest.cpp: + (WebCore::TEST): + +2012-02-16 Daniel Cheng <dcheng@chromium.org> + + [chromium] Add WEBKIT_EXPORT to new WebDragData methods. + https://bugs.webkit.org/show_bug.cgi?id=78843 + + Reviewed by Tony Chang. + + * public/platform/WebDragData.h: + (WebDragData): + +2012-02-16 Viet-Trung Luu <viettrungluu@chromium.org> + + [chromium] Add method to WebPluginContainer to check if a rectangle is topmost + https://bugs.webkit.org/show_bug.cgi?id=78166 + + Reviewed by Darin Fisher. + + * public/WebPluginContainer.h: + (WebPluginContainer): + * src/WebPluginContainerImpl.cpp: + * src/WebPluginContainerImpl.h: + (WebPluginContainerImpl): + +2012-02-16 Yosifumi Inoue <yosin@chromium.org> + + Build Fix: R107894 breaks Chromium Linux Build. + https://bugs.webkit.org/show_bug.cgi?id=78790 + + WebDragDataPrivate::types, inherited from ChromiumDataObject, returns PassRef<DOMStringList> since r107894. However, WebDragData expected to get old return value type HashSet<String>. + + Reviewed by Kent Tamura. + + * src/WebDragData.cpp: + (WebKit::WebDragData::items): Use RefPtr<DOMStringList> rather than HashSet<String> for value of m_private->types(). + +2012-02-15 Sami Kyostila <skyostil@google.com> + + Enable -webkit-overflow-scrolling CSS property + https://bugs.webkit.org/show_bug.cgi?id=78664 + + Reviewed by Eric Seidel. + + * features.gypi: + +2012-02-15 Tommy Widenflycht <tommyw@google.com> + + MediaStream API: Removing SecurityContext from the embedder API + https://bugs.webkit.org/show_bug.cgi?id=73816 + + Reviewed by Darin Fisher. + + * bridge/PeerConnectionHandler.cpp: + (WebCore::PeerConnectionHandler::create): + (WebCore::PeerConnectionHandler::PeerConnectionHandler): + * bridge/PeerConnectionHandlerInternal.cpp: + (WebCore::PeerConnectionHandlerInternal::PeerConnectionHandlerInternal): + * bridge/PeerConnectionHandlerInternal.h: + (WebCore): + (PeerConnectionHandlerInternal): + * public/platform/WebPeerConnectionHandler.h: + (WebPeerConnectionHandler): + (WebKit::WebPeerConnectionHandler::initialize): + +2012-02-15 Peter Beverloo <peter@chromium.org> + + [Chromium] Roll DEPS to r122122 + https://bugs.webkit.org/show_bug.cgi?id=78754 + + Unreviewed DEPS roll. + + * DEPS: + +2012-02-01 Daniel Cheng <dcheng@chromium.org> + + [chromium] Add setter/getter to expose drag data as a list of items + https://bugs.webkit.org/show_bug.cgi?id=77125 + + This change supports the unification of the data store backing ChromiumDataObject and + DataTransferItemListChromium. ChromiumDataObject will represent dragging and clipboard data + as a list of data nodes to make it more straightforward to implement the HTML spec for + DataTransferItemList. Thus, we extend the abstraction to the webkit glue layer to + simplify the serialization/deserialization between platform-specific data and WebDragData. + The other setter/getter methods are deprecated and will be removed once the dependencies in + Chromium code are gone. + + Reviewed by Darin Fisher. + + * public/platform/WebDragData.h: + (WebKit): + (WebDragData): + * src/WebDragData.cpp: + (WebKit::WebDragData::items): + (WebKit): + (WebKit::WebDragData::setItems): + (WebKit::WebDragData::addItem): + +2012-02-15 Sadrul Habib Chowdhury <sadrul@chromium.org> + + Notify ChromeClient when touch-event handlers are installed/removed. + https://bugs.webkit.org/show_bug.cgi?id=77440 + + Reviewed by Darin Fisher and Ryosuke Niwa. + + * public/WebViewClient.h: + (WebKit::WebViewClient::numberOfTouchEventHandlersChanged): + * src/ChromeClientImpl.cpp: + (WebKit::ChromeClientImpl::numTouchEventHandlersChanged): + (WebKit): + * src/ChromeClientImpl.h: + (ChromeClientImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::numberOfTouchEventHandlersChanged): + (WebKit): + * src/WebViewImpl.h: + (WebViewImpl): + +2012-02-15 Anders Carlsson <andersca@apple.com> + + Remove ScrollableArea::handleGestureEvent + https://bugs.webkit.org/show_bug.cgi?id=78661 + + Reviewed by Adam Roben. + + Update for WebCore changes. + + * src/WebPluginContainerImpl.cpp: + * src/WebPluginContainerImpl.h: + (WebPluginContainerImpl): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::gestureEvent): + +2012-02-14 Takashi Toyoshima <toyoshim@chromium.org> + + Provide SocketStreamHandleInternal::toWebSocketStreamHandle(SocketStreamHandle*). + https://bugs.webkit.org/show_bug.cgi?id=78581 + + Reviewed by Kent Tamura. + + Now, there is no way to convert SocketStreamHandle to + WebSocketStreamHandle. In subsequent changes, I'll use this function + in FrameLoaderClientImpl. + + * src/SocketStreamHandle.cpp: Remove SocketStreamHandleInternal class declaration. + * src/SocketStreamHandleInternal.h: Move SocketStreamHandleInternal class declaration from SocketStreamHandle.cpp to expose, and add conversion function to WebSocketStreamHandle from SocketStreamHandle. + (WebKit): + (WebCore): + (SocketStreamHandleInternal): + (WebCore::SocketStreamHandleInternal::create): + (WebCore::SocketStreamHandleInternal::toWebSocketStreamHandle): + * WebKit.gyp: Add SocketStreamHandleInternal.h entry. + +2012-02-14 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r107766. + http://trac.webkit.org/changeset/107766 + https://bugs.webkit.org/show_bug.cgi?id=78665 + + Breaks Chromium Win build (Requested by bashi1 on #webkit). + + * WebKit.gypi: + * tests/WebSocketDeflaterTest.cpp: Removed. + +2012-02-14 Kenichi Ishibashi <bashi@chromium.org> + + [WebSocket] Add extension attribute support + https://bugs.webkit.org/show_bug.cgi?id=78557 + + Add WebSocketExtensionDispatcher::acceptedExtensions() checks. + + Reviewed by Kent Tamura. + + * tests/WebSocketExtensionDispatcherTest.cpp: + (WebCore::TEST_F): + +2012-02-14 Kenichi Ishibashi <bashi@chromium.org> + + [WebSocket] Add deflater/inflater classes. + https://bugs.webkit.org/show_bug.cgi?id=78449 + + Add tests which ensure WebSocketDeflater/WebSocketInflater can + compress/decompress data correctly. + + Reviewed by Kent Tamura. + + * WebKit.gypi: + * tests/WebSocketDeflaterTest.cpp: Added. + (WebCore): + (WebCore::TEST): + +2012-02-14 Dana Jansens <danakj@chromium.org> + + [chromium] Compare filters on impl thread when setting them, and test setting in unit tests + https://bugs.webkit.org/show_bug.cgi?id=78643 + + Reviewed by James Robinson. + + * tests/CCLayerImplTest.cpp: + (WebCore::TEST): + +2012-02-14 Ramya Chandrasekaran <cramya@google.com> + + Last character display for passwords in Android. + https://bugs.webkit.org/show_bug.cgi?id=78532 + + Reviewed by Adam Barth. + + * public/WebSettings.h: + * src/WebSettingsImpl.cpp: + (WebKit::WebSettingsImpl::setPasswordEchoEnabled): + (WebKit): + (WebKit::WebSettingsImpl::setPasswordEchoDurationInSeconds): + * src/WebSettingsImpl.h: + (WebSettingsImpl): + +2012-02-14 David Reveman <reveman@chromium.org> + + [Chromium] Expose perTilePainting setting through WebLayerTreeView::Settings interface. + https://bugs.webkit.org/show_bug.cgi?id=76937 + + Reviewed by James Robinson. + + Add perTilePainting to WebLayerTreeView::Settings. + + * public/platform/WebLayerTreeView.h: + (WebKit::WebLayerTreeView::Settings::Settings): + (Settings): + * src/WebLayerTreeView.cpp: + (WebKit::WebLayerTreeView::Settings::operator CCSettings): + +2012-02-14 Vsevolod Vlasov <vsevik@chromium.org> + + Web Inspector: Make ScriptsNavigator default file selector. + https://bugs.webkit.org/show_bug.cgi?id=78349 + + Reviewed by Pavel Feldman. + + * src/js/Tests.js: + (.TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch.checkNoDuplicates): + (.TestSuite.prototype.uiSourceCodesToString_): + (.TestSuite.prototype.nonAnonymousUISourceCodes_): + (.TestSuite.prototype._scriptsAreParsed): + (.TestSuite.prototype._waitUntilScriptsAreParsed.waitForAllScripts): + (.TestSuite.prototype._waitUntilScriptsAreParsed): + +2012-02-14 Hayato Ito <hayato@chromium.org> + + Make ShadowRoot.nodeType return DOCUMENT_FRAGMENT_NODE. + https://bugs.webkit.org/show_bug.cgi?id=77514 + + Reviewed by Dimitri Glazkov. + + NodeType.SHADOW_ROOT_NODE type is finally gone. + + * src/WebPageSerializerImpl.cpp: + (WebKit::WebPageSerializerImpl::buildContentForNode): + +2012-02-14 David Reveman <reveman@chromium.org> + + [Chromium] Inconsistent initialization of CCSettings in WebLayerTreeView. + https://bugs.webkit.org/show_bug.cgi?id=76927 + + Reviewed by James Robinson. + + Remove unnecessary initialization and include maxPartialTextureUpdates + in FIXME comment. + + * src/WebLayerTreeView.cpp: + (WebKit::WebLayerTreeView::Settings::operator CCSettings): + +2012-02-14 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed, rolling out r107661. + http://trac.webkit.org/changeset/107661 + https://bugs.webkit.org/show_bug.cgi?id=78591 + + crash on lion/qt bots (Requested by hayato on #webkit). + + * src/WebPageSerializerImpl.cpp: + (WebKit::WebPageSerializerImpl::buildContentForNode): + +2012-02-14 Yuzhu Shen <yzshen@chromium.com> + + [chromium] Pepper plugins don't receive mouse movement information in + non-mouse-lock mode. + https://bugs.webkit.org/show_bug.cgi?id=78014 + + This change makes WebMouseEventBuilder pass along mouse movement + information properly. + + There isn't test for this change because: + - the movement information added is only used by pepper, and there + isn't any test for pepper at the WebKit side. (WebKit doesn't know + about pepper.) + - this change is trivial. It just copies two newly-added data fields + from MouseEvent to WebMouseEventBuilder during conversion. + + Reviewed by Tony Chang. + + * src/WebInputEventConversion.cpp: + (WebKit::WebMouseEventBuilder::WebMouseEventBuilder): + +2012-02-11 Nikolas Zimmermann <nzimmermann@rim.com> + + Convert svg/animations to use SMIL methods for driving the timeline + https://bugs.webkit.org/show_bug.cgi?id=78422 + + Reviewed by Dirk Schulze. + + Remove SVG animation sampling functionality provided for DRT, which no longer uses it. + Instead we switched the svg/animations tests to use SVGSVGElement.setCurrentTime. + + * public/WebFrame.h: + (WebFrame): + * src/WebFrameImpl.cpp: + * src/WebFrameImpl.h: + (WebFrameImpl): + +2012-02-13 Mihai Parparita <mihaip@chromium.org> + + [Chromium] Remove BoundObject + https://bugs.webkit.org/show_bug.cgi?id=78531 + + Reviewed by Pavel Feldman. + + Remove the BoundObject class, references to it were removed in r56999. + + * WebKit.gyp: + * src/BoundObject.cpp: Removed. + * src/BoundObject.h: Removed. + * src/WebDevToolsFrontendImpl.cpp: + +2012-02-13 W. James MacLean <wjmaclean@chromium.org> + + [chromium] Remove obsolete zoom animation pathway. + https://bugs.webkit.org/show_bug.cgi?id=78359 + + Reviewed by James Robinson. + + This patch removes dead code from the previous incarnation of zoom animation for chromium. + + * src/WebViewImpl.cpp: + +2012-02-13 Hayato Ito <hayato@chromium.org> + + Make ShadowRoot.nodeType return DOCUMENT_FRAGMENT_NODE. + https://bugs.webkit.org/show_bug.cgi?id=77514 + + Reviewed by Dimitri Glazkov. + + NodeType.SHADOW_ROOT_NODE type is finally gone. + + * src/WebPageSerializerImpl.cpp: + (WebKit::WebPageSerializerImpl::buildContentForNode): + +2012-02-13 Nico Weber <thakis@chromium.org> + + [chromium] Let WebKit::initialize call InitWebCoreSystemInterface on mac. + https://bugs.webkit.org/show_bug.cgi?id=78246 + + This allows removing a bunch of code in chromium land (https://chromiumcodereview.appspot.com/9374020/), + and helps with the component build on mac (InitWebCoreSystemInterface is not an + exported function, and it shouldn't be). + + Source/WebKit/mac/WebCoreSupport/WebSystemInterface.mm early-returns when it's + called twice, so it's safe to land this change, and remove the calls in client + code in a later CL. + + Reviewed by Darin Fisher. + + * src/WebKit.cpp: + (WebKit::initializeWithoutV8): + +2012-02-13 Yosifumi Inoue <yosin@chromium.org> + + [Forms] Use enum instead of bool for HTMLInputElement::setValue + https://bugs.webkit.org/show_bug.cgi?id=75217 + + Reviewed by Kent Tamura. + + * src/WebInputElement.cpp: + (WebKit::WebInputElement::setValue): Use enum for HTMLInputElement::setValue + +2012-02-12 Hajime Morrita <morrita@chromium.org> + + Page should have less intrusive way to associate API implementation objects. + https://bugs.webkit.org/show_bug.cgi?id=78085 + + Reviewed by Adam Barth. + + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::WebViewImpl): + +2012-02-10 David Grogan <dgrogan@chromium.org> + + Disable IndexedDB permissions check from shared workers + https://bugs.webkit.org/show_bug.cgi?id=78316 + + We want to temporarily bypass this check because it causes a crash + when called from a shared worker. We'll have to fix it before + including idb on shared workers in a release but don't want to stop + developers from testing out idb on shared workers. + + No new tests because it affects shared workers only, which aren't + testable by DRT. + + Reviewed by Tony Chang. + + * src/IDBFactoryBackendProxy.cpp: + (WebKit::IDBFactoryBackendProxy::allowIDBFromWorkerThread): + +2012-02-10 Sheriff Bot <webkit.review.bot@gmail.com> + + Unreviewed. Rolled DEPS. + + * DEPS: + +2012-02-09 Kenichi Ishibashi <bashi@chromium.org> + + Add WebSocket extension support + https://bugs.webkit.org/show_bug.cgi?id=78079 + + Add some tests which check WebSocketExtensions::processHeaderValue() + parses the given response correctly. + + Reviewed by Kent Tamura. + + * WebKit.gypi: + * tests/WebSocketExtensionDispatcherTest.cpp: Added. + (WebCore): + (MockWebSocketExtensionProcessor): + (WebCore::MockWebSocketExtensionProcessor::MockWebSocketExtensionProcessor): + (WebSocketExtensionDispatcherTest): + (WebCore::WebSocketExtensionDispatcherTest::WebSocketExtensionDispatcherTest): + (WebCore::WebSocketExtensionDispatcherTest::SetUp): + (WebCore::WebSocketExtensionDispatcherTest::TearDown): + (WebCore::WebSocketExtensionDispatcherTest::addMockProcessor): + (WebCore::WebSocketExtensionDispatcherTest::appendResult): + (WebCore::MockWebSocketExtensionProcessor::processResponse): + (WebCore::TEST_F): + +2012-02-09 W. James MacLean <wjmaclean@chromium.org> + + [chromium] Add support for starting page/scale animations on CC impl thread from WebViewImpl + https://bugs.webkit.org/show_bug.cgi?id=77872 + + Reviewed by James Robinson. + + Provides a pathway to invoke CCLayerTreeHostImpl::startPageScaleAnimation() from + WebViewImpl. This is intended to support scale and scroll animations, such as WebInputEvent::GestureDoubleTap. + + * src/WebViewImpl.cpp: + (WebKit): + (WebKit::WebViewImpl::startPageScaleAnimation): + * src/WebViewImpl.h: + (WebViewImpl): + * tests/CCLayerTreeHostTest.cpp: + (WTF): + (CCLayerTreeHostTestStartPageScaleAnimation): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::CCLayerTreeHostTestStartPageScaleAnimation): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::beginTest): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::requestStartPageScaleAnimation): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::drawLayersOnCCThread): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::applyScrollAndScale): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::commitCompleteOnCCThread): + (WTF::CCLayerTreeHostTestStartPageScaleAnimation::afterTest): + (WTF::TEST_F): + +2012-02-09 John Bates <jbates@google.com> + + [Chromium] Add chromium-style tracing support + https://bugs.webkit.org/show_bug.cgi?id=76885 + + Reviewed by Darin Fisher. + + This code enables WebKit trace events to pass through more data to the + chromium platform tracing API and generally to use the full tracing + API provided by chromium. + + * public/platform/WebKitPlatformSupport.h: + (WebKit::WebKitPlatformSupport::getTraceCategoryEnabledFlag): + (WebKit::WebKitPlatformSupport::addTraceEvent): + * src/PlatformSupport.cpp: + (WebCore::PlatformSupport::getTraceCategoryEnabledFlag): + (WebCore::PlatformSupport::addTraceEvent): + +2012-02-09 Jonathan Backer <backer@chromium.org> + + [chromium] Plumb setNeedsRedraw. + https://bugs.webkit.org/show_bug.cgi?id=78248 + + Reviewed by James Robinson. + + * public/platform/WebLayerTreeView.h: + (WebLayerTreeView): + * src/WebLayerTreeView.cpp: + (WebKit::WebLayerTreeView::setNeedsRedraw): + (WebKit): + +2012-02-09 Jonathan Backer <backer@chromium.org> + + [chromium] Add setNeedsRedraw to WebWidget + https://bugs.webkit.org/show_bug.cgi?id=77555 + + Reviewed by James Robinson. + + * public/WebWidget.h: + (WebWidget): + (WebKit::WebWidget::setNeedsRedraw): + * src/WebViewImpl.cpp: + (WebKit::WebViewImpl::setNeedsRedraw): + (WebKit): + * src/WebViewImpl.h: + (WebViewImpl): + 2012-02-08 Raymond Liu <raymond.liu@intel.com> Fix a typo for r107125 diff --git a/Source/WebKit/chromium/DEPS b/Source/WebKit/chromium/DEPS index 2e0adf6f0..ba422445c 100644 --- a/Source/WebKit/chromium/DEPS +++ b/Source/WebKit/chromium/DEPS @@ -32,7 +32,7 @@ vars = { 'chromium_svn': 'http://src.chromium.org/svn/trunk/src', - 'chromium_rev': '121041' + 'chromium_rev': '123353' } deps = { @@ -163,6 +163,8 @@ deps_os = { # Linux, actually. 'tools/xdisplaycheck': Var('chromium_svn')+'/tools/xdisplaycheck@'+Var('chromium_rev'), + 'third_party/gold': + From('chromium_deps', 'src/third_party/gold'), 'third_party/openssl': From('chromium_deps', 'src/third_party/openssl'), }, diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp index 12ac1ab22..f8e58b383 100644 --- a/Source/WebKit/chromium/WebKit.gyp +++ b/Source/WebKit/chromium/WebKit.gyp @@ -232,6 +232,7 @@ 'public/WebReferrerPolicy.h', 'public/WebRegularExpression.h', 'public/WebRuntimeFeatures.h', + 'public/WebScopedUserGesture.h', 'public/WebScreenInfo.h', 'public/WebScriptController.h', 'public/WebScriptSource.h', @@ -256,6 +257,7 @@ 'public/WebStorageNamespace.h', 'public/WebStorageQuotaCallbacks.h', 'public/WebStorageQuotaType.h', + 'public/WebStreamTextureClient.h', 'public/WebTextAffinity.h', 'public/WebTextCaseSensitivity.h', 'public/WebTextCheckingCompletion.h', @@ -372,8 +374,6 @@ 'src/BackForwardListChromium.h', 'src/BlobRegistryProxy.cpp', 'src/BlobRegistryProxy.h', - 'src/BoundObject.cpp', - 'src/BoundObject.h', 'src/CCThreadImpl.cpp', 'src/CCThreadImpl.h', 'src/ChromeClientImpl.cpp', @@ -465,6 +465,7 @@ 'src/ScrollbarGroup.h', 'src/SharedWorkerRepository.cpp', 'src/SocketStreamHandle.cpp', + 'src/SocketStreamHandleInternal.h', 'src/SpeechInputClientImpl.cpp', 'src/SpeechInputClientImpl.h', 'src/StorageAreaProxy.cpp', @@ -633,6 +634,7 @@ 'src/WebRange.cpp', 'src/WebRegularExpression.cpp', 'src/WebRuntimeFeatures.cpp', + 'src/WebScopedUserGesture.cpp', 'src/WebScriptController.cpp', 'src/WebScrollbarImpl.cpp', 'src/WebScrollbarImpl.h', @@ -668,6 +670,7 @@ 'src/WebURLResponse.cpp', 'src/WebURLResponsePrivate.h', 'src/WebURLError.cpp', + 'src/WebScopedUserGesture.cpp', 'src/WebUserMediaRequest.cpp', 'src/WebViewImpl.cpp', 'src/WebViewImpl.h', diff --git a/Source/WebKit/chromium/WebKit.gypi b/Source/WebKit/chromium/WebKit.gypi index c8502f573..e91e336db 100644 --- a/Source/WebKit/chromium/WebKit.gypi +++ b/Source/WebKit/chromium/WebKit.gypi @@ -61,10 +61,14 @@ 'tests/AssociatedURLLoaderTest.cpp', 'tests/Canvas2DLayerChromiumTest.cpp', 'tests/CCActiveAnimationTest.cpp', + 'tests/CCAnimationTestCommon.cpp', + 'tests/CCAnimationTestCommon.h', 'tests/CCDamageTrackerTest.cpp', 'tests/CCDelayBasedTimeSourceTest.cpp', 'tests/CCFrameRateControllerTest.cpp', + 'tests/CCKeyframedAnimationCurveTest.cpp', 'tests/CCLayerAnimationControllerImplTest.cpp', + 'tests/CCLayerAnimationControllerTest.cpp', 'tests/CCLayerImplTest.cpp', 'tests/CCLayerIteratorTest.cpp', 'tests/CCLayerQuadTest.cpp', @@ -75,6 +79,7 @@ 'tests/CCLayerTreeHostImplTest.cpp', 'tests/CCLayerTreeHostTest.cpp', 'tests/CCLayerTreeTestCommon.h', + 'tests/CCOcclusionTrackerTest.cpp', 'tests/CCQuadCullerTest.cpp', 'tests/CCRenderSurfaceTest.cpp', 'tests/CCSchedulerStateMachineTest.cpp', @@ -118,7 +123,10 @@ 'tests/WebLayerTest.cpp', 'tests/WebPageNewSerializerTest.cpp', 'tests/WebPageSerializerTest.cpp', + 'tests/WebSocketDeflaterTest.cpp', + 'tests/WebSocketExtensionDispatcherTest.cpp', 'tests/WebURLRequestTest.cpp', + 'tests/WebURLResponseTest.cpp', 'tests/WebViewTest.cpp', ], diff --git a/Source/WebKit/chromium/WebKitUnitTests.gyp b/Source/WebKit/chromium/WebKitUnitTests.gyp index 5a98a8459..d50ad1523 100644 --- a/Source/WebKit/chromium/WebKitUnitTests.gyp +++ b/Source/WebKit/chromium/WebKitUnitTests.gyp @@ -61,6 +61,7 @@ '<(chromium_src_dir)/base/base.gyp:base', '<(chromium_src_dir)/base/base.gyp:base_i18n', '<(chromium_src_dir)/base/base.gyp:test_support_base', + '<(chromium_src_dir)/third_party/zlib/zlib.gyp:zlib', '<(chromium_src_dir)/webkit/support/webkit_support.gyp:webkit_support', '<(chromium_src_dir)/webkit/support/webkit_support.gyp:webkit_user_agent', ], diff --git a/Source/WebKit/chromium/bridge/PeerConnectionHandler.cpp b/Source/WebKit/chromium/bridge/PeerConnectionHandler.cpp index e9bd9e82d..c59b2d46c 100644 --- a/Source/WebKit/chromium/bridge/PeerConnectionHandler.cpp +++ b/Source/WebKit/chromium/bridge/PeerConnectionHandler.cpp @@ -36,17 +36,16 @@ #include "PeerConnectionHandlerClient.h" #include "PeerConnectionHandlerInternal.h" -#include "SecurityOrigin.h" namespace WebCore { -PassOwnPtr<PeerConnectionHandler> PeerConnectionHandler::create(PeerConnectionHandlerClient* client, const String& serverConfiguration, PassRefPtr<SecurityOrigin> securityOrigin) +PassOwnPtr<PeerConnectionHandler> PeerConnectionHandler::create(PeerConnectionHandlerClient* client, const String& serverConfiguration, const String& username) { - return adoptPtr(new PeerConnectionHandler(client, serverConfiguration, securityOrigin)); + return adoptPtr(new PeerConnectionHandler(client, serverConfiguration, username)); } -PeerConnectionHandler::PeerConnectionHandler(PeerConnectionHandlerClient* client, const String& serverConfiguration, PassRefPtr<SecurityOrigin> securityOrigin) - : m_private(adoptPtr(new PeerConnectionHandlerInternal(client, serverConfiguration, securityOrigin))) +PeerConnectionHandler::PeerConnectionHandler(PeerConnectionHandlerClient* client, const String& serverConfiguration, const String& username) + : m_private(adoptPtr(new PeerConnectionHandlerInternal(client, serverConfiguration, username))) { } diff --git a/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.cpp b/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.cpp index cfc33584a..d8f61f7f0 100644 --- a/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.cpp +++ b/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.cpp @@ -45,15 +45,21 @@ namespace WebCore { -PeerConnectionHandlerInternal::PeerConnectionHandlerInternal(PeerConnectionHandlerClient* client, const String& serverConfiguration, PassRefPtr<SecurityOrigin> securityOrigin) +PeerConnectionHandlerInternal::PeerConnectionHandlerInternal(PeerConnectionHandlerClient* client, const String& serverConfiguration, const String& username) : m_client(client) { ASSERT(m_client); m_webHandler = adoptPtr(WebKit::webKitPlatformSupport()->createPeerConnectionHandler(this)); // FIXME: When there is some error reporting avaliable in the PeerConnection object report // if we didn't get a WebPeerConnectionHandler instance. - if (m_webHandler) - m_webHandler->initialize(serverConfiguration, securityOrigin); + + if (m_webHandler) { + // Dual calls due to API change + m_webHandler->initialize(serverConfiguration, username); + + // DEPRECATED + m_webHandler->initialize(serverConfiguration, SecurityOrigin::createFromString(username)); + } } PeerConnectionHandlerInternal::~PeerConnectionHandlerInternal() diff --git a/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.h b/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.h index a3e79e0ac..e17fd96b5 100644 --- a/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.h +++ b/Source/WebKit/chromium/bridge/PeerConnectionHandlerInternal.h @@ -48,11 +48,10 @@ class WebMediaStreamDescriptor; namespace WebCore { class PeerConnectionHandlerClient; -class SecurityOrigin; class PeerConnectionHandlerInternal : public WebKit::WebPeerConnectionHandlerClient { public: - PeerConnectionHandlerInternal(PeerConnectionHandlerClient*, const String& serverConfiguration, PassRefPtr<SecurityOrigin>); + PeerConnectionHandlerInternal(PeerConnectionHandlerClient*, const String& serverConfiguration, const String& username); ~PeerConnectionHandlerInternal(); virtual void produceInitialOffer(const MediaStreamDescriptorVector& pendingAddStreams); diff --git a/Source/WebKit/chromium/features.gypi b/Source/WebKit/chromium/features.gypi index 4cca26795..4c46d4de4 100644 --- a/Source/WebKit/chromium/features.gypi +++ b/Source/WebKit/chromium/features.gypi @@ -73,6 +73,7 @@ 'ENABLE_MUTATION_OBSERVERS=<(enable_mutation_observers)', 'ENABLE_NOTIFICATIONS=1', 'ENABLE_ORIENTATION_EVENTS=0', + 'ENABLE_OVERFLOW_SCROLLING=1', 'ENABLE_PAGE_VISIBILITY_API=1', 'ENABLE_POINTER_LOCK=1', 'ENABLE_PROGRESS_TAG=1', @@ -84,7 +85,7 @@ 'ENABLE_SHARED_WORKERS=1', 'ENABLE_SMOOTH_SCROLLING=1', 'ENABLE_SQL_DATABASE=1', - 'ENABLE_STYLE_SCOPED=0', + 'ENABLE_STYLE_SCOPED=1', 'ENABLE_SVG=<(enable_svg)', 'ENABLE_SVG_FONTS=<(enable_svg)', 'ENABLE_TOUCH_EVENTS=<(enable_touch_events)', diff --git a/Source/WebKit/chromium/public/WebFrame.h b/Source/WebKit/chromium/public/WebFrame.h index 9574c490e..0d5406d52 100644 --- a/Source/WebKit/chromium/public/WebFrame.h +++ b/Source/WebKit/chromium/public/WebFrame.h @@ -624,12 +624,6 @@ public: // Returns true if selection.anchorNode has a marker on range from |from| with |length|. virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const = 0; - // Pauses and samples an SVG animation. Returns false if there's no svg - // animation to pause. This is only for testing. - virtual bool pauseSVGAnimation(const WebString& animationId, - double time, - const WebString& elementId) = 0; - // Dumps the layer tree, used by the accelerated compositor, in // text form. This is used only by layout tests. virtual WebString layerTreeAsText(bool showDebugInfo = false) const = 0; diff --git a/Source/WebKit/chromium/public/WebIDBObjectStore.h b/Source/WebKit/chromium/public/WebIDBObjectStore.h index 6bd51f419..981f5ec7e 100644 --- a/Source/WebKit/chromium/public/WebIDBObjectStore.h +++ b/Source/WebKit/chromium/public/WebIDBObjectStore.h @@ -69,6 +69,7 @@ public: virtual void put(const WebSerializedScriptValue&, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } virtual void deleteFunction(const WebIDBKey&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } + virtual void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } virtual void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&) { WEBKIT_ASSERT_NOT_REACHED(); } virtual WebIDBIndex* createIndex(const WebString& name, const WebString& keyPath, bool unique, bool multiEntry, const WebIDBTransaction& transaction, WebExceptionCode& ec) { diff --git a/Source/WebKit/chromium/public/WebMediaPlayer.h b/Source/WebKit/chromium/public/WebMediaPlayer.h index 9aaf1a3d0..239134963 100644 --- a/Source/WebKit/chromium/public/WebMediaPlayer.h +++ b/Source/WebKit/chromium/public/WebMediaPlayer.h @@ -40,6 +40,7 @@ namespace WebKit { class WebAudioSourceProvider; class WebAudioSourceProviderClient; class WebMediaPlayerClient; +class WebStreamTextureClient; class WebURL; struct WebRect; struct WebSize; @@ -162,6 +163,8 @@ public: // method should no longer be referenced after the call is made. virtual void putCurrentFrame(WebVideoFrame*) { } + virtual void setStreamTextureClient(WebStreamTextureClient*) { } + virtual WebAudioSourceProvider* audioSourceProvider() { return 0; } virtual bool sourceAppend(const unsigned char* data, unsigned length) { return false; } diff --git a/Source/WebKit/chromium/public/WebPluginContainer.h b/Source/WebKit/chromium/public/WebPluginContainer.h index 122c4c8df..845cb1a28 100644 --- a/Source/WebKit/chromium/public/WebPluginContainer.h +++ b/Source/WebKit/chromium/public/WebPluginContainer.h @@ -100,6 +100,10 @@ public: // Notifies that the zoom level has changed. virtual void zoomLevelChanged(double zoomLevel) = 0; + // Determines whether the given rectangle in this plugin is above all other + // content. The rectangle is in the plugin's coordinate system. + virtual bool isRectTopmost(const WebRect&) = 0; + virtual WebPlugin* plugin() = 0; virtual void setPlugin(WebPlugin*) = 0; diff --git a/Source/WebKit/chromium/public/WebRuntimeFeatures.h b/Source/WebKit/chromium/public/WebRuntimeFeatures.h index 7e29ab0db..34e3947f6 100644 --- a/Source/WebKit/chromium/public/WebRuntimeFeatures.h +++ b/Source/WebKit/chromium/public/WebRuntimeFeatures.h @@ -124,6 +124,9 @@ public: WEBKIT_EXPORT static void enableShadowDOM(bool); WEBKIT_EXPORT static bool isShadowDOMEnabled(); + WEBKIT_EXPORT static void enableStyleScoped(bool); + WEBKIT_EXPORT static bool isStyleScopedEnabled(); + private: WebRuntimeFeatures(); }; diff --git a/Source/WebKit/chromium/src/BoundObject.h b/Source/WebKit/chromium/public/WebScopedUserGesture.h index 394ff7c9e..14798f153 100644 --- a/Source/WebKit/chromium/src/BoundObject.h +++ b/Source/WebKit/chromium/public/WebScopedUserGesture.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Google Inc. All rights reserved. + * Copyright (C) 2011 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -28,34 +28,33 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef BoundObject_h -#define BoundObject_h +#ifndef WebScopedUserGesture_h +#define WebScopedUserGesture_h -#include <v8.h> -#include <wtf/Noncopyable.h> +#include "platform/WebPrivateOwnPtr.h" + +namespace WebCore { +class UserGestureIndicator; +} namespace WebKit { -// BoundObject is a helper class that lets you map JavaScript method calls -// directly to C++ method calls. It should be destroyed once JS object is -// built. -class BoundObject { - WTF_MAKE_NONCOPYABLE(BoundObject); +// An instance of this class, while kept alive, will indicate that we are in +// the context of a known user gesture. To use, create one, perform whatever +// actions were done under color of a known user gesture, and then delete it. +// Usually this will be done on the stack. +class WebScopedUserGesture { public: - BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName); - virtual ~BoundObject(); - - void addProtoFunction(const char* name, v8::InvocationCallback callback); - void build(); + WebScopedUserGesture() { initialize(); } + ~WebScopedUserGesture() { reset(); } private: - v8::HandleScope m_handleScope; - const char* m_objectName; - v8::Handle<v8::Context> m_context; - v8::Persistent<v8::FunctionTemplate> m_hostTemplate; - void* m_v8This; + WEBKIT_EXPORT void initialize(); + WEBKIT_EXPORT void reset(); + + WebPrivateOwnPtr<WebCore::UserGestureIndicator> m_indicator; }; } // namespace WebKit -#endif +#endif // WebScopedUserGesture_h diff --git a/Source/WebKit/chromium/public/WebSettings.h b/Source/WebKit/chromium/public/WebSettings.h index 25ac07523..7f1bbb0c4 100644 --- a/Source/WebKit/chromium/public/WebSettings.h +++ b/Source/WebKit/chromium/public/WebSettings.h @@ -96,6 +96,7 @@ public: virtual void setOfflineWebApplicationCacheEnabled(bool) = 0; virtual void setWebAudioEnabled(bool) = 0; virtual void setExperimentalWebGLEnabled(bool) = 0; + virtual void setExperimentalCSSRegionsEnabled(bool) = 0; virtual void setOpenGLMultisamplingEnabled(bool) = 0; virtual void setPrivilegedWebGLExtensionsEnabled(bool) = 0; virtual void setWebGLErrorsToConsoleEnabled(bool) = 0; @@ -132,6 +133,8 @@ public: virtual void setFullScreenEnabled(bool) = 0; virtual void setAllowDisplayOfInsecureContent(bool) = 0; virtual void setAllowRunningOfInsecureContent(bool) = 0; + virtual void setPasswordEchoEnabled(bool) = 0; + virtual void setPasswordEchoDurationInSeconds(double) = 0; virtual void setShouldPrintBackgrounds(bool) = 0; virtual void setEnableScrollAnimator(bool) = 0; virtual void setHixie76WebSocketProtocolEnabled(bool) = 0; @@ -139,6 +142,7 @@ public: virtual void setAcceleratedPaintingEnabled(bool) = 0; virtual void setPerTilePaintingEnabled(bool) = 0; virtual void setPartialSwapEnabled(bool) = 0; + virtual void setThreadedAnimationEnabled(bool) = 0; protected: ~WebSettings() { } diff --git a/Source/WebKit/chromium/public/WebStreamTextureClient.h b/Source/WebKit/chromium/public/WebStreamTextureClient.h new file mode 100644 index 000000000..81002fb26 --- /dev/null +++ b/Source/WebKit/chromium/public/WebStreamTextureClient.h @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef WebStreamTextureClient_h +#define WebStreamTextureClient_h + +namespace WebKit { + +class WebStreamTextureClient { +public: + virtual void didReceiveFrame() = 0; + virtual void didUpdateMatrix(const float*) = 0; + +protected: + virtual ~WebStreamTextureClient() { } +}; + +} // namespace WebKit + +#endif diff --git a/Source/WebKit/chromium/public/WebTextCheckingResult.h b/Source/WebKit/chromium/public/WebTextCheckingResult.h index 8d0a745cc..e46f48cdc 100644 --- a/Source/WebKit/chromium/public/WebTextCheckingResult.h +++ b/Source/WebKit/chromium/public/WebTextCheckingResult.h @@ -34,7 +34,6 @@ #include "WebTextCheckingType.h" #include "platform/WebCommon.h" #include "platform/WebString.h" -#include "platform/WebVector.h" namespace WebCore { struct TextCheckingResult; @@ -44,50 +43,19 @@ namespace WebKit { // A checked entry of text checking. struct WebTextCheckingResult { - // FIXME: Should be removed after we confirm Chromium does not use it. - enum Error { - ErrorSpelling = 1 << 0, - ErrorGrammar = 1 << 1 - }; - WebTextCheckingResult() : type(WebTextCheckingTypeSpelling) - , error(ErrorSpelling) - , position(0) , location(0) , length(0) { } - explicit WebTextCheckingResult(Error e, int p = 0, int l = 0) - : type(WebTextCheckingTypeSpelling) - , error(e) - , position(p) - , location(p) - , length(l) - { - if (e & ErrorSpelling) - type = WebTextCheckingTypeSpelling; - else if (e & ErrorGrammar) - type = WebTextCheckingTypeGrammar; - else - WEBKIT_ASSERT_NOT_REACHED(); - } - WebTextCheckingResult(WebTextCheckingType type, int location, int length, const WebString& replacement = WebString()) : type(type) - , error(ErrorSpelling) - , position(location) , location(location) , length(length) , replacement(replacement) { - if (type & WebTextCheckingTypeSpelling) - error = ErrorSpelling; - else if (type & WebTextCheckingTypeGrammar) - error = ErrorGrammar; - else - WEBKIT_ASSERT_NOT_REACHED(); } #if WEBKIT_IMPLEMENTATION @@ -95,8 +63,6 @@ struct WebTextCheckingResult { #endif WebTextCheckingType type; - Error error; // FIXME: Should be removed after we confirm Chromium does not use it. - int position; // FIXME: Should be removed after we confirm Chromium does not use it. int location; int length; WebString replacement; diff --git a/Source/WebKit/chromium/public/WebVideoFrame.h b/Source/WebKit/chromium/public/WebVideoFrame.h index 8e3b2cdbd..78790627d 100644 --- a/Source/WebKit/chromium/public/WebVideoFrame.h +++ b/Source/WebKit/chromium/public/WebVideoFrame.h @@ -61,6 +61,7 @@ public: virtual int stride(unsigned plane) const { return 0; } virtual const void* data(unsigned plane) const { return 0; } virtual unsigned textureId() const { return 0; } + virtual unsigned textureTarget() const { return 0; } }; } // namespace WebKit diff --git a/Source/WebKit/chromium/public/WebViewClient.h b/Source/WebKit/chromium/public/WebViewClient.h index 1b42a48a8..b656fd5ad 100644 --- a/Source/WebKit/chromium/public/WebViewClient.h +++ b/Source/WebKit/chromium/public/WebViewClient.h @@ -263,6 +263,7 @@ public: virtual void focusedNodeChanged(const WebNode&) { } virtual void numberOfWheelEventHandlersChanged(unsigned) { } + virtual void numberOfTouchEventHandlersChanged(unsigned) { } // Indicates two things: // 1) This view may have a new layout now. diff --git a/Source/WebKit/chromium/public/WebWidget.h b/Source/WebKit/chromium/public/WebWidget.h index ca160a26e..58f3fa169 100644 --- a/Source/WebKit/chromium/public/WebWidget.h +++ b/Source/WebKit/chromium/public/WebWidget.h @@ -107,6 +107,11 @@ public: // animate or layout in this case. virtual void composite(bool finish) = 0; + // Temporary method for the embedder to notify the WebWidget that the widget + // has taken damage, e.g. due to a window expose. This method will be + // removed when the WebWidget inversion patch lands --- http://crbug.com/112837 + virtual void setNeedsRedraw() { } + // Called to inform the WebWidget of a change in theme. // Implementors that cache rendered copies of widgets need to re-render // on receiving this message diff --git a/Source/WebKit/chromium/public/platform/WebDragData.h b/Source/WebKit/chromium/public/platform/WebDragData.h index 171231eca..a6c82aee1 100644 --- a/Source/WebKit/chromium/public/platform/WebDragData.h +++ b/Source/WebKit/chromium/public/platform/WebDragData.h @@ -32,7 +32,9 @@ #define WebDragData_h #include "WebCommon.h" +#include "WebData.h" #include "WebString.h" +#include "WebURL.h" #if WEBKIT_IMPLEMENTATION namespace WebCore { class ChromiumDataObject; } @@ -41,15 +43,45 @@ namespace WTF { template <typename T> class PassRefPtr; } namespace WebKit { -class WebData; class WebDragDataPrivate; -class WebURL; template <typename T> class WebVector; // Holds data that may be exchanged through a drag-n-drop operation. It is // inexpensive to copy a WebDragData object. class WebDragData { public: + struct Item { + enum StorageType { + // String data with an associated MIME type. Depending on the MIME type, there may be + // optional metadata attributes as well. + StorageTypeString, + // Stores the name of one file being dragged into the renderer. + StorageTypeFilename, + // An image being dragged out of the renderer. Contains a buffer holding the image data + // as well as the suggested name for saving the image to. + StorageTypeBinaryData, + }; + + StorageType storageType; + + // Only valid when storageType == StorageTypeString. + WebString stringType; + WebString stringData; + + // Only valid when storageType == StorageTypeFilename. + WebString filenameData; + + // Only valid when storageType == StorageTypeBinaryData. + WebData binaryData; + + // Title associated with a link when stringType == "text/uri-list". + // Filename when storageType == StorageTypeBinaryData. + WebString title; + + // Only valid when stringType == "text/html". + WebURL baseURL; + }; + ~WebDragData() { reset(); } WebDragData() : m_private(0) { } @@ -66,44 +98,9 @@ public: bool isNull() const { return !m_private; } - WEBKIT_EXPORT WebString url() const; - WEBKIT_EXPORT void setURL(const WebURL&); - - WEBKIT_EXPORT WebString urlTitle() const; - WEBKIT_EXPORT void setURLTitle(const WebString&); - - WEBKIT_EXPORT WebString downloadMetadata() const; - WEBKIT_EXPORT void setDownloadMetadata(const WebString&); - - WEBKIT_EXPORT WebString fileExtension() const; - WEBKIT_EXPORT void setFileExtension(const WebString&); - - WEBKIT_EXPORT bool containsFilenames() const; - WEBKIT_EXPORT void filenames(WebVector<WebString>&) const; - WEBKIT_EXPORT void setFilenames(const WebVector<WebString>&); - WEBKIT_EXPORT void appendToFilenames(const WebString&); - - WEBKIT_EXPORT WebString plainText() const; - WEBKIT_EXPORT void setPlainText(const WebString&); - - WEBKIT_EXPORT WebString htmlText() const; - WEBKIT_EXPORT void setHTMLText(const WebString&); - - WEBKIT_EXPORT WebURL htmlBaseURL() const; - WEBKIT_EXPORT void setHTMLBaseURL(const WebURL&); - - WEBKIT_EXPORT WebString fileContentFilename() const; - WEBKIT_EXPORT void setFileContentFilename(const WebString&); - - WEBKIT_EXPORT WebData fileContent() const; - WEBKIT_EXPORT void setFileContent(const WebData&); - - struct CustomData { - WebString type; - WebString data; - }; - WEBKIT_EXPORT WebVector<CustomData> customData() const; - WEBKIT_EXPORT void setCustomData(const WebVector<CustomData>&); + WEBKIT_EXPORT WebVector<Item> items() const; + WEBKIT_EXPORT void setItems(const WebVector<Item>&); + WEBKIT_EXPORT void addItem(const Item&); #if WEBKIT_IMPLEMENTATION WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>&); diff --git a/Source/WebKit/chromium/public/platform/WebGamepad.h b/Source/WebKit/chromium/public/platform/WebGamepad.h index 71d37b3ba..788e78ba4 100644 --- a/Source/WebKit/chromium/public/platform/WebGamepad.h +++ b/Source/WebKit/chromium/public/platform/WebGamepad.h @@ -26,8 +26,14 @@ #include "WebCommon.h" +#if WEBKIT_IMPLEMENTATION +#include <wtf/Assertions.h> +#endif + namespace WebKit { +#pragma pack(push, 1) + // This structure is intentionally POD and fixed size so that it can be shared // memory between hardware polling threads and the rest of the browser. See // also WebGamepads.h. @@ -69,6 +75,12 @@ public: float buttons[buttonsLengthCap]; }; +#if WEBKIT_IMPLEMENTATION +COMPILE_ASSERT(sizeof(WebGamepad) == 465, WebGamepad_has_wrong_size); +#endif + +#pragma pack(pop) + } #endif // WebGamepad_h diff --git a/Source/WebKit/chromium/public/platform/WebGamepads.h b/Source/WebKit/chromium/public/platform/WebGamepads.h index b1cc18ef8..50e2ab208 100644 --- a/Source/WebKit/chromium/public/platform/WebGamepads.h +++ b/Source/WebKit/chromium/public/platform/WebGamepads.h @@ -26,8 +26,14 @@ #include "WebGamepad.h" +#if WEBKIT_IMPLEMENTATION +#include <wtf/Assertions.h> +#endif + namespace WebKit { +#pragma pack(push, 1) + // This structure is intentionally POD and fixed size so that it can be stored // in shared memory between hardware polling threads and the rest of the // browser. @@ -45,6 +51,12 @@ public: WebGamepad items[itemsLengthCap]; }; +#if WEBKIT_IMPLEMENTATION +COMPILE_ASSERT(sizeof(WebGamepads) == 1864, WebGamepads_has_wrong_size); +#endif + +#pragma pack(pop) + } #endif // WebGamepads_h diff --git a/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h b/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h index 57f9d7985..f13f7c44d 100644 --- a/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h +++ b/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h @@ -130,6 +130,14 @@ public: virtual ~WebGraphicsSwapBuffersCompleteCallbackCHROMIUM() { } }; + class WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { + public: + virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) = 0; + + protected: + virtual ~WebGraphicsMemoryAllocationChangedCallbackCHROMIUM() { } + }; + // This destructor needs to be public so that using classes can destroy instances if initialization fails. virtual ~WebGraphicsContext3D() {} @@ -151,6 +159,9 @@ public: // GL_CHROMIUM_setVisibility - Changes the visibility of the backbuffer virtual void setVisibilityCHROMIUM(bool visible) = 0; + // GL_CHROMIUM_gpu_memory_manager - sets callback to observe changes to memory allocation limits. + virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { } + // Query whether it is built on top of compliant GLES2 implementation. virtual bool isGLES2Compliant() = 0; diff --git a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h index 54795fa48..3bf4cb43a 100644 --- a/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h +++ b/Source/WebKit/chromium/public/platform/WebKitPlatformSupport.h @@ -240,11 +240,76 @@ public: virtual void decrementStatsCounter(const char* name) { } virtual void incrementStatsCounter(const char* name) { } - // An event is identified by the pair (name, id). The extra parameter - // specifies additional data to log with the event. - virtual bool isTraceEventEnabled() const { return true; } - virtual void traceEventBegin(const char* name, void* id, const char* extra) { } - virtual void traceEventEnd(const char* name, void* id, const char* extra) { } + // Tracing ------------------------------------------------------------- + + // Get a pointer to the enabled state of the given trace category. The + // embedder can dynamically change the enabled state as trace event + // recording is started and stopped by the application. Only long-lived + // literal strings should be given as the category name. The implementation + // expects the returned pointer to be held permanently in a local static. If + // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, + // addTraceEvent is expected to be called by the trace event macros. + virtual const unsigned char* getTraceCategoryEnabledFlag(const char* categoryName) { return 0; } + // Add a trace event to the platform tracing system. Depending on the actual + // enabled state, this event may be recorded or dropped. Returns + // thresholdBeginId for use in a corresponding end addTraceEvent call. + // - phase specifies the type of event: + // - BEGIN ('B'): Marks the beginning of a scoped event. + // - END ('E'): Marks the end of a scoped event. + // - INSTANT ('I'): Standalone, instantaneous event. + // - START ('S'): Marks the beginning of an asynchronous event (the end + // event can occur in a different scope or thread). The id parameter is + // used to match START/FINISH pairs. + // - FINISH ('F'): Marks the end of an asynchronous event. + // - COUNTER ('C'): Used to trace integer quantities that change over + // time. The argument values are expected to be of type int. + // - METADATA ('M'): Reserved for internal use. + // - categoryEnabled is the pointer returned by getTraceCategoryEnabledFlag. + // - name is the name of the event. Also used to match BEGIN/END and + // START/FINISH pairs. + // - id optionally allows events of the same name to be distinguished from + // each other. For example, to trace the consutruction and destruction of + // objects, specify the pointer as the id parameter. + // - numArgs specifies the number of elements in argNames, argTypes, and + // argValues. + // - argNames is the array of argument names. Use long-lived literal strings + // or specify the COPY flag. + // - argTypes is the array of argument types: + // - BOOL (1): bool + // - UINT (2): unsigned long long + // - INT (3): long long + // - DOUBLE (4): double + // - POINTER (5): void* + // - STRING (6): char* (long-lived null-terminated char* string) + // - COPY_STRING (7): char* (temporary null-terminated char* string) + // - argValues is the array of argument values. Each value is the unsigned + // long long member of a union of all supported types. + // - thresholdBeginId optionally specifies the value returned by a previous + // call to addTraceEvent with a BEGIN phase. + // - threshold is used on an END phase event in conjunction with the + // thresholdBeginId of a prior BEGIN event. The threshold is the minimum + // number of microseconds that must have passed since the BEGIN event. If + // less than threshold microseconds has passed, the BEGIN/END pair is + // dropped. + // - flags can be 0 or one or more of the following, ORed together: + // - COPY (0x1): treat all strings (name, argNames and argValues of type + // string) as temporary so that they will be copied by addTraceEvent. + // - HAS_ID (0x2): use the id argument to uniquely identify the event for + // matching with other events of the same name. + // - MANGLE_ID (0x4): specify this flag if the id parameter is the value + // of a pointer. + virtual int addTraceEvent( + char phase, + const unsigned char* categoryEnabledFlag, + const char* name, + unsigned long long id, + int numArgs, + const char** argNames, + const unsigned char* argTypes, + const unsigned long long* argValues, + int thresholdBeginId, + long long threshold, + unsigned char flags) { return -1; } // Callbacks for reporting histogram data. // CustomCounts histogram has exponential bucket sizes, so that min=1, max=1000000, bucketCount=50 would do. diff --git a/Source/WebKit/chromium/public/platform/WebLayerTreeView.h b/Source/WebKit/chromium/public/platform/WebLayerTreeView.h index 0263b3926..17a876a98 100644 --- a/Source/WebKit/chromium/public/platform/WebLayerTreeView.h +++ b/Source/WebKit/chromium/public/platform/WebLayerTreeView.h @@ -49,14 +49,18 @@ public: , showFPSCounter(false) , showPlatformLayerTree(false) , refreshRate(0) - , partialSwapEnabled(false) { } + , perTilePainting(false) + , partialSwapEnabled(false) + , threadedAnimationEnabled(false) { } bool acceleratePainting; bool compositeOffscreen; bool showFPSCounter; bool showPlatformLayerTree; double refreshRate; + bool perTilePainting; bool partialSwapEnabled; + bool threadedAnimationEnabled; #if WEBKIT_IMPLEMENTATION operator WebCore::CCSettings() const; #endif @@ -107,6 +111,8 @@ public: operator WTF::PassRefPtr<WebCore::CCLayerTreeHost>() const; #endif + WEBKIT_EXPORT void setNeedsRedraw(); + protected: WebPrivatePtr<WebCore::CCLayerTreeHost> m_private; }; diff --git a/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h b/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h index 7586abc03..bd2093577 100644 --- a/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h +++ b/Source/WebKit/chromium/public/platform/WebPeerConnectionHandler.h @@ -54,7 +54,10 @@ class WebPeerConnectionHandler { public: virtual ~WebPeerConnectionHandler() { } - virtual void initialize(const WebString& serverConfiguration, const WebSecurityOrigin&) = 0; + // DEPRECATED + virtual void initialize(const WebString& serverConfiguration, const WebSecurityOrigin&) { }; + + virtual void initialize(const WebString& serverConfiguration, const WebString& username) { }; virtual void produceInitialOffer(const WebVector<WebMediaStreamDescriptor>& pendingAddStreams) = 0; virtual void handleInitialOffer(const WebString& sdp) = 0; diff --git a/Source/WebKit/chromium/public/platform/WebURLResponse.h b/Source/WebKit/chromium/public/platform/WebURLResponse.h index 8629b849c..8d53eac38 100644 --- a/Source/WebKit/chromium/public/platform/WebURLResponse.h +++ b/Source/WebKit/chromium/public/platform/WebURLResponse.h @@ -50,6 +50,11 @@ class WebURLResponsePrivate; class WebURLResponse { public: + class ExtraData { + public: + virtual ~ExtraData() { } + }; + ~WebURLResponse() { reset(); } WebURLResponse() : m_private(0) { } @@ -174,6 +179,15 @@ public: WEBKIT_EXPORT unsigned short remotePort() const; WEBKIT_EXPORT void setRemotePort(unsigned short); + // Extra data associated with the underlying resource response. Resource + // responses can be copied. If non-null, each copy of a resource response + // holds a pointer to the extra data, and the extra data pointer will be + // deleted when the last resource response is destroyed. Setting the extra + // data pointer will cause the underlying resource response to be + // dissociated from any existing non-null extra data pointer. + WEBKIT_EXPORT ExtraData* extraData() const; + WEBKIT_EXPORT void setExtraData(ExtraData*); + protected: void assign(WebURLResponsePrivate*); diff --git a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp index a451b88a6..3f0875b53 100644 --- a/Source/WebKit/chromium/src/AssertMatchingEnums.cpp +++ b/Source/WebKit/chromium/src/AssertMatchingEnums.cpp @@ -454,9 +454,6 @@ COMPILE_ASSERT_MATCHING_ENUM(WebFileErrorPathExists, FileError::PATH_EXISTS_ERR) COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPermissionDenied, GeolocationError::PermissionDenied); COMPILE_ASSERT_MATCHING_ENUM(WebGeolocationError::ErrorPositionUnavailable, GeolocationError::PositionUnavailable); -COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingResult::ErrorSpelling, DocumentMarker::Spelling); -COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingResult::ErrorGrammar, DocumentMarker::Grammar); - COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeSpelling, TextCheckingTypeSpelling); COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeGrammar, TextCheckingTypeGrammar); COMPILE_ASSERT_MATCHING_ENUM(WebTextCheckingTypeLink, TextCheckingTypeLink); diff --git a/Source/WebKit/chromium/src/BoundObject.cpp b/Source/WebKit/chromium/src/BoundObject.cpp deleted file mode 100644 index d0f66aac5..000000000 --- a/Source/WebKit/chromium/src/BoundObject.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2010 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "BoundObject.h" - -#include "V8Binding.h" -#include "V8Proxy.h" - -namespace WebKit { - -BoundObject::BoundObject(v8::Handle<v8::Context> context, void* v8This, const char* objectName) - : m_objectName(objectName) - , m_context(context) - , m_v8This(v8This) -{ - v8::Context::Scope contextScope(context); - v8::Local<v8::FunctionTemplate> localTemplate = v8::FunctionTemplate::New(WebCore::V8Proxy::checkNewLegal); - m_hostTemplate = v8::Persistent<v8::FunctionTemplate>::New(localTemplate); - m_hostTemplate->SetClassName(v8::String::New(objectName)); -} - -BoundObject::~BoundObject() -{ - m_hostTemplate.Dispose(); -} - -void BoundObject::addProtoFunction(const char* name, v8::InvocationCallback callback) -{ - v8::Context::Scope contextScope(m_context); - v8::Local<v8::Signature> signature = v8::Signature::New(m_hostTemplate); - v8::Local<v8::ObjectTemplate> proto = m_hostTemplate->PrototypeTemplate(); - v8::Local<v8::External> v8This = v8::External::New(m_v8This); - proto->Set( - v8::String::New(name), - v8::FunctionTemplate::New( - callback, - v8This, - signature), - static_cast<v8::PropertyAttribute>(v8::DontDelete)); -} - -void BoundObject::build() -{ - v8::Context::Scope contextScope(m_context); - v8::Local<v8::Function> constructor = m_hostTemplate->GetFunction(); - v8::Local<v8::Object> boundObject = WebCore::SafeAllocation::newInstance(constructor); - - v8::Handle<v8::Object> global = m_context->Global(); - global->Set(v8::String::New(m_objectName), boundObject); -} - -} // namespace WebKit diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.cpp b/Source/WebKit/chromium/src/ChromeClientImpl.cpp index fb07b4c10..45a813859 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.cpp +++ b/Source/WebKit/chromium/src/ChromeClientImpl.cpp @@ -1018,6 +1018,11 @@ void ChromeClientImpl::numWheelEventHandlersChanged(unsigned numberOfWheelHandle m_webView->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); } +void ChromeClientImpl::numTouchEventHandlersChanged(unsigned numberOfTouchHandlers) +{ + m_webView->numberOfTouchEventHandlersChanged(numberOfTouchHandlers); +} + #if ENABLE(POINTER_LOCK) bool ChromeClientImpl::requestPointerLock() { diff --git a/Source/WebKit/chromium/src/ChromeClientImpl.h b/Source/WebKit/chromium/src/ChromeClientImpl.h index 8fd2488d9..23e02ff3d 100644 --- a/Source/WebKit/chromium/src/ChromeClientImpl.h +++ b/Source/WebKit/chromium/src/ChromeClientImpl.h @@ -204,6 +204,7 @@ public: virtual bool shouldRubberBandInDirection(WebCore::ScrollDirection) const; virtual void numWheelEventHandlersChanged(unsigned); + virtual void numTouchEventHandlersChanged(unsigned); #if ENABLE(POINTER_LOCK) virtual bool requestPointerLock(); diff --git a/Source/WebKit/chromium/src/EditorClientImpl.cpp b/Source/WebKit/chromium/src/EditorClientImpl.cpp index 04aa719ed..934281a29 100644 --- a/Source/WebKit/chromium/src/EditorClientImpl.cpp +++ b/Source/WebKit/chromium/src/EditorClientImpl.cpp @@ -238,13 +238,11 @@ bool EditorClientImpl::shouldChangeSelectedRange(Range* fromRange, return true; } -bool EditorClientImpl::shouldApplyStyle(CSSStyleDeclaration* style, - Range* range) +bool EditorClientImpl::shouldApplyStyle(StylePropertySet* style, Range* range) { if (m_webView->client()) { // FIXME: Pass a reference to the CSSStyleDeclaration somehow. - return m_webView->client()->shouldApplyStyle(WebString(), - WebRange(range)); + return m_webView->client()->shouldApplyStyle(WebString(), WebRange(range)); } return true; } @@ -731,10 +729,10 @@ void EditorClientImpl::checkSpellingOfString(const UChar* text, int length, *misspellingLength = spellLength; } -void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, int identifier, TextCheckingTypeMask, const String& text) +void EditorClientImpl::requestCheckingOfString(SpellChecker* sender, const WebCore::TextCheckingRequest& request) { if (m_webView->spellCheckClient()) - m_webView->spellCheckClient()->requestCheckingOfText(text, new WebTextCheckingCompletionImpl(identifier, sender)); + m_webView->spellCheckClient()->requestCheckingOfText(request.text(), new WebTextCheckingCompletionImpl(request.sequence(), sender)); } String EditorClientImpl::getAutoCorrectSuggestionForMisspelledWord(const String& misspelledWord) diff --git a/Source/WebKit/chromium/src/EditorClientImpl.h b/Source/WebKit/chromium/src/EditorClientImpl.h index 2b577107c..b167b6c2d 100644 --- a/Source/WebKit/chromium/src/EditorClientImpl.h +++ b/Source/WebKit/chromium/src/EditorClientImpl.h @@ -67,7 +67,7 @@ public: virtual bool shouldDeleteRange(WebCore::Range*); virtual bool shouldChangeSelectedRange(WebCore::Range* fromRange, WebCore::Range* toRange, WebCore::EAffinity, bool stillSelecting); - virtual bool shouldApplyStyle(WebCore::CSSStyleDeclaration*, WebCore::Range*); + virtual bool shouldApplyStyle(WebCore::StylePropertySet*, WebCore::Range*); virtual bool shouldMoveRangeAfterDelete(WebCore::Range*, WebCore::Range*); virtual void didBeginEditing(); virtual void respondToChangedContents(); @@ -109,7 +109,7 @@ public: virtual void getGuessesForWord(const WTF::String& word, const WTF::String& context, WTF::Vector<WTF::String>& guesses); virtual void willSetInputMethodState(); virtual void setInputMethodState(bool enabled); - virtual void requestCheckingOfString(WebCore::SpellChecker*, int, WebCore::TextCheckingTypeMask, const WTF::String&); + virtual void requestCheckingOfString(WebCore::SpellChecker*, const WebCore::TextCheckingRequest&); virtual WebCore::TextCheckerClient* textChecker() { return this; } diff --git a/Source/WebKit/chromium/src/Extensions3DChromium.cpp b/Source/WebKit/chromium/src/Extensions3DChromium.cpp index ece0405ae..73397bd2b 100644 --- a/Source/WebKit/chromium/src/Extensions3DChromium.cpp +++ b/Source/WebKit/chromium/src/Extensions3DChromium.cpp @@ -107,6 +107,11 @@ void Extensions3DChromium::setVisibilityCHROMIUM(bool visibility) m_private->setVisibilityCHROMIUM(visibility); } +void Extensions3DChromium::setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<GpuMemoryAllocationChangedCallbackCHROMIUM> callback) +{ + m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(callback); +} + Platform3DObject Extensions3DChromium::createVertexArrayOES() { return 0; diff --git a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp index cbbf5c581..c7ac894b0 100644 --- a/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp +++ b/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp @@ -85,12 +85,11 @@ namespace WebCore { //---------------------------------------------------------------------- // GraphicsContext3DPrivate -GraphicsContext3DPrivate::GraphicsContext3DPrivate(WebKit::WebViewImpl* webViewImpl, PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::Attributes attrs) +GraphicsContext3DPrivate::GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer) : m_impl(webContext) - , m_webViewImpl(webViewImpl) , m_initializedAvailableExtensions(false) , m_layerComposited(false) - , m_preserveDrawingBuffer(attrs.preserveDrawingBuffer) + , m_preserveDrawingBuffer(preserveDrawingBuffer) , m_resourceSafety(ResourceSafetyUnknown) #if USE(SKIA) , m_grContext(0) @@ -112,59 +111,19 @@ GraphicsContext3DPrivate::~GraphicsContext3DPrivate() #endif } - -PassOwnPtr<GraphicsContext3DPrivate> GraphicsContext3DPrivate::create(WebKit::WebViewImpl* webViewImpl, PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::Attributes attrs) -{ - return adoptPtr(new GraphicsContext3DPrivate(webViewImpl, webContext, attrs)); -} - -PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle, ThreadUsage threadUsage) +PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, GraphicsContext3D::RenderStyle renderStyle, bool preserveDrawingBuffer) { - Chrome* chrome = static_cast<Chrome*>(hostWindow); - WebKit::WebViewImpl* webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0; + bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - OwnPtr<GraphicsContext3DPrivate> priv = GraphicsContext3DPrivate::create(webViewImpl, webContext, attrs); - if (!priv) - return 0; + RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0, renderDirectlyToHostWindow)); - bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - RefPtr<GraphicsContext3D> result = adoptRef(new GraphicsContext3D(attrs, hostWindow, renderDirectlyToHostWindow)); - result->m_private = priv.release(); - return result.release(); + OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); + context->m_private = priv.release(); + return context.release(); } namespace { -PassRefPtr<GraphicsContext3D> createGraphicsContext(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle, GraphicsContext3DPrivate::ThreadUsage threadUsage) -{ - bool renderDirectlyToHostWindow = renderStyle == GraphicsContext3D::RenderDirectlyToHostWindow; - - WebKit::WebGraphicsContext3D::Attributes webAttributes; - webAttributes.alpha = attrs.alpha; - webAttributes.depth = attrs.depth; - webAttributes.stencil = attrs.stencil; - webAttributes.antialias = attrs.antialias; - webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; - webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; - webAttributes.noExtensions = attrs.noExtensions; - webAttributes.shareResources = attrs.shareResources; - webAttributes.forUseOnAnotherThread = threadUsage == GraphicsContext3DPrivate::ForUseOnAnotherThread; - - Chrome* chrome = static_cast<Chrome*>(hostWindow); - WebKit::WebViewImpl* webViewImpl = chrome ? static_cast<WebKit::WebViewImpl*>(chrome->client()->webView()) : 0; - OwnPtr<WebKit::WebGraphicsContext3D> webContext; - if (!webViewImpl || !webViewImpl->client()) { - if (renderDirectlyToHostWindow) - return 0; - webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes)); - } else - webContext = adoptPtr(webViewImpl->client()->createGraphicsContext3D(webAttributes, renderDirectlyToHostWindow)); - if (!webContext) - return 0; - - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attrs, hostWindow, renderStyle, threadUsage); -} - void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsContext3D* graphicsContext3D, Platform3DObject* frameBufferId, int* width, int* height) { @@ -181,11 +140,6 @@ void getDrawingParameters(DrawingBuffer* drawingBuffer, WebKit::WebGraphicsConte } // anonymous namespace -PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextForAnotherThread(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) -{ - return createGraphicsContext(attrs, hostWindow, renderStyle, ForUseOnAnotherThread); -} - WebKit::WebGraphicsContext3D* GraphicsContext3DPrivate::extractWebGraphicsContext3D(GraphicsContext3D* context) { if (!context) @@ -200,8 +154,6 @@ PlatformGraphicsContext3D GraphicsContext3DPrivate::platformGraphicsContext3D() Platform3DObject GraphicsContext3DPrivate::platformTexture() const { - ASSERT(m_webViewImpl); - m_impl->setParentContext(m_webViewImpl->graphicsContext3D()); return m_impl->getPlatformTextureId(); } @@ -345,13 +297,6 @@ PassRefPtr<ImageData> GraphicsContext3DPrivate::paintRenderingResultsToImageData return imageData.release(); } -bool GraphicsContext3DPrivate::paintsIntoCanvasBuffer() const -{ - // If the gpu compositor is on then skip the readback and software rendering path. - ASSERT(m_webViewImpl); - return !m_webViewImpl->isAcceleratedCompositingActive(); -} - void GraphicsContext3DPrivate::reshape(int width, int height) { if (width == m_impl->width() && height == m_impl->height()) @@ -1035,11 +980,28 @@ GraphicsContext3D::~GraphicsContext3D() m_private->setContextLostCallback(nullptr); m_private->setErrorMessageCallback(nullptr); m_private->setSwapBuffersCompleteCallbackCHROMIUM(nullptr); + m_private->setGpuMemoryAllocationChangedCallbackCHROMIUM(nullptr); } -PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle) +PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow*, GraphicsContext3D::RenderStyle renderStyle) { - return createGraphicsContext(attrs, hostWindow, renderStyle, GraphicsContext3DPrivate::ForUseOnThisThread); + ASSERT(renderStyle != GraphicsContext3D::RenderDirectlyToHostWindow); + + WebKit::WebGraphicsContext3D::Attributes webAttributes; + webAttributes.alpha = attrs.alpha; + webAttributes.depth = attrs.depth; + webAttributes.stencil = attrs.stencil; + webAttributes.antialias = attrs.antialias; + webAttributes.premultipliedAlpha = attrs.premultipliedAlpha; + webAttributes.canRecoverFromContextLoss = attrs.canRecoverFromContextLoss; + webAttributes.noExtensions = attrs.noExtensions; + webAttributes.shareResources = attrs.shareResources; + + OwnPtr<WebKit::WebGraphicsContext3D> webContext = adoptPtr(WebKit::webKitPlatformSupport()->createOffscreenGraphicsContext3D(webAttributes)); + if (!webContext) + return 0; + + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), renderStyle, attrs.preserveDrawingBuffer); } PlatformGraphicsContext3D GraphicsContext3D::platformGraphicsContext3D() const @@ -1247,11 +1209,6 @@ PassRefPtr<ImageData> GraphicsContext3D::paintRenderingResultsToImageData(Drawin DELEGATE_TO_INTERNAL_1R(paintCompositedResultsToCanvas, CanvasRenderingContext*, bool) -bool GraphicsContext3D::paintsIntoCanvasBuffer() const -{ - return m_private->paintsIntoCanvasBuffer(); -} - DELEGATE_TO_INTERNAL_R(createBuffer, Platform3DObject) DELEGATE_TO_INTERNAL_R(createFramebuffer, Platform3DObject) DELEGATE_TO_INTERNAL_R(createProgram, Platform3DObject) @@ -1359,6 +1316,31 @@ void GraphicsContext3DPrivate::setSwapBuffersCompleteCallbackCHROMIUM(PassOwnPtr m_impl->setSwapBuffersCompleteCallbackCHROMIUM(m_swapBuffersCompleteCallbackAdapter.get()); } +class GraphicsContext3DMemoryAllocationChangedCallbackAdapter : public WebKit::WebGraphicsContext3D::WebGraphicsMemoryAllocationChangedCallbackCHROMIUM { +public: + GraphicsContext3DMemoryAllocationChangedCallbackAdapter(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> cb) + : m_memoryAllocationChangedCallback(cb) + { + } + + virtual ~GraphicsContext3DMemoryAllocationChangedCallbackAdapter() { } + + virtual void onMemoryAllocationChanged(size_t gpuResourceSizeInBytes) + { + if (m_memoryAllocationChangedCallback) + m_memoryAllocationChangedCallback->onGpuMemoryAllocationChanged(gpuResourceSizeInBytes); + } + +private: + OwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> m_memoryAllocationChangedCallback; +}; + +void GraphicsContext3DPrivate::setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM> cb) +{ + m_memoryAllocationChangedCallbackAdapter = adoptPtr(new GraphicsContext3DMemoryAllocationChangedCallbackAdapter(cb)); + m_impl->setMemoryAllocationChangedCallbackCHROMIUM(m_memoryAllocationChangedCallbackAdapter.get()); +} + } // namespace WebCore #endif // ENABLE(WEBGL) diff --git a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h index f2d49a132..d296eeb9b 100644 --- a/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h +++ b/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h @@ -41,8 +41,7 @@ class GrContext; namespace WebKit { class WebGraphicsContext3D; -class WebViewImpl; -} // namespace WebKit +} namespace WebCore { @@ -51,25 +50,14 @@ class Extensions3DChromium; class GraphicsContextLostCallbackAdapter; class GraphicsContext3DSwapBuffersCompleteCallbackAdapter; class GraphicsErrorMessageCallbackAdapter; +class GraphicsContext3DMemoryAllocationChangedCallbackAdapter; class GraphicsContext3DPrivate { public: - static PassOwnPtr<GraphicsContext3DPrivate> create(WebKit::WebViewImpl*, PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::Attributes); - - enum ThreadUsage { - ForUseOnThisThread, - ForUseOnAnotherThread, - }; - - // createGraphicsContextForAnotherThread is equivalent to - // GraphicsContext3D::create, but will skip making the context - // current. Callers must make the context current before using it AND check - // that the context was created successfully via ContextLost. Once made - // current on a thread, the context cannot be used on any other thread. - static PassRefPtr<GraphicsContext3D> createGraphicsContextForAnotherThread(GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle); - - // Used in tests to create a GraphicsContext3D from a mocked WebGraphicsContext3D. - static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::Attributes, HostWindow*, GraphicsContext3D::RenderStyle, ThreadUsage); + // Callers must make the context current before using it AND check that the context was created successfully + // via ContextLost before using the context in any way. Once made current on a thread, the context cannot + // be used on any other thread. + static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::RenderStyle, bool preserveDrawingBuffer = false); ~GraphicsContext3DPrivate(); @@ -97,7 +85,6 @@ public: void paintRenderingResultsToCanvas(CanvasRenderingContext*, DrawingBuffer*); void paintFramebufferToCanvas(int framebuffer, int width, int height, bool premultiplyAlpha, ImageBuffer*); PassRefPtr<ImageData> paintRenderingResultsToImageData(DrawingBuffer*); - bool paintsIntoCanvasBuffer() const; bool paintCompositedResultsToCanvas(CanvasRenderingContext*); void prepareTexture(); @@ -295,6 +282,9 @@ public: // GL_CHROMIUM_set_visibility void setVisibilityCHROMIUM(bool); + // GL_CHROMIUM_gpu_memory_manager + void setGpuMemoryAllocationChangedCallbackCHROMIUM(PassOwnPtr<Extensions3DChromium::GpuMemoryAllocationChangedCallbackCHROMIUM>); + // GL_CHROMIUM_framebuffer_multisample void blitFramebufferCHROMIUM(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter); void renderbufferStorageMultisampleCHROMIUM(GC3Denum target, GC3Dsizei samples, GC3Denum internalformat, GC3Dsizei width, GC3Dsizei height); @@ -318,14 +308,14 @@ public: void texStorage2DEXT(GC3Denum target, GC3Dint levels, GC3Duint internalformat, GC3Dint width, GC3Dint height); private: - GraphicsContext3DPrivate(WebKit::WebViewImpl*, PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::Attributes); + GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer); OwnPtr<WebKit::WebGraphicsContext3D> m_impl; OwnPtr<Extensions3DChromium> m_extensions; OwnPtr<GraphicsContextLostCallbackAdapter> m_contextLostCallbackAdapter; OwnPtr<GraphicsErrorMessageCallbackAdapter> m_errorMessageCallbackAdapter; OwnPtr<GraphicsContext3DSwapBuffersCompleteCallbackAdapter> m_swapBuffersCompleteCallbackAdapter; - WebKit::WebViewImpl* m_webViewImpl; + OwnPtr<GraphicsContext3DMemoryAllocationChangedCallbackAdapter> m_memoryAllocationChangedCallbackAdapter; bool m_initializedAvailableExtensions; HashSet<String> m_enabledExtensions; HashSet<String> m_requestableExtensions; diff --git a/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp index 99a0afae4..a1cce45b0 100755 --- a/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp +++ b/Source/WebKit/chromium/src/IDBFactoryBackendProxy.cpp @@ -157,6 +157,12 @@ private: bool IDBFactoryBackendProxy::allowIDBFromWorkerThread(WorkerContext* workerContext, const String& name, const WebSecurityOrigin&) { + // FIXME: Bypass checking for permission so as not to block shared worker + // testing until a permissions check is implemented. This has to be fixed + // before m19 goes to beta. http://crbug.com/112855 + if (workerContext->isSharedWorkerContext()) + return true; + WebWorkerClientImpl* webWorkerClientImpl = static_cast<WebWorkerClientImpl*>(&workerContext->thread()->workerLoaderProxy()); WorkerRunLoop& runLoop = workerContext->thread()->runLoop(); @@ -181,15 +187,7 @@ void IDBFactoryBackendProxy::openFromWorker(const String& name, IDBCallbacks* ca callbacks->onError(WebIDBDatabaseError(0, "The user denied permission to access the database.")); return; } - WorkerLoaderProxy* workerLoaderProxy = &context->thread()->workerLoaderProxy(); - WebWorkerBase* webWorker = static_cast<WebWorkerBase*>(workerLoaderProxy); - WebView* webView = webWorker->view(); - if (!webView) { - // Frame is closed, worker is terminaring. - return; - } - WebFrame* webFrame = webView->mainFrame(); - m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, webFrame, dataDir); + m_webIDBFactory->open(name, new WebIDBCallbacksImpl(callbacks), origin, /*webFrame*/0, dataDir); #endif } diff --git a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp index 71fb571d1..485487ac0 100755 --- a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp +++ b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.cpp @@ -98,6 +98,14 @@ void IDBObjectStoreBackendProxy::deleteFunction(PassRefPtr<IDBKey> key, PassRefP m_webIDBObjectStore->deleteFunction(key, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec); } +void IDBObjectStoreBackendProxy::deleteFunction(PassRefPtr<IDBKeyRange> keyRange, PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) +{ + // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, + // all implementations of IDB interfaces are proxy objects. + IDBTransactionBackendProxy* transactionProxy = static_cast<IDBTransactionBackendProxy*>(transaction); + m_webIDBObjectStore->deleteFunction(keyRange, new WebIDBCallbacksImpl(callbacks), *transactionProxy->getWebIDBTransaction(), ec); +} + void IDBObjectStoreBackendProxy::clear(PassRefPtr<IDBCallbacks> callbacks, IDBTransactionBackendInterface* transaction, ExceptionCode& ec) { // The transaction pointer is guaranteed to be a pointer to a proxy object as, in the renderer, diff --git a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h index 6d335635c..c19a0f0a4 100644 --- a/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h +++ b/Source/WebKit/chromium/src/IDBObjectStoreBackendProxy.h @@ -49,6 +49,7 @@ public: virtual void get(PassRefPtr<WebCore::IDBKey>, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); virtual void put(PassRefPtr<WebCore::SerializedScriptValue>, PassRefPtr<WebCore::IDBKey>, PutMode, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); virtual void deleteFunction(PassRefPtr<WebCore::IDBKey>, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); + virtual void deleteFunction(PassRefPtr<WebCore::IDBKeyRange>, PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); virtual void clear(PassRefPtr<WebCore::IDBCallbacks>, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); PassRefPtr<WebCore::IDBIndexBackendInterface> createIndex(const String& name, const String& keyPath, bool unique, bool multiEntry, WebCore::IDBTransactionBackendInterface*, WebCore::ExceptionCode&); diff --git a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp index c9be08a84..b6b1a2294 100644 --- a/Source/WebKit/chromium/src/NonCompositedContentHost.cpp +++ b/Source/WebKit/chromium/src/NonCompositedContentHost.cpp @@ -27,6 +27,7 @@ #include "NonCompositedContentHost.h" +#include "FloatPoint.h" #include "FloatRect.h" #include "GraphicsLayer.h" #include "LayerChromium.h" @@ -103,6 +104,7 @@ void NonCompositedContentHost::setViewport(const WebCore::IntSize& viewportSize, m_viewportSize = viewportSize; scrollLayer()->setScrollPosition(scrollPosition); + scrollLayer()->setPosition(-scrollPosition); // Due to the possibility of pinch zoom, the noncomposited layer is always // assumed to be scrollable. scrollLayer()->setScrollable(true); diff --git a/Source/WebKit/chromium/src/PlatformSupport.cpp b/Source/WebKit/chromium/src/PlatformSupport.cpp index b4d479ca6..63be0245c 100644 --- a/Source/WebKit/chromium/src/PlatformSupport.cpp +++ b/Source/WebKit/chromium/src/PlatformSupport.cpp @@ -947,19 +947,24 @@ void PlatformSupport::paintThemePart( // Trace Event ---------------------------------------------------------------- -bool PlatformSupport::isTraceEventEnabled() -{ - return webKitPlatformSupport()->isTraceEventEnabled(); -} - -void PlatformSupport::traceEventBegin(const char* name, void* id, const char* extra) -{ - webKitPlatformSupport()->traceEventBegin(name, id, extra); -} - -void PlatformSupport::traceEventEnd(const char* name, void* id, const char* extra) -{ - webKitPlatformSupport()->traceEventEnd(name, id, extra); +const unsigned char* PlatformSupport::getTraceCategoryEnabledFlag(const char* categoryName) +{ + return webKitPlatformSupport()->getTraceCategoryEnabledFlag(categoryName); +} +int PlatformSupport::addTraceEvent(char phase, + const unsigned char* categoryEnabledFlag, + const char* name, + unsigned long long id, + int numArgs, + const char** argNames, + const unsigned char* argTypes, + const unsigned long long* argValues, + int thresholdBeginId, + long long threshold, + unsigned char flags) +{ + return webKitPlatformSupport()->addTraceEvent( + phase, categoryEnabledFlag, name, id, numArgs, argNames, argTypes, argValues, thresholdBeginId, threshold, flags); } // Visited Links -------------------------------------------------------------- diff --git a/Source/WebKit/chromium/src/SocketStreamHandle.cpp b/Source/WebKit/chromium/src/SocketStreamHandle.cpp index cf8aa02cd..298e733a4 100644 --- a/Source/WebKit/chromium/src/SocketStreamHandle.cpp +++ b/Source/WebKit/chromium/src/SocketStreamHandle.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Google Inc. All rights reserved. + * Copyright (C) 2009, 2012 Google Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are @@ -30,6 +30,7 @@ #include "config.h" #include "SocketStreamHandle.h" +#include "SocketStreamHandleInternal.h" #if ENABLE(WEB_SOCKETS) @@ -40,41 +41,12 @@ #include "WebKit.h" #include "platform/WebKitPlatformSupport.h" #include "platform/WebSocketStreamHandle.h" -#include "platform/WebSocketStreamHandleClient.h" -#include "platform/WebURL.h" #include <wtf/PassOwnPtr.h> using namespace WebKit; namespace WebCore { -class SocketStreamHandleInternal : public WebSocketStreamHandleClient { -public: - static PassOwnPtr<SocketStreamHandleInternal> create(SocketStreamHandle* handle) - { - return adoptPtr(new SocketStreamHandleInternal(handle)); - } - virtual ~SocketStreamHandleInternal(); - - void connect(const KURL&); - int send(const char*, int); - void close(); - - virtual void didOpenStream(WebSocketStreamHandle*, int); - virtual void didSendData(WebSocketStreamHandle*, int); - virtual void didReceiveData(WebSocketStreamHandle*, const WebData&); - virtual void didClose(WebSocketStreamHandle*); - virtual void didFail(WebSocketStreamHandle*, const WebSocketStreamError&); - -private: - explicit SocketStreamHandleInternal(SocketStreamHandle*); - - SocketStreamHandle* m_handle; - OwnPtr<WebSocketStreamHandle> m_socket; - int m_maxPendingSendAllowed; - int m_pendingAmountSent; -}; - SocketStreamHandleInternal::SocketStreamHandleInternal(SocketStreamHandle* handle) : m_handle(handle) , m_maxPendingSendAllowed(0) diff --git a/Source/WebKit/chromium/src/SocketStreamHandleInternal.h b/Source/WebKit/chromium/src/SocketStreamHandleInternal.h new file mode 100644 index 000000000..857b279e7 --- /dev/null +++ b/Source/WebKit/chromium/src/SocketStreamHandleInternal.h @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef SocketStreamHandleInternal_h +#define SocketStreamHandleInternal_h + +#if ENABLE(WEB_SOCKETS) + +#include "SocketStreamHandle.h" +#include "platform/WebSocketStreamHandleClient.h" +#include "platform/WebURL.h" +#include <wtf/PassOwnPtr.h> + +namespace WebKit { + +class WebData; +class WebSocketStreamError; +class WebSocketStreamHandle; + +} + +namespace WebCore { + +class SocketStreamHandleInternal : public WebKit::WebSocketStreamHandleClient { +public: + static PassOwnPtr<SocketStreamHandleInternal> create(SocketStreamHandle* handle) + { + return adoptPtr(new SocketStreamHandleInternal(handle)); + } + virtual ~SocketStreamHandleInternal(); + + void connect(const KURL&); + int send(const char*, int); + void close(); + + virtual void didOpenStream(WebKit::WebSocketStreamHandle*, int); + virtual void didSendData(WebKit::WebSocketStreamHandle*, int); + virtual void didReceiveData(WebKit::WebSocketStreamHandle*, const WebKit::WebData&); + virtual void didClose(WebKit::WebSocketStreamHandle*); + virtual void didFail(WebKit::WebSocketStreamHandle*, const WebKit::WebSocketStreamError&); + + static WebKit::WebSocketStreamHandle* toWebSocketStreamHandle(SocketStreamHandle* handle) + { + if (handle && handle->m_internal) + return handle->m_internal->m_socket.get(); + return 0; + } + +private: + explicit SocketStreamHandleInternal(SocketStreamHandle*); + + SocketStreamHandle* m_handle; + OwnPtr<WebKit::WebSocketStreamHandle> m_socket; + int m_maxPendingSendAllowed; + int m_pendingAmountSent; +}; + +} // namespace WebCore + +#endif // ENABLE(WEB_SOCKETS) + +#endif // SocketStreamHandleInternal_h diff --git a/Source/WebKit/chromium/src/UserMediaClientImpl.h b/Source/WebKit/chromium/src/UserMediaClientImpl.h index f6ab0416b..a1c6ac281 100644 --- a/Source/WebKit/chromium/src/UserMediaClientImpl.h +++ b/Source/WebKit/chromium/src/UserMediaClientImpl.h @@ -31,6 +31,8 @@ #ifndef UserMediaClientImpl_h #define UserMediaClientImpl_h +#if ENABLE(MEDIA_STREAM) + #include "MediaStreamSource.h" #include "UserMediaClient.h" #include <wtf/PassRefPtr.h> @@ -61,4 +63,6 @@ private: } // namespace WebKit +#endif // ENABLE(MEDIA_STREAM) + #endif // UserMediaClientImpl_h diff --git a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp index ce389adc6..fcce939f7 100644 --- a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp +++ b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.cpp @@ -128,4 +128,11 @@ unsigned VideoFrameChromiumImpl::textureId() const return 0; } +unsigned VideoFrameChromiumImpl::textureTarget() const +{ + if (m_webVideoFrame) + return m_webVideoFrame->textureTarget(); + return 0; +} + } // namespace WebKit diff --git a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h index 446ab5f54..67920866f 100644 --- a/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h +++ b/Source/WebKit/chromium/src/VideoFrameChromiumImpl.h @@ -58,6 +58,7 @@ public: virtual const WebCore::IntSize requiredTextureSize(unsigned plane) const; virtual bool hasPaddingBytes(unsigned plane) const; virtual unsigned textureId() const; + virtual unsigned textureTarget() const; private: WebVideoFrame* m_webVideoFrame; diff --git a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp index 40c151dfd..397308b52 100644 --- a/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp +++ b/Source/WebKit/chromium/src/WebCompositorInputHandlerImpl.cpp @@ -121,9 +121,9 @@ void WebCompositorInputHandlerImpl::handleInputEvent(const WebInputEvent& event) ASSERT(CCProxy::isImplThread()); ASSERT(m_client); - if (event.type == WebInputEvent::MouseWheel && !m_inputHandlerClient->haveWheelEventHandlers()) { + if (event.type == WebInputEvent::MouseWheel) { const WebMouseWheelEvent& wheelEvent = *static_cast<const WebMouseWheelEvent*>(&event); - CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(wheelEvent.x, wheelEvent.y)); + CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(wheelEvent.x, wheelEvent.y), CCInputHandlerClient::Wheel); switch (scrollStatus) { case CCInputHandlerClient::ScrollStarted: m_inputHandlerClient->scrollBy(IntSize(-wheelEvent.deltaX, -wheelEvent.deltaY)); @@ -143,7 +143,7 @@ void WebCompositorInputHandlerImpl::handleInputEvent(const WebInputEvent& event) m_expectScrollUpdateEnd = true; #endif const WebGestureEvent& gestureEvent = *static_cast<const WebGestureEvent*>(&event); - CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y)); + CCInputHandlerClient::ScrollStatus scrollStatus = m_inputHandlerClient->scrollBegin(IntPoint(gestureEvent.x, gestureEvent.y), CCInputHandlerClient::Gesture); switch (scrollStatus) { case CCInputHandlerClient::ScrollStarted: m_scrollStarted = true; diff --git a/Source/WebKit/chromium/src/WebDatabase.cpp b/Source/WebKit/chromium/src/WebDatabase.cpp index 9545a07e0..9ea6ee9b5 100644 --- a/Source/WebKit/chromium/src/WebDatabase.cpp +++ b/Source/WebKit/chromium/src/WebDatabase.cpp @@ -122,10 +122,7 @@ void WebDatabase::resetSpaceAvailable(const WebString& originIdentifier) void WebDatabase::closeDatabaseImmediately(const WebString& originIdentifier, const WebString& databaseName) { #if ENABLE(SQL_DATABASE) - HashSet<RefPtr<AbstractDatabase> > databaseHandles; - DatabaseTracker::tracker().getOpenDatabases(originIdentifier, databaseName, &databaseHandles); - for (HashSet<RefPtr<AbstractDatabase> >::iterator it = databaseHandles.begin(); it != databaseHandles.end(); ++it) - it->get()->closeImmediately(); + DatabaseTracker::tracker().closeDatabasesImmediately(originIdentifier, databaseName); #endif } diff --git a/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp index dc126f0f5..054e5b245 100644 --- a/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp +++ b/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp @@ -31,7 +31,6 @@ #include "config.h" #include "WebDevToolsFrontendImpl.h" -#include "BoundObject.h" #include "ContextMenuController.h" #include "ContextMenuItem.h" #include "DOMWindow.h" diff --git a/Source/WebKit/chromium/src/WebDragData.cpp b/Source/WebKit/chromium/src/WebDragData.cpp index 5c3123918..9e634340e 100644 --- a/Source/WebKit/chromium/src/WebDragData.cpp +++ b/Source/WebKit/chromium/src/WebDragData.cpp @@ -66,166 +66,88 @@ void WebDragData::assign(const WebDragData& other) assign(p); } -WebString WebDragData::url() const -{ - ASSERT(!isNull()); - bool ignoredSuccess; - return m_private->getData(mimeTypeURL, ignoredSuccess); -} - -void WebDragData::setURL(const WebURL& url) -{ - ensureMutable(); - m_private->setData(mimeTypeURL, KURL(url).string()); -} - -WebString WebDragData::urlTitle() const -{ - ASSERT(!isNull()); - return m_private->urlTitle(); -} - -void WebDragData::setURLTitle(const WebString& urlTitle) -{ - ensureMutable(); - m_private->setUrlTitle(urlTitle); -} - -WebString WebDragData::downloadMetadata() const -{ - ASSERT(!isNull()); - bool ignoredSuccess; - return m_private->getData(mimeTypeDownloadURL, ignoredSuccess); -} - -void WebDragData::setDownloadMetadata(const WebString& downloadMetadata) -{ - ensureMutable(); - m_private->setData(mimeTypeDownloadURL, downloadMetadata); -} - -WebString WebDragData::fileExtension() const -{ - ASSERT(!isNull()); - return m_private->fileExtension(); -} - -void WebDragData::setFileExtension(const WebString& fileExtension) -{ - ensureMutable(); - m_private->setFileExtension(fileExtension); -} - -bool WebDragData::containsFilenames() const -{ - ASSERT(!isNull()); - return m_private->containsFilenames(); -} - -void WebDragData::filenames(WebVector<WebString>& filenames) const -{ - ASSERT(!isNull()); - filenames = m_private->filenames(); -} - -void WebDragData::setFilenames(const WebVector<WebString>& filenames) -{ - ensureMutable(); - Vector<String> filenamesCopy; - filenamesCopy.append(filenames.data(), filenames.size()); - m_private->setFilenames(filenamesCopy); -} - -void WebDragData::appendToFilenames(const WebString& filename) -{ - ensureMutable(); - Vector<String> filenames = m_private->filenames(); - filenames.append(filename); - m_private->setFilenames(filenames); -} - -WebString WebDragData::plainText() const -{ - ASSERT(!isNull()); - bool ignoredSuccess; - return m_private->getData(mimeTypeTextPlain, ignoredSuccess); -} - -void WebDragData::setPlainText(const WebString& plainText) -{ - ensureMutable(); - m_private->setData(mimeTypeTextPlain, plainText); -} - -WebString WebDragData::htmlText() const -{ - ASSERT(!isNull()); - bool ignoredSuccess; - return m_private->getData(mimeTypeTextHTML, ignoredSuccess); -} - -void WebDragData::setHTMLText(const WebString& htmlText) -{ - ensureMutable(); - m_private->setData(mimeTypeTextHTML, htmlText); -} - -WebURL WebDragData::htmlBaseURL() const -{ - ASSERT(!isNull()); - return m_private->htmlBaseUrl(); -} - -void WebDragData::setHTMLBaseURL(const WebURL& htmlBaseURL) -{ - ensureMutable(); - m_private->setHtmlBaseUrl(htmlBaseURL); -} - -WebString WebDragData::fileContentFilename() const -{ - ASSERT(!isNull()); - return m_private->fileContentFilename(); -} - -void WebDragData::setFileContentFilename(const WebString& filename) -{ - ensureMutable(); - m_private->setFileContentFilename(filename); +WebVector<WebDragData::Item> WebDragData::items() const +{ + Vector<Item> itemList; + RefPtr<DOMStringList> types = m_private->types(); + if (types->contains(mimeTypeTextPlain)) { + Item item; + item.storageType = Item::StorageTypeString; + item.stringType = String(mimeTypeTextPlain); + bool ignored; + item.stringData = m_private->getData(mimeTypeTextPlain, ignored); + itemList.append(item); + } + if (types->contains(mimeTypeTextURIList)) { + Item item; + item.storageType = Item::StorageTypeString; + item.stringType = String(mimeTypeTextURIList); + bool ignored; + item.stringData = m_private->getData(mimeTypeURL, ignored); + item.title = m_private->urlTitle(); + itemList.append(item); + } + if (types->contains(mimeTypeTextHTML)) { + Item item; + item.storageType = Item::StorageTypeString; + item.stringType = String(mimeTypeTextHTML); + bool ignored; + item.stringData = m_private->getData(mimeTypeTextHTML, ignored); + item.baseURL = m_private->htmlBaseUrl(); + itemList.append(item); + } + if (types->contains(mimeTypeDownloadURL)) { + Item item; + item.storageType = Item::StorageTypeString; + item.stringType = String(mimeTypeDownloadURL); + bool ignored; + item.stringData = m_private->getData(mimeTypeDownloadURL, ignored); + itemList.append(item); + } + const HashMap<String, String>& customData = m_private->customData(); + for (HashMap<String, String>::const_iterator it = customData.begin(); it != customData.end(); ++it) { + Item item; + item.storageType = Item::StorageTypeString; + item.stringType = it->first; + item.stringData = it->second; + itemList.append(item); + } + if (m_private->fileContent()) { + Item item; + item.storageType = Item::StorageTypeBinaryData; + item.binaryData = m_private->fileContent(); + item.title = m_private->fileContentFilename(); + itemList.append(item); + } + // We don't handle filenames here, since they are never used for dragging out. + return itemList; } -WebData WebDragData::fileContent() const +void WebDragData::setItems(const WebVector<Item>& itemList) { - ASSERT(!isNull()); - return WebData(m_private->fileContent()); + m_private->clearAll(); + for (size_t i = 0; i < itemList.size(); ++i) + addItem(itemList[i]); } -void WebDragData::setFileContent(const WebData& fileContent) +void WebDragData::addItem(const Item& item) { ensureMutable(); - m_private->setFileContent(fileContent); -} - -WebVector<WebDragData::CustomData> WebDragData::customData() const -{ - ASSERT(!isNull()); - WebVector<CustomData> customData(static_cast<size_t>(m_private->customData().size())); - HashMap<String, String>::const_iterator begin = m_private->customData().begin(); - HashMap<String, String>::const_iterator end = m_private->customData().end(); - size_t i = 0; - for (HashMap<String, String>::const_iterator it = begin; it != end; ++it) { - CustomData data = {it->first, it->second}; - customData[i++] = data; + switch (item.storageType) { + case Item::StorageTypeString: + m_private->setData(item.stringType, item.stringData); + if (String(item.stringType) == mimeTypeTextURIList) + m_private->setUrlTitle(item.title); + else if (String(item.stringType) == mimeTypeTextHTML) + m_private->setHtmlBaseUrl(item.baseURL); + return; + case Item::StorageTypeFilename: + m_private->addFilename(item.filenameData); + return; + case Item::StorageTypeBinaryData: + // This should never happen when dragging in. + ASSERT_NOT_REACHED(); } - return customData; -} - -void WebDragData::setCustomData(const WebVector<WebDragData::CustomData>& customData) -{ - ensureMutable(); - HashMap<String, String>& customDataMap = m_private->customData(); - for (size_t i = 0; i < customData.size(); ++i) - customDataMap.set(customData[i].type, customData[i].data); } WebDragData::WebDragData(const WTF::PassRefPtr<WebCore::ChromiumDataObject>& data) diff --git a/Source/WebKit/chromium/src/WebFrameImpl.cpp b/Source/WebKit/chromium/src/WebFrameImpl.cpp index f8d2034fd..adf202371 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.cpp +++ b/Source/WebKit/chromium/src/WebFrameImpl.cpp @@ -123,8 +123,6 @@ #include "ReplaceSelectionCommand.h" #include "ResourceHandle.h" #include "ResourceRequest.h" -#include "SVGDocumentExtensions.h" -#include "SVGSMILElement.h" #include "SchemeRegistry.h" #include "ScriptController.h" #include "ScriptSourceCode.h" @@ -1303,7 +1301,7 @@ void WebFrameImpl::requestTextChecking(const WebElement& webElem) RefPtr<Range> rangeToCheck = rangeOfContents(const_cast<Element*>(webElem.constUnwrap<Element>())); - frame()->editor()->spellChecker()->requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, rangeToCheck, rangeToCheck)); + frame()->editor()->spellChecker()->requestCheckingFor(SpellCheckRequest::create(TextCheckingTypeSpelling | TextCheckingTypeGrammar, TextCheckingProcessBatch, rangeToCheck, rangeToCheck)); } bool WebFrameImpl::hasSelection() const @@ -1946,26 +1944,6 @@ bool WebFrameImpl::selectionStartHasSpellingMarkerFor(int from, int length) cons return m_frame->editor()->selectionStartHasMarkerFor(DocumentMarker::Spelling, from, length); } -bool WebFrameImpl::pauseSVGAnimation(const WebString& animationId, double time, const WebString& elementId) -{ -#if !ENABLE(SVG) - return false; -#else - if (!m_frame) - return false; - - Document* document = m_frame->document(); - if (!document || !document->svgExtensions()) - return false; - - Node* coreNode = document->getElementById(animationId); - if (!coreNode || !SVGSMILElement::isSMILElement(coreNode)) - return false; - - return document->accessSVGExtensions()->sampleAnimationAtTime(elementId, static_cast<SVGSMILElement*>(coreNode), time); -#endif -} - WebString WebFrameImpl::layerTreeAsText(bool showDebugInfo) const { if (!m_frame) diff --git a/Source/WebKit/chromium/src/WebFrameImpl.h b/Source/WebKit/chromium/src/WebFrameImpl.h index de38d0dca..700f6ea40 100644 --- a/Source/WebKit/chromium/src/WebFrameImpl.h +++ b/Source/WebKit/chromium/src/WebFrameImpl.h @@ -214,9 +214,6 @@ public: virtual WebRect selectionBoundsRect() const; virtual bool selectionStartHasSpellingMarkerFor(int from, int length) const; - virtual bool pauseSVGAnimation(const WebString& animationId, - double time, - const WebString& elementId); virtual WebString layerTreeAsText(bool showDebugInfo = false) const; static PassRefPtr<WebFrameImpl> create(WebFrameClient* client); diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp index 1ec8af5bc..55a6add57 100755 --- a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp +++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.cpp @@ -82,6 +82,11 @@ void WebIDBObjectStoreImpl::deleteFunction(const WebIDBKey& key, WebIDBCallbacks m_objectStore->deleteFunction(key, IDBCallbacksProxy::create(adoptPtr(callbacks)), transaction.getIDBTransactionBackendInterface(), ec); } +void WebIDBObjectStoreImpl::deleteFunction(const WebIDBKeyRange& keyRange, WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec) +{ + m_objectStore->deleteFunction(keyRange, IDBCallbacksProxy::create(adoptPtr(callbacks)), transaction.getIDBTransactionBackendInterface(), ec); +} + void WebIDBObjectStoreImpl::clear(WebIDBCallbacks* callbacks, const WebIDBTransaction& transaction, WebExceptionCode& ec) { m_objectStore->clear(IDBCallbacksProxy::create(adoptPtr(callbacks)), transaction.getIDBTransactionBackendInterface(), ec); diff --git a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h index 6f580f01a..d2202fc7f 100644 --- a/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h +++ b/Source/WebKit/chromium/src/WebIDBObjectStoreImpl.h @@ -51,7 +51,8 @@ public: void get(const WebIDBKey& key, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); void put(const WebSerializedScriptValue&, const WebIDBKey&, PutMode, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); - void deleteFunction(const WebIDBKey& key, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); + void deleteFunction(const WebIDBKey&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); + void deleteFunction(const WebIDBKeyRange&, WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); void clear(WebIDBCallbacks*, const WebIDBTransaction&, WebExceptionCode&); // FIXME: Remove once callers are updated. diff --git a/Source/WebKit/chromium/src/WebInputElement.cpp b/Source/WebKit/chromium/src/WebInputElement.cpp index 5dadb0cf8..736165bbf 100644 --- a/Source/WebKit/chromium/src/WebInputElement.cpp +++ b/Source/WebKit/chromium/src/WebInputElement.cpp @@ -90,7 +90,7 @@ int WebInputElement::size() const void WebInputElement::setValue(const WebString& value, bool sendChangeEvent) { - unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent); + unwrap<HTMLInputElement>()->setValue(value, sendChangeEvent ? DispatchChangeEvent : DispatchNoEvent); } WebString WebInputElement::value() const diff --git a/Source/WebKit/chromium/src/WebInputEventConversion.cpp b/Source/WebKit/chromium/src/WebInputEventConversion.cpp index 64ba31170..5cf0ccaec 100644 --- a/Source/WebKit/chromium/src/WebInputEventConversion.cpp +++ b/Source/WebKit/chromium/src/WebInputEventConversion.cpp @@ -389,6 +389,10 @@ WebMouseEventBuilder::WebMouseEventBuilder(const Widget* widget, const MouseEven windowY = p.y(); x = event.absoluteLocation().x() - widget->location().x(); y = event.absoluteLocation().y() - widget->location().y(); +#if ENABLE(POINTER_LOCK) + movementX = event.webkitMovementX(); + movementY = event.webkitMovementY(); +#endif clickCount = event.detail(); } diff --git a/Source/WebKit/chromium/src/WebKit.cpp b/Source/WebKit/chromium/src/WebKit.cpp index 2b2b2597c..77858c4e7 100644 --- a/Source/WebKit/chromium/src/WebKit.cpp +++ b/Source/WebKit/chromium/src/WebKit.cpp @@ -45,6 +45,10 @@ #include "WorkerContextExecutionProxy.h" #include "v8.h" +#if OS(DARWIN) +#include "WebSystemInterface.h" +#endif + #include <wtf/Assertions.h> #include <wtf/MainThread.h> #include <wtf/Threading.h> @@ -107,6 +111,10 @@ void initializeWithoutV8(WebKitPlatformSupport* webKitPlatformSupport) ASSERT(!s_webKitInitialized); s_webKitInitialized = true; +#if OS(DARWIN) + InitWebCoreSystemInterface(); +#endif + ASSERT(webKitPlatformSupport); ASSERT(!s_webKitPlatformSupport); s_webKitPlatformSupport = webKitPlatformSupport; diff --git a/Source/WebKit/chromium/src/WebLayerTreeView.cpp b/Source/WebKit/chromium/src/WebLayerTreeView.cpp index b288b563b..d2c0f0c12 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeView.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeView.cpp @@ -43,11 +43,11 @@ WebLayerTreeView::Settings::operator CCSettings() const settings.showFPSCounter = showFPSCounter; settings.showPlatformLayerTree = showPlatformLayerTree; settings.refreshRate = refreshRate; + settings.perTilePainting = perTilePainting; settings.partialSwapEnabled = partialSwapEnabled; + settings.threadedAnimationEnabled = threadedAnimationEnabled; - // FIXME: showFPSCounter / showPlatformLayerTree aren't supported currently. - settings.showFPSCounter = false; - settings.showPlatformLayerTree = false; + // FIXME: showFPSCounter / showPlatformLayerTree / maxPartialTextureUpdates aren't supported currently. return settings; } @@ -118,4 +118,9 @@ WebLayerTreeView::operator PassRefPtr<CCLayerTreeHost>() const return m_private.get(); } +void WebLayerTreeView::setNeedsRedraw() +{ + m_private->setNeedsRedraw(); +} + } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp index 981477118..29d033215 100644 --- a/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebLayerTreeViewImpl.cpp @@ -86,21 +86,7 @@ PassRefPtr<GraphicsContext3D> WebLayerTreeViewImpl::createLayerTreeHostContext3D if (!webContext) return 0; - WebGraphicsContext3D::Attributes webAttributes = webContext->getContextAttributes(); - GraphicsContext3D::Attributes attributes; - attributes.alpha = webAttributes.alpha; - attributes.depth = webAttributes.depth; - attributes.stencil = webAttributes.stencil; - attributes.antialias = webAttributes.antialias; - attributes.premultipliedAlpha = webAttributes.premultipliedAlpha; - attributes.canRecoverFromContextLoss = webAttributes.canRecoverFromContextLoss; - attributes.noExtensions = webAttributes.noExtensions; - attributes.shareResources = webAttributes.shareResources; - attributes.preserveDrawingBuffer = false; - - GraphicsContext3D::RenderStyle style = GraphicsContext3D::RenderDirectlyToHostWindow; - GraphicsContext3DPrivate::ThreadUsage usage = CCProxy::hasImplThread() ? GraphicsContext3DPrivate::ForUseOnAnotherThread : GraphicsContext3DPrivate::ForUseOnThisThread; - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), attributes, 0, style, usage); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow, false /* preserveDrawingBuffer */ ); } void WebLayerTreeViewImpl::didCommitAndDrawFrame() diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp index 996e70710..ec74b6bea 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.cpp @@ -28,6 +28,7 @@ #include "WebMediaElement.h" #include "WebMediaPlayer.h" #include "WebViewImpl.h" +#include "cc/CCProxy.h" #include "platform/WebCString.h" #include "platform/WebCanvas.h" #include "platform/WebKitPlatformSupport.h" @@ -105,6 +106,8 @@ WebMediaPlayerClientImpl::~WebMediaPlayerClientImpl() MutexLocker locker(m_compositingMutex); if (m_videoFrameProviderClient) m_videoFrameProviderClient->stopUsingProvider(); + if (m_webMediaPlayer) + m_webMediaPlayer->setStreamTextureClient(0); #endif } @@ -149,7 +152,7 @@ void WebMediaPlayerClientImpl::repaint() ASSERT(m_mediaPlayer); #if USE(ACCELERATED_COMPOSITING) if (m_videoLayer && supportsAcceleratedRendering()) - m_videoLayer->setNeedsDisplay(); + m_videoLayer->contentChanged(); #endif m_mediaPlayer->repaint(); } @@ -237,6 +240,7 @@ void WebMediaPlayerClientImpl::load(const String& url) m_url = url; if (m_preload == MediaPlayer::None) { + MutexLocker locker(m_compositingMutex); #if ENABLE(WEB_AUDIO) m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider. #endif @@ -248,6 +252,7 @@ void WebMediaPlayerClientImpl::load(const String& url) void WebMediaPlayerClientImpl::loadInternal() { + MutexLocker locker(m_compositingMutex); #if ENABLE(WEB_AUDIO) m_audioSourceProvider.wrap(0); // Clear weak reference to m_webMediaPlayer's WebAudioSourceProvider. #endif @@ -597,6 +602,8 @@ void WebMediaPlayerClientImpl::setVideoFrameProviderClient(VideoFrameProvider::C { MutexLocker locker(m_compositingMutex); m_videoFrameProviderClient = client; + if (m_webMediaPlayer) + m_webMediaPlayer->setStreamTextureClient(client ? this : 0); } VideoFrameChromium* WebMediaPlayerClientImpl::getCurrentFrame() @@ -679,6 +686,20 @@ void WebMediaPlayerClientImpl::startDelayedLoad() loadInternal(); } +void WebMediaPlayerClientImpl::didReceiveFrame() +{ + // No lock since this gets called on the client's thread. + ASSERT(CCProxy::isImplThread()); + m_videoFrameProviderClient->didReceiveFrame(); +} + +void WebMediaPlayerClientImpl::didUpdateMatrix(const float* matrix) +{ + // No lock since this gets called on the client's thread. + ASSERT(CCProxy::isImplThread()); + m_videoFrameProviderClient->didUpdateMatrix(matrix); +} + WebMediaPlayerClientImpl::WebMediaPlayerClientImpl() : m_mediaPlayer(0) , m_delayingLoad(false) diff --git a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h index e75e73ae1..d85e0d1fc 100644 --- a/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h +++ b/Source/WebKit/chromium/src/WebMediaPlayerClientImpl.h @@ -40,7 +40,9 @@ #include "VideoLayerChromium.h" #include "WebAudioSourceProviderClient.h" #include "WebMediaPlayerClient.h" +#include "WebStreamTextureClient.h" #include <wtf/OwnPtr.h> +#include <wtf/PassOwnPtr.h> namespace WebCore { class AudioSourceProviderClient; } @@ -56,7 +58,8 @@ class WebMediaPlayerClientImpl : public WebCore::MediaPlayerPrivateInterface #if USE(ACCELERATED_COMPOSITING) , public WebCore::VideoFrameProvider #endif - , public WebMediaPlayerClient { + , public WebMediaPlayerClient + , public WebStreamTextureClient { public: static bool isEnabled(); @@ -150,6 +153,10 @@ public: virtual void sourceEndOfStream(WebCore::MediaPlayer::EndOfStreamStatus); #endif + // WebStreamTextureClient methods: + virtual void didReceiveFrame(); + virtual void didUpdateMatrix(const float*); + private: WebMediaPlayerClientImpl(); void startDelayedLoad(); diff --git a/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp b/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp index ca0583488..072a9909c 100644 --- a/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp +++ b/Source/WebKit/chromium/src/WebPageSerializerImpl.cpp @@ -417,7 +417,6 @@ void WebPageSerializerImpl::buildContentForNode(Node* node, case Node::ATTRIBUTE_NODE: case Node::DOCUMENT_NODE: case Node::DOCUMENT_FRAGMENT_NODE: - case Node::SHADOW_ROOT_NODE: // Should not exist. ASSERT_NOT_REACHED(); break; diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp index 129088ef4..10c3e2e4b 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.cpp @@ -60,6 +60,7 @@ #include "FrameLoadRequest.h" #include "FrameView.h" #include "GraphicsContext.h" +#include "HitTestResult.h" #include "HostWindow.h" #include "HTMLFormElement.h" #include "HTMLNames.h" @@ -433,6 +434,26 @@ void WebPluginContainerImpl::zoomLevelChanged(double zoomLevel) WebViewImpl* view = WebViewImpl::fromPage(m_element->document()->frame()->page()); view->fullFramePluginZoomLevelChanged(zoomLevel); } + +bool WebPluginContainerImpl::isRectTopmost(const WebRect& rect) +{ + Page* page = m_element->document()->page(); + if (!page) + return false; + + // hitTestResultAtPoint() takes a padding rectangle. + // FIXME: We'll be off by 1 when the width or height is even. + IntRect windowRect = convertToContainingWindow(static_cast<IntRect>(rect)); + LayoutPoint center = windowRect.center(); + // Make the rect we're checking (the point surrounded by padding rects) contained inside the requested rect. (Note that -1/2 is 0.) + LayoutSize padding((windowRect.width() - 1) / 2, (windowRect.height() - 1) / 2); + HitTestResult result = + page->mainFrame()->eventHandler()->hitTestResultAtPoint(center, false, false, DontHitTestScrollbars, HitTestRequest::ReadOnly | HitTestRequest::Active, padding); + const HitTestResult::NodeSet& nodes = result.rectBasedTestResult(); + if (nodes.size() != 1) + return false; + return (nodes.first().get() == m_element); +} void WebPluginContainerImpl::didReceiveResponse(const ResourceResponse& response) { @@ -519,17 +540,6 @@ bool WebPluginContainerImpl::paintCustomOverhangArea(GraphicsContext* context, c return true; } -#if ENABLE(GESTURE_EVENTS) -bool WebPluginContainerImpl::handleGestureEvent(const WebCore::PlatformGestureEvent& gestureEvent) -{ - if (m_scrollbarGroup) { - m_scrollbarGroup->handleGestureEvent(gestureEvent); - return true; - } - return false; -} -#endif - // Private methods ------------------------------------------------------------- WebPluginContainerImpl::WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin) diff --git a/Source/WebKit/chromium/src/WebPluginContainerImpl.h b/Source/WebKit/chromium/src/WebPluginContainerImpl.h index 8d6794d6f..898130084 100644 --- a/Source/WebKit/chromium/src/WebPluginContainerImpl.h +++ b/Source/WebKit/chromium/src/WebPluginContainerImpl.h @@ -104,6 +104,7 @@ public: virtual WebString executeScriptURL(const WebURL&, bool popupsAllowed); virtual void loadFrameRequest(const WebURLRequest&, const WebString& target, bool notifyNeeded, void* notifyData); virtual void zoomLevelChanged(double zoomLevel); + virtual bool isRectTopmost(const WebRect&); // This cannot be null. WebPlugin* plugin() { return m_webPlugin; } @@ -150,10 +151,6 @@ public: bool paintCustomOverhangArea(WebCore::GraphicsContext*, const WebCore::IntRect&, const WebCore::IntRect&, const WebCore::IntRect&); -#if ENABLE(GESTURE_EVENTS) - bool handleGestureEvent(const WebCore::PlatformGestureEvent&); -#endif - private: WebPluginContainerImpl(WebCore::HTMLPlugInElement* element, WebPlugin* webPlugin); ~WebPluginContainerImpl(); diff --git a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp index 38963b521..f1960eb31 100644 --- a/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp +++ b/Source/WebKit/chromium/src/WebRuntimeFeatures.cpp @@ -450,5 +450,23 @@ bool WebRuntimeFeatures::isShadowDOMEnabled() #endif } +void WebRuntimeFeatures::enableStyleScoped(bool enable) +{ +#if ENABLE(STYLE_SCOPED) + RuntimeEnabledFeatures::setStyleScopedEnabled(enable); +#else + UNUSED_PARAM(enable); +#endif +} + +bool WebRuntimeFeatures::isStyleScopedEnabled() +{ +#if ENABLE(STYLE_SCOPED) + return RuntimeEnabledFeatures::styleScopedEnabled(); +#else + return false; +#endif +} + } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebScopedUserGesture.cpp b/Source/WebKit/chromium/src/WebScopedUserGesture.cpp new file mode 100644 index 000000000..68426fcae --- /dev/null +++ b/Source/WebKit/chromium/src/WebScopedUserGesture.cpp @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2011 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" +#include "WebScopedUserGesture.h" + +#include "UserGestureIndicator.h" + +namespace WebKit { + +void WebScopedUserGesture::initialize() +{ + m_indicator.reset(new WebCore::UserGestureIndicator(WebCore::DefinitelyProcessingUserGesture)); +} + +void WebScopedUserGesture::reset() +{ + m_indicator.reset(0); +} + +} // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.cpp b/Source/WebKit/chromium/src/WebSettingsImpl.cpp index 11e9c337b..485a5b051 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.cpp +++ b/Source/WebKit/chromium/src/WebSettingsImpl.cpp @@ -288,6 +288,11 @@ void WebSettingsImpl::setExperimentalWebGLEnabled(bool enabled) m_settings->setWebGLEnabled(enabled); } +void WebSettingsImpl::setExperimentalCSSRegionsEnabled(bool enabled) +{ + m_settings->setCSSRegionsEnabled(enabled); +} + void WebSettingsImpl::setOpenGLMultisamplingEnabled(bool enabled) { m_settings->setOpenGLMultisamplingEnabled(enabled); @@ -326,6 +331,7 @@ void WebSettingsImpl::setEditingBehavior(EditingBehavior behavior) void WebSettingsImpl::setAcceleratedCompositingEnabled(bool enabled) { m_settings->setAcceleratedCompositingEnabled(enabled); + m_settings->setScrollingCoordinatorEnabled(enabled); } void WebSettingsImpl::setForceCompositingMode(bool enabled) @@ -457,6 +463,16 @@ void WebSettingsImpl::setAllowRunningOfInsecureContent(bool enabled) m_settings->setAllowRunningOfInsecureContent(enabled); } +void WebSettingsImpl::setPasswordEchoEnabled(bool flag) +{ + m_settings->setPasswordEchoEnabled(flag); +} + +void WebSettingsImpl::setPasswordEchoDurationInSeconds(double durationInSeconds) +{ + m_settings->setPasswordEchoDurationInSeconds(durationInSeconds); +} + void WebSettingsImpl::setShouldPrintBackgrounds(bool enabled) { m_settings->setShouldPrintBackgrounds(enabled); @@ -527,4 +543,9 @@ void WebSettingsImpl::setPartialSwapEnabled(bool enabled) m_settings->setPartialSwapEnabled(enabled); } +void WebSettingsImpl::setThreadedAnimationEnabled(bool enabled) +{ + m_settings->setThreadedAnimationEnabled(enabled); +} + } // namespace WebKit diff --git a/Source/WebKit/chromium/src/WebSettingsImpl.h b/Source/WebKit/chromium/src/WebSettingsImpl.h index 45e62db6f..51d9323a4 100644 --- a/Source/WebKit/chromium/src/WebSettingsImpl.h +++ b/Source/WebKit/chromium/src/WebSettingsImpl.h @@ -88,6 +88,7 @@ public: virtual void setOfflineWebApplicationCacheEnabled(bool); virtual void setWebAudioEnabled(bool); virtual void setExperimentalWebGLEnabled(bool); + virtual void setExperimentalCSSRegionsEnabled(bool); virtual void setOpenGLMultisamplingEnabled(bool); virtual void setPrivilegedWebGLExtensionsEnabled(bool); virtual void setWebGLErrorsToConsoleEnabled(bool); @@ -124,6 +125,8 @@ public: virtual void setFullScreenEnabled(bool); virtual void setAllowDisplayOfInsecureContent(bool); virtual void setAllowRunningOfInsecureContent(bool); + virtual void setPasswordEchoEnabled(bool); + virtual void setPasswordEchoDurationInSeconds(double); virtual void setShouldPrintBackgrounds(bool); virtual void setEnableScrollAnimator(bool); virtual void setHixie76WebSocketProtocolEnabled(bool); @@ -134,6 +137,7 @@ public: virtual void setAcceleratedPaintingEnabled(bool); virtual void setPerTilePaintingEnabled(bool); virtual void setPartialSwapEnabled(bool); + virtual void setThreadedAnimationEnabled(bool); private: WebCore::Settings* m_settings; diff --git a/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp b/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp index 7a4bddb22..3fa19d25d 100644 --- a/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp +++ b/Source/WebKit/chromium/src/WebSharedWorkerImpl.cpp @@ -443,6 +443,7 @@ static void dispatchOnInspectorBackendTask(ScriptExecutionContext* context, cons void WebSharedWorkerImpl::dispatchDevToolsMessage(const WebString& message) { workerThread()->runLoop().postTaskForMode(createCallbackTask(dispatchOnInspectorBackendTask, String(message)), WorkerDebuggerAgent::debuggerTaskMode); + WorkerDebuggerAgent::interruptAndDispatchInspectorCommands(workerThread()); } WebSharedWorker* WebSharedWorker::create(WebSharedWorkerClient* client) diff --git a/Source/WebKit/chromium/src/WebURLResponse.cpp b/Source/WebKit/chromium/src/WebURLResponse.cpp index 2eacda580..ec212e517 100644 --- a/Source/WebKit/chromium/src/WebURLResponse.cpp +++ b/Source/WebKit/chromium/src/WebURLResponse.cpp @@ -47,6 +47,27 @@ using namespace WebCore; namespace WebKit { +namespace { + +class ExtraDataContainer : public ResourceResponse::ExtraData { +public: + static PassRefPtr<ExtraDataContainer> create(WebURLResponse::ExtraData* extraData) { return adoptRef(new ExtraDataContainer(extraData)); } + + virtual ~ExtraDataContainer() { } + + WebURLResponse::ExtraData* extraData() const { return m_extraData.get(); } + +private: + explicit ExtraDataContainer(WebURLResponse::ExtraData* extraData) + : m_extraData(adoptPtr(extraData)) + { + } + + OwnPtr<WebURLResponse::ExtraData> m_extraData; +}; + +} // namespace + // The standard implementation of WebURLResponsePrivate, which maintains // ownership of a ResourceResponse instance. class WebURLResponsePrivateImpl : public WebURLResponsePrivate { @@ -399,6 +420,19 @@ void WebURLResponse::setRemotePort(unsigned short remotePort) m_private->m_resourceResponse->setRemotePort(remotePort); } +WebURLResponse::ExtraData* WebURLResponse::extraData() const +{ + RefPtr<ResourceResponse::ExtraData> data = m_private->m_resourceResponse->extraData(); + if (!data) + return 0; + return static_cast<ExtraDataContainer*>(data.get())->extraData(); +} + +void WebURLResponse::setExtraData(WebURLResponse::ExtraData* extraData) +{ + m_private->m_resourceResponse->setExtraData(ExtraDataContainer::create(extraData)); +} + void WebURLResponse::assign(WebURLResponsePrivate* p) { // Subclasses may call this directly so a self-assignment check is needed diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp index a05e98920..55a2052a4 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.cpp +++ b/Source/WebKit/chromium/src/WebViewImpl.cpp @@ -99,7 +99,6 @@ #include "RenderWidget.h" #include "ResourceHandle.h" #include "SchemeRegistry.h" -#include "ScrollAnimator.h" #include "SecurityOrigin.h" #include "SecurityPolicy.h" #include "Settings.h" @@ -171,7 +170,7 @@ using namespace std; namespace { -GraphicsContext3D::Attributes getCompositorContextAttributes() +WebKit::WebGraphicsContext3D::Attributes getCompositorContextAttributes(bool threaded) { // Explicitly disable antialiasing for the compositor. As of the time of // this writing, the only platform that supported antialiasing for the @@ -183,12 +182,21 @@ GraphicsContext3D::Attributes getCompositorContextAttributes() // be optimized to resolve directly into the IOSurface shared between the // GPU and browser processes. For these reasons and to avoid platform // disparities we explicitly disable antialiasing. - GraphicsContext3D::Attributes attributes; + WebKit::WebGraphicsContext3D::Attributes attributes; attributes.antialias = false; attributes.shareResources = true; + attributes.forUseOnAnotherThread = threaded; return attributes; } +// The following constants control parameters for automated scaling of webpages +// (such as due to a double tap gesture or find in page etc.). These are +// experimentally determined. +static const int touchPointPadding = 32; +static const float minScaleDifference = 0.01; +static const float doubleTapZoomContentDefaultMargin = 5; +static const float doubleTapZoomContentMinimumMargin = 2; + } // anonymous namespace namespace WebKit { @@ -390,21 +398,21 @@ WebViewImpl::WebViewImpl(WebViewClient* client) pageClients.editorClient = &m_editorClientImpl; pageClients.dragClient = &m_dragClientImpl; pageClients.inspectorClient = &m_inspectorClientImpl; -#if ENABLE(INPUT_SPEECH) - pageClients.speechInputClient = m_speechInputClient.get(); -#endif - pageClients.deviceOrientationClient = m_deviceOrientationClientProxy.get(); pageClients.geolocationClient = m_geolocationClientProxy.get(); -#if ENABLE(NOTIFICATIONS) - pageClients.notificationClient = notificationPresenterImpl(); -#endif pageClients.backForwardClient = BackForwardListChromium::create(this); -#if ENABLE(MEDIA_STREAM) - pageClients.userMediaClient = &m_userMediaClientImpl; -#endif m_page = adoptPtr(new Page(pageClients)); +#if ENABLE(MEDIA_STREAM) + provideUserMediaTo(m_page.get(), &m_userMediaClientImpl); +#endif +#if ENABLE(INPUT_SPEECH) + provideSpeechInputTo(m_page.get(), m_speechInputClient.get()); +#endif +#if ENABLE(NOTIFICATIONS) + provideNotification(m_page.get(), notificationPresenterImpl()); +#endif + provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get()); m_geolocationClientProxy->setController(m_page->geolocationController()); m_page->setGroupName(pageGroupName); @@ -614,14 +622,13 @@ bool WebViewImpl::mouseWheel(const WebMouseWheelEvent& event) bool WebViewImpl::gestureEvent(const WebGestureEvent& event) { PlatformGestureEventBuilder platformEvent(mainFrameImpl()->frameView(), event); - bool handled = mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); - - Frame* frame = mainFrameImpl()->frame(); - WebPluginContainerImpl* pluginContainer = WebFrameImpl::pluginContainerFromFrame(frame); - if (pluginContainer) - handled |= pluginContainer->handleGestureEvent(platformEvent); + return mainFrameImpl()->frame()->eventHandler()->handleGestureEvent(platformEvent); +} - return handled; +void WebViewImpl::startPageScaleAnimation(const IntPoint& scroll, bool useAnchor, float newScale, double durationSec) +{ + if (m_layerTreeHost) + m_layerTreeHost->startPageScaleAnimation(IntSize(scroll.x(), scroll.y()), useAnchor, newScale, durationSec); } #endif @@ -797,15 +804,159 @@ bool WebViewImpl::touchEvent(const WebTouchEvent& event) } #endif +#if ENABLE(GESTURE_EVENTS) +WebRect WebViewImpl::computeBlockBounds(const WebRect& rect, AutoZoomType zoomType) +{ + if (!mainFrameImpl()) + return WebRect(); + + // Use the rect-based hit test to find the node. + IntPoint point = mainFrameImpl()->frameView()->windowToContents(IntPoint(rect.x, rect.y)); + HitTestResult result = mainFrameImpl()->frame()->eventHandler()->hitTestResultAtPoint(point, + false, zoomType == FindInPage, DontHitTestScrollbars, HitTestRequest::Active | HitTestRequest::ReadOnly, + IntSize(rect.width, rect.height)); + + Node* node = result.innerNonSharedNode(); + if (!node) + return WebRect(); + + // Find the block type node based on the hit node. + while (node && (!node->renderer() || node->renderer()->isInline())) + node = node->parentNode(); + + // Return the bounding box in the window coordinate system. + if (node) { + IntRect rect = node->Node::getRect(); + Frame* frame = node->document()->frame(); + return frame->view()->contentsToWindow(rect); + } + return WebRect(); +} + +WebRect WebViewImpl::widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin) +{ + WebSize maxSize; + if (mainFrame()) + maxSize = mainFrame()->contentsSize(); + IntSize scrollOffset; + if (mainFrame()) + scrollOffset = mainFrame()->scrollOffset(); + int leftMargin = targetMargin; + int rightMargin = targetMargin; + + const int absoluteSourceX = source.x + scrollOffset.width(); + if (leftMargin > absoluteSourceX) { + leftMargin = absoluteSourceX; + rightMargin = max(leftMargin, minimumMargin); + } + + const int maximumRightMargin = maxSize.width - (source.width + absoluteSourceX); + if (rightMargin > maximumRightMargin) { + rightMargin = maximumRightMargin; + leftMargin = min(leftMargin, max(rightMargin, minimumMargin)); + } + + const int newWidth = source.width + leftMargin + rightMargin; + const int newX = source.x - leftMargin; + + ASSERT(newWidth >= 0); + ASSERT(scrollOffset.width() + newX + newWidth <= maxSize.width); + + return WebRect(newX, source.y, newWidth, source.height); +} + +void WebViewImpl::computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType zoomType, float& scale, WebPoint& scroll) +{ + scale = pageScaleFactor(); + scroll.x = scroll.y = 0; + WebRect targetRect = hitRect; + if (targetRect.isEmpty()) + targetRect.width = targetRect.height = touchPointPadding; + + WebRect rect = computeBlockBounds(targetRect, zoomType); + + const float overviewScale = m_minimumPageScaleFactor; + bool scaleUnchanged = true; + if (!rect.isEmpty()) { + // Pages should be as legible as on desktop when at dpi scale, so no + // need to zoom in further when automatically determining zoom level + // (after double tap, find in page, etc), though the user should still + // be allowed to manually pinch zoom in further if they desire. + const float maxScale = deviceScaleFactor(); + + const float defaultMargin = doubleTapZoomContentDefaultMargin * deviceScaleFactor(); + const float minimumMargin = doubleTapZoomContentMinimumMargin * deviceScaleFactor(); + // We want the margins to have the same physical size, which means we + // need to express them in post-scale size. To do that we'd need to know + // the scale we're scaling to, but that depends on the margins. Instead + // we express them as a fraction of the target rectangle: this will be + // correct if we end up fully zooming to it, and won't matter if we + // don't. + rect = widenRectWithinPageBounds(rect, + static_cast<int>(defaultMargin * rect.width / m_size.width), + static_cast<int>(minimumMargin * rect.width / m_size.width)); + + // Fit block to screen, respecting limits. + scale *= static_cast<float>(m_size.width) / rect.width; + scale = min(scale, maxScale); + scale = clampPageScaleFactorToLimits(scale); + + scaleUnchanged = fabs(pageScaleFactor() - scale) < minScaleDifference; + } + + if (zoomType == DoubleTap) { + if (rect.isEmpty() || scaleUnchanged) { + // Zoom out to overview mode. + if (overviewScale) + scale = overviewScale; + return; + } + } else if (rect.isEmpty()) { + // Keep current scale (no need to scroll as x,y will normally already + // be visible). FIXME: Revisit this if it isn't always true. + return; + } + + // FIXME: If this is being called for auto zoom during find in page, + // then if the user manually zooms in it'd be nice to preserve the relative + // increase in zoom they caused (if they zoom out then it's ok to zoom + // them back in again). This isn't compatible with our current double-tap + // zoom strategy (fitting the containing block to the screen) though. + + float screenHeight = m_size.height / scale * pageScaleFactor(); + float screenWidth = m_size.width / scale * pageScaleFactor(); + + // Scroll to vertically align the block. + if (rect.height < screenHeight) { + // Vertically center short blocks. + rect.y -= 0.5 * (screenHeight - rect.height); + } else { + // Ensure position we're zooming to (+ padding) isn't off the bottom of + // the screen. + rect.y = max<float>(rect.y, hitRect.y + touchPointPadding - screenHeight); + } // Otherwise top align the block. + + // Do the same thing for horizontal alignment. + if (rect.width < screenWidth) + rect.x -= 0.5 * (screenWidth - rect.width); + else + rect.x = max<float>(rect.x, hitRect.x + touchPointPadding - screenWidth); + + scroll.x = rect.x; + scroll.y = rect.y; +} +#endif + void WebViewImpl::numberOfWheelEventHandlersChanged(unsigned numberOfWheelHandlers) { - m_haveWheelEventHandlers = numberOfWheelHandlers > 0; if (m_client) m_client->numberOfWheelEventHandlersChanged(numberOfWheelHandlers); -#if USE(ACCELERATED_COMPOSITING) - if (m_layerTreeHost) - m_layerTreeHost->setHaveWheelEventHandlers(m_haveWheelEventHandlers); -#endif +} + +void WebViewImpl::numberOfTouchEventHandlersChanged(unsigned numberOfTouchHandlers) +{ + if (m_client) + m_client->numberOfTouchEventHandlersChanged(numberOfTouchHandlers); } #if !OS(DARWIN) @@ -1257,6 +1408,14 @@ void WebViewImpl::composite(bool) #endif } +void WebViewImpl::setNeedsRedraw() +{ +#if USE(ACCELERATED_COMPOSITING) + if (m_layerTreeHost && isAcceleratedCompositingActive()) + m_layerTreeHost->setNeedsRedraw(); +#endif +} + void WebViewImpl::loseCompositorContext(int numTimes) { #if USE(ACCELERATED_COMPOSITING) @@ -2140,12 +2299,12 @@ bool WebViewImpl::computePageScaleFactorLimits() m_maximumPageScaleFactor = max(m_minimumPageScaleFactor, m_maximumPageScaleFactor); } ASSERT(m_minimumPageScaleFactor <= m_maximumPageScaleFactor); + + float clampedScale = clampPageScaleFactorToLimits(pageScaleFactor()); #if USE(ACCELERATED_COMPOSITING) if (m_layerTreeHost) - m_layerTreeHost->setPageScaleFactorLimits(m_minimumPageScaleFactor, m_maximumPageScaleFactor); + m_layerTreeHost->setPageScaleFactorAndLimits(clampedScale, m_minimumPageScaleFactor, m_maximumPageScaleFactor); #endif - - float clampedScale = clampPageScaleFactorToLimits(pageScaleFactor()); if (clampedScale != pageScaleFactor()) { setPageScaleFactorPreservingScrollOffset(clampedScale); return true; @@ -3005,6 +3164,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) ccSettings.perTilePainting = page()->settings()->perTileDrawingEnabled(); ccSettings.partialSwapEnabled = page()->settings()->partialSwapEnabled(); + ccSettings.threadedAnimationEnabled = page()->settings()->threadedAnimationEnabled(); m_nonCompositedContentHost = NonCompositedContentHost::create(WebViewImplContentPainter::create(this)); m_nonCompositedContentHost->setShowDebugBorders(page()->settings()->showDebugBorders()); @@ -3014,8 +3174,7 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) m_layerTreeHost = CCLayerTreeHost::create(this, ccSettings); if (m_layerTreeHost) { - m_layerTreeHost->setHaveWheelEventHandlers(m_haveWheelEventHandlers); - m_layerTreeHost->setPageScaleFactorLimits(m_minimumPageScaleFactor, m_maximumPageScaleFactor); + m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); updateLayerTreeViewport(); m_client->didActivateCompositor(m_layerTreeHost->compositorIdentifier()); m_isAcceleratedCompositingActive = true; @@ -3036,15 +3195,25 @@ void WebViewImpl::setIsAcceleratedCompositingActive(bool active) #endif +PassRefPtr<GraphicsContext3D> WebViewImpl::createCompositorGraphicsContext3D() +{ + WebKit::WebGraphicsContext3D::Attributes attributes = getCompositorContextAttributes(CCProxy::hasImplThread()); + OwnPtr<WebGraphicsContext3D> webContext = adoptPtr(client()->createGraphicsContext3D(attributes, true /* renderDirectlyToHostWindow */)); + if (!webContext) + return 0; + + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); +} + PassRefPtr<GraphicsContext3D> WebViewImpl::createLayerTreeHostContext3D() { - RefPtr<GraphicsContext3D> context = m_temporaryOnscreenGraphicsContext3D.release(); - if (!context) { - if (CCProxy::hasImplThread()) - context = GraphicsContext3DPrivate::createGraphicsContextForAnotherThread(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - else - context = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - } + RefPtr<GraphicsContext3D> context; + + // If we've already created an onscreen context for this view, return that. + if (m_temporaryOnscreenGraphicsContext3D) + context = m_temporaryOnscreenGraphicsContext3D.release(); + else // Otherwise make a new one. + context = createCompositorGraphicsContext3D(); return context; } @@ -3125,7 +3294,7 @@ void WebViewImpl::updateLayerTreeViewport() } m_nonCompositedContentHost->setViewport(visibleRect.size(), view->contentsSize(), scroll, pageScaleFactor(), layerAdjustX); m_layerTreeHost->setViewportSize(visibleRect.size()); - m_layerTreeHost->setPageScale(pageScaleFactor()); + m_layerTreeHost->setPageScaleFactorAndLimits(pageScaleFactor(), m_minimumPageScaleFactor, m_maximumPageScaleFactor); } WebGraphicsContext3D* WebViewImpl::graphicsContext3D() @@ -3137,17 +3306,16 @@ WebGraphicsContext3D* WebViewImpl::graphicsContext3D() if (webContext && !webContext->isContextLost()) return webContext; } - if (m_temporaryOnscreenGraphicsContext3D) { - WebGraphicsContext3D* webContext = GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); - if (webContext && !webContext->isContextLost()) - return webContext; - } - if (CCProxy::hasImplThread()) - m_temporaryOnscreenGraphicsContext3D = GraphicsContext3DPrivate::createGraphicsContextForAnotherThread(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - else - m_temporaryOnscreenGraphicsContext3D = GraphicsContext3D::create(getCompositorContextAttributes(), m_page->chrome(), GraphicsContext3D::RenderDirectlyToHostWindow); - - return GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); + // If we get here it means that some system needs access to the context the compositor will use but the compositor itself + // hasn't requested a context or it was unable to successfully instantiate a context. + // We need to return the context that the compositor will later use so we allocate a new context (if needed) and stash it + // until the compositor requests and takes ownership of the context via createLayerTreeHost3D(). + if (!m_temporaryOnscreenGraphicsContext3D) + m_temporaryOnscreenGraphicsContext3D = createCompositorGraphicsContext3D(); + + WebGraphicsContext3D* webContext = GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_temporaryOnscreenGraphicsContext3D.get()); + if (webContext && !webContext->isContextLost()) + return webContext; } #endif return 0; diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h index 800d18254..bc7a53d04 100644 --- a/Source/WebKit/chromium/src/WebViewImpl.h +++ b/Source/WebKit/chromium/src/WebViewImpl.h @@ -45,6 +45,7 @@ #include "GraphicsContext3D.h" #include "GraphicsLayer.h" #include "InspectorClientImpl.h" +#include "IntPoint.h" #include "IntRect.h" #include "NotificationPresenterImpl.h" #include "PageOverlayList.h" @@ -95,6 +96,11 @@ class WebTouchEvent; class WebViewImpl : public WebView, public WebCore::CCLayerTreeHostClient, public RefCounted<WebViewImpl> { public: + enum AutoZoomType { + DoubleTap, + FindInPage, + }; + // WebWidget methods: virtual void close(); virtual WebSize size() { return m_size; } @@ -110,6 +116,7 @@ public: virtual void paint(WebCanvas*, const WebRect&); virtual void themeChanged(); virtual void composite(bool finish); + virtual void setNeedsRedraw(); virtual bool handleInputEvent(const WebInputEvent&); virtual void mouseCaptureLost(); virtual void setFocus(bool enable); @@ -314,11 +321,13 @@ public: void mouseDoubleClick(const WebMouseEvent&); bool mouseWheel(const WebMouseWheelEvent&); bool gestureEvent(const WebGestureEvent&); + void startPageScaleAnimation(const WebCore::IntPoint& targetPosition, bool useAnchor, float newScale, double durationSec); bool keyEvent(const WebKeyboardEvent&); bool charEvent(const WebKeyboardEvent&); bool touchEvent(const WebTouchEvent&); void numberOfWheelEventHandlersChanged(unsigned); + void numberOfTouchEventHandlersChanged(unsigned); // Handles context menu events orignated via the the keyboard. These // include the VK_APPS virtual key and the Shift+F10 combine. Code is @@ -437,9 +446,12 @@ public: // Returns the onscreen 3D context used by the compositor. This is // used by the renderer's code to set up resource sharing between // the compositor's context and subordinate contexts for APIs like - // WebGL. Returns 0 if compositing support is not compiled in. + // WebGL. Returns 0 if compositing support is not compiled in or + // we could not successfully instantiate a context. virtual WebGraphicsContext3D* graphicsContext3D(); + PassRefPtr<WebCore::GraphicsContext3D> createCompositorGraphicsContext3D(); + virtual void setVisibilityState(WebPageVisibilityState, bool); WebCore::PopupContainer* selectPopup() const { return m_selectPopup.get(); } @@ -455,6 +467,10 @@ public: // a plugin can update its own zoom, say because of its own UI. void fullFramePluginZoomLevelChanged(double zoomLevel); +#if ENABLE(GESTURE_EVENTS) + void computeScaleAndScrollForHitRect(const WebRect& hitRect, AutoZoomType, float& scale, WebPoint& scroll); +#endif + void loseCompositorContext(int numTimes); void enterFullScreenForElement(WebCore::Element*); @@ -525,6 +541,15 @@ private: void updateLayerTreeViewport(); #endif +#if ENABLE(GESTURE_EVENTS) + // Returns the bounding box of the block type node touched by the WebRect. + WebRect computeBlockBounds(const WebRect&, AutoZoomType); + + // Helper function: Widens the width of |source| by the specified margins + // while keeping it smaller than page width. + WebRect widenRectWithinPageBounds(const WebRect& source, int targetMargin, int minimumMargin); +#endif + #if ENABLE(POINTER_LOCK) void pointerLockMouseEvent(const WebInputEvent&); #endif @@ -670,7 +695,6 @@ private: // If true, the graphics context is being restored. bool m_recreatingGraphicsContext; #endif - bool m_haveWheelEventHandlers; static const WebInputEvent* m_currentInputEvent; #if ENABLE(INPUT_SPEECH) diff --git a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp index 796ab166d..1db2d1dd9 100644 --- a/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp +++ b/Source/WebKit/chromium/src/WebWorkerClientImpl.cpp @@ -39,6 +39,7 @@ #include "ErrorEvent.h" #include "Frame.h" #include "FrameLoaderClient.h" +#include "InspectorInstrumentation.h" #include "MessageEvent.h" #include "MessagePort.h" #include "MessagePortChannel.h" @@ -90,6 +91,7 @@ void WebWorkerClientImpl::startWorkerContext(const KURL& scriptURL, const String m_scriptExecutionContext->contentSecurityPolicy()->headerType()); m_proxy->workerThreadCreated(thread); thread->start(); + InspectorInstrumentation::didStartWorkerContext(m_scriptExecutionContext.get(), m_proxy, scriptURL); } void WebWorkerClientImpl::terminateWorkerContext() diff --git a/Source/WebKit/chromium/src/js/Tests.js b/Source/WebKit/chromium/src/js/Tests.js index a41eefdd0..16a1ba257 100644 --- a/Source/WebKit/chromium/src/js/Tests.js +++ b/Source/WebKit/chromium/src/js/Tests.js @@ -308,7 +308,6 @@ TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function() this.showPanel("scripts"); - function switchToElementsTab() { test.showPanel("elements"); setTimeout(switchToScriptsTab, 0); @@ -320,19 +319,17 @@ TestSuite.prototype.testNoScriptDuplicatesOnPanelSwitch = function() } function checkScriptsPanel() { - test.assertTrue(!!WebInspector.panels.scripts.visibleView, "No visible script view."); test.assertTrue(test._scriptsAreParsed(["debugger_test_page.html"]), "Some scripts are missing."); checkNoDuplicates(); test.releaseControl(); } function checkNoDuplicates() { - var scriptSelect = document.getElementById("scripts-files"); - var options = scriptSelect.options; - for (var i = 0; i < options.length; i++) { - var scriptName = options[i].text; - for (var j = i + 1; j < options.length; j++) - test.assertTrue(scriptName !== options[j].text, "Found script duplicates: " + test.optionsToString_(options)); + var uiSourceCodes = test.nonAnonymousUISourceCodes_(); + for (var i = 0; i < uiSourceCodes.length; i++) { + var scriptName = uiSourceCodes[i].fileName; + for (var j = i + 1; j < uiSourceCodes.length; j++) + test.assertTrue(scriptName !== uiSourceCodes[j].fileName, "Found script duplicates: " + test.uiSourceCodesToString_(uiSourceCodes)); } } @@ -584,70 +581,32 @@ TestSuite.prototype.waitForTestResultsInConsole = function() /** - * Serializes options collection to string. - * @param {HTMLOptionsCollection} options + * Serializes array of uiSourceCodes to string. + * @param {Array.<WebInspectorUISourceCode>} uiSourceCodes * @return {string} */ -TestSuite.prototype.optionsToString_ = function(options) +TestSuite.prototype.uiSourceCodesToString_ = function(uiSourceCodes) { var names = []; - for (var i = 0; i < options.length; i++) - names.push('"' + options[i].text + '"'); + for (var i = 0; i < uiSourceCodes.length; i++) + names.push('"' + uiSourceCodes[i].fileName + '"'); return names.join(","); }; /** - * Ensures that main HTML resource is selected in Scripts panel and that its - * source frame is setup. Invokes the callback when the condition is satisfied. - * @param {HTMLOptionsCollection} options - * @param {function(WebInspector.SourceView,string)} callback + * Returns all loaded non anonymous uiSourceCodes. + * @return {Array.<WebInspectorUISourceCode>} */ -TestSuite.prototype.showMainPageScriptSource_ = function(scriptName, callback) +TestSuite.prototype.nonAnonymousUISourceCodes_ = function() { - var test = this; - - var scriptSelect = document.getElementById("scripts-files"); - var options = scriptSelect.options; - - test.assertTrue(options.length, "Scripts list is empty"); - - // Select page's script if it's not current option. - var scriptResource; - if (options[scriptSelect.selectedIndex].text === scriptName) - scriptResource = options[scriptSelect.selectedIndex].representedObject; - else { - var pageScriptIndex = -1; - for (var i = 0; i < options.length; i++) { - if (options[i].text === scriptName) { - pageScriptIndex = i; - break; - } - } - test.assertTrue(-1 !== pageScriptIndex, "Script with url " + scriptName + " not found among " + test.optionsToString_(options)); - scriptResource = options[pageScriptIndex].representedObject; - - // Current panel is "Scripts". - WebInspector.inspectorView.currentPanel()._showScriptOrResource(scriptResource); - test.assertEquals(pageScriptIndex, scriptSelect.selectedIndex, "Unexpected selected option index."); + function filterOutAnonymous(uiSourceCode) + { + return !!uiSourceCode.url; } - test.assertTrue(scriptResource instanceof WebInspector.Resource, - "Unexpected resource class."); - test.assertTrue(!!scriptResource.url, "Resource URL is null."); - test.assertTrue(scriptResource.url.search(scriptName + "$") !== -1, "Main HTML resource should be selected."); - - var scriptsPanel = WebInspector.panels.scripts; - - var view = scriptsPanel.visibleView; - test.assertTrue(view instanceof WebInspector.SourceView); - - if (!view.sourceFrame._loaded) { - test.addSniffer(view, "_sourceFrameSetupFinished", function(event) { - callback(view, scriptResource.url); - }); - } else - callback(view, scriptResource.url); + var uiSourceCodes = WebInspector.panels.scripts._presentationModel.uiSourceCodes(); + return uiSourceCodes.filter(filterOutAnonymous); }; @@ -680,14 +639,12 @@ TestSuite.prototype.evaluateInConsole_ = function(code, callback) */ TestSuite.prototype._scriptsAreParsed = function(expected) { - var scriptSelect = document.getElementById("scripts-files"); - var options = scriptSelect.options; - + var uiSourceCodes = this.nonAnonymousUISourceCodes_(); // Check that at least all the expected scripts are present. var missing = expected.slice(0); - for (var i = 0 ; i < options.length; i++) { - for (var j = 0; j < missing.length; j++) { - if (options[i].text.search(missing[j]) !== -1) { + for (var i = 0; i < uiSourceCodes.length; ++i) { + for (var j = 0; j < missing.length; ++j) { + if (uiSourceCodes[i].fileName.search(missing[j]) !== -1) { missing.splice(j, 1); break; } @@ -744,7 +701,7 @@ TestSuite.prototype._waitUntilScriptsAreParsed = function(expectedScripts, callb if (test._scriptsAreParsed(expectedScripts)) callback(); else - test.addSniffer(WebInspector.panels.scripts, "_uiSourceCodeAdded", waitForAllScripts); + test.addSniffer(WebInspector.panels.scripts, "_addUISourceCode", waitForAllScripts); } waitForAllScripts(); diff --git a/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp b/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp index 3e93d95de..e14ef9bc0 100644 --- a/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp +++ b/Source/WebKit/chromium/tests/CCActiveAnimationTest.cpp @@ -25,24 +25,20 @@ #include "config.h" #include "cc/CCActiveAnimation.h" - -#include "cc/CCAnimationCurve.h" +#include "CCAnimationTestCommon.h" #include <gmock/gmock.h> #include <gtest/gtest.h> #include <wtf/Vector.h> -namespace WebCore { +using namespace WebKitTests; +using namespace WebCore; -class FakeFloatAnimation : public CCFloatAnimationCurve { -public: - virtual double duration() const { return 1; } - virtual float getValue(double now) const { return 0; } -}; +namespace { PassOwnPtr<CCActiveAnimation> createActiveAnimation(int iterations) { - OwnPtr<CCActiveAnimation> toReturn(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimation), 1, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toReturn(CCActiveAnimation::create(adoptPtr(new FakeFloatAnimationCurve), 0, 1, CCActiveAnimation::Opacity)); toReturn->setIterations(iterations); return toReturn.release(); } @@ -164,4 +160,4 @@ TEST(CCActiveAnimationTest, IsFinished) EXPECT_TRUE(anim->isFinished()); } -} // namespace WebCore +} // namespace diff --git a/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp new file mode 100644 index 000000000..c9240e31f --- /dev/null +++ b/Source/WebKit/chromium/tests/CCAnimationTestCommon.cpp @@ -0,0 +1,133 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "CCAnimationTestCommon.h" + +#include "GraphicsLayer.h" +#include "LayerChromium.h" +#include "cc/CCLayerAnimationController.h" + +using namespace WebCore; + +namespace { + +template <class Target> +void addOpacityTransition(Target& target, double duration, float startOpacity, float endOpacity) +{ + WebCore::KeyframeValueList values(AnimatedPropertyOpacity); + if (duration > 0) + values.insert(new FloatAnimationValue(0, startOpacity)); + values.insert(new FloatAnimationValue(duration, endOpacity)); + + RefPtr<Animation> animation = Animation::create(); + animation->setDuration(duration); + + IntSize boxSize; + + target.addAnimation(values, boxSize, animation.get(), 0, 0, 0); +} + +} // namespace + +namespace WebKitTests { + +FakeFloatAnimationCurve::FakeFloatAnimationCurve() +{ +} + +FakeFloatAnimationCurve::~FakeFloatAnimationCurve() +{ +} + +PassOwnPtr<WebCore::CCAnimationCurve> FakeFloatAnimationCurve::clone() const +{ + return adoptPtr(new FakeFloatAnimationCurve); +} + +FakeTransformTransition::FakeTransformTransition(double duration) + : m_duration(duration) +{ +} + +FakeTransformTransition::~FakeTransformTransition() +{ +} + +WebCore::TransformationMatrix FakeTransformTransition::getValue(double time, const WebCore::IntSize& size) const +{ + return WebCore::TransformationMatrix(); +} + +PassOwnPtr<WebCore::CCAnimationCurve> FakeTransformTransition::clone() const +{ + return adoptPtr(new FakeTransformTransition(*this)); +} + + +FakeFloatTransition::FakeFloatTransition(double duration, float from, float to) + : m_duration(duration) + , m_from(from) + , m_to(to) +{ +} + +FakeFloatTransition::~FakeFloatTransition() +{ +} + +float FakeFloatTransition::getValue(double time) const +{ + time /= m_duration; + if (time >= 1) + time = 1; + return (1 - time) * m_from + time * m_to; +} + +FakeLayerAnimationControllerImplClient::FakeLayerAnimationControllerImplClient() + : m_opacity(0) +{ +} + +FakeLayerAnimationControllerImplClient::~FakeLayerAnimationControllerImplClient() +{ +} + +PassOwnPtr<WebCore::CCAnimationCurve> FakeFloatTransition::clone() const +{ + return adoptPtr(new FakeFloatTransition(*this)); +} + +void addOpacityTransitionToController(WebCore::CCLayerAnimationController& controller, double duration, float startOpacity, float endOpacity) +{ + addOpacityTransition(controller, duration, startOpacity, endOpacity); +} + +void addOpacityTransitionToLayer(WebCore::LayerChromium& layer, double duration, float startOpacity, float endOpacity) +{ + addOpacityTransition(layer, duration, startOpacity, endOpacity); +} + +} // namespace WebKitTests diff --git a/Source/WebKit/chromium/tests/CCAnimationTestCommon.h b/Source/WebKit/chromium/tests/CCAnimationTestCommon.h new file mode 100644 index 000000000..d13e74ca1 --- /dev/null +++ b/Source/WebKit/chromium/tests/CCAnimationTestCommon.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef CCAnimationTestCommon_h +#define CCAnimationTestCommon_h + +#include "cc/CCAnimationCurve.h" +#include "cc/CCLayerAnimationControllerImpl.h" + +#include <wtf/OwnPtr.h> + +namespace WebCore { +class CCLayerAnimationController; +class LayerChromium; +} + +namespace WebKitTests { + +class FakeFloatAnimationCurve : public WebCore::CCFloatAnimationCurve { +public: + FakeFloatAnimationCurve(); + virtual ~FakeFloatAnimationCurve(); + + virtual double duration() const { return 1; } + virtual float getValue(double now) const { return 0; } + virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const; +}; + +class FakeTransformTransition : public WebCore::CCTransformAnimationCurve { +public: + FakeTransformTransition(double duration); + virtual ~FakeTransformTransition(); + + virtual double duration() const { return m_duration; } + virtual WebCore::TransformationMatrix getValue(double time, const WebCore::IntSize&) const; + + virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const; + +private: + double m_duration; +}; + +class FakeFloatTransition : public WebCore::CCFloatAnimationCurve { +public: + FakeFloatTransition(double duration, float from, float to); + virtual ~FakeFloatTransition(); + + virtual double duration() const { return m_duration; } + virtual float getValue(double time) const; + + virtual PassOwnPtr<WebCore::CCAnimationCurve> clone() const; + +private: + double m_duration; + float m_from; + float m_to; +}; + +class FakeLayerAnimationControllerImplClient : public WebCore::CCLayerAnimationControllerImplClient { +public: + FakeLayerAnimationControllerImplClient(); + virtual ~FakeLayerAnimationControllerImplClient(); + + virtual int id() const { return 0; } + virtual float opacity() const { return m_opacity; } + virtual void setOpacity(float opacity) { m_opacity = opacity; } + virtual const WebCore::TransformationMatrix& transform() const { return m_transform; } + virtual void setTransform(const WebCore::TransformationMatrix& transform) { m_transform = transform; } + virtual const WebCore::IntSize& bounds() const { return m_bounds; } + +private: + float m_opacity; + WebCore::TransformationMatrix m_transform; + WebCore::IntSize m_bounds; +}; + +void addOpacityTransitionToController(WebCore::CCLayerAnimationController&, double duration, float startOpacity, float endOpacity); + +void addOpacityTransitionToLayer(WebCore::LayerChromium&, double duration, float startOpacity, float endOpacity); + +} // namespace WebKitTests + +#endif // CCAnimationTesctCommon_h diff --git a/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp new file mode 100644 index 000000000..b7732aeab --- /dev/null +++ b/Source/WebKit/chromium/tests/CCKeyframedAnimationCurveTest.cpp @@ -0,0 +1,241 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "cc/CCKeyframedAnimationCurve.h" + +#include "Length.h" +#include "TranslateTransformOperation.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <wtf/OwnPtr.h> +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace { + +void expectTranslateX(double translateX, const TransformationMatrix& matrix) +{ + TransformationMatrix::DecomposedType decomposedType; + matrix.decompose(decomposedType); + EXPECT_FLOAT_EQ(translateX, decomposedType.translateX); +} + +// Tests that a float animation with one keyframe works as expected. +TEST(CCKeyframedAnimationCurveTest, OneFloatKeyframe) +{ + Vector<CCFloatKeyframe> keyframes; + keyframes.append(CCFloatKeyframe(0, 2)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + EXPECT_FLOAT_EQ(2, curve->getValue(-1)); + EXPECT_FLOAT_EQ(2, curve->getValue(0)); + EXPECT_FLOAT_EQ(2, curve->getValue(0.5)); + EXPECT_FLOAT_EQ(2, curve->getValue(1)); + EXPECT_FLOAT_EQ(2, curve->getValue(2)); +} + +// Tests that a float animation with two keyframes works as expected. +TEST(CCKeyframedAnimationCurveTest, TwoFloatKeyframe) +{ + Vector<CCFloatKeyframe> keyframes; + keyframes.append(CCFloatKeyframe(0, 2)); + keyframes.append(CCFloatKeyframe(1, 4)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + EXPECT_FLOAT_EQ(2, curve->getValue(-1)); + EXPECT_FLOAT_EQ(2, curve->getValue(0)); + EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); + EXPECT_FLOAT_EQ(4, curve->getValue(1)); + EXPECT_FLOAT_EQ(4, curve->getValue(2)); +} + +// Tests that a float animation with three keyframes works as expected. +TEST(CCKeyframedAnimationCurveTest, ThreeFloatKeyframe) +{ + Vector<CCFloatKeyframe> keyframes; + keyframes.append(CCFloatKeyframe(0, 2)); + keyframes.append(CCFloatKeyframe(1, 4)); + keyframes.append(CCFloatKeyframe(2, 8)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + EXPECT_FLOAT_EQ(2, curve->getValue(-1)); + EXPECT_FLOAT_EQ(2, curve->getValue(0)); + EXPECT_FLOAT_EQ(3, curve->getValue(0.5)); + EXPECT_FLOAT_EQ(4, curve->getValue(1)); + EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); + EXPECT_FLOAT_EQ(8, curve->getValue(2)); + EXPECT_FLOAT_EQ(8, curve->getValue(3)); +} + +// Tests that a float animation with multiple keys at a given time works sanely. +TEST(CCKeyframedAnimationCurveTest, RepeatedFloatKeyTimes) +{ + Vector<CCFloatKeyframe> keyframes; + // A step function. + keyframes.append(CCFloatKeyframe(0, 4)); + keyframes.append(CCFloatKeyframe(1, 4)); + keyframes.append(CCFloatKeyframe(1, 6)); + keyframes.append(CCFloatKeyframe(2, 6)); + OwnPtr<CCKeyframedFloatAnimationCurve> curve(CCKeyframedFloatAnimationCurve::create(keyframes)); + + EXPECT_FLOAT_EQ(4, curve->getValue(-1)); + EXPECT_FLOAT_EQ(4, curve->getValue(0)); + EXPECT_FLOAT_EQ(4, curve->getValue(0.5)); + + // There is a discontinuity at 1. Any value between 4 and 6 is valid. + float value = curve->getValue(1); + EXPECT_TRUE(value >= 4 && value <= 6); + + EXPECT_FLOAT_EQ(6, curve->getValue(1.5)); + EXPECT_FLOAT_EQ(6, curve->getValue(2)); + EXPECT_FLOAT_EQ(6, curve->getValue(3)); +} + + +// Tests that a transform animation with one keyframe works as expected. +TEST(CCKeyframedAnimationCurveTest, OneTransformKeyframe) +{ + Vector<CCTransformKeyframe> keyframes; + TransformOperations operations; + operations.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + keyframes.append(CCTransformKeyframe(0, operations)); + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + IntSize layerSize; // ignored + expectTranslateX(2, curve->getValue(-1, layerSize)); + expectTranslateX(2, curve->getValue(0, layerSize)); + expectTranslateX(2, curve->getValue(0.5, layerSize)); + expectTranslateX(2, curve->getValue(1, layerSize)); + expectTranslateX(2, curve->getValue(2, layerSize)); +} + +// Tests that a transform animation with two keyframes works as expected. +TEST(CCKeyframedAnimationCurveTest, TwoTransformKeyframe) +{ + Vector<CCTransformKeyframe> keyframes; + TransformOperations operations1; + operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations2; + operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + keyframes.append(CCTransformKeyframe(0, operations1)); + keyframes.append(CCTransformKeyframe(1, operations2)); + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + IntSize layerSize; // ignored + expectTranslateX(2, curve->getValue(-1, layerSize)); + expectTranslateX(2, curve->getValue(0, layerSize)); + expectTranslateX(3, curve->getValue(0.5, layerSize)); + expectTranslateX(4, curve->getValue(1, layerSize)); + expectTranslateX(4, curve->getValue(2, layerSize)); +} + +// Tests that a transform animation with three keyframes works as expected. +TEST(CCKeyframedAnimationCurveTest, ThreeTransformKeyframe) +{ + Vector<CCTransformKeyframe> keyframes; + TransformOperations operations1; + operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations2; + operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations3; + operations3.operations().append(TranslateTransformOperation::create(Length(8, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + keyframes.append(CCTransformKeyframe(0, operations1)); + keyframes.append(CCTransformKeyframe(1, operations2)); + keyframes.append(CCTransformKeyframe(2, operations3)); + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + IntSize layerSize; // ignored + expectTranslateX(2, curve->getValue(-1, layerSize)); + expectTranslateX(2, curve->getValue(0, layerSize)); + expectTranslateX(3, curve->getValue(0.5, layerSize)); + expectTranslateX(4, curve->getValue(1, layerSize)); + expectTranslateX(6, curve->getValue(1.5, layerSize)); + expectTranslateX(8, curve->getValue(2, layerSize)); + expectTranslateX(8, curve->getValue(3, layerSize)); +} + +// Tests that a transform animation with multiple keys at a given time works sanely. +TEST(CCKeyframedAnimationCurveTest, RepeatedTransformKeyTimes) +{ + Vector<CCTransformKeyframe> keyframes; + // A step function. + TransformOperations operations1; + operations1.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations2; + operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations3; + operations3.operations().append(TranslateTransformOperation::create(Length(6, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations4; + operations4.operations().append(TranslateTransformOperation::create(Length(6, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + keyframes.append(CCTransformKeyframe(0, operations1)); + keyframes.append(CCTransformKeyframe(1, operations2)); + keyframes.append(CCTransformKeyframe(1, operations3)); + keyframes.append(CCTransformKeyframe(2, operations4)); + OwnPtr<CCKeyframedTransformAnimationCurve> curve(CCKeyframedTransformAnimationCurve::create(keyframes)); + + IntSize layerSize; // ignored + + expectTranslateX(4, curve->getValue(-1, layerSize)); + expectTranslateX(4, curve->getValue(0, layerSize)); + expectTranslateX(4, curve->getValue(0.5, layerSize)); + + // There is a discontinuity at 1. Any value between 4 and 6 is valid. + TransformationMatrix value = curve->getValue(1, layerSize); + TransformationMatrix::DecomposedType decomposedType; + value.decompose(decomposedType); + EXPECT_TRUE(decomposedType.translateX >= 4 && decomposedType.translateX <= 6); + + expectTranslateX(6, curve->getValue(1.5, layerSize)); + expectTranslateX(6, curve->getValue(2, layerSize)); + expectTranslateX(6, curve->getValue(3, layerSize)); +} + +// Tests that invalid lists of keyframes result in nothing being returned from ::create. +TEST(CCKeyframedAnimationCurveTest, InvalidKeyframes) +{ + // It is invalid to pass an empty vector of keyframes to create. + Vector<CCTransformKeyframe> transformKeyframes; + OwnPtr<CCKeyframedTransformAnimationCurve> transformCurve = CCKeyframedTransformAnimationCurve::create(transformKeyframes); + EXPECT_FALSE(transformCurve.get()); + + Vector<CCFloatKeyframe> floatKeyframes; + OwnPtr<CCKeyframedFloatAnimationCurve> floatCurve = CCKeyframedFloatAnimationCurve::create(floatKeyframes); + EXPECT_FALSE(floatCurve.get()); + + // It is invalid to pass a vector of unsorted keyframes to create; + TransformOperations operations1; + operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + TransformOperations operations2; + operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + transformKeyframes.append(CCTransformKeyframe(1, operations1)); + transformKeyframes.append(CCTransformKeyframe(0, operations2)); + transformCurve = CCKeyframedTransformAnimationCurve::create(transformKeyframes); + EXPECT_FALSE(transformCurve.get()); + + floatKeyframes.append(CCFloatKeyframe(1, 2)); + floatKeyframes.append(CCFloatKeyframe(0, 4)); + floatCurve = CCKeyframedFloatAnimationCurve::create(floatKeyframes); + EXPECT_FALSE(floatCurve.get()); +} + + +} // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerAnimationControllerImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerAnimationControllerImplTest.cpp index 3d50d06e6..e1aeccc53 100644 --- a/Source/WebKit/chromium/tests/CCLayerAnimationControllerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerAnimationControllerImplTest.cpp @@ -24,92 +24,39 @@ #include "config.h" +#include "CCAnimationTestCommon.h" #include "cc/CCLayerAnimationControllerImpl.h" - -#include "TransformOperations.h" #include "cc/CCAnimationCurve.h" - +#include "cc/CCAnimationEvents.h" #include <gmock/gmock.h> #include <gtest/gtest.h> #include <wtf/Vector.h> using namespace WebCore; +using namespace WebKitTests; namespace { -class FakeControllerClient : public CCLayerAnimationControllerImplClient { -public: - FakeControllerClient() : m_opacity(0) { } - virtual ~FakeControllerClient() { } - - virtual float opacity() const { return m_opacity; } - virtual void setOpacity(float opacity) { m_opacity = opacity; } - virtual const TransformationMatrix& transform() const { return m_transform; } - virtual void setTransform(const TransformationMatrix& transform) { m_transform = transform; } - virtual void animationControllerImplDidActivate(CCLayerAnimationControllerImpl* controller) - { - m_activeControllers.append(controller); - } - - Vector<CCLayerAnimationControllerImpl*>& activeControllers() { return m_activeControllers; } - -private: - float m_opacity; - TransformationMatrix m_transform; - Vector<CCLayerAnimationControllerImpl*> m_activeControllers; -}; - -class FakeTransformTransition : public CCTransformAnimationCurve { -public: - FakeTransformTransition(double duration) : m_duration(duration) { } - virtual double duration() const { return m_duration; } - virtual TransformOperations getValue(double time) const - { - return TransformOperations(); - } - -private: - double m_duration; -}; - -class FakeFloatTransition : public CCFloatAnimationCurve { -public: - FakeFloatTransition(double duration, float from, float to) - : m_duration(duration) - , m_from(from) - , m_to(to) - { - } - - virtual double duration() const { return m_duration; } - virtual float getValue(double time) const - { - time /= m_duration; - if (time >= 1) - time = 1; - return (1 - time) * m_from + time * m_to; - } - -private: - double m_duration; - float m_from; - float m_to; -}; +PassOwnPtr<CCActiveAnimation> createActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int id, CCActiveAnimation::TargetProperty property) +{ + return CCActiveAnimation::create(curve, 0, id, property); +} // Tests that transitioning opacity from 0 to 1 works as expected. TEST(CCLayerAnimationControllerImplTest, TrivialTransition) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); controller->add(toAdd.release()); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(1); + controller->animate(1, *events); EXPECT_EQ(1, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -117,20 +64,21 @@ TEST(CCLayerAnimationControllerImplTest, TrivialTransition) // Tests that two queued animations affecting the same property run in sequence. TEST(CCLayerAnimationControllerImplTest, TrivialQueuing) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 1, 0.5f)), 2, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5f)), 2, CCActiveAnimation::Opacity)); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(1); + controller->animate(1, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); - controller->animate(2); + controller->animate(2, *events); EXPECT_EQ(0.5f, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -138,22 +86,23 @@ TEST(CCLayerAnimationControllerImplTest, TrivialQueuing) // Tests interrupting a transition with another transition. TEST(CCLayerAnimationControllerImplTest, Interrupt) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - controller->animate(0); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 1, 0.5f)), 2, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5f)), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForNextTick, 0); controller->add(toAdd.release()); - controller->animate(0.5); // second anim starts NOW. + controller->animate(0.5, *events); // second anim starts NOW. EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); - controller->animate(1.5); + controller->animate(1.5, *events); EXPECT_EQ(0.5f, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -161,23 +110,24 @@ TEST(CCLayerAnimationControllerImplTest, Interrupt) // Tests scheduling two animations to run together when only one property is free. TEST(CCLayerAnimationControllerImplTest, ScheduleTogetherWhenAPropertyIsBlocked) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeTransformTransition(1)), 1, CCActiveAnimation::Transform)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeTransformTransition(1)), 2, CCActiveAnimation::Transform)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 2, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), 1, CCActiveAnimation::Transform)); + controller->add(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), 2, CCActiveAnimation::Transform)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 2, CCActiveAnimation::Opacity)); - controller->animate(0); + controller->animate(0, *events); EXPECT_EQ(0, dummy.opacity()); EXPECT_TRUE(controller->hasActiveAnimation()); - controller->animate(1); + controller->animate(1, *events); // Should not have started the float transition yet. EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); // The the float animation should have started at time 1 and should be done. - controller->animate(2); + controller->animate(2, *events); EXPECT_EQ(1, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -187,29 +137,30 @@ TEST(CCLayerAnimationControllerImplTest, ScheduleTogetherWhenAPropertyIsBlocked) // for both to finish). TEST(CCLayerAnimationControllerImplTest, ScheduleTogetherWithAnAnimWaiting) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeTransformTransition(2)), 1, CCActiveAnimation::Transform)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 1, 0.5f)), 2, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeTransformTransition(2)), 1, CCActiveAnimation::Transform)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.5f)), 2, CCActiveAnimation::Opacity)); // Anims with id 1 should both start now. - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); // The opacity animation should have finished at time 1, but the group // of animations with id 1 don't finish until time 2 because of the length // of the transform animation. - controller->animate(2); + controller->animate(2, *events); // Should not have started the float transition yet. EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); // The the second opacity animation should start at time 2 and should be // done by time 3 - controller->animate(3); + controller->animate(3, *events); EXPECT_EQ(0.5f, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -217,22 +168,23 @@ TEST(CCLayerAnimationControllerImplTest, ScheduleTogetherWithAnAnimWaiting) // Tests scheduling an animation to start in the future. TEST(CCLayerAnimationControllerImplTest, ScheduleAnimation) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); controller->add(toAdd.release()); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(1); + controller->animate(1, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(2); + controller->animate(2, *events); EXPECT_EQ(1, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -240,28 +192,29 @@ TEST(CCLayerAnimationControllerImplTest, ScheduleAnimation) // Tests scheduling an animation to start in the future that's interrupting a running animation. TEST(CCLayerAnimationControllerImplTest, ScheduledAnimationInterruptsRunningAnimation) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0.5f, 0)), 2, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0.5f, 0)), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); controller->add(toAdd.release()); // First 2s opacity transition should start immediately. - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(0.5); + controller->animate(0.5, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.25f, dummy.opacity()); - controller->animate(1); + controller->animate(1, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5f, dummy.opacity()); - controller->animate(2); + controller->animate(2, *events); EXPECT_EQ(0, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -270,34 +223,35 @@ TEST(CCLayerAnimationControllerImplTest, ScheduledAnimationInterruptsRunningAnim // and there is yet another animation queued to start later. TEST(CCLayerAnimationControllerImplTest, ScheduledAnimationInterruptsRunningAnimationWithAnimInQueue) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), 1, CCActiveAnimation::Opacity)); - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(2, 0.5f, 0)), 2, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0.5f, 0)), 2, CCActiveAnimation::Opacity)); toAdd->setRunState(CCActiveAnimation::WaitingForStartTime, 0); toAdd->setStartTime(1); controller->add(toAdd.release()); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 0.75f)), 3, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 0.75f)), 3, CCActiveAnimation::Opacity)); // First 2s opacity transition should start immediately. - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(0.5); + controller->animate(0.5, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.25f, dummy.opacity()); EXPECT_TRUE(controller->hasActiveAnimation()); - controller->animate(1); + controller->animate(1, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5f, dummy.opacity()); - controller->animate(3); + controller->animate(3, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(4); + controller->animate(4, *events); EXPECT_EQ(0.75f, dummy.opacity()); EXPECT_FALSE(controller->hasActiveAnimation()); } @@ -305,64 +259,66 @@ TEST(CCLayerAnimationControllerImplTest, ScheduledAnimationInterruptsRunningAnim // Test that a looping animation loops and for the correct number of iterations. TEST(CCLayerAnimationControllerImplTest, TrivialLooping) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); toAdd->setIterations(3); controller->add(toAdd.release()); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(1.25); + controller->animate(1.25, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.25f, dummy.opacity()); - controller->animate(1.75); + controller->animate(1.75, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.75f, dummy.opacity()); - controller->animate(2.25); + controller->animate(2.25, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.25f, dummy.opacity()); - controller->animate(2.75); + controller->animate(2.75, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.75f, dummy.opacity()); - controller->animate(3); + controller->animate(3, *events); EXPECT_FALSE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); // Just be extra sure. - controller->animate(4); + controller->animate(4, *events); EXPECT_EQ(1, dummy.opacity()); } // Test that an infinitely looping animation does indeed go until aborted. TEST(CCLayerAnimationControllerImplTest, InfiniteLooping) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); const int id = 1; - OwnPtr<CCActiveAnimation> toAdd(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); + OwnPtr<CCActiveAnimation> toAdd(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); toAdd->setIterations(-1); controller->add(toAdd.release()); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(1.25); + controller->animate(1.25, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.25f, dummy.opacity()); - controller->animate(1.75); + controller->animate(1.75, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.75f, dummy.opacity()); - controller->animate(1073741824.25); + controller->animate(1073741824.25, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.25f, dummy.opacity()); - controller->animate(1073741824.75); + controller->animate(1073741824.75, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.75f, dummy.opacity()); @@ -375,80 +331,66 @@ TEST(CCLayerAnimationControllerImplTest, InfiniteLooping) // Test that pausing and resuming work as expected. TEST(CCLayerAnimationControllerImplTest, PauseResume) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); const int id = 1; - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 0, 1)), id, CCActiveAnimation::Opacity)); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(0.5); + controller->animate(0.5, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5f, dummy.opacity()); EXPECT_TRUE(controller->getActiveAnimation(id, CCActiveAnimation::Opacity)); controller->getActiveAnimation(id, CCActiveAnimation::Opacity)->setRunState(CCActiveAnimation::Paused, 0.5f); - controller->animate(1024); + controller->animate(1024, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5f, dummy.opacity()); EXPECT_TRUE(controller->getActiveAnimation(id, CCActiveAnimation::Opacity)); controller->getActiveAnimation(id, CCActiveAnimation::Opacity)->setRunState(CCActiveAnimation::Running, 1024); - controller->animate(1024.25); + controller->animate(1024.25, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.75f, dummy.opacity()); - controller->animate(1024.5); + controller->animate(1024.5, *events); EXPECT_FALSE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); } TEST(CCLayerAnimationControllerImplTest, AbortAGroupedAnimation) { - FakeControllerClient dummy; + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + FakeLayerAnimationControllerImplClient dummy; OwnPtr<CCLayerAnimationControllerImpl> controller( CCLayerAnimationControllerImpl::create(&dummy)); const int id = 1; - controller->add(CCActiveAnimation::create(adoptPtr(new FakeTransformTransition(1)), id, CCActiveAnimation::Transform)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(2, 0, 1)), id, CCActiveAnimation::Opacity)); - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 1, 0.75f)), 2, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeTransformTransition(1)), id, CCActiveAnimation::Transform)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(2, 0, 1)), id, CCActiveAnimation::Opacity)); + controller->add(createActiveAnimation(adoptPtr(new FakeFloatTransition(1, 1, 0.75f)), 2, CCActiveAnimation::Opacity)); - controller->animate(0); + controller->animate(0, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0, dummy.opacity()); - controller->animate(1); + controller->animate(1, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(0.5f, dummy.opacity()); EXPECT_TRUE(controller->getActiveAnimation(id, CCActiveAnimation::Opacity)); controller->getActiveAnimation(id, CCActiveAnimation::Opacity)->setRunState(CCActiveAnimation::Aborted, 1); - controller->animate(1); + controller->animate(1, *events); EXPECT_TRUE(controller->hasActiveAnimation()); EXPECT_EQ(1, dummy.opacity()); - controller->animate(2); + controller->animate(2, *events); EXPECT_TRUE(!controller->hasActiveAnimation()); EXPECT_EQ(0.75f, dummy.opacity()); } -// Tests that adding an animation to the controller calls the appropriate callback on the controller client -// (in this case, adding the controller to the list of active controller). -TEST(CCLayerAnimationControllerImplTest, DidActivate) -{ - FakeControllerClient dummy; - OwnPtr<CCLayerAnimationControllerImpl> controller( - CCLayerAnimationControllerImpl::create(&dummy)); - - EXPECT_EQ(size_t(0), dummy.activeControllers().size()); - - controller->add(CCActiveAnimation::create(adoptPtr(new FakeFloatTransition(1, 0, 1)), 1, CCActiveAnimation::Opacity)); - - EXPECT_EQ(size_t(1), dummy.activeControllers().size()); - EXPECT_EQ(controller.get(), dummy.activeControllers()[0]); -} - } // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp new file mode 100644 index 000000000..c4f103a3c --- /dev/null +++ b/Source/WebKit/chromium/tests/CCLayerAnimationControllerTest.cpp @@ -0,0 +1,215 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "cc/CCLayerAnimationController.h" + +#include "CCAnimationTestCommon.h" +#include "GraphicsLayer.h" +#include "Length.h" +#include "TranslateTransformOperation.h" +#include "cc/CCActiveAnimation.h" +#include "cc/CCAnimationCurve.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> +#include <wtf/Vector.h> + +using namespace WebCore; +using namespace WebKitTests; + +namespace { + +void expectTranslateX(double translateX, const TransformationMatrix& matrix) +{ + TransformationMatrix::DecomposedType decomposedType; + matrix.decompose(decomposedType); + EXPECT_FLOAT_EQ(translateX, decomposedType.translateX); +} + +PassOwnPtr<CCActiveAnimation> createActiveAnimation(PassOwnPtr<CCAnimationCurve> curve, int id, CCActiveAnimation::TargetProperty property) +{ + return CCActiveAnimation::create(curve, 0, id, property); +} + +TEST(CCLayerAnimationControllerTest, createOpacityAnimation) +{ + OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); + const double duration = 1; + WebCore::KeyframeValueList values(AnimatedPropertyOpacity); + values.insert(new FloatAnimationValue(0, 0)); + values.insert(new FloatAnimationValue(duration, 1)); + + RefPtr<Animation> animation = Animation::create(); + animation->setDuration(duration); + + IntSize boxSize; + controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0); + + EXPECT_TRUE(controller->hasActiveAnimation()); + + CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Opacity); + EXPECT_TRUE(activeAnimation); + + EXPECT_EQ(1, activeAnimation->iterations()); + EXPECT_EQ(CCActiveAnimation::Opacity, activeAnimation->targetProperty()); + + EXPECT_EQ(CCAnimationCurve::Float, activeAnimation->curve()->type()); + + const CCFloatAnimationCurve* curve = activeAnimation->curve()->toFloatAnimationCurve(); + EXPECT_TRUE(curve); + + EXPECT_EQ(0, curve->getValue(0)); + EXPECT_EQ(1, curve->getValue(duration)); +} + +TEST(CCLayerAnimationControllerTest, createTransformAnimation) +{ + OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); + const double duration = 1; + WebCore::KeyframeValueList values(AnimatedPropertyWebkitTransform); + + TransformOperations operations1; + operations1.operations().append(TranslateTransformOperation::create(Length(2, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + values.insert(new TransformAnimationValue(0, &operations1)); + + TransformOperations operations2; + operations2.operations().append(TranslateTransformOperation::create(Length(4, Fixed), Length(0, Fixed), TransformOperation::TRANSLATE_X)); + values.insert(new TransformAnimationValue(duration, &operations2)); + + RefPtr<Animation> animation = Animation::create(); + animation->setDuration(duration); + + IntSize boxSize; + controller->addAnimation(values, boxSize, animation.get(), 0, 0, 0); + + EXPECT_TRUE(controller->hasActiveAnimation()); + + CCActiveAnimation* activeAnimation = controller->getActiveAnimation(0, CCActiveAnimation::Transform); + EXPECT_TRUE(activeAnimation); + + EXPECT_EQ(1, activeAnimation->iterations()); + EXPECT_EQ(CCActiveAnimation::Transform, activeAnimation->targetProperty()); + + EXPECT_EQ(CCAnimationCurve::Transform, activeAnimation->curve()->type()); + + const CCTransformAnimationCurve* curve = activeAnimation->curve()->toTransformAnimationCurve(); + EXPECT_TRUE(curve); + + expectTranslateX(2, curve->getValue(0, boxSize)); + expectTranslateX(4, curve->getValue(duration, boxSize)); +} + +TEST(CCLayerAnimationControllerTest, syncNewAnimation) +{ + FakeLayerAnimationControllerImplClient dummy; + OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); + OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); + + EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + + addOpacityTransitionToController(*controller, 1, 0, 1); + + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_TRUE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + EXPECT_EQ(CCActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)->runState()); +} + +TEST(CCLayerAnimationControllerTest, syncAnimationProperties) +{ + FakeLayerAnimationControllerImplClient dummy; + OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); + OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); + + EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + + addOpacityTransitionToController(*controller, 1, 0, 1); + + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_TRUE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + EXPECT_EQ(CCActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)->runState()); + + // Push an animation property change to the impl thread (should not cause an animation to be added). + controller->pauseAnimation(0, 0); + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_TRUE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + EXPECT_EQ(CCActiveAnimation::Paused, controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)->runState()); +} + +TEST(CCLayerAnimationControllerTest, syncAbortedAnimation) +{ + FakeLayerAnimationControllerImplClient dummy; + OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); + OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); + + EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + + addOpacityTransitionToController(*controller, 1, 0, 1); + + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_TRUE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + EXPECT_EQ(CCActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)->runState()); + + controller->removeAnimation(0); + + // Abort an animation from the main thread. + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); +} + +TEST(CCLayerAnimationControllerTest, syncCompletedAnimation) +{ + FakeLayerAnimationControllerImplClient dummy; + OwnPtr<CCLayerAnimationControllerImpl> controllerImpl(CCLayerAnimationControllerImpl::create(&dummy)); + OwnPtr<CCLayerAnimationController> controller(CCLayerAnimationController::create()); + + EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + + addOpacityTransitionToController(*controller, 1, 0, 1); + + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_TRUE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + EXPECT_EQ(CCActiveAnimation::WaitingForTargetAvailability, controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)->runState()); + + // Step through the animation until it is finished. At the next sync, the main thread's animation should be cleared. + OwnPtr<CCAnimationEventsVector> events(adoptPtr(new CCAnimationEventsVector)); + controllerImpl->animate(0, *events); + controllerImpl->animate(2, *events); + + EXPECT_FALSE(controllerImpl->getActiveAnimation(0, CCActiveAnimation::Opacity)); + EXPECT_TRUE(controller->hasActiveAnimation()); + + controller->synchronizeAnimations(controllerImpl.get()); + + EXPECT_FALSE(controller->hasActiveAnimation()); +} + +} // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp index 27728cbef..16a25e12e 100644 --- a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp @@ -88,10 +88,13 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly) Color arbitraryColor = Color(10, 20, 30); TransformationMatrix arbitraryTransform; arbitraryTransform.scale3d(0.1, 0.2, 0.3); + FilterOperations arbitraryFilters; + arbitraryFilters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::OPACITY)); // Changing these properties affects the entire subtree of layers. EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPoint(arbitraryFloatPoint)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setAnchorPointZ(arbitraryNumber)); + EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setFilters(arbitraryFilters)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMaskLayer(dummyMask)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setMasksToBounds(true)); EXECUTE_AND_VERIFY_SUBTREE_CHANGED(root->setOpaque(true)); diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp index b1fa72918..d2e1cfef9 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp @@ -28,7 +28,6 @@ #include "CCLayerTreeTestCommon.h" #include "LayerChromium.h" -#include "Region.h" #include "TransformationMatrix.h" #include <gmock/gmock.h> @@ -36,12 +35,6 @@ using namespace WebCore; -#define EXPECT_EQ_RECT(a, b) \ - EXPECT_EQ(a.x(), b.x()); \ - EXPECT_EQ(a.y(), b.y()); \ - EXPECT_EQ(a.width(), b.width()); \ - EXPECT_EQ(a.height(), b.height()); - namespace { void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatrix& transform, const TransformationMatrix& sublayerTransform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool preserves3D) @@ -602,174 +595,4 @@ TEST(CCLayerTreeHostCommonTest, verifyClipRectCullsRenderSurfaces) // - test the other functions in CCLayerTreeHostCommon // -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegion) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr<LayerChromium> parent = LayerChromium::create(); - RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(layer); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - - layer->setOpaque(true); - - Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; - Vector<RefPtr<LayerChromium> > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); -} - -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithRotation) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr<LayerChromium> parent = LayerChromium::create(); - RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(layer); - - TransformationMatrix layerTransform; - layerTransform.translate(250, 250); - layerTransform.rotate(90); - layerTransform.translate(-250, -250); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - - layer->setOpaque(true); - - Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; - Vector<RefPtr<LayerChromium> > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); -} - -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithTranslation) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr<LayerChromium> parent = LayerChromium::create(); - RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(layer); - - TransformationMatrix layerTransform; - layerTransform.translate(20, 20); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - - layer->setOpaque(true); - - Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; - Vector<RefPtr<LayerChromium> > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); -} - -TEST(CCLayerTreeHostCommonTest, layerAddsSelfToOccludedRegionWithRotatedSurface) -{ - // This tests that the right transforms are being used. - Region occluded; - const TransformationMatrix identityMatrix; - RefPtr<LayerChromium> parent = LayerChromium::create(); - RefPtr<LayerChromium> child = LayerChromium::create(); - RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); - parent->createRenderSurface(); - parent->addChild(child); - child->addChild(layer); - - TransformationMatrix childTransform; - childTransform.translate(250, 250); - childTransform.rotate(90); - childTransform.translate(-250, -250); - - setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); - setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); - setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), false); - - child->setMasksToBounds(true); - layer->setOpaque(true); - - Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; - Vector<RefPtr<LayerChromium> > dummyLayerList; - int dummyMaxTextureSize = 512; - - // FIXME: when we fix this "root-layer special case" behavior in CCLayerTreeHost, we will have to fix it here, too. - parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); - parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); - renderSurfaceLayerList.append(parent); - - CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); - - occluded = Region(); - layer->addSelfToOccludedScreenSpace(occluded); - EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); - - /* Justification for the above opaque rect from |layer|: - 100 - +---------------------+ +---------------------+ - | | | |30 Visible region of |layer|: ///// - | 30 | rotate(90) | | - | 30 + ---------------------------------+ | +---------------------------------+ - 100 | | 10 | | ==> | | |10 | - | |10+---------------------------------+ | +---------------------------------+ | - | | | | | | | | |///////////////| 420 | | - | | | | | | | | |///////////////|60 | | - | | | | | | | | |///////////////| | | - +----|--|-------------+ | | +--|--|---------------+ | | - | | | | 20|10| 70 | | - | | | | | | | | - | | | |500 | | | | - | | | | | | | | - | | | | | | | | - | | | | | | | | - | | | | | | |10| - +--|-------------------------------+ | | +------------------------------|--+ - | | | 490 | - +---------------------------------+ +---------------------------------+ - 500 500 - */ -} - } // namespace diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp index f59893de9..9ba1cf4ad 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp @@ -52,6 +52,7 @@ public: virtual void onSwapBuffersCompleteOnImplThread() { } virtual void setNeedsRedrawOnImplThread() { m_didRequestRedraw = true; } virtual void setNeedsCommitOnImplThread() { m_didRequestCommit = true; } + virtual void postAnimationEventsToMainThreadOnImplThread(PassOwnPtr<CCAnimationEventsVector>) { } static void expectClearedScrollDeltasRecursive(CCLayerImpl* layer) { @@ -67,7 +68,8 @@ public: for (size_t i = 0; i < scrollInfo.scrolls.size(); ++i) { if (scrollInfo.scrolls[i].layerId != id) continue; - ASSERT_EQ(scrollInfo.scrolls[i].scrollDelta, scrollDelta); + EXPECT_EQ(scrollDelta.width(), scrollInfo.scrolls[i].scrollDelta.width()); + EXPECT_EQ(scrollDelta.height(), scrollInfo.scrolls[i].scrollDelta.height()); timesEncountered++; } @@ -89,6 +91,11 @@ public: } protected: + PassRefPtr<GraphicsContext3D> createContext() + { + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3D()), GraphicsContext3D::RenderDirectlyToHostWindow); + } + DebugScopedSetImplThread m_alwaysImplThread; OwnPtr<CCLayerTreeHostImpl> m_hostImpl; bool m_didRequestCommit; @@ -142,14 +149,14 @@ TEST_F(CCLayerTreeHostImplTest, scrollDeltaRepeatedScrolls) scrollInfo = m_hostImpl->processScrollDeltas(); ASSERT_EQ(scrollInfo->scrolls.size(), 1u); EXPECT_EQ(root->sentScrollDelta(), scrollDelta); - expectContains(*scrollInfo.get(), root->id(), scrollDelta); + expectContains(*scrollInfo, root->id(), scrollDelta); IntSize scrollDelta2(-5, 27); root->scrollBy(scrollDelta2); scrollInfo = m_hostImpl->processScrollDeltas(); ASSERT_EQ(scrollInfo->scrolls.size(), 1u); EXPECT_EQ(root->sentScrollDelta(), scrollDelta + scrollDelta2); - expectContains(*scrollInfo.get(), root->id(), scrollDelta + scrollDelta2); + expectContains(*scrollInfo, root->id(), scrollDelta + scrollDelta2); root->scrollBy(IntSize()); scrollInfo = m_hostImpl->processScrollDeltas(); @@ -163,13 +170,28 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootCallsCommitAndRedraw) root->setScrollPosition(IntPoint(0, 0)); root->setMaxScrollPosition(IntSize(100, 100)); m_hostImpl->setRootLayer(root); - EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0)), CCInputHandlerClient::ScrollStarted); + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollStarted); m_hostImpl->scrollBy(IntSize(0, 10)); m_hostImpl->scrollEnd(); EXPECT_TRUE(m_didRequestRedraw); EXPECT_TRUE(m_didRequestCommit); } +TEST_F(CCLayerTreeHostImplTest, wheelEventHandlers) +{ + RefPtr<CCLayerImpl> root = CCLayerImpl::create(0); + root->setScrollable(true); + root->setScrollPosition(IntPoint(0, 0)); + root->setMaxScrollPosition(IntSize(100, 100)); + m_hostImpl->setRootLayer(root); + root->setHaveWheelEventHandlers(true); + // With registered event handlers, wheel scrolls have to go to the main thread. + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Wheel), CCInputHandlerClient::ScrollFailed); + + // But gesture scrolls can still be handled. + EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(0, 0), CCInputHandlerClient::Gesture), CCInputHandlerClient::ScrollStarted); +} + TEST_F(CCLayerTreeHostImplTest, pinchGesture) { setupScrollAndContentsLayers(IntSize(100, 100)); @@ -184,6 +206,7 @@ TEST_F(CCLayerTreeHostImplTest, pinchGesture) { m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); scrollLayer->setPageScaleDelta(1); + scrollLayer->setScrollDelta(IntSize()); float pageScaleDelta = 2; m_hostImpl->pinchGestureBegin(); @@ -200,6 +223,7 @@ TEST_F(CCLayerTreeHostImplTest, pinchGesture) { m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); scrollLayer->setPageScaleDelta(1); + scrollLayer->setScrollDelta(IntSize()); float pageScaleDelta = 10; m_hostImpl->pinchGestureBegin(); @@ -214,6 +238,7 @@ TEST_F(CCLayerTreeHostImplTest, pinchGesture) { m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); scrollLayer->setPageScaleDelta(1); + scrollLayer->setScrollDelta(IntSize()); scrollLayer->setScrollPosition(IntPoint(50, 50)); float pageScaleDelta = 0.1; @@ -225,7 +250,25 @@ TEST_F(CCLayerTreeHostImplTest, pinchGesture) EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); // Pushed to (0,0) via clamping against contents layer size. - expectContains(*scrollInfo.get(), scrollLayer->id(), IntSize(-50, -50)); + expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); + } + + // Two-finger panning + { + m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); + scrollLayer->setPageScaleDelta(1); + scrollLayer->setScrollDelta(IntSize()); + scrollLayer->setScrollPosition(IntPoint(20, 20)); + + float pageScaleDelta = 1; + m_hostImpl->pinchGestureBegin(); + m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(10, 10)); + m_hostImpl->pinchGestureUpdate(pageScaleDelta, IntPoint(20, 20)); + m_hostImpl->pinchGestureEnd(); + + OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); + EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); + expectContains(*scrollInfo, scrollLayer->id(), IntSize(-10, -10)); } } @@ -255,7 +298,7 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); EXPECT_EQ(scrollInfo->pageScaleDelta, 2); - expectContains(*scrollInfo.get(), scrollLayer->id(), IntSize(-50, -50)); + expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); } // Anchor zoom-out @@ -272,8 +315,107 @@ TEST_F(CCLayerTreeHostImplTest, pageScaleAnimation) OwnPtr<CCScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas(); EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); // Pushed to (0,0) via clamping against contents layer size. - expectContains(*scrollInfo.get(), scrollLayer->id(), IntSize(-50, -50)); + expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); + } +} + +class DidDrawCheckLayer : public CCLayerImpl { +public: + static PassRefPtr<DidDrawCheckLayer> create(int id) { return adoptRef(new DidDrawCheckLayer(id)); } + + virtual void didDraw() + { + m_didDrawCalled = true; + } + + virtual void willDraw(LayerRendererChromium*) + { + m_willDrawCalled = true; + } + + bool didDrawCalled() const { return m_didDrawCalled; } + bool willDrawCalled() const { return m_willDrawCalled; } + +private: + explicit DidDrawCheckLayer(int id) + : CCLayerImpl(id) + , m_didDrawCalled(false) + , m_willDrawCalled(false) + { + setAnchorPoint(FloatPoint(0, 0)); + setBounds(IntSize(10, 10)); + setDrawsContent(true); } + + bool m_didDrawCalled; + bool m_willDrawCalled; +}; + +TEST_F(CCLayerTreeHostImplTest, didDrawNotCalledOnHiddenLayer) +{ + RefPtr<GraphicsContext3D> context = createContext(); + m_hostImpl->initializeLayerRenderer(context); + + // Ensure visibleLayerRect for root layer is empty + m_hostImpl->setViewportSize(IntSize(0, 0)); + + RefPtr<DidDrawCheckLayer> root = DidDrawCheckLayer::create(0); + m_hostImpl->setRootLayer(root); + + EXPECT_FALSE(root->willDrawCalled()); + EXPECT_FALSE(root->didDrawCalled()); + + m_hostImpl->drawLayers(); + + EXPECT_FALSE(root->willDrawCalled()); + EXPECT_FALSE(root->didDrawCalled()); + + EXPECT_TRUE(root->visibleLayerRect().isEmpty()); + + // Ensure visibleLayerRect for root layer is not empty + m_hostImpl->setViewportSize(IntSize(10, 10)); + + EXPECT_FALSE(root->willDrawCalled()); + EXPECT_FALSE(root->didDrawCalled()); + + m_hostImpl->drawLayers(); + + EXPECT_TRUE(root->willDrawCalled()); + EXPECT_TRUE(root->didDrawCalled()); + + EXPECT_FALSE(root->visibleLayerRect().isEmpty()); +} + +TEST_F(CCLayerTreeHostImplTest, didDrawCalledOnAllLayers) +{ + RefPtr<GraphicsContext3D> context = createContext(); + m_hostImpl->initializeLayerRenderer(context); + m_hostImpl->setViewportSize(IntSize(10, 10)); + + RefPtr<DidDrawCheckLayer> root = DidDrawCheckLayer::create(0); + m_hostImpl->setRootLayer(root); + + RefPtr<DidDrawCheckLayer> layer1 = DidDrawCheckLayer::create(1); + root->addChild(layer1); + + RefPtr<DidDrawCheckLayer> layer2 = DidDrawCheckLayer::create(2); + layer1->addChild(layer2); + + layer1->setOpacity(0.3); + layer1->setPreserves3D(false); + + EXPECT_FALSE(root->didDrawCalled()); + EXPECT_FALSE(layer1->didDrawCalled()); + EXPECT_FALSE(layer2->didDrawCalled()); + + m_hostImpl->drawLayers(); + + EXPECT_TRUE(root->didDrawCalled()); + EXPECT_TRUE(layer1->didDrawCalled()); + EXPECT_TRUE(layer2->didDrawCalled()); + + EXPECT_NE(root->renderSurface(), layer1->renderSurface()); + EXPECT_TRUE(!!layer1->renderSurface()); } class BlendStateTrackerContext: public FakeWebGraphicsContext3D { @@ -347,8 +489,7 @@ private: // https://bugs.webkit.org/show_bug.cgi?id=75783 TEST_F(CCLayerTreeHostImplTest, blendingOffWhenDrawingOpaqueLayers) { - GraphicsContext3D::Attributes attrs; - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new BlendStateTrackerContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> context = createContext(); m_hostImpl->initializeLayerRenderer(context); m_hostImpl->setViewportSize(IntSize(10, 10)); @@ -507,7 +648,6 @@ private: class FakeDrawableCCLayerImpl: public CCLayerImpl { public: explicit FakeDrawableCCLayerImpl(int id) : CCLayerImpl(id) { } - virtual void draw(LayerRendererChromium* renderer) { } }; // Only reshape when we know we are going to draw. Otherwise, the reshape @@ -515,9 +655,8 @@ public: // viewport size is never set. TEST_F(CCLayerTreeHostImplTest, reshapeNotCalledUntilDraw) { - GraphicsContext3D::Attributes attrs; ReshapeTrackerContext* reshapeTracker = new ReshapeTrackerContext(); - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(reshapeTracker), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(reshapeTracker), GraphicsContext3D::RenderDirectlyToHostWindow); m_hostImpl->initializeLayerRenderer(context); m_hostImpl->setViewportSize(IntSize(10, 10)); @@ -559,9 +698,8 @@ private: // where it should request to swap only the subBuffer that is damaged. TEST_F(CCLayerTreeHostImplTest, partialSwapReceivesDamageRect) { - GraphicsContext3D::Attributes attrs; PartialSwapTrackerContext* partialSwapTracker = new PartialSwapTrackerContext(); - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(partialSwapTracker), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(partialSwapTracker), GraphicsContext3D::RenderDirectlyToHostWindow); // This test creates its own CCLayerTreeHostImpl, so // that we can force partial swap enabled. diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp index fc414f739..10cfa6931 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp @@ -26,14 +26,18 @@ #include "cc/CCLayerTreeHost.h" +#include "CCAnimationTestCommon.h" #include "CompositorFakeWebGraphicsContext3D.h" #include "ContentLayerChromium.h" +#include "FilterOperations.h" #include "GraphicsContext3DPrivate.h" #include "LayerChromium.h" #include "Region.h" #include "TextureManager.h" #include "WebCompositor.h" #include "WebKit.h" +#include "cc/CCActiveAnimation.h" +#include "cc/CCLayerAnimationController.h" #include "cc/CCLayerImpl.h" #include "cc/CCLayerTreeHostImpl.h" #include "cc/CCScopedThreadProxy.h" @@ -49,6 +53,7 @@ using namespace WebCore; using namespace WebKit; +using namespace WebKitTests; using namespace WTF; namespace { @@ -59,6 +64,7 @@ public: virtual void beginCommitOnCCThread(CCLayerTreeHostImpl*) { } virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl*) { } virtual void drawLayersOnCCThread(CCLayerTreeHostImpl*) { } + virtual void animateLayers(CCLayerTreeHostImpl*) { } virtual void applyScrollAndScale(const IntSize&, float) { } virtual void updateAnimations(double frameBeginTime) { } virtual void layout() { } @@ -90,6 +96,13 @@ public: m_testHooks->drawLayersOnCCThread(this); } +protected: + virtual void animateLayers(double frameBeginTimeMs) + { + CCLayerTreeHostImpl::animateLayers(frameBeginTimeMs); + m_testHooks->animateLayers(this); + } + private: MockLayerTreeHostImpl(TestHooks* testHooks, const CCSettings& settings, CCLayerTreeHostImplClient* client) : CCLayerTreeHostImpl(settings, client) @@ -105,7 +118,11 @@ class MockLayerTreeHost : public CCLayerTreeHost { public: static PassRefPtr<MockLayerTreeHost> create(TestHooks* testHooks, CCLayerTreeHostClient* client, PassRefPtr<LayerChromium> rootLayer, const CCSettings& settings) { - RefPtr<MockLayerTreeHost> layerTreeHost = adoptRef(new MockLayerTreeHost(testHooks, client, settings)); + // For these tests, we will enable threaded animations. + CCSettings settingsCopy = settings; + settingsCopy.threadedAnimationEnabled = true; + + RefPtr<MockLayerTreeHost> layerTreeHost = adoptRef(new MockLayerTreeHost(testHooks, client, settingsCopy)); bool success = layerTreeHost->initialize(); EXPECT_TRUE(success); layerTreeHost->setRootLayer(rootLayer); @@ -118,7 +135,10 @@ public: virtual PassOwnPtr<CCLayerTreeHostImpl> createLayerTreeHostImpl(CCLayerTreeHostImplClient* client) { - return MockLayerTreeHostImpl::create(m_testHooks, settings(), client); + // For these tests, we will enable threaded animations. + CCSettings settings; + settings.threadedAnimationEnabled = true; + return MockLayerTreeHostImpl::create(m_testHooks, settings, client); } private: @@ -207,10 +227,7 @@ public: webAttrs.alpha = attrs.alpha; OwnPtr<WebGraphicsContext3D> webContext = CompositorFakeWebGraphicsContext3DWithTextureTracking::create(webAttrs); - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext( - webContext.release(), attrs, 0, - GraphicsContext3D::RenderDirectlyToHostWindow, - GraphicsContext3DPrivate::ForUseOnAnotherThread); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); } virtual void didCommitAndDrawFrame() @@ -225,7 +242,9 @@ public: { } - virtual void scheduleComposite() { } + virtual void scheduleComposite() + { + } private: explicit MockLayerTreeHostClient(TestHooks* testHooks) : m_testHooks(testHooks) { } @@ -255,6 +274,11 @@ public: callOnMainThread(CCLayerTreeHostTest::dispatchSetNeedsAnimate, this); } + void postAddAnimationToMainThread() + { + callOnMainThread(CCLayerTreeHostTest::dispatchAddAnimation, this); + } + void postSetNeedsCommitToMainThread() { callOnMainThread(CCLayerTreeHostTest::dispatchSetNeedsCommit, this); @@ -270,7 +294,6 @@ public: callOnMainThread(CCLayerTreeHostTest::dispatchSetNeedsAnimateAndCommit, this); } - void postSetVisibleToMainThread(bool visible) { callOnMainThread(visible ? CCLayerTreeHostTest::dispatchSetVisible : CCLayerTreeHostTest::dispatchSetInvisible, this); @@ -313,6 +336,15 @@ protected: test->m_layerTreeHost->setNeedsAnimate(); } + static void dispatchAddAnimation(void* self) + { + ASSERT(isMainThread()); + CCLayerTreeHostTest* test = static_cast<CCLayerTreeHostTest*>(self); + ASSERT(test); + if (test->m_layerTreeHost && test->m_layerTreeHost->rootLayer()) + addOpacityTransitionToLayer(*test->m_layerTreeHost->rootLayer(), 0, 0, 1); + } + static void dispatchSetNeedsAnimateAndCommit(void* self) { ASSERT(isMainThread()); @@ -789,6 +821,47 @@ TEST_F(CCLayerTreeHostTestSetNeedsAnimateInsideAnimationCallback, runMultiThread runTestThreaded(); } +// Add a layer animation and confirm that CCLayerTreeHostImpl::animateLayers does get +// called and continues to get called. +class CCLayerTreeHostTestAddAnimation : public CCLayerTreeHostTestThreadOnly { +public: + CCLayerTreeHostTestAddAnimation() + : m_numAnimates(0) + , m_layerTreeHostImpl(0) + { + } + + virtual void beginTest() + { + postAddAnimationToMainThread(); + } + + virtual void animateLayers(CCLayerTreeHostImpl* layerTreeHostImpl) + { + if (!m_numAnimates) { + // The animation had zero duration so layerTreeHostImpl should no + // longer need to animate its layers. + EXPECT_FALSE(layerTreeHostImpl->needsAnimateLayers()); + m_numAnimates++; + return; + } + endTest(); + } + + virtual void afterTest() + { + } + +private: + int m_numAnimates; + CCLayerTreeHostImpl* m_layerTreeHostImpl; +}; + +TEST_F(CCLayerTreeHostTestAddAnimation, runMultiThread) +{ + runTestThreaded(); +} + class CCLayerTreeHostTestScrollSimple : public CCLayerTreeHostTestThreadOnly { public: CCLayerTreeHostTestScrollSimple() @@ -938,6 +1011,75 @@ TEST_F(CCLayerTreeHostTestScrollMultipleRedraw, DISABLED_runMultiThread) runTestThreaded(); } +// Verifies that startPageScaleAnimation events propagate correctly from CCLayerTreeHost to +// CCLayerTreeHostImpl in the MT compositor. +class CCLayerTreeHostTestStartPageScaleAnimation : public CCLayerTreeHostTest { +public: + + CCLayerTreeHostTestStartPageScaleAnimation() + : m_animationRequested(false) + { + } + + virtual void beginTest() + { + m_layerTreeHost->rootLayer()->setScrollable(true); + m_layerTreeHost->rootLayer()->setScrollPosition(IntPoint()); + postSetNeedsRedrawToMainThread(); + } + + static void requestStartPageScaleAnimation(void* self) + { + CCLayerTreeHostTestStartPageScaleAnimation* test = static_cast<CCLayerTreeHostTestStartPageScaleAnimation*>(self); + if (test->layerTreeHost()) + test->layerTreeHost()->startPageScaleAnimation(IntSize(), false, 1.25, 0); + } + + virtual void drawLayersOnCCThread(CCLayerTreeHostImpl* impl) + { + impl->rootLayer()->setScrollable(true); + impl->rootLayer()->setScrollPosition(IntPoint()); + impl->setPageScaleFactorAndLimits(impl->pageScale(), 0.5, 2); + + // We request animation only once. + if (!m_animationRequested) { + callOnMainThread(CCLayerTreeHostTestStartPageScaleAnimation::requestStartPageScaleAnimation, this); + m_animationRequested = true; + } + } + + virtual void applyScrollAndScale(const IntSize& scrollDelta, float scale) + { + IntPoint position = m_layerTreeHost->rootLayer()->scrollPosition(); + m_layerTreeHost->rootLayer()->setScrollPosition(position + scrollDelta); + m_layerTreeHost->setPageScaleFactorAndLimits(scale, 0.5, 2); + } + + virtual void commitCompleteOnCCThread(CCLayerTreeHostImpl* impl) + { + impl->processScrollDeltas(); + // We get one commit before the first draw, and the animation doesn't happen until the second draw, + // so results available on the third commit. + if (impl->frameNumber() == 2) { + EXPECT_EQ(1.25, impl->pageScale()); + endTest(); + } else + postSetNeedsRedrawToMainThread(); + } + + virtual void afterTest() + { + } + +private: + bool m_animationRequested; +}; + +TEST_F(CCLayerTreeHostTestStartPageScaleAnimation, runTest) +{ + runTest(true); +} + class CCLayerTreeHostTestSetVisible : public CCLayerTreeHostTest { public: @@ -1596,6 +1738,94 @@ public: SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusion) +class CCLayerTreeHostTestLayerOcclusionWithFilters : public CCLayerTreeHostTest { +public: + CCLayerTreeHostTestLayerOcclusionWithFilters() { } + + virtual void beginTest() + { + RefPtr<TestLayerChromium> rootLayer = TestLayerChromium::create(); + RefPtr<TestLayerChromium> child = TestLayerChromium::create(); + RefPtr<TestLayerChromium> child2 = TestLayerChromium::create(); + RefPtr<TestLayerChromium> grandChild = TestLayerChromium::create(); + RefPtr<TestLayerChromium> mask = TestLayerChromium::create(); + + TransformationMatrix identityMatrix; + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(90); + childTransform.translate(-250, -250); + + child->setMasksToBounds(true); + + // If the child layer has a filter that changes alpha values, and is below child2, then child2 should contribute to occlusion on everything, + // and child shouldn't contribute to the rootLayer + setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); + setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); + setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); + + { + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::OPACITY)); + child->setFilters(filters); + } + + m_layerTreeHost->setRootLayer(rootLayer); + m_layerTreeHost->setViewportSize(rootLayer->bounds()); + m_layerTreeHost->updateLayers(); + m_layerTreeHost->commitComplete(); + + EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds()); + EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), grandChild->occludedScreenSpace().bounds()); + EXPECT_EQ(1u, grandChild->occludedScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 40, 90, 60), child->occludedScreenSpace().bounds()); + EXPECT_EQ(2u, child->occludedScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds()); + EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); + + // If the child layer has a filter that moves pixels/changes alpha, and is below child2, then child should not inherit occlusion from outside its subtree, + // and should not contribute to the rootLayer + setLayerPropertiesForTesting(rootLayer.get(), 0, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), true); + setLayerPropertiesForTesting(child.get(), rootLayer.get(), childTransform, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(grandChild.get(), child.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); + setLayerPropertiesForTesting(child2.get(), rootLayer.get(), identityMatrix, FloatPoint(0, 0), FloatPoint(10, 70), IntSize(500, 500), true); + + { + FilterOperations filters; + filters.operations().append(BlurFilterOperation::create(Length(10, WebCore::Percent), FilterOperation::BLUR)); + child->setFilters(filters); + } + + m_layerTreeHost->setRootLayer(rootLayer); + m_layerTreeHost->setViewportSize(rootLayer->bounds()); + m_layerTreeHost->updateLayers(); + m_layerTreeHost->commitComplete(); + + EXPECT_EQ_RECT(IntRect(), child2->occludedScreenSpace().bounds()); + EXPECT_EQ(0u, child2->occludedScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(), grandChild->occludedScreenSpace().bounds()); + EXPECT_EQ(0u, grandChild->occludedScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), child->occludedScreenSpace().bounds()); + EXPECT_EQ(1u, child->occludedScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 70, 90, 30), rootLayer->occludedScreenSpace().bounds()); + EXPECT_EQ(1u, rootLayer->occludedScreenSpace().rects().size()); + + // Kill the layerTreeHost immediately. + m_layerTreeHost->setRootLayer(0); + m_layerTreeHost.clear(); + + endTest(); + } + + virtual void afterTest() + { + } +}; + +SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestLayerOcclusionWithFilters) + class CCLayerTreeHostTestManySurfaces : public CCLayerTreeHostTest { public: CCLayerTreeHostTestManySurfaces() { } diff --git a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp new file mode 100644 index 000000000..678ec9645 --- /dev/null +++ b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp @@ -0,0 +1,1173 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "cc/CCOcclusionTracker.h" + +#include "FilterOperations.h" +#include "LayerChromium.h" +#include "Region.h" +#include "TransformationMatrix.h" +#include "cc/CCLayerTreeHostCommon.h" + +#include <gmock/gmock.h> +#include <gtest/gtest.h> + +using namespace WebCore; + +#define EXPECT_EQ_RECT(a, b) \ + EXPECT_EQ(a.x(), b.x()); \ + EXPECT_EQ(a.y(), b.y()); \ + EXPECT_EQ(a.width(), b.width()); \ + EXPECT_EQ(a.height(), b.height()); + +namespace { + +void setLayerPropertiesForTesting(LayerChromium* layer, const TransformationMatrix& transform, const TransformationMatrix& sublayerTransform, const FloatPoint& anchor, const FloatPoint& position, const IntSize& bounds, bool opaque) +{ + layer->setTransform(transform); + layer->setSublayerTransform(sublayerTransform); + layer->setAnchorPoint(anchor); + layer->setPosition(position); + layer->setBounds(bounds); + layer->setOpaque(opaque); +} + +class LayerChromiumWithForcedDrawsContent : public LayerChromium { +public: + LayerChromiumWithForcedDrawsContent() + : LayerChromium() + { + } + + virtual bool drawsContent() const { return true; } +}; + +// A subclass to expose the total current occlusion. +class TestCCOcclusionTracker : public CCOcclusionTracker { +public: + Region occlusionInScreenSpace() const { return CCOcclusionTracker::m_stack.last().occlusionInScreen; } + Region occlusionInTargetSurface() const { return CCOcclusionTracker::m_stack.last().occlusionInTarget; } + + void setOcclusionInScreenSpace(const Region& region) { CCOcclusionTracker::m_stack.last().occlusionInScreen = region; } + void setOcclusionInTargetSurface(const Region& region) { CCOcclusionTracker::m_stack.last().occlusionInTarget = region; } +}; + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegion) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(layer); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 29, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(31, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 31, 70, 70))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 30, 70, 70)).isEmpty()); + EXPECT_EQ_RECT(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_EQ_RECT(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 29, 70, 70))); + EXPECT_EQ_RECT(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 29, 70, 70))); + EXPECT_EQ_RECT(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 29, 70, 70))); + EXPECT_EQ_RECT(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 30, 70, 70))); + EXPECT_EQ_RECT(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 31, 70, 70))); + EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 31, 70, 70))); + EXPECT_EQ_RECT(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 31, 70, 70))); +} + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotation) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(layer); + + TransformationMatrix layerTransform; + layerTransform.translate(250, 250); + layerTransform.rotate(90); + layerTransform.translate(-250, -250); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 29, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(31, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 31, 70, 70))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 30, 70, 70)).isEmpty()); + EXPECT_EQ_RECT(IntRect(29, 30, 1, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_EQ_RECT(IntRect(29, 29, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 29, 70, 70))); + EXPECT_EQ_RECT(IntRect(30, 29, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 29, 70, 70))); + EXPECT_EQ_RECT(IntRect(31, 29, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 29, 70, 70))); + EXPECT_EQ_RECT(IntRect(100, 30, 1, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 30, 70, 70))); + EXPECT_EQ_RECT(IntRect(31, 31, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 31, 70, 70))); + EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 31, 70, 70))); + EXPECT_EQ_RECT(IntRect(29, 31, 70, 70), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 31, 70, 70))); +} + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithTranslation) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(layer); + + TransformationMatrix layerTransform; + layerTransform.translate(20, 20); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(50, 50, 50, 50), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(50, 50, 50, 50))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(49, 50, 50, 50))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(50, 49, 50, 50))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(51, 50, 50, 50))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(50, 51, 50, 50))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(50, 50, 50, 50)).isEmpty()); + EXPECT_EQ_RECT(IntRect(49, 50, 1, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 50, 50, 50))); + EXPECT_EQ_RECT(IntRect(49, 49, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 49, 50, 50))); + EXPECT_EQ_RECT(IntRect(50, 49, 50, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(50, 49, 50, 50))); + EXPECT_EQ_RECT(IntRect(51, 49, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(51, 49, 50, 50))); + EXPECT_EQ_RECT(IntRect(100, 50, 1, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(51, 50, 50, 50))); + EXPECT_EQ_RECT(IntRect(51, 51, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(51, 51, 50, 50))); + EXPECT_EQ_RECT(IntRect(50, 100, 50, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(50, 51, 50, 50))); + EXPECT_EQ_RECT(IntRect(49, 51, 50, 50), occlusion.unoccludedContentRect(parent.get(), IntRect(49, 51, 50, 50))); +} + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedSurface) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child); + child->addChild(layer); + + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(90); + childTransform.translate(-250, -250); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); + setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); + + child->setMasksToBounds(true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(child->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(9, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 430, 61, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 71))); + + occlusion.markOccludedBehindLayer(child.get()); + occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 39, 70, 60))); + + + /* Justification for the above occlusion from |layer|: + 100 + +---------------------+ +---------------------+ + | | | |30 Visible region of |layer|: ///// + | 30 | rotate(90) | | + | 30 + ---------------------------------+ | +---------------------------------+ + 100 | | 10 | | ==> | | |10 | + | |10+---------------------------------+ | +---------------------------------+ | + | | | | | | | | |///////////////| 420 | | + | | | | | | | | |///////////////|60 | | + | | | | | | | | |///////////////| | | + +----|--|-------------+ | | +--|--|---------------+ | | + | | | | 20|10| 70 | | + | | | | | | | | + | | | |500 | | | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | | |10| + +--|-------------------------------+ | | +------------------------------|--+ + | | | 490 | + +---------------------------------+ +---------------------------------+ + 500 500 + */ +} + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithSurfaceAlreadyOnStack) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> child2 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child); + child->addChild(layer); + parent->addChild(child2); + + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(90); + childTransform.translate(-250, -250); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); + setLayerPropertiesForTesting(layer.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 500), true); + + // |child2| makes |parent|'s surface get considered by CCOcclusionTracker first, instead of |child|'s. This exercises different code in + // leaveToTargetRenderSurface, as the target surface has already been seen. + setLayerPropertiesForTesting(child2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(60, 20), true); + + child->setMasksToBounds(true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(parent->renderSurface()); + occlusion.markOccludedBehindLayer(child2.get()); + + EXPECT_EQ_RECT(IntRect(30, 30, 60, 20), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 30, 60, 20), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + occlusion.enterTargetRenderSurface(child->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(9, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(11, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 431, 60, 70))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(10, 430, 60, 70)).isEmpty()); + // This is the little piece not occluded by child2 + EXPECT_EQ_RECT(IntRect(9, 430, 1, 10), occlusion.unoccludedContentRect(child.get(), IntRect(9, 430, 60, 70))); + // This extends past both sides of child2, so it will be the original rect. + EXPECT_EQ_RECT(IntRect(9, 430, 60, 80), occlusion.unoccludedContentRect(child.get(), IntRect(9, 430, 60, 80))); + // This extends past two adjacent sides of child2, and should included the unoccluded parts of each side. + // This also demonstrates that the rect can be arbitrary and does not get clipped to the layer's visibleLayerRect(). + EXPECT_EQ_RECT(IntRect(-10, 430, 20, 70), occlusion.unoccludedContentRect(child.get(), IntRect(-10, 430, 60, 70))); + // This extends past three adjacent sides of child2, so it should contain the unoccluded parts of each side. The left + // and bottom edges are completely unoccluded for some row/column so we get back the original query rect. + EXPECT_EQ_RECT(IntRect(-10, 430, 60, 80), occlusion.unoccludedContentRect(child.get(), IntRect(-10, 430, 60, 80))); + EXPECT_EQ_RECT(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_EQ_RECT(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child.get(), IntRect(11, 430, 60, 70))); + EXPECT_EQ_RECT(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child.get(), IntRect(10, 431, 60, 70))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.surfaceUnoccludedContentRect(child.get(), IntRect(10, 430, 60, 70))); + + occlusion.markOccludedBehindLayer(child.get()); + // |child2| should get merged with the surface we are leaving now + occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); + + Vector<IntRect> screen = occlusion.occlusionInScreenSpace().rects(); + Vector<IntRect> target = occlusion.occlusionInTargetSurface().rects(); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 30, 70, 70))); + EXPECT_EQ_RECT(IntRect(90, 30, 10, 10), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 30, 70, 70))); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 30, 60, 10))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 30, 60, 10))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 29, 60, 10))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(31, 30, 60, 10))); + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 31, 60, 10))); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 39, 70, 60))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 30, 60, 10)).isEmpty()); + EXPECT_EQ_RECT(IntRect(29, 30, 1, 10), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 30, 60, 10))); + EXPECT_EQ_RECT(IntRect(30, 29, 60, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 29, 60, 10))); + EXPECT_EQ_RECT(IntRect(90, 30, 1, 10), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 30, 60, 10))); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 31, 60, 10)).isEmpty()); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 40, 70, 60)).isEmpty()); + EXPECT_EQ_RECT(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 40, 70, 60))); + // This rect is mostly occluded by |child2|. + EXPECT_EQ_RECT(IntRect(90, 39, 10, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 39, 70, 60))); + // This rect extends past top/right ends of |child2|. + EXPECT_EQ_RECT(IntRect(30, 29, 70, 11), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 29, 70, 70))); + // This rect extends past left/right ends of |child2|. + EXPECT_EQ_RECT(IntRect(20, 39, 80, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(20, 39, 80, 60))); + EXPECT_EQ_RECT(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 40, 70, 60))); + EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 41, 70, 60))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(30, 40, 70, 60))); + + + /* Justification for the above occlusion from |layer|: + 100 + +---------------------+ +---------------------+ + | | | |30 Visible region of |layer|: ///// + | 30 | rotate(90) | 30 60 | |child2|: \\\\\ + | 30 + ------------+--------------------+ | 30 +------------+--------------------+ + 100 | | 10 | | | ==> | |\\\\\\\\\\\\| |10 | + | |10+----------|----------------------+ | +--|\\\\\\\\\\\\|-----------------+ | + | + ------------+ | | | | | +------------+//| 420 | | + | | | | | | | | |///////////////|60 | | + | | | | | | | | |///////////////| | | + +----|--|-------------+ | | +--|--|---------------+ | | + | | | | 20|10| 70 | | + | | | | | | | | + | | | |500 | | | | + | | | | | | | | + | | | | | | | | + | | | | | | | | + | | | | | | |10| + +--|-------------------------------+ | | +------------------------------|--+ + | | | 490 | + +---------------------------------+ +---------------------------------+ + 500 500 + */ +} + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithRotatedOffAxisSurface) +{ + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child); + child->addChild(layer); + + // Now rotate the child a little more so it is not axis-aligned. The parent will no longer be occluded by |layer|, but + // the child's occlusion should be unchanged. + + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(95); + childTransform.translate(-250, -250); + + TransformationMatrix layerTransform; + layerTransform.translate(10, 10); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); + setLayerPropertiesForTesting(layer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), true); + + child->setMasksToBounds(true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + IntRect clippedLayerInChild = layerTransform.mapRect(layer->visibleLayerRect()); + + occlusion.enterTargetRenderSurface(child->renderSurface()); + occlusion.markOccludedBehindLayer(layer.get()); + + EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(clippedLayerInChild, occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child.get(), clippedLayerInChild)); + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), clippedLayerInChild).isEmpty()); + clippedLayerInChild.move(-1, 0); + EXPECT_FALSE(occlusion.occluded(child.get(), clippedLayerInChild)); + EXPECT_FALSE(occlusion.unoccludedContentRect(parent.get(), clippedLayerInChild).isEmpty()); + clippedLayerInChild.move(1, 0); + clippedLayerInChild.move(1, 0); + EXPECT_FALSE(occlusion.occluded(child.get(), clippedLayerInChild)); + EXPECT_FALSE(occlusion.unoccludedContentRect(parent.get(), clippedLayerInChild).isEmpty()); + clippedLayerInChild.move(-1, 0); + clippedLayerInChild.move(0, -1); + EXPECT_FALSE(occlusion.occluded(child.get(), clippedLayerInChild)); + EXPECT_FALSE(occlusion.unoccludedContentRect(parent.get(), clippedLayerInChild).isEmpty()); + clippedLayerInChild.move(0, 1); + clippedLayerInChild.move(0, 1); + EXPECT_FALSE(occlusion.occluded(child.get(), clippedLayerInChild)); + EXPECT_FALSE(occlusion.unoccludedContentRect(parent.get(), clippedLayerInChild).isEmpty()); + clippedLayerInChild.move(0, -1); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(0, 0, 500, 500), occlusion.surfaceUnoccludedContentRect(child.get(), IntRect(0, 0, 500, 500))); + + occlusion.markOccludedBehindLayer(child.get()); + occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(0u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(0u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(75, 55, 1, 1))); + EXPECT_EQ_RECT(IntRect(75, 55, 1, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(75, 55, 1, 1))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(0, 0, 100, 100), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(0, 0, 100, 100))); +} + +TEST(CCOcclusionTrackerTest, layerAddedToOccludedRegionWithMultipleOpaqueLayers) +{ + // This is similar to the previous test but now we make a few opaque layers inside of |child| so that the occluded parts of child are not a simple rect. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer1 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer2 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child); + child->addChild(layer1); + child->addChild(layer2); + + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(90); + childTransform.translate(-250, -250); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 10), IntSize(500, 440), true); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(10, 450), IntSize(500, 60), true); + + child->setMasksToBounds(true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(child->renderSurface()); + occlusion.markOccludedBehindLayer(layer2.get()); + occlusion.markOccludedBehindLayer(layer1.get()); + + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child.get(), IntRect(10, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(9, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(11, 430, 60, 70))); + EXPECT_FALSE(occlusion.occluded(child.get(), IntRect(10, 431, 60, 70))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(child.get(), IntRect(10, 430, 60, 70)).isEmpty()); + EXPECT_EQ_RECT(IntRect(9, 430, 1, 70), occlusion.unoccludedContentRect(child.get(), IntRect(9, 430, 60, 70))); + EXPECT_EQ_RECT(IntRect(10, 429, 60, 1), occlusion.unoccludedContentRect(child.get(), IntRect(10, 429, 60, 70))); + EXPECT_EQ_RECT(IntRect(70, 430, 1, 70), occlusion.unoccludedContentRect(child.get(), IntRect(11, 430, 60, 70))); + EXPECT_EQ_RECT(IntRect(10, 500, 60, 1), occlusion.unoccludedContentRect(child.get(), IntRect(10, 431, 60, 70))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(10, 430, 60, 70), occlusion.surfaceUnoccludedContentRect(child.get(), IntRect(10, 430, 60, 70))); + + occlusion.markOccludedBehindLayer(child.get()); + occlusion.finishedTargetRenderSurface(child.get(), child->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 40, 70, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 39, 70, 60))); + + EXPECT_TRUE(occlusion.unoccludedContentRect(parent.get(), IntRect(30, 40, 70, 60)).isEmpty()); + EXPECT_EQ_RECT(IntRect(29, 40, 1, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(29, 40, 70, 60))); + EXPECT_EQ_RECT(IntRect(30, 39, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 39, 70, 60))); + EXPECT_EQ_RECT(IntRect(100, 40, 1, 60), occlusion.unoccludedContentRect(parent.get(), IntRect(31, 40, 70, 60))); + EXPECT_EQ_RECT(IntRect(30, 100, 70, 1), occlusion.unoccludedContentRect(parent.get(), IntRect(30, 41, 70, 60))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(30, 40, 70, 60), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(30, 40, 70, 60))); + + + /* Justification for the above occlusion from |layer1| and |layer2|: + + +---------------------+ + | |30 Visible region of |layer1|: ///// + | | Visible region of |layer2|: \\\\\ + | +---------------------------------+ + | | |10 | + | +---------------+-----------------+ | + | | |\\\\\\\\\\\\|//| 420 | | + | | |\\\\\\\\\\\\|//|60 | | + | | |\\\\\\\\\\\\|//| | | + +--|--|------------|--+ | | + 20|10| 70 | | | + | | | | | + | | | | | + | | | | | + | | | | | + | | | | | + | | | |10| + | +------------|-----------------|--+ + | | 490 | + +---------------+-----------------+ + 60 440 + */ +} + +TEST(CCOcclusionTrackerTest, surfaceOcclusionWithOverlappingSiblingSurfaces) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child1 = LayerChromium::create(); + RefPtr<LayerChromium> child2 = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer1 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer2 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child1); + parent->addChild(child2); + child1->addChild(layer1); + child2->addChild(layer2); + + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(90); + childTransform.translate(-250, -250); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child1.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), false); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), true); + setLayerPropertiesForTesting(child2.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(20, 40), IntSize(500, 500), false); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(500, 500), true); + + child1->setMasksToBounds(true); + child2->setMasksToBounds(true); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(child2->renderSurface()); + occlusion.markOccludedBehindLayer(layer2.get()); + + EXPECT_EQ_RECT(IntRect(20, 40, 80, 60), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(0, 420, 60, 80), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(0, 420, 60, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-1, 420, 60, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(0, 419, 60, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(0, 420, 61, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(0, 420, 60, 81))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(0, 420, 60, 80), occlusion.surfaceUnoccludedContentRect(child2.get(), IntRect(0, 420, 60, 80))); + + occlusion.markOccludedBehindLayer(child2.get()); + occlusion.finishedTargetRenderSurface(child2.get(), child2->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(child1->renderSurface()); + occlusion.markOccludedBehindLayer(layer1.get()); + + EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(0, 430, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child1.get(), IntRect(0, 430, 70, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-1, 430, 70, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(0, 429, 70, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(0, 430, 71, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(0, 430, 70, 71))); + + // Surface is not occluded by things that draw into itself, but the |child1| surface should be occluded by the |child2| surface. + EXPECT_EQ_RECT(IntRect(0, 430, 10, 70), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(0, 430, 70, 70))); + + occlusion.markOccludedBehindLayer(child1.get()); + occlusion.finishedTargetRenderSurface(child1.get(), child1->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(20, 30, 80, 70))); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 30, 70, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 29, 70, 70))); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(20, 40, 80, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(19, 40, 80, 60))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(20, 39, 80, 60))); + + // |child1| and |child2| both draw into parent so they should not occlude it. + EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(20, 30, 80, 70))); + + + /* Justification for the above occlusion: + 100 + +---------------------+ + | | + | 30 | child1 + | 30+ ---------------------------------+ + 100 | 40| | child2 | + |20+----------------------------------+ | + | | | | | | + | | | | | | + | | | | | | + +--|-|----------------+ | | + | | | | 500 + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | +--------------------------------|-+ + | | + +----------------------------------+ + 500 + */ +} + +TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpace) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child1 = LayerChromium::create(); + RefPtr<LayerChromium> child2 = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer1 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer2 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child1); + parent->addChild(child2); + child1->addChild(layer1); + child2->addChild(layer2); + + TransformationMatrix childTransform; + childTransform.translate(250, 250); + childTransform.rotate(90); + childTransform.translate(-250, -250); + + // The owning layers have very different bounds from the surfaces that they own. + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child1.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(10, 10), false); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -10), IntSize(510, 510), true); + setLayerPropertiesForTesting(child2.get(), childTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(20, 40), IntSize(10, 10), false); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -10), IntSize(510, 510), true); + + // Make them both render surfaces + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + child1->setFilters(filters); + child2->setFilters(filters); + + child1->setMasksToBounds(false); + child2->setMasksToBounds(false); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(child2->renderSurface()); + occlusion.markOccludedBehindLayer(layer2.get()); + + EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-11, 420, 70, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 419, 70, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 71, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 81))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.surfaceUnoccludedContentRect(child2.get(), IntRect(-10, 420, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child2.get(), IntRect(30, 250, 1, 1))); + + occlusion.markOccludedBehindLayer(child2.get()); + occlusion.finishedTargetRenderSurface(child2.get(), child2->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(child1->renderSurface()); + occlusion.markOccludedBehindLayer(layer1.get()); + + EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(-10, 430, 80, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child1.get(), IntRect(-10, 430, 80, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-11, 430, 80, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-10, 429, 80, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-10, 430, 81, 70))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(-10, 430, 80, 71))); + + // Surface is not occluded by things that draw into itself, but the |child1| surface should be occluded by the |child2| surface. + EXPECT_EQ_RECT(IntRect(-10, 430, 10, 80), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(-10, 430, 70, 80))); + EXPECT_TRUE(occlusion.surfaceOccluded(child1.get(), IntRect(0, 430, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(-1, 430, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(0, 429, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(1, 430, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(0, 431, 70, 80))); + + occlusion.markOccludedBehindLayer(child1.get()); + occlusion.finishedTargetRenderSurface(child1.get(), child1->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(2u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(20, 20, 80, 80))); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(30, 20, 70, 80))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(29, 20, 70, 80))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(30, 19, 70, 80))); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(20, 30, 80, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(19, 30, 80, 70))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(20, 29, 80, 70))); + + // |child1| and |child2| both draw into parent so they should not occlude it. + EXPECT_EQ_RECT(IntRect(20, 20, 80, 80), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(20, 20, 80, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(50, 50, 1, 1))); + + + /* Justification for the above occlusion: + 100 + +---------------------+ + | 20 | layer1 + | 30+ ---------------------------------+ + 100 | 30| | layer2 | + |20+----------------------------------+ | + | | | | | | + | | | | | | + | | | | | | + +--|-|----------------+ | | + | | | | 510 + | | | | + | | | | + | | | | + | | | | + | | | | + | | | | + | +--------------------------------|-+ + | | + +----------------------------------+ + 510 + */ +} + +TEST(CCOcclusionTrackerTest, surfaceOcclusionInScreenSpaceDifferentTransforms) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromium> child1 = LayerChromium::create(); + RefPtr<LayerChromium> child2 = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> layer1 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> layer2 = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(child1); + parent->addChild(child2); + child1->addChild(layer1); + child2->addChild(layer2); + + TransformationMatrix child1Transform; + child1Transform.translate(250, 250); + child1Transform.rotate(-90); + child1Transform.translate(-250, -250); + + TransformationMatrix child2Transform; + child2Transform.translate(250, 250); + child2Transform.rotate(90); + child2Transform.translate(-250, -250); + + // The owning layers have very different bounds from the surfaces that they own. + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(child1.get(), child1Transform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 20), IntSize(10, 10), false); + setLayerPropertiesForTesting(layer1.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -20), IntSize(510, 520), true); + setLayerPropertiesForTesting(child2.get(), child2Transform, identityMatrix, FloatPoint(0, 0), FloatPoint(20, 40), IntSize(10, 10), false); + setLayerPropertiesForTesting(layer2.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(-10, -10), IntSize(510, 510), true); + + // Make them both render surfaces + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + child1->setFilters(filters); + child2->setFilters(filters); + + child1->setMasksToBounds(false); + child2->setMasksToBounds(false); + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + occlusion.enterTargetRenderSurface(child2->renderSurface()); + occlusion.markOccludedBehindLayer(layer2.get()); + + EXPECT_EQ_RECT(IntRect(20, 30, 80, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-11, 420, 70, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 419, 70, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 71, 80))); + EXPECT_FALSE(occlusion.occluded(child2.get(), IntRect(-10, 420, 70, 81))); + + // Surface is not occluded by things that draw into itself. + EXPECT_EQ_RECT(IntRect(-10, 420, 70, 80), occlusion.surfaceUnoccludedContentRect(child2.get(), IntRect(-10, 420, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child2.get(), IntRect(30, 250, 1, 1))); + + occlusion.markOccludedBehindLayer(child2.get()); + occlusion.finishedTargetRenderSurface(child2.get(), child2->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + occlusion.enterTargetRenderSurface(child1->renderSurface()); + occlusion.markOccludedBehindLayer(layer1.get()); + + EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(420, -20, 80, 90), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(child1.get(), IntRect(420, -20, 80, 90))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(419, -20, 80, 90))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(420, -21, 80, 90))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(420, -19, 80, 90))); + EXPECT_FALSE(occlusion.occluded(child1.get(), IntRect(421, -20, 80, 90))); + + // Surface is not occluded by things that draw into itself, but the |child1| surface should be occluded by the |child2| surface. + EXPECT_EQ_RECT(IntRect(420, -20, 80, 90), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(420, -20, 80, 90))); + EXPECT_EQ_RECT(IntRect(490, -10, 10, 80), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(420, -10, 80, 80))); + EXPECT_EQ_RECT(IntRect(420, -20, 70, 10), occlusion.surfaceUnoccludedContentRect(child1.get(), IntRect(420, -20, 70, 90))); + EXPECT_TRUE(occlusion.surfaceOccluded(child1.get(), IntRect(420, -10, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(419, -10, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(420, -11, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(421, -10, 70, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(child1.get(), IntRect(420, -9, 70, 80))); + + occlusion.markOccludedBehindLayer(child1.get()); + occlusion.finishedTargetRenderSurface(child1.get(), child1->renderSurface()); + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + + EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + EXPECT_TRUE(occlusion.occluded(parent.get(), IntRect(10, 20, 90, 80))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(9, 20, 90, 80))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(10, 19, 90, 80))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(11, 20, 90, 80))); + EXPECT_FALSE(occlusion.occluded(parent.get(), IntRect(10, 21, 90, 80))); + + // |child1| and |child2| both draw into parent so they should not occlude it. + EXPECT_EQ_RECT(IntRect(10, 20, 90, 80), occlusion.surfaceUnoccludedContentRect(parent.get(), IntRect(10, 20, 90, 80))); + EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(10, 20, 1, 1))); + EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(99, 20, 1, 1))); + EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(10, 9, 1, 1))); + EXPECT_FALSE(occlusion.surfaceOccluded(parent.get(), IntRect(99, 99, 1, 1))); + + + /* Justification for the above occlusion: + 100 + +---------------------+ + |20 | layer1 + 10+----------------------------------+ + 100 || 30 | layer2 | + |20+----------------------------------+ + || | | | | + || | | | | + || | | | | + +|-|------------------+ | | + | | | | 510 + | | 510 | | + | | | | + | | | | + | | | | + | | | | + | | 520 | | + +----------------------------------+ | + | | + +----------------------------------+ + 510 + */ +} + +TEST(CCOcclusionTrackerTest, occlusionInteractionWithFilters) +{ + // This tests that the right transforms are being used. + TestCCOcclusionTracker occlusion; + const TransformationMatrix identityMatrix; + RefPtr<LayerChromium> parent = LayerChromium::create(); + RefPtr<LayerChromiumWithForcedDrawsContent> blurLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> opacityLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + RefPtr<LayerChromiumWithForcedDrawsContent> opaqueLayer = adoptRef(new LayerChromiumWithForcedDrawsContent()); + parent->createRenderSurface(); + parent->addChild(blurLayer); + parent->addChild(opacityLayer); + parent->addChild(opaqueLayer); + + TransformationMatrix layerTransform; + layerTransform.translate(250, 250); + layerTransform.rotate(90); + layerTransform.translate(-250, -250); + + setLayerPropertiesForTesting(parent.get(), identityMatrix, identityMatrix, FloatPoint(0, 0), FloatPoint(0, 0), IntSize(100, 100), false); + setLayerPropertiesForTesting(blurLayer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(opaqueLayer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + setLayerPropertiesForTesting(opacityLayer.get(), layerTransform, identityMatrix, FloatPoint(0, 0), FloatPoint(30, 30), IntSize(500, 500), true); + + { + FilterOperations filters; + filters.operations().append(BlurFilterOperation::create(Length(10, WebCore::Percent), FilterOperation::BLUR)); + blurLayer->setFilters(filters); + } + + { + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::GRAYSCALE)); + opaqueLayer->setFilters(filters); + } + + { + FilterOperations filters; + filters.operations().append(BasicComponentTransferFilterOperation::create(0.5, FilterOperation::OPACITY)); + opacityLayer->setFilters(filters); + } + + + Vector<RefPtr<LayerChromium> > renderSurfaceLayerList; + Vector<RefPtr<LayerChromium> > dummyLayerList; + int dummyMaxTextureSize = 512; + + parent->renderSurface()->setContentRect(IntRect(IntPoint::zero(), parent->bounds())); + parent->setClipRect(IntRect(IntPoint::zero(), parent->bounds())); + renderSurfaceLayerList.append(parent); + + CCLayerTreeHostCommon::calculateDrawTransformsAndVisibility(parent.get(), parent.get(), identityMatrix, identityMatrix, renderSurfaceLayerList, dummyLayerList, dummyMaxTextureSize); + + // Opacity layer won't contribute to occlusion. + occlusion.enterTargetRenderSurface(opacityLayer->renderSurface()); + occlusion.markOccludedBehindLayer(opacityLayer.get()); + occlusion.finishedTargetRenderSurface(opacityLayer.get(), opacityLayer->renderSurface()); + + EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); + EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); + + // And has nothing to contribute to its parent surface. + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); + EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); + + // Opaque layer will contribute to occlusion. + occlusion.enterTargetRenderSurface(opaqueLayer->renderSurface()); + occlusion.markOccludedBehindLayer(opaqueLayer.get()); + occlusion.finishedTargetRenderSurface(opaqueLayer.get(), opaqueLayer->renderSurface()); + + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(0, 430, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + // And it gets translated to the parent surface. + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); + + // The blur layer needs to throw away any occlusion from outside its subtree. + occlusion.enterTargetRenderSurface(blurLayer->renderSurface()); + EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); + EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); + + // And it won't contribute to occlusion. + occlusion.markOccludedBehindLayer(blurLayer.get()); + occlusion.finishedTargetRenderSurface(blurLayer.get(), blurLayer->renderSurface()); + EXPECT_TRUE(occlusion.occlusionInScreenSpace().isEmpty()); + EXPECT_TRUE(occlusion.occlusionInTargetSurface().isEmpty()); + + // But the opaque layer's occlusion is preserved on the parent. + occlusion.leaveToTargetRenderSurface(parent->renderSurface()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInScreenSpace().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInScreenSpace().rects().size()); + EXPECT_EQ_RECT(IntRect(30, 30, 70, 70), occlusion.occlusionInTargetSurface().bounds()); + EXPECT_EQ(1u, occlusion.occlusionInTargetSurface().rects().size()); +} + +} // namespace diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp index 299e5c7e5..d49703e14 100644 --- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp +++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp @@ -79,7 +79,7 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpTopLeft) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 9u); } @@ -92,7 +92,7 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpacityNotOne) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 13u); } @@ -105,7 +105,7 @@ TEST(CCQuadCullerTest, verifyCullWhenChildOpaqueFlagFalse) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 13u); } @@ -120,7 +120,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 12u); IntRect quadVisibleRect1 = quadList[1].get()->quadVisibleRect(); @@ -158,7 +158,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize1) quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100)))); EXPECT_EQ(quadList.size(), 2u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 2u); } @@ -181,7 +181,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileNonIntegralSize2) quadList.append(MakeTileQuad(childState.get(), IntRect(IntPoint(), IntSize(100, 100)))); EXPECT_EQ(quadList.size(), 2u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 2u); } @@ -196,7 +196,7 @@ TEST(CCQuadCullerTest, verifyCullChildLinesUpBottomRight) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 9u); } @@ -212,7 +212,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegion) setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 12u); } @@ -228,7 +228,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegion2) setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 12u); } @@ -244,7 +244,7 @@ TEST(CCQuadCullerTest, verifyCullSubRegionCheckOvercull) setQuads(rootState.get(), childState.get(), quadList, childOpaqueRect); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 13u); } @@ -260,7 +260,7 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsDontOcclude) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 13u); } @@ -282,8 +282,61 @@ TEST(CCQuadCullerTest, verifyNonAxisAlignedQuadsSafelyCulled) setQuads(rootState.get(), childState.get(), quadList); EXPECT_EQ(quadList.size(), 13u); - CCQuadCuller::cullOccludedQuads(quadList); + CCQuadCuller::cullOccludedQuads(quadList, false, IntRect()); EXPECT_EQ(quadList.size(), 12u); } +TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverTile) +{ + DECLARE_AND_INITIALIZE_TEST_QUADS + + OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true); + OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true); + + setQuads(rootState.get(), childState.get(), quadList); + EXPECT_EQ(quadList.size(), 13u); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(200, 100, 100, 100)); + EXPECT_EQ(quadList.size(), 1u); +} + +TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverCulledTile) +{ + DECLARE_AND_INITIALIZE_TEST_QUADS + + OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true); + OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true); + + setQuads(rootState.get(), childState.get(), quadList); + EXPECT_EQ(quadList.size(), 13u); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(100, 100, 100, 100)); + EXPECT_EQ(quadList.size(), 1u); +} + +TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverPartialTiles) +{ + DECLARE_AND_INITIALIZE_TEST_QUADS + + OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true); + OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true); + + setQuads(rootState.get(), childState.get(), quadList); + EXPECT_EQ(quadList.size(), 13u); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(50, 50, 200, 200)); + EXPECT_EQ(quadList.size(), 9u); +} + +TEST(CCQuadCullerTest, veriftyCullOutsideScissorOverNoTiles) +{ + DECLARE_AND_INITIALIZE_TEST_QUADS + + OwnPtr<CCSharedQuadState> rootState = CCSharedQuadState::create(TransformationMatrix(), TransformationMatrix(), rootRect, IntRect(), 1.0, true); + OwnPtr<CCSharedQuadState> childState = CCSharedQuadState::create(childTransform, TransformationMatrix(), childRect, IntRect(), 1.0, true); + + setQuads(rootState.get(), childState.get(), quadList); + EXPECT_EQ(quadList.size(), 13u); + CCQuadCuller::cullOccludedQuads(quadList, true, IntRect(500, 500, 100, 100)); + EXPECT_EQ(quadList.size(), 0u); +} + + } // namespace diff --git a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp index 4b3dd27d3..ec0ce0c6a 100644 --- a/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/Canvas2DLayerChromiumTest.cpp @@ -79,8 +79,8 @@ protected: { GraphicsContext3D::Attributes attrs; - RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); - RefPtr<GraphicsContext3D> implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> mainContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow); + RefPtr<GraphicsContext3D> implContext = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext()), GraphicsContext3D::RenderDirectlyToHostWindow); MockCanvasContext& mainMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(mainContext.get())); MockCanvasContext& implMock = *static_cast<MockCanvasContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(implContext.get())); diff --git a/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h b/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h index 1f0897341..937b62d4c 100644 --- a/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h +++ b/Source/WebKit/chromium/tests/CompositorFakeGraphicsContext3D.h @@ -37,10 +37,7 @@ static PassRefPtr<GraphicsContext3D> createCompositorMockGraphicsContext3D(Graph webAttrs.alpha = attrs.alpha; OwnPtr<WebKit::WebGraphicsContext3D> webContext = WebKit::CompositorFakeWebGraphicsContext3D::create(webAttrs); - return GraphicsContext3DPrivate::createGraphicsContextFromWebContext( - webContext.release(), attrs, 0, - GraphicsContext3D::RenderDirectlyToHostWindow, - GraphicsContext3DPrivate::ForUseOnAnotherThread); + return GraphicsContext3DPrivate::createGraphicsContextFromWebContext(webContext.release(), GraphicsContext3D::RenderDirectlyToHostWindow); } } diff --git a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp index 2b76b80ad..71cb8bab1 100644 --- a/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp +++ b/Source/WebKit/chromium/tests/FakeGraphicsContext3DTest.cpp @@ -52,7 +52,7 @@ private: TEST(FakeGraphicsContext3DTest, CanOverrideManually) { GraphicsContext3D::Attributes attrs; - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new FrameCountingContext()), GraphicsContext3D::RenderDirectlyToHostWindow); FrameCountingContext& mockContext = *static_cast<FrameCountingContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); for (int i = 0; i < 10; i++) { @@ -73,7 +73,7 @@ public: TEST(FakeGraphicsContext3DTest, CanUseGMock) { GraphicsContext3D::Attributes attrs; - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new GMockContext()), GraphicsContext3D::RenderDirectlyToHostWindow); GMockContext& mockContext = *static_cast<GMockContext*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); EXPECT_CALL(mockContext, getError()) @@ -104,7 +104,7 @@ private: TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent) { GraphicsContext3D::Attributes attrs; - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnThisThread); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), GraphicsContext3D::RenderDirectlyToHostWindow); EXPECT_TRUE(context); ContextThatCountsMakeCurrents& mockContext = *static_cast<ContextThatCountsMakeCurrents*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); EXPECT_EQ(0, mockContext.makeCurrentCount()); @@ -113,7 +113,7 @@ TEST(FakeGraphicsContext3DTest, ContextForThisThreadShouldNotMakeCurrent) TEST(FakeGraphicsContext3DTest, ContextForAnotherThreadShouldNotMakeCurrent) { GraphicsContext3D::Attributes attrs; - RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), attrs, 0, GraphicsContext3D::RenderDirectlyToHostWindow, GraphicsContext3DPrivate::ForUseOnAnotherThread); + RefPtr<GraphicsContext3D> context = GraphicsContext3DPrivate::createGraphicsContextFromWebContext(adoptPtr(new ContextThatCountsMakeCurrents()), GraphicsContext3D::RenderDirectlyToHostWindow); EXPECT_TRUE(context); ContextThatCountsMakeCurrents& mockContext = *static_cast<ContextThatCountsMakeCurrents*>(GraphicsContext3DPrivate::extractWebGraphicsContext3D(context.get())); EXPECT_EQ(0, mockContext.makeCurrentCount()); diff --git a/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h b/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h index cf0651b77..ae27da730 100644 --- a/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h +++ b/Source/WebKit/chromium/tests/FakeWebGraphicsContext3D.h @@ -65,6 +65,8 @@ public: virtual void setVisibilityCHROMIUM(bool visible) { } + virtual void setMemoryAllocationChangedCallbackCHROMIUM(WebGraphicsMemoryAllocationChangedCallbackCHROMIUM* callback) { } + virtual WebString getRequestableExtensionsCHROMIUM() { return WebString(); } virtual void requestExtensionCHROMIUM(const char*) { } diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp index 43083a1d7..2e9ca9661 100644 --- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp @@ -515,6 +515,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setReplicaLayer(dummyLayer.get())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setSublayerTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollable(true)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setHaveWheelEventHandlers(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setScrollPosition(IntPoint(10, 10))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setTransform(TransformationMatrix(0, 0, 0, 0, 0, 0))); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setDoubleSided(false)); @@ -539,10 +540,21 @@ public: return true; } + virtual void setNeedsDisplayRect(const FloatRect& dirtyRect) + { + m_lastNeedsDisplayRect = dirtyRect; + LayerChromium::setNeedsDisplayRect(dirtyRect); + } + void resetNeedsDisplay() { m_needsDisplay = false; } + + const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; } + +private: + FloatRect m_lastNeedsDisplayRect; }; TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay) @@ -558,6 +570,7 @@ TEST_F(LayerChromiumTest, checkContentsScaleChangeTriggersNeedsDisplay) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(1, testLayer->setContentsScale(testLayer->contentsScale() + 1.f)); EXPECT_TRUE(testLayer->needsDisplay()); + EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 320, 240), testLayer->lastNeedsDisplayRect()); } class FakeCCLayerTreeHost : public CCLayerTreeHost { diff --git a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp index 924b42d28..d097c499a 100644 --- a/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp +++ b/Source/WebKit/chromium/tests/PlatformContextSkiaTest.cpp @@ -163,6 +163,30 @@ TEST(PlatformContextSkiaTest, trackOpaqueClipTest) context.clearRect(FloatRect(10, 10, 90, 90)); EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); + // The transform and the clip need to interact correctly (transform first) + context.save(); + context.translate(10, 10); + context.clip(FloatRect(20, 20, 10, 10)); + context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver); + EXPECT_EQ_RECT(IntRect(30, 30, 10, 10), platformContext.opaqueRegion().asRect()); + EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect()); + context.restore(); + + context.clearRect(FloatRect(10, 10, 90, 90)); + EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); + + // The transform and the clip need to interact correctly (clip first) + context.save(); + context.clip(FloatRect(20, 20, 10, 10)); + context.translate(10, 10); + context.fillRect(FloatRect(10, 10, 90, 90), opaque, ColorSpaceDeviceRGB, CompositeSourceOver); + EXPECT_EQ_RECT(IntRect(20, 20, 10, 10), platformContext.opaqueRegion().asRect()); + EXPECT_PIXELS_MATCH(bitmap, platformContext.opaqueRegion().asRect()); + context.restore(); + + context.clearRect(FloatRect(10, 10, 90, 90)); + EXPECT_EQ_RECT(IntRect(), platformContext.opaqueRegion().asRect()); + Path path; path.moveTo(FloatPoint(0, 0)); path.addLineTo(FloatPoint(100, 0)); diff --git a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp index fcd3878a6..e03559046 100644 --- a/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/TiledLayerChromiumTest.cpp @@ -162,6 +162,14 @@ public: return TiledLayerChromium::skipsDraw(); } + virtual void setNeedsDisplayRect(const FloatRect& rect) + { + m_lastNeedsDisplayRect = rect; + TiledLayerChromium::setNeedsDisplayRect(rect); + } + + const FloatRect& lastNeedsDisplayRect() const { return m_lastNeedsDisplayRect; } + FakeLayerTextureUpdater* fakeLayerTextureUpdater() { return m_fakeTextureUpdater.get(); } virtual TextureManager* textureManager() const { return m_textureManager; } @@ -181,6 +189,7 @@ private: RefPtr<FakeLayerTextureUpdater> m_fakeTextureUpdater; TextureManager* m_textureManager; + FloatRect m_lastNeedsDisplayRect; }; class FakeTiledLayerWithScaledBounds : public FakeTiledLayerChromium { @@ -434,6 +443,57 @@ TEST(TiledLayerChromiumTest, verifyUpdateRectWhenContentBoundsAreScaled) EXPECT_FLOAT_RECT_EQ(FloatRect(45, 80, 15, 8), layer->updateRect()); } +TEST(TiledLayerChromiumTest, verifyInvalidationWhenContentsScaleChanges) +{ + OwnPtr<TextureManager> textureManager = TextureManager::create(4*1024*1024, 2*1024*1024, 1024); + RefPtr<FakeTiledLayerChromium> layer = adoptRef(new FakeTiledLayerChromium(textureManager.get())); + DebugScopedSetImplThread implThread; + RefPtr<FakeCCTiledLayerImpl> layerImpl = adoptRef(new FakeCCTiledLayerImpl(0)); + + FakeTextureAllocator textureAllocator; + CCTextureUpdater updater(&textureAllocator); + + // Create a layer with one tile. + layer->setBounds(IntSize(100, 100)); + + // Invalidate the entire layer. + layer->setNeedsDisplay(); + EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect()); + + // Push the tiles to the impl side and check that there is exactly one. + layer->prepareToUpdate(IntRect(0, 0, 100, 100)); + layer->updateCompositorResources(0, updater); + layer->pushPropertiesTo(layerImpl.get()); + EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); + EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); + EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); + EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); + + // Change the contents scale and verify that the content rectangle requiring painting + // is not scaled. + layer->setContentsScale(2); + EXPECT_FLOAT_RECT_EQ(FloatRect(0, 0, 100, 100), layer->lastNeedsDisplayRect()); + + // The impl side should get 2x2 tiles now. + layer->prepareToUpdate(IntRect(0, 0, 200, 200)); + layer->updateCompositorResources(0, updater); + layer->pushPropertiesTo(layerImpl.get()); + EXPECT_TRUE(layerImpl->hasTileAt(0, 0)); + EXPECT_TRUE(layerImpl->hasTileAt(0, 1)); + EXPECT_TRUE(layerImpl->hasTileAt(1, 0)); + EXPECT_TRUE(layerImpl->hasTileAt(1, 1)); + + // Invalidate the entire layer again, but do not paint. All tiles should be gone now from the + // impl side. + layer->setNeedsDisplay(); + layer->updateCompositorResources(0, updater); + layer->pushPropertiesTo(layerImpl.get()); + EXPECT_FALSE(layerImpl->hasTileAt(0, 0)); + EXPECT_FALSE(layerImpl->hasTileAt(0, 1)); + EXPECT_FALSE(layerImpl->hasTileAt(1, 0)); + EXPECT_FALSE(layerImpl->hasTileAt(1, 1)); +} + TEST(TiledLayerChromiumTest, skipsDrawGetsReset) { // Initialize without threading support. @@ -524,7 +584,7 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) occluded = Region(); layer->addSelfToOccludedScreenSpace(occluded); EXPECT_EQ_RECT(IntRect(), occluded.bounds()); - EXPECT_EQ(1u, occluded.rects().size()); + EXPECT_EQ(0u, occluded.rects().size()); // If the layer paints opaque content, then the occluded region should match the visible opaque content. IntRect opaquePaintRect = IntRect(10, 10, 90, 190); @@ -546,6 +606,28 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); EXPECT_EQ(1u, occluded.rects().size()); + // If we repaint a non-opaque part of the tile, then it shouldn't lose its opaque-ness. And other tiles should + // not be affected. + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->invalidateRect(IntRect(0, 0, 1, 1)); + layer->prepareToUpdate(contentBounds); + + occluded = Region(); + layer->addSelfToOccludedScreenSpace(occluded); + EXPECT_EQ_RECT(intersection(opaquePaintRect, visibleBounds), occluded.bounds()); + EXPECT_EQ(1u, occluded.rects().size()); + + // If we repaint an opaque part of the tile, then it should lose its opaque-ness. But other tiles should still + // not be affected. + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(IntRect()); + layer->invalidateRect(IntRect(10, 10, 1, 1)); + layer->prepareToUpdate(contentBounds); + + occluded = Region(); + layer->addSelfToOccludedScreenSpace(occluded); + EXPECT_EQ_RECT(intersection(IntRect(10, 100, 90, 100), visibleBounds), occluded.bounds()); + EXPECT_EQ(1u, occluded.rects().size()); + // If the layer is transformed then the resulting occluded area needs to be transformed to its target space. TransformationMatrix transform; transform.translate(contentBounds.width() / 2.0, contentBounds.height() / 2.0); @@ -556,6 +638,8 @@ TEST(TiledLayerChromiumTest, layerAddsSelfToOccludedRegion) screenSpaceTransform *= transform; screenSpaceTransform.translate(-contentBounds.width() / 2.0, -contentBounds.height() / 2.0); layer->setScreenSpaceTransform(screenSpaceTransform); + layer->fakeLayerTextureUpdater()->setOpaquePaintRect(opaquePaintRect); + layer->invalidateRect(opaquePaintRect); layer->prepareToUpdate(contentBounds); occluded = Region(); diff --git a/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp b/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp index 1557a7d93..4724b4a43 100644 --- a/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp +++ b/Source/WebKit/chromium/tests/TreeSynchronizerTest.cpp @@ -26,13 +26,16 @@ #include "TreeSynchronizer.h" +#include "CCAnimationTestCommon.h" #include "LayerChromium.h" +#include "cc/CCLayerAnimationController.h" #include "cc/CCLayerImpl.h" #include "cc/CCProxy.h" #include "cc/CCSingleThreadProxy.h" #include <gtest/gtest.h> using namespace WebCore; +using namespace WebKitTests; namespace { @@ -91,6 +94,30 @@ private: Vector<int>* m_ccLayerDestructionList; }; +class FakeLayerAnimationController : public CCLayerAnimationController { +public: + static PassOwnPtr<FakeLayerAnimationController> create() + { + return adoptPtr(new FakeLayerAnimationController); + } + + bool synchronizedAnimations() const { return m_synchronizedAnimations; } + +private: + FakeLayerAnimationController() + : m_synchronizedAnimations(false) + { + } + + virtual void synchronizeAnimations(CCLayerAnimationControllerImpl* controllerImpl) + { + CCLayerAnimationController::synchronizeAnimations(controllerImpl); + m_synchronizedAnimations = true; + } + + bool m_synchronizedAnimations; +}; + void expectTreesAreIdentical(LayerChromium* layer, CCLayerImpl* ccLayer) { ASSERT_TRUE(layer); @@ -307,5 +334,19 @@ TEST(TreeSynchronizerTest, syncMaskReplicaAndReplicaMaskLayers) expectTreesAreIdentical(layerTreeRoot.get(), ccLayerTreeRoot.get()); } +TEST(TreeSynchronizerTest, synchronizeAnimations) +{ + DebugScopedSetImplThread impl; + RefPtr<LayerChromium> layerTreeRoot = LayerChromium::create(); + + layerTreeRoot->setLayerAnimationController(FakeLayerAnimationController::create()); + + EXPECT_FALSE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); + + RefPtr<CCLayerImpl> ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), 0); + ccLayerTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), ccLayerTreeRoot.get()); + + EXPECT_TRUE(static_cast<FakeLayerAnimationController*>(layerTreeRoot->layerAnimationController())->synchronizedAnimations()); +} } // namespace diff --git a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp index ad5810524..459255e02 100644 --- a/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp +++ b/Source/WebKit/chromium/tests/WebCompositorInputHandlerImplTest.cpp @@ -67,14 +67,13 @@ public: private: virtual void setNeedsRedraw() OVERRIDE { } - virtual ScrollStatus scrollBegin(const WebCore::IntPoint&) OVERRIDE + virtual ScrollStatus scrollBegin(const WebCore::IntPoint&, WebCore::CCInputHandlerClient::ScrollInputType) OVERRIDE { return m_scrollStatus; } virtual void scrollBy(const WebCore::IntSize&) OVERRIDE { } virtual void scrollEnd() OVERRIDE { } - virtual bool haveWheelEventHandlers() OVERRIDE { return false; } virtual void pinchGestureBegin() OVERRIDE { m_pinchStarted = true; diff --git a/Source/WebKit/chromium/tests/WebFrameTest.cpp b/Source/WebKit/chromium/tests/WebFrameTest.cpp index b59001860..f61e98648 100644 --- a/Source/WebKit/chromium/tests/WebFrameTest.cpp +++ b/Source/WebKit/chromium/tests/WebFrameTest.cpp @@ -151,6 +151,78 @@ TEST_F(WebFrameTest, ChromePageNoJavascript) EXPECT_EQ(std::string::npos, content.find("Clobbered")); } +#if ENABLE(GESTURE_EVENTS) +TEST_F(WebFrameTest, DivAutoZoomParamsTest) +{ + registerMockedHttpURLLoad("get_scale_for_auto_zoom_into_div_test.html"); + + WebViewImpl* webViewImpl = static_cast<WebViewImpl*>(FrameTestHelpers::createWebViewAndLoad(m_baseURL + "get_scale_for_auto_zoom_into_div_test.html", true)); + int pageWidth = 640; + int pageHeight = 480; + int divPosX = 200; + int divPosY = 200; + int divWidth = 200; + int divHeight = 150; + WebRect doubleTapPoint(250, 250, 0, 0); + webViewImpl->resize(WebSize(pageWidth, pageHeight)); + float scale; + WebPoint scroll; + + // Test for Doubletap scaling + + // Tests for zooming in and out without clamping. + // Set device scale and scale limits so we dont get clamped. + webViewImpl->setDeviceScaleFactor(4); + webViewImpl->setPageScaleFactorLimits(0, 4 / webViewImpl->deviceScaleFactor()); + + // Test zooming into div. + webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); + float scaledDivWidth = divWidth * scale; + float scaledDivHeight = divHeight * scale; + int hScroll = ((divPosX * scale) - ((pageWidth - scaledDivWidth) / 2)) / scale; + int vScroll = ((divPosY * scale) - ((pageHeight - scaledDivHeight) / 2)) / scale; + EXPECT_NEAR(pageWidth / divWidth, scale, 0.1); + EXPECT_EQ(hScroll, scroll.x); + EXPECT_EQ(vScroll, scroll.y); + + // Test zoom out to overview scale. + webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); + EXPECT_FLOAT_EQ(1, scale); + EXPECT_EQ(WebPoint(0, 0), scroll); + + // Tests for clamped scaling. + // Test clamp to device scale: + webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->setDeviceScaleFactor(2.5); + webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); + EXPECT_FLOAT_EQ(2.5, scale); + + // Test clamp to minimum scale: + webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->setPageScaleFactorLimits(1.5 / webViewImpl->deviceScaleFactor(), 4 / webViewImpl->deviceScaleFactor()); + webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); + EXPECT_FLOAT_EQ(1.5, scale); + EXPECT_EQ(WebPoint(0, 0), scroll); + + // Test clamp to maximum scale: + webViewImpl->applyScrollAndScale(WebCore::IntSize(scroll.x, scroll.y), scale / webViewImpl->pageScaleFactor()); + webViewImpl->setDeviceScaleFactor(4); + webViewImpl->setPageScaleFactorLimits(0, 3 / webViewImpl->deviceScaleFactor()); + webViewImpl->computeScaleAndScrollForHitRect(doubleTapPoint, WebViewImpl::DoubleTap, scale, scroll); + EXPECT_FLOAT_EQ(3, scale); + + + // Test for Non-doubletap scaling + webViewImpl->setPageScaleFactor(1, WebPoint(0, 0)); + webViewImpl->setDeviceScaleFactor(4); + webViewImpl->setPageScaleFactorLimits(0, 4 / webViewImpl->deviceScaleFactor()); + // Test zooming into div. + webViewImpl->computeScaleAndScrollForHitRect(WebRect(250, 250, 10, 10), WebViewImpl::FindInPage, scale, scroll); + EXPECT_NEAR(pageWidth / divWidth, scale, 0.1); +} +#endif + class TestReloadDoesntRedirectWebFrameClient : public WebFrameClient { public: virtual WebNavigationPolicy decidePolicyForNavigation( diff --git a/Source/WebKit/chromium/tests/WebSocketDeflaterTest.cpp b/Source/WebKit/chromium/tests/WebSocketDeflaterTest.cpp new file mode 100644 index 000000000..423a5969f --- /dev/null +++ b/Source/WebKit/chromium/tests/WebSocketDeflaterTest.cpp @@ -0,0 +1,157 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "WebSocketDeflater.h" + +#include <gtest/gtest.h> +#include <wtf/Vector.h> + +using namespace WebCore; + +namespace { + +TEST(WebSocketDeflaterTest, TestCompressHello) +{ + // Test the first example on section 4.3 of the specification. + OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(15); + ASSERT_TRUE(deflater->initialize()); + OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(); + ASSERT_TRUE(inflater->initialize()); + const char* inputData = "Hello"; + const size_t inputLength = strlen(inputData); + + ASSERT_TRUE(deflater->addBytes(inputData, inputLength)); + ASSERT_TRUE(deflater->finish()); + const char expectedFirst[] = {0xf2, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00}; + EXPECT_EQ(sizeof(expectedFirst), deflater->size()); + EXPECT_EQ(0, memcmp(expectedFirst, deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->finish()); + EXPECT_EQ(inputLength, inflater->size()); + EXPECT_EQ(0, memcmp(inputData, inflater->data(), inflater->size())); + + deflater->reset(); + inflater->reset(); + + ASSERT_TRUE(deflater->addBytes(inputData, inputLength)); + ASSERT_TRUE(deflater->finish()); + const char expectedSecond[] = {0xf2, 0x00, 0x11, 0x00, 0x00}; + EXPECT_EQ(sizeof(expectedSecond), deflater->size()); + EXPECT_EQ(0, memcmp(expectedSecond, deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->finish()); + EXPECT_EQ(inputLength, inflater->size()); + EXPECT_EQ(0, memcmp(inputData, inflater->data(), inflater->size())); +} + +TEST(WebSocketDeflaterTest, TestMultipleAddBytesCalls) +{ + OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(15); + ASSERT_TRUE(deflater->initialize()); + OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(); + ASSERT_TRUE(inflater->initialize()); + Vector<char> inputData(32); + inputData.fill('a'); + + for (size_t i = 0; i < inputData.size(); ++i) + ASSERT_TRUE(deflater->addBytes(inputData.data() + i, 1)); + ASSERT_TRUE(deflater->finish()); + for (size_t i = 0; i < deflater->size(); ++i) + ASSERT_TRUE(inflater->addBytes(deflater->data() + i, 1)); + ASSERT_TRUE(inflater->finish()); + EXPECT_EQ(inputData.size(), inflater->size()); + EXPECT_EQ(0, memcmp(inputData.data(), inflater->data(), inflater->size())); +} + +TEST(WebSocketDeflaterTest, TestNoContextTakeOver) +{ + OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(15, WebSocketDeflater::DoNotTakeOverContext); + ASSERT_TRUE(deflater->initialize()); + OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(); + ASSERT_TRUE(inflater->initialize()); + const char expected[] = {0xf2, 0x48, 0xcd, 0xc9, 0xc9, 0x07, 0x00}; + const char* inputData = "Hello"; + const size_t inputLength = strlen(inputData); + + // If we don't take over context, the second result should be the identical + // with the first one. + for (size_t i = 0; i < 2; ++i) { + ASSERT_TRUE(deflater->addBytes(inputData, inputLength)); + ASSERT_TRUE(deflater->finish()); + EXPECT_EQ(sizeof(expected), deflater->size()); + EXPECT_EQ(0, memcmp(expected, deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->finish()); + EXPECT_EQ(inputLength, inflater->size()); + EXPECT_EQ(0, memcmp(inputData, inflater->data(), inflater->size())); + deflater->reset(); + inflater->reset(); + } +} + +TEST(WebSocketDeflaterTest, TestWindowBits) +{ + Vector<char> inputData(1024 + 64 * 2); + inputData.fill('a'); + // Modify the head and tail of the inputData so that back-reference + // can be used if the window size is sufficiently-large. + for (size_t j = 0; j < 64; ++j) { + inputData[j] = 'b'; + inputData[inputData.size() - j - 1] = 'b'; + } + + OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(8); + ASSERT_TRUE(deflater->initialize()); + ASSERT_TRUE(deflater->addBytes(inputData.data(), inputData.size())); + ASSERT_TRUE(deflater->finish()); + + OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(8); + ASSERT_TRUE(inflater->initialize()); + ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->finish()); + EXPECT_EQ(inputData.size(), inflater->size()); + EXPECT_EQ(0, memcmp(inputData.data(), inflater->data(), inflater->size())); +} + +TEST(WebSocketDeflaterTest, TestLargeData) +{ + OwnPtr<WebSocketDeflater> deflater = WebSocketDeflater::create(15); + ASSERT_TRUE(deflater->initialize()); + OwnPtr<WebSocketInflater> inflater = WebSocketInflater::create(); + ASSERT_TRUE(inflater->initialize()); + Vector<char> inputData(16 * 1024 * 1024); + inputData.fill('a'); + + ASSERT_TRUE(deflater->addBytes(inputData.data(), inputData.size())); + ASSERT_TRUE(deflater->finish()); + ASSERT_TRUE(inflater->addBytes(deflater->data(), deflater->size())); + ASSERT_TRUE(inflater->finish()); + EXPECT_EQ(inputData.size(), inflater->size()); + EXPECT_EQ(0, memcmp(inputData.data(), inflater->data(), inflater->size())); +} + +} diff --git a/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp b/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp new file mode 100644 index 000000000..358983b83 --- /dev/null +++ b/Source/WebKit/chromium/tests/WebSocketExtensionDispatcherTest.cpp @@ -0,0 +1,179 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "WebSocketExtensionDispatcher.h" + +#include "WebSocketExtensionProcessor.h" + +#include <gtest/gtest.h> +#include <wtf/text/StringHash.h> + +using namespace WebCore; + +namespace { + +class WebSocketExtensionDispatcherTest; + +class MockWebSocketExtensionProcessor : public WebSocketExtensionProcessor { +public: + MockWebSocketExtensionProcessor(const String& name, WebSocketExtensionDispatcherTest* test) + : WebSocketExtensionProcessor(name) + , m_test(test) + { + } + virtual String handshakeString() OVERRIDE { return extensionToken(); } + virtual bool processResponse(const HashMap<String, String>&) OVERRIDE; + +private: + WebSocketExtensionDispatcherTest* m_test; +}; + +class WebSocketExtensionDispatcherTest : public testing::Test { +public: + WebSocketExtensionDispatcherTest() { } + + void SetUp() { } + + void TearDown() { } + + void addMockProcessor(const String& extensionToken) + { + m_extensions.addProcessor(adoptPtr(new MockWebSocketExtensionProcessor(extensionToken, this))); + + } + + void appendResult(const String& extensionToken, const HashMap<String, String>& parameters) + { + m_parsedExtensionTokens.append(extensionToken); + m_parsedParameters.append(parameters); + } + +protected: + WebSocketExtensionDispatcher m_extensions; + Vector<String> m_parsedExtensionTokens; + Vector<HashMap<String, String> > m_parsedParameters; +}; + +bool MockWebSocketExtensionProcessor::processResponse(const HashMap<String, String>& parameters) +{ + m_test->appendResult(extensionToken(), parameters); + return true; +} + +TEST_F(WebSocketExtensionDispatcherTest, TestSingle) +{ + addMockProcessor("deflate-frame"); + EXPECT_TRUE(m_extensions.processHeaderValue("deflate-frame")); + EXPECT_EQ(1UL, m_parsedExtensionTokens.size()); + EXPECT_EQ("deflate-frame", m_parsedExtensionTokens[0]); + EXPECT_EQ("deflate-frame", m_extensions.acceptedExtensions()); + EXPECT_EQ(0, m_parsedParameters[0].size()); +} + +TEST_F(WebSocketExtensionDispatcherTest, TestParameters) +{ + addMockProcessor("mux"); + EXPECT_TRUE(m_extensions.processHeaderValue("mux; max-channels=4; flow-control ")); + EXPECT_EQ(1UL, m_parsedExtensionTokens.size()); + EXPECT_EQ("mux", m_parsedExtensionTokens[0]); + EXPECT_EQ(2, m_parsedParameters[0].size()); + HashMap<String, String>::iterator parameter = m_parsedParameters[0].find("max-channels"); + EXPECT_TRUE(parameter != m_parsedParameters[0].end()); + EXPECT_EQ("4", parameter->second); + parameter = m_parsedParameters[0].find("flow-control"); + EXPECT_TRUE(parameter != m_parsedParameters[0].end()); + EXPECT_TRUE(parameter->second.isNull()); +} + +TEST_F(WebSocketExtensionDispatcherTest, TestMultiple) +{ + struct { + String token; + HashMap<String, String> parameters; + } expected[2]; + expected[0].token = "mux"; + expected[0].parameters.add("max-channels", "4"); + expected[0].parameters.add("flow-control", String()); + expected[1].token = "deflate-frame"; + + addMockProcessor("mux"); + addMockProcessor("deflate-frame"); + EXPECT_TRUE(m_extensions.processHeaderValue("mux ; max-channels =4;flow-control, deflate-frame ")); + EXPECT_TRUE(m_extensions.acceptedExtensions().find("mux") != notFound); + EXPECT_TRUE(m_extensions.acceptedExtensions().find("deflate-frame") != notFound); + for (size_t i = 0; i < sizeof(expected) / sizeof(expected[0]); ++i) { + EXPECT_EQ(expected[i].token, m_parsedExtensionTokens[i]); + const HashMap<String, String>& expectedParameters = expected[i].parameters; + const HashMap<String, String>& parsedParameters = m_parsedParameters[i]; + EXPECT_EQ(expected[i].parameters.size(), m_parsedParameters[i].size()); + for (HashMap<String, String>::const_iterator iterator = expectedParameters.begin(); iterator != expectedParameters.end(); ++iterator) { + HashMap<String, String>::const_iterator parsed = parsedParameters.find(iterator->first); + EXPECT_TRUE(parsed != parsedParameters.end()); + if (iterator->second.isNull()) + EXPECT_TRUE(parsed->second.isNull()); + else + EXPECT_EQ(iterator->second, parsed->second); + } + } +} + +TEST_F(WebSocketExtensionDispatcherTest, TestQuotedString) +{ + addMockProcessor("x-foo"); + EXPECT_TRUE(m_extensions.processHeaderValue("x-foo; param1=\"quoted string\"; param2=\"\\\"quoted\\\" string\\\\\"")); + EXPECT_EQ(2, m_parsedParameters[0].size()); + EXPECT_EQ("quoted string", m_parsedParameters[0].get("param1")); + EXPECT_EQ("\"quoted\" string\\", m_parsedParameters[0].get("param2")); +} + +TEST_F(WebSocketExtensionDispatcherTest, TestInvalid) +{ + const char* inputs[] = { + "\"x-foo\"", + "x-baz", + "x-foo\\", + "x-(foo)", + "x-foo; ", + "x-foo; bar=", + "x-foo; bar=x y", + "x-foo; bar=\"mismatch quote", + "x-foo; bar=\"\\\"", + "x-foo; \"bar\"=baz", + "x-foo x-bar", + "x-foo, x-baz" + "x-foo, ", + }; + for (size_t i = 0; i < sizeof(inputs) / sizeof(inputs[0]); ++i) { + m_extensions.reset(); + addMockProcessor("x-foo"); + addMockProcessor("x-bar"); + EXPECT_FALSE(m_extensions.processHeaderValue(inputs[i])); + EXPECT_TRUE(m_extensions.acceptedExtensions().isNull()); + } +} + +} diff --git a/Source/WebKit/chromium/tests/WebURLResponseTest.cpp b/Source/WebKit/chromium/tests/WebURLResponseTest.cpp new file mode 100644 index 000000000..112ed8601 --- /dev/null +++ b/Source/WebKit/chromium/tests/WebURLResponseTest.cpp @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2012 Google Inc. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include "config.h" + +#include "platform/WebURLResponse.h" + +#include <gtest/gtest.h> + +using namespace WebKit; + +namespace { + +class TestExtraData : public WebURLResponse::ExtraData { +public: + explicit TestExtraData(bool* alive) + : m_alive(alive) + { + *alive = true; + } + + virtual ~TestExtraData() { *m_alive = false; } + +private: + bool* m_alive; +}; + +TEST(WebURLResponseTest, ExtraData) +{ + bool alive = false; + { + WebURLResponse urlResponse; + TestExtraData* extraData = new TestExtraData(&alive); + EXPECT_TRUE(alive); + + urlResponse.initialize(); + urlResponse.setExtraData(extraData); + EXPECT_EQ(extraData, urlResponse.extraData()); + { + WebURLResponse otherUrlResponse = urlResponse; + EXPECT_TRUE(alive); + EXPECT_EQ(extraData, otherUrlResponse.extraData()); + EXPECT_EQ(extraData, urlResponse.extraData()); + } + EXPECT_TRUE(alive); + EXPECT_EQ(extraData, urlResponse.extraData()); + } + EXPECT_FALSE(alive); +} + +} // namespace diff --git a/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html b/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html new file mode 100644 index 000000000..1817dc47d --- /dev/null +++ b/Source/WebKit/chromium/tests/data/get_scale_for_auto_zoom_into_div_test.html @@ -0,0 +1,13 @@ +<html> + <body> + <div style="background-color: green; position: absolute; left: 0px; top: 0px; width: 640px; height: 480px"> + <p>Top Div</p> + <div style="background-color: white; position: absolute; left: 200px; top: 200px; width: 200px; height: 150px"> + <p id="innerDiv">Div to zoom to</p> + <div style="background-color: red; position: fixed; left: 220px; top: 350px; width: 160px; height: 40px"> + <p id="innerInnerDiv">Div NOT to zoom to</p> + </div> + </div> + </div> + </body> +</html> |