diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-18 13:59:13 +0200 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-07-18 13:59:28 +0200 |
commit | 4d6084feccab99c0a7b3ecef26bb49c41dd50201 (patch) | |
tree | fd1195897f551eee6d5a15d07ff5733b15aa2a5c /Source/WebKit/chromium/tests | |
parent | ae901828d4689ab9e89113f6b6ea8042b37a9fda (diff) | |
download | qtwebkit-4d6084feccab99c0a7b3ecef26bb49c41dd50201.tar.gz |
Imported WebKit commit ff52235a78888e5cb8e286a828a8698042200e67 (http://svn.webkit.org/repository/webkit/trunk@122948)
New snapshot that should fix the rendering issues recently introduced
Diffstat (limited to 'Source/WebKit/chromium/tests')
15 files changed, 324 insertions, 142 deletions
diff --git a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp index f498069f0..9433d89da 100644 --- a/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp +++ b/Source/WebKit/chromium/tests/CCDamageTrackerTest.cpp @@ -1107,7 +1107,7 @@ TEST_F(CCDamageTrackerTest, verifyDamageForEmptyLayerList) OwnPtr<CCLayerImpl> root = CCLayerImpl::create(1); root->createRenderSurface(); - ASSERT_TRUE(root->renderSurface() == root->targetRenderSurface()); + ASSERT_TRUE(root == root->renderTarget()); CCRenderSurface* targetSurface = root->renderSurface(); targetSurface->clearLayerList(); targetSurface->damageTracker()->updateDamageTrackingState(targetSurface->layerList(), targetSurface->owningLayerId(), false, IntRect(), 0, WebFilterOperations()); diff --git a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp index 892da4f2f..22cf897cb 100644 --- a/Source/WebKit/chromium/tests/CCLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerImplTest.cpp @@ -170,7 +170,7 @@ TEST(CCLayerImplTest, verifyLayerChangesAreTrackedProperly) EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setClipRect(arbitraryIntRect)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setUsesLayerClipping(true)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawOpacity(arbitraryNumber)); - EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setTargetRenderSurface(0)); + EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setRenderTarget(0)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawTransform(arbitraryTransform)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setScreenSpaceTransform(arbitraryTransform)); EXECUTE_AND_VERIFY_SUBTREE_DID_NOT_CHANGE(root->setDrawableContentRect(arbitraryIntRect)); diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp index 54409514c..0fa742548 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostCommonTest.cpp @@ -357,7 +357,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) // Render surface should have been created now. ASSERT_TRUE(child->renderSurface()); - ASSERT_EQ(child->renderSurface(), child->targetRenderSurface()); + ASSERT_EQ(child, child->renderTarget()); // The child layer's draw transform should refer to its new render surface; they only differ by a translation to center. // The screen-space transform, however, should still refer to the root. @@ -365,11 +365,11 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForSingleRenderSurface) EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->screenSpaceTransform()); // Without clipping, the origin transform and draw transform (in this particular case) should be the same. - EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->targetRenderSurface()->originTransform()); - EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->targetRenderSurface()->drawTransform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->originTransform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->drawTransform()); // The screen space is the same as the target since the child surface draws into the root. - EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->targetRenderSurface()->screenSpaceTransform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(parentCompositeTransform, child->renderTarget()->renderSurface()->screenSpaceTransform()); } TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) @@ -464,11 +464,11 @@ TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) IntRect rootDamage(rootRect); CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // child surface doesn't have a clip rect, therefore it will be computed as intersection // between root surface's contentrect and child surface's drawable content rect. - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(childRect.x(), childRect.y(), rootRect.width() - childRect.x(), rootRect.height() - childRect.y())); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(childRect.x(), childRect.y(), rootRect.width() - childRect.x(), rootRect.height() - childRect.y())); EXPECT_EQ(root->scissorRect(), IntRect(rootRect)); @@ -486,8 +486,8 @@ TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Empty damage == empty scissor - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); EXPECT_EQ(root->scissorRect(), IntRect(0, 0, 0, 0)); EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, 0, 0)); @@ -498,10 +498,10 @@ TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Entire damage rect is within the root surface - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), rootDamage); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage); // Entire damage rect is within the layer EXPECT_EQ(root->scissorRect(), rootDamage); @@ -517,10 +517,10 @@ TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Entire damage rect is within the root surface - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), rootDamage); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage); // Entire damage rect is within the layer EXPECT_EQ(root->scissorRect(), rootDamage); @@ -536,11 +536,11 @@ TEST(CCLayerTreeHostCommonTest, scissorRectNoClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Root surface does not have a clipRect, so its contentRect will be used to intersect with damage. // Result is that root damage rect is clipped at root layer boundary - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y())); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y())); // Root does not use layer clipping, so its content rect will be used to intersect with damage // Result is that root damage rect is clipped at root layer boundary @@ -648,8 +648,8 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip) IntRect rootDamage(rootRect); CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(rootRect)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootRect)); EXPECT_EQ(root->scissorRect(), IntRect(rootRect)); @@ -667,8 +667,8 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Empty damage == empty scissor - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); EXPECT_EQ(root->scissorRect(), IntRect(0, 0, 0, 0)); EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, 0, 0)); @@ -679,10 +679,10 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Entire damage rect is within the root surface - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), rootDamage); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage); // Entire damage rect is within the layer EXPECT_EQ(root->scissorRect(), rootDamage); @@ -698,10 +698,10 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Entire damage rect is within the root surface - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), rootDamage); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage); // Entire damage rect is within the layer EXPECT_EQ(root->scissorRect(), rootDamage); @@ -717,11 +717,11 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClip) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Root surface does not have a clipRect, so its contentRect will be used to intersect with damage. // Result is that root damage rect is clipped at root layer boundary - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y())); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y())); // Root does not use layer clipping, so its content rect will be used to intersect with damage // Result is that root damage rect is clipped at root layer boundary @@ -839,8 +839,8 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform) IntRect rootDamage(rootRect); CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(rootRect)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootRect)); EXPECT_EQ(root->scissorRect(), IntRect(rootRect)); @@ -857,8 +857,8 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Empty damage == empty scissor - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); EXPECT_EQ(root->scissorRect(), IntRect(0, 0, 0, 0)); EXPECT_EQ(childPtr->scissorRect(), IntRect(0, 0, 0, 0)); @@ -869,10 +869,10 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Entire damage rect is within the root surface - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), rootDamage); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage); // Entire damage rect is within the layer EXPECT_EQ(root->scissorRect(), rootDamage); @@ -888,10 +888,10 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Entire damage rect is within the root surface - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), rootDamage); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), rootDamage); // Entire damage rect is within the layer EXPECT_EQ(root->scissorRect(), rootDamage); @@ -907,11 +907,11 @@ TEST(CCLayerTreeHostCommonTest, scissorRectWithClipAndSpaceTransform) CCLayerTreeHostCommon::calculateVisibleAndScissorRects(renderSurfaceLayerList, rootDamage); // Scissors are not computed for root - EXPECT_EQ(root->targetRenderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); + EXPECT_EQ(root->renderTarget()->renderSurface()->scissorRect(), IntRect(0, 0, 0, 0)); // Root surface does not have a clipRect, so its contentRect will be used to intersect with damage. // Result is that root damage rect is clipped at root layer boundary - EXPECT_EQ(childPtr->targetRenderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y())); + EXPECT_EQ(childPtr->renderTarget()->renderSurface()->scissorRect(), IntRect(rootDamage.x(), rootDamage.y(), rootRect.width() - rootDamage.x(), rootRect.height() - rootDamage.y())); // Root does not use layer clipping, so its content rect will be used to intersect with damage // Result is that root damage rect is clipped at root layer boundary @@ -966,10 +966,10 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForReplica) // Render surface should have been created now. ASSERT_TRUE(child->renderSurface()); - ASSERT_EQ(child->renderSurface(), child->targetRenderSurface()); + ASSERT_EQ(child, child->renderTarget()); - EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->targetRenderSurface()->replicaOriginTransform()); - EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->targetRenderSurface()->replicaScreenSpaceTransform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarget()->renderSurface()->replicaOriginTransform()); + EXPECT_TRANSFORMATION_MATRIX_EQ(replicaCompositeTransform, child->renderTarget()->renderSurface()->replicaScreenSpaceTransform()); } TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) @@ -979,7 +979,7 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) // - A render surface described w.r.t. an ancestor render surface: should have a draw transform described w.r.t. that ancestor surface // - Replicas of a render surface are described w.r.t. the replica's transform around its anchor, along with the surface itself. // - Sanity check on recursion: verify transforms of layers described w.r.t. a render surface that is described w.r.t. an ancestor render surface. - // - verifying that each layer has a reference to the correct renderSurface and targetRenderSurface values. + // - verifying that each layer has a reference to the correct renderSurface and renderTarget values. RefPtr<LayerChromium> parent = LayerChromium::create(); RefPtr<LayerChromium> renderSurface1 = LayerChromium::create(); @@ -1058,19 +1058,19 @@ TEST(CCLayerTreeHostCommonTest, verifyTransformsForRenderSurfaceHierarchy) ASSERT_FALSE(childOfRS2->renderSurface()); ASSERT_FALSE(grandChildOfRS2->renderSurface()); - // Verify all targetRenderSurface accessors + // Verify all renderTarget accessors // - EXPECT_EQ(parent->renderSurface(), parent->targetRenderSurface()); - EXPECT_EQ(parent->renderSurface(), childOfRoot->targetRenderSurface()); - EXPECT_EQ(parent->renderSurface(), grandChildOfRoot->targetRenderSurface()); + EXPECT_EQ(parent, parent->renderTarget()); + EXPECT_EQ(parent, childOfRoot->renderTarget()); + EXPECT_EQ(parent, grandChildOfRoot->renderTarget()); - EXPECT_EQ(renderSurface1->renderSurface(), renderSurface1->targetRenderSurface()); - EXPECT_EQ(renderSurface1->renderSurface(), childOfRS1->targetRenderSurface()); - EXPECT_EQ(renderSurface1->renderSurface(), grandChildOfRS1->targetRenderSurface()); + EXPECT_EQ(renderSurface1, renderSurface1->renderTarget()); + EXPECT_EQ(renderSurface1, childOfRS1->renderTarget()); + EXPECT_EQ(renderSurface1, grandChildOfRS1->renderTarget()); - EXPECT_EQ(renderSurface2->renderSurface(), renderSurface2->targetRenderSurface()); - EXPECT_EQ(renderSurface2->renderSurface(), childOfRS2->targetRenderSurface()); - EXPECT_EQ(renderSurface2->renderSurface(), grandChildOfRS2->targetRenderSurface()); + EXPECT_EQ(renderSurface2, renderSurface2->renderTarget()); + EXPECT_EQ(renderSurface2, childOfRS2->renderTarget()); + EXPECT_EQ(renderSurface2, grandChildOfRS2->renderTarget()); // Verify layer draw transforms // note that draw transforms are described with respect to the nearest ancestor render surface @@ -1278,7 +1278,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit CCLayerImpl* child = root->children()[0].get(); CCLayerImpl* grandChild = child->children()[0].get(); - // This scale will cause child and grandChild to be effectively 200 x 800 with respect to the targetRenderSurface. + // This scale will cause child and grandChild to be effectively 200 x 800 with respect to the renderTarget. WebTransformationMatrix nonUniformScale; nonUniformScale.scaleNonUniform(2, 8); child->setTransform(nonUniformScale); @@ -1378,7 +1378,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit child->setTransform(rotationAboutZ); grandChild->setPosition(FloatPoint(8, 6)); grandChild->setTransform(rotationAboutZ); - greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the targetRenderSurface + greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget. // Case 1: scrollDelta of 0, 0 child->setScrollDelta(IntSize(0, 0)); @@ -1444,7 +1444,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit child->setTransform(rotationAboutZ); grandChild->setPosition(FloatPoint(8, 6)); grandChild->setTransform(rotationAboutZ); - greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the targetRenderSurface + greatGrandChild->setFixedToContainerLayer(true); // greatGrandChild is positioned upside-down with respect to the renderTarget. // Case 1: scrollDelta of 0, 0 child->setScrollDelta(IntSize(0, 0)); @@ -1685,7 +1685,7 @@ TEST(CCLayerTreeHostCommonTest, verifyScrollCompensationForFixedPositionLayerWit { // This test checks for correct scroll compensation when the fixed-position container // itself has a renderSurface. In this case, the container layer should be treated - // like a layer that contributes to a targetRenderSurface, and that targetRenderSurface + // like a layer that contributes to a renderTarget, and that renderTarget // is completely irrelevant; it should not affect the scroll compensation. DebugScopedSetImplThread scopedImplThread; @@ -2231,19 +2231,19 @@ TEST(CCLayerTreeHostCommonTest, verifyAnimationsForRenderSurfaceHierarchy) ASSERT_FALSE(childOfRS2->renderSurface()); ASSERT_FALSE(grandChildOfRS2->renderSurface()); - // Verify all targetRenderSurface accessors + // Verify all renderTarget accessors // - EXPECT_EQ(parent->renderSurface(), parent->targetRenderSurface()); - EXPECT_EQ(parent->renderSurface(), childOfRoot->targetRenderSurface()); - EXPECT_EQ(parent->renderSurface(), grandChildOfRoot->targetRenderSurface()); + EXPECT_EQ(parent, parent->renderTarget()); + EXPECT_EQ(parent, childOfRoot->renderTarget()); + EXPECT_EQ(parent, grandChildOfRoot->renderTarget()); - EXPECT_EQ(renderSurface1->renderSurface(), renderSurface1->targetRenderSurface()); - EXPECT_EQ(renderSurface1->renderSurface(), childOfRS1->targetRenderSurface()); - EXPECT_EQ(renderSurface1->renderSurface(), grandChildOfRS1->targetRenderSurface()); + EXPECT_EQ(renderSurface1, renderSurface1->renderTarget()); + EXPECT_EQ(renderSurface1, childOfRS1->renderTarget()); + EXPECT_EQ(renderSurface1, grandChildOfRS1->renderTarget()); - EXPECT_EQ(renderSurface2->renderSurface(), renderSurface2->targetRenderSurface()); - EXPECT_EQ(renderSurface2->renderSurface(), childOfRS2->targetRenderSurface()); - EXPECT_EQ(renderSurface2->renderSurface(), grandChildOfRS2->targetRenderSurface()); + EXPECT_EQ(renderSurface2, renderSurface2->renderTarget()); + EXPECT_EQ(renderSurface2, childOfRS2->renderTarget()); + EXPECT_EQ(renderSurface2, grandChildOfRS2->renderTarget()); // Verify drawOpacityIsAnimating values // @@ -3789,7 +3789,7 @@ TEST(CCLayerTreeHostCommonTest, verifySubtreeSearch) // - add a case that checks if a render surface's replicaTransform is computed correctly. // - test all the conditions under which render surfaces are created // - if possible, test all conditions under which render surfaces are not created -// - verify that the layer lists of render surfaces are correct, verify that "targetRenderSurface" values for each layer are correct. +// - verify that the layer lists of render surfaces are correct, verify that renderTarget's RenderSurface values for each layer are correct. // - test the computation of clip rects and content rects // - test the special cases for mask layers and replica layers // - test the other functions in CCLayerTreeHostCommon diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp index cb2b7f36f..e9b9f0281 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostImplTest.cpp @@ -989,6 +989,45 @@ TEST_F(CCLayerTreeHostImplTest, scrollRootAndChangePageScaleOnImplThread) EXPECT_EQ(m_hostImpl->rootLayer()->pageScaleDelta(), pageScale); } +TEST_F(CCLayerTreeHostImplTest, pageScaleDeltaAppliedToRootScrollLayerOnly) +{ + IntSize surfaceSize(10, 10); + float defaultPageScale = 1; + float newPageScale = 2; + + // Create a normal scrollable root layer and another scrollable child layer. + setupScrollAndContentsLayers(surfaceSize); + CCLayerImpl* root = m_hostImpl->rootLayer(); + CCLayerImpl* child = root->children()[0].get(); + + OwnPtr<CCLayerImpl> scrollableChild = createScrollableLayer(3, FloatPoint(5, 5), surfaceSize); + child->addChild(scrollableChild.release()); + CCLayerImpl* grandChild = child->children()[0].get(); + + // Set new page scale on impl thread by pinching. + m_hostImpl->pinchGestureBegin(); + m_hostImpl->pinchGestureUpdate(newPageScale, IntPoint()); + m_hostImpl->pinchGestureEnd(); + + // The page scale delta should only be applied to the scrollable root layer. + EXPECT_EQ(root->pageScaleDelta(), newPageScale); + EXPECT_EQ(child->pageScaleDelta(), defaultPageScale); + EXPECT_EQ(grandChild->pageScaleDelta(), defaultPageScale); + + // Make sure all the layers are drawn with the page scale delta applied, i.e., the page scale + // delta on the root layer is applied hierarchically. + CCLayerTreeHostImpl::FrameData frame; + EXPECT_TRUE(m_hostImpl->prepareToDraw(frame)); + m_hostImpl->drawLayers(frame); + m_hostImpl->didDrawAllLayers(frame); + + WebTransformationMatrix pageScaleTransform; + pageScaleTransform.scale(newPageScale); + EXPECT_EQ(root->drawTransform(), pageScaleTransform); + EXPECT_EQ(child->drawTransform(), pageScaleTransform); + EXPECT_EQ(grandChild->drawTransform(), pageScaleTransform); +} + TEST_F(CCLayerTreeHostImplTest, scrollChildAndChangePageScaleOnMainThread) { IntSize surfaceSize(10, 10); diff --git a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp index 97d4568da..b0e9ee8d6 100644 --- a/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp +++ b/Source/WebKit/chromium/tests/CCLayerTreeHostTest.cpp @@ -2267,7 +2267,9 @@ public: CCLayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit() : m_rootLayer(ContentLayerChromiumWithUpdateTracking::create(&m_mockDelegate)) , m_surfaceLayer1(ContentLayerChromiumWithUpdateTracking::create(&m_mockDelegate)) + , m_replicaLayer1(ContentLayerChromiumWithUpdateTracking::create(&m_mockDelegate)) , m_surfaceLayer2(ContentLayerChromiumWithUpdateTracking::create(&m_mockDelegate)) + , m_replicaLayer2(ContentLayerChromiumWithUpdateTracking::create(&m_mockDelegate)) { } @@ -2283,6 +2285,9 @@ public: m_surfaceLayer2->setForceRenderSurface(true); m_surfaceLayer2->setOpacity(0.5); + m_surfaceLayer1->setReplicaLayer(m_replicaLayer1.get()); + m_surfaceLayer2->setReplicaLayer(m_replicaLayer2.get()); + m_rootLayer->addChild(m_surfaceLayer1); m_surfaceLayer1->addChild(m_surfaceLayer2); m_layerTreeHost->setRootLayer(m_rootLayer); @@ -2321,14 +2326,18 @@ public: // Clear layer references so CCLayerTreeHost dies. m_rootLayer.clear(); m_surfaceLayer1.clear(); + m_replicaLayer1.clear(); m_surfaceLayer2.clear(); + m_replicaLayer2.clear(); } private: MockContentLayerDelegate m_mockDelegate; RefPtr<ContentLayerChromiumWithUpdateTracking> m_rootLayer; RefPtr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer1; + RefPtr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer1; RefPtr<ContentLayerChromiumWithUpdateTracking> m_surfaceLayer2; + RefPtr<ContentLayerChromiumWithUpdateTracking> m_replicaLayer2; }; SINGLE_AND_MULTI_THREAD_TEST_F(CCLayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit) diff --git a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp index f0bfd0ea3..87bde5117 100644 --- a/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp +++ b/Source/WebKit/chromium/tests/CCOcclusionTrackerTest.cpp @@ -1044,7 +1044,7 @@ protected: occlusion.setLayerScissorRect(IntRect(-20, -20, 1000, 1000)); // There is nothing above child2's surface in the z-order. - EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2->renderSurface(), false, IntRect(-10, 420, 70, 80))); + EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2, false, IntRect(-10, 420, 70, 80))); this->leaveContributingSurface(child2, occlusion); this->visitLayer(layer1, occlusion); @@ -1062,7 +1062,7 @@ protected: EXPECT_FALSE(occlusion.occluded(child1, IntRect(-10, 430, 80, 71))); // child2's contents will occlude child1 below it. - EXPECT_INT_RECT_EQ(IntRect(-10, 430, 10, 70), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(-10, 430, 80, 70))); + EXPECT_INT_RECT_EQ(IntRect(-10, 430, 10, 70), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(-10, 430, 80, 70))); this->leaveContributingSurface(child1, occlusion); this->enterLayer(parent, occlusion); @@ -1153,7 +1153,7 @@ protected: this->enterContributingSurface(child2, occlusion); // There is nothing above child2's surface in the z-order. - EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2->renderSurface(), false, IntRect(-10, 420, 70, 80))); + EXPECT_INT_RECT_EQ(IntRect(-10, 420, 70, 80), occlusion.unoccludedContributingSurfaceContentRect(child2, false, IntRect(-10, 420, 70, 80))); this->leaveContributingSurface(child2, occlusion); this->visitLayer(layer1, occlusion); @@ -1171,9 +1171,9 @@ protected: EXPECT_FALSE(occlusion.occluded(child1, IntRect(421, -20, 80, 90))); // child2's contents will occlude child1 below it. - EXPECT_INT_RECT_EQ(IntRect(420, -20, 80, 90), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -20, 80, 90))); - EXPECT_INT_RECT_EQ(IntRect(490, -10, 10, 80), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -10, 80, 90))); - EXPECT_INT_RECT_EQ(IntRect(420, -20, 70, 10), occlusion.unoccludedContributingSurfaceContentRect(child1->renderSurface(), false, IntRect(420, -20, 70, 90))); + EXPECT_INT_RECT_EQ(IntRect(420, -20, 80, 90), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(420, -20, 80, 90))); + EXPECT_INT_RECT_EQ(IntRect(490, -10, 10, 80), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(420, -10, 80, 90))); + EXPECT_INT_RECT_EQ(IntRect(420, -20, 70, 10), occlusion.unoccludedContributingSurfaceContentRect(child1, false, IntRect(420, -20, 70, 90))); this->leaveContributingSurface(child1, occlusion); this->enterLayer(parent, occlusion); @@ -2077,7 +2077,7 @@ protected: this->enterContributingSurface(surface, occlusion); // Occlusion within the surface is lost when leaving the animating surface. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 300, 300))); this->leaveContributingSurface(surface, occlusion); this->visitLayer(layer, occlusion); @@ -2129,7 +2129,7 @@ protected: this->enterContributingSurface(surface, occlusion); // Occlusion within the surface is lost when leaving the animating surface. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 250, 300), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 300, 300))); this->leaveContributingSurface(surface, occlusion); this->visitLayer(layer, occlusion); @@ -2218,7 +2218,7 @@ protected: this->enterContributingSurface(surface, occlusion); // The contributing |surface| is animating so it can't be occluded. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 300), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 300, 300))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 300, 300), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 300, 300))); this->leaveContributingSurface(surface, occlusion); this->enterLayer(layer, occlusion); @@ -2333,7 +2333,7 @@ protected: this->enterContributingSurface(surface, occlusion); // Surface is not occluded so it shouldn't think it is. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); } }; @@ -2371,8 +2371,8 @@ protected: this->enterContributingSurface(surface, occlusion); // Surface is occluded, but only the top 10px of the replica. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100))); - EXPECT_INT_RECT_EQ(IntRect(0, 10, 100, 90), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), true, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 0, 0), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(0, 10, 100, 90), occlusion.unoccludedContributingSurfaceContentRect(surface, true, IntRect(0, 0, 100, 100))); } }; @@ -2412,8 +2412,8 @@ protected: this->enterContributingSurface(surface, occlusion); // Surface and replica are occluded different amounts. - EXPECT_INT_RECT_EQ(IntRect(40, 0, 60, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100))); - EXPECT_INT_RECT_EQ(IntRect(50, 0, 50, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), true, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(40, 0, 60, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(50, 0, 50, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, true, IntRect(0, 0, 100, 100))); } }; @@ -2458,7 +2458,7 @@ protected: this->enterContributingSurface(surfaceChild, occlusion); // The surfaceChild's parent does not have a clipRect as it owns a render surface. Make sure the unoccluded rect // does not get clipped away inappropriately. - EXPECT_INT_RECT_EQ(IntRect(0, 40, 100, 10), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild->renderSurface(), false, IntRect(0, 0, 100, 50))); + EXPECT_INT_RECT_EQ(IntRect(0, 40, 100, 10), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild, false, IntRect(0, 0, 100, 50))); this->leaveContributingSurface(surfaceChild, occlusion); // When the surfaceChild's occlusion is transformed up to its parent, make sure it is not clipped away inappropriately also. @@ -2471,7 +2471,7 @@ protected: this->enterContributingSurface(surface, occlusion); // The surface's parent does have a clipRect as it is the root layer. - EXPECT_INT_RECT_EQ(IntRect(0, 50, 100, 50), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(0, 50, 100, 50), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); } }; @@ -2497,7 +2497,7 @@ protected: // The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect. this->enterContributingSurface(surface, occlusion); // Make sure the parent's clipRect clips the unoccluded region of the child surface. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 300))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 200), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 300))); } this->resetLayerIterator(); { @@ -2509,7 +2509,7 @@ protected: // The root layer always has a clipRect. So the parent of |surface| has a clipRect giving the surface itself a clipRect. this->enterContributingSurface(surface, occlusion); // Make sure the screen scissor rect clips the unoccluded region of the child surface. - EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 300))); + EXPECT_INT_RECT_EQ(IntRect(0, 0, 100, 100), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 300))); } } }; @@ -2554,13 +2554,13 @@ protected: this->enterContributingSurface(surfaceChild, occlusion); // The surfaceChild's parent does not have a clipRect as it owns a render surface. - EXPECT_INT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild->renderSurface(), false, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surfaceChild, false, IntRect(0, 0, 100, 100))); this->leaveContributingSurface(surfaceChild, occlusion); this->visitLayer(surface, occlusion); this->enterContributingSurface(surface, occlusion); // The surface's parent does have a clipRect as it is the root layer. - EXPECT_INT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surface->renderSurface(), false, IntRect(0, 0, 100, 100))); + EXPECT_INT_RECT_EQ(IntRect(0, 50, 80, 50), occlusion.unoccludedContributingSurfaceContentRect(surface, false, IntRect(0, 0, 100, 100))); } }; diff --git a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp index 624d24711..e1d9fb367 100644 --- a/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp +++ b/Source/WebKit/chromium/tests/CCQuadCullerTest.cpp @@ -58,18 +58,22 @@ private: typedef CCLayerIterator<CCLayerImpl, Vector<CCLayerImpl*>, CCRenderSurface, CCLayerIteratorActions::FrontToBack> CCLayerIteratorType; -static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& drawTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList) +static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const WebTransformationMatrix& originTransform, const IntRect& layerRect, float opacity, bool opaque, const IntRect& layerOpaqueRect, Vector<CCLayerImpl*>& surfaceLayerList) { OwnPtr<CCTiledLayerImpl> layer = CCTiledLayerImpl::create(1); OwnPtr<CCLayerTilingData> tiler = CCLayerTilingData::create(IntSize(100, 100), CCLayerTilingData::NoBorderTexels); tiler->setBounds(layerRect.size()); layer->setTilingData(*tiler); layer->setSkipsDraw(false); + WebTransformationMatrix drawTransform = originTransform; + drawTransform.translate(0.5 * layerRect.width(), 0.5 * layerRect.height()); layer->setDrawTransform(drawTransform); - layer->setScreenSpaceTransform(drawTransform); + layer->setScreenSpaceTransform(originTransform); layer->setVisibleContentRect(layerRect); layer->setDrawOpacity(opacity); layer->setOpaque(opaque); + layer->setBounds(layerRect.size()); + layer->setContentBounds(layerRect.size()); int textureId = 1; for (int i = 0; i < tiler->numTilesX(); ++i) @@ -80,11 +84,10 @@ static PassOwnPtr<CCTiledLayerImpl> makeLayer(CCTiledLayerImpl* parent, const We if (!parent) { layer->createRenderSurface(); - layer->setTargetRenderSurface(layer->renderSurface()); surfaceLayerList.append(layer.get()); layer->renderSurface()->layerList().append(layer.get()); } else { - layer->setTargetRenderSurface(parent->targetRenderSurface()); + layer->setRenderTarget(parent->renderTarget()); parent->renderSurface()->layerList().append(layer.get()); } @@ -195,7 +198,7 @@ TEST(CCQuadCullerTest, verifyCullCenterTileOnly) appendQuads(quadList, sharedStateList, childLayer.get(), it, occlusionTracker); appendQuads(quadList, sharedStateList, rootLayer.get(), it, occlusionTracker); - EXPECT_EQ(quadList.size(), 12u); + ASSERT_EQ(quadList.size(), 12u); IntRect quadVisibleRect1 = quadList[5].get()->quadVisibleRect(); EXPECT_EQ(quadVisibleRect1.height(), 50); diff --git a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp index 1bfc81d8c..f9a9292b7 100644 --- a/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCSolidColorLayerImplTest.cpp @@ -50,6 +50,7 @@ TEST(CCSolidColorLayerImplTest, verifyTilingCompleteAndNoOverlap) OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1); layer->setVisibleContentRect(visibleContentRect); layer->setBounds(layerSize); + layer->setContentBounds(layerSize); OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); bool hadMissingTiles = false; @@ -71,6 +72,7 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectBackgroundColorInQuad) OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1); layer->setVisibleContentRect(visibleContentRect); layer->setBounds(layerSize); + layer->setContentBounds(layerSize); layer->setBackgroundColor(testColor); OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); @@ -94,6 +96,7 @@ TEST(CCSolidColorLayerImplTest, verifyCorrectOpacityInQuad) OwnPtr<CCSolidColorLayerImpl> layer = CCSolidColorLayerImpl::create(1); layer->setVisibleContentRect(visibleContentRect); layer->setBounds(layerSize); + layer->setContentBounds(layerSize); layer->setDrawOpacity(opacity); OwnPtr<CCSharedQuadState> sharedQuadState = layer->createSharedQuadState(); diff --git a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp index 588c0ff08..00d38a7ec 100644 --- a/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp +++ b/Source/WebKit/chromium/tests/CCTiledLayerImplTest.cpp @@ -50,6 +50,8 @@ static PassOwnPtr<CCTiledLayerImpl> createLayer(const IntSize& tileSize, const I layer->setSkipsDraw(false); layer->setVisibleContentRect(IntRect(IntPoint(), layerSize)); layer->setDrawOpacity(1); + layer->setBounds(layerSize); + layer->setContentBounds(layerSize); int textureId = 1; for (int i = 0; i < tiler->numTilesX(); ++i) diff --git a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp index 2d1603e48..26ffd9079 100644 --- a/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp +++ b/Source/WebKit/chromium/tests/CCTiledLayerTestCommon.cpp @@ -125,18 +125,16 @@ void FakeTiledLayerChromium::setTexturePriorities(const CCPriorityCalculator& ca { // Ensure there is always a target render surface available. If none has been // set (the layer is an orphan for the test), then just set a surface on itself. - bool missingTargetRenderSurface = !targetRenderSurface(); + bool missingTargetRenderSurface = !renderTarget(); - if (missingTargetRenderSurface) { + if (missingTargetRenderSurface) createRenderSurface(); - setTargetRenderSurface(renderSurface()); - } TiledLayerChromium::setTexturePriorities(calculator); if (missingTargetRenderSurface) { clearRenderSurface(); - setTargetRenderSurface(0); + setRenderTarget(0); } } diff --git a/Source/WebKit/chromium/tests/DecimalTest.cpp b/Source/WebKit/chromium/tests/DecimalTest.cpp index 454dfea2c..8d4106260 100644 --- a/Source/WebKit/chromium/tests/DecimalTest.cpp +++ b/Source/WebKit/chromium/tests/DecimalTest.cpp @@ -89,7 +89,7 @@ protected: return Decimal::fromString(string); } - protected: String stepDown(const String& minimum, const String& maximum, const String& step, const String& valueString, int numberOfStepTimes) + protected: Decimal stepDown(const String& minimum, const String& maximum, const String& step, const String& valueString, int numberOfStepTimes) { DecimalStepRange stepRange(fromString(minimum), fromString(maximum), fromString(step)); Decimal value = fromString(valueString); @@ -97,10 +97,10 @@ protected: value -= stepRange.step; value = stepRange.clampValue(value); } - return value.toString(); + return value; } - protected: String stepUp(const String& minimum, const String& maximum, const String& step, const String& valueString, int numberOfStepTimes) + protected: Decimal stepUp(const String& minimum, const String& maximum, const String& step, const String& valueString, int numberOfStepTimes) { DecimalStepRange stepRange(fromString(minimum), fromString(maximum), fromString(step)); Decimal value = fromString(valueString); @@ -108,10 +108,18 @@ protected: value += stepRange.step; value = stepRange.clampValue(value); } - return value.toString(); + return value; } }; +// FIXME: We should use expectedSign without "Decimal::", however, g++ causes undefined references for DecimalTest::Positive and Negative. +#define EXPECT_DECIMAL_ENCODED_DATA_EQ(expectedCoefficient, expectedExponent, expectedSign, decimal) \ + EXPECT_EQ((expectedCoefficient), (decimal).value().coefficient()); \ + EXPECT_EQ((expectedExponent), (decimal).value().exponent()); \ + EXPECT_EQ(Decimal::expectedSign, (decimal).value().sign()); + +#define EXPECT_DECIMAL_STREQ(expected, decimal) EXPECT_STREQ((expected), (decimal).toString().ascii().data()) + TEST_F(DecimalTest, Abs) { EXPECT_EQ(encode(0, 0, Positive), encode(0, 0, Positive).abs()); @@ -231,9 +239,9 @@ TEST_F(DecimalTest, CeilingBigExponent) EXPECT_EQ(encode(1, 1000, Negative), encode(1, 1000, Negative).ceiling()); } -TEST_F(DecimalTest, DISABLED_CeilingSmallExponent) +TEST_F(DecimalTest, CeilingSmallExponent) { - EXPECT_EQ(encode(0, 0, Positive), encode(1, -1000, Positive).ceiling()); + EXPECT_EQ(encode(1, 0, Positive), encode(1, -1000, Positive).ceiling()); EXPECT_EQ(encode(0, 0, Negative), encode(1, -1000, Negative).ceiling()); } @@ -445,6 +453,28 @@ TEST_F(DecimalTest, CompareSpecialValues) EXPECT_TRUE(NaN >= NaN); } +TEST_F(DecimalTest, Constructor) +{ + EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Positive, encode(0, 0, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Negative, encode(0, 0, Negative)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 0, Positive, encode(1, 0, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 0, Negative, encode(1, 0, Negative)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1022, Positive, encode(1, 1022, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1022, Negative, encode(1, 1022, Negative)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1023, Positive, encode(1, 1023, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(1u, 1023, Negative, encode(1, 1023, Negative)); + EXPECT_TRUE(encode(1, 2000, Positive).isInfinity()); + EXPECT_TRUE(encode(1, 2000, Negative).isInfinity()); + EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Positive, encode(1, -2000, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(0u, 0, Negative, encode(1, -2000, Negative)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999998), 0, Positive, encode(UINT64_C(99999999999999998), 0, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999998), 0, Negative, encode(UINT64_C(99999999999999998), 0, Negative)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999999), 0, Positive, encode(UINT64_C(99999999999999999), 0, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(99999999999999999), 0, Negative, encode(UINT64_C(99999999999999999), 0, Negative)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(10000000000000000), 1, Positive, encode(UINT64_C(100000000000000000), 0, Positive)); + EXPECT_DECIMAL_ENCODED_DATA_EQ(UINT64_C(10000000000000000), 1, Negative, encode(UINT64_C(100000000000000000), 0, Negative)); +} + TEST_F(DecimalTest, Division) { EXPECT_EQ(encode(0, 0, Positive), Decimal(0) / Decimal(1)); @@ -547,10 +577,10 @@ TEST_F(DecimalTest, FloorBigExponent) EXPECT_EQ(encode(1, 1000, Negative), encode(1, 1000, Negative).floor()); } -TEST_F(DecimalTest, DISABLED_FloorSmallExponent) +TEST_F(DecimalTest, FloorSmallExponent) { EXPECT_EQ(encode(0, 0, Positive), encode(1, -1000, Positive).floor()); - EXPECT_EQ(encode(0, 0, Negative), encode(1, -1000, Negative).floor()); + EXPECT_EQ(encode(1, 0, Negative), encode(1, -1000, Negative).floor()); } TEST_F(DecimalTest, FloorSpecialValues) @@ -840,29 +870,29 @@ TEST_F(DecimalTest, PredicatesSpecialValues) // LayoutTests/fast/forms/number/number-stepup-stepdown-from-renderer TEST_F(DecimalTest, RealWorldExampleNumberStepUpStepDownFromRenderer) { - EXPECT_EQ(String("10"), stepDown("0", "100", "10", "19", 1)); - EXPECT_EQ(String("90"), stepUp("0", "99", "10", "89", 1)); - EXPECT_EQ(String("1"), stepUp("0", "1", "0.33333333333333333", "0", 3)); // step=1/3 - EXPECT_EQ(String("0.01"), stepUp("0", "0.01", "0.0033333333333333333", "0", 3)); // step=1/300 - EXPECT_EQ(String("1"), stepUp("0", "1", "0.003921568627450980", "0", 255)); // step=1/255 - EXPECT_EQ(String("1"), stepUp("0", "1", "0.1", "0", 10)); + EXPECT_DECIMAL_STREQ("10", stepDown("0", "100", "10", "19", 1)); + EXPECT_DECIMAL_STREQ("90", stepUp("0", "99", "10", "89", 1)); + EXPECT_DECIMAL_STREQ("1", stepUp("0", "1", "0.33333333333333333", "0", 3)); // step=1/3 + EXPECT_DECIMAL_STREQ("0.01", stepUp("0", "0.01", "0.0033333333333333333", "0", 3)); // step=1/300 + EXPECT_DECIMAL_STREQ("1", stepUp("0", "1", "0.003921568627450980", "0", 255)); // step=1/255 + EXPECT_DECIMAL_STREQ("1", stepUp("0", "1", "0.1", "0", 10)); } TEST_F(DecimalTest, RealWorldExampleNumberStepUpStepDownFromRendererRounding) { - EXPECT_EQ(String("5.015"), stepUp("0", "100", "0.005", "5.005", 2)); - EXPECT_EQ(String("5.06"), stepUp("0", "100", "0.005", "5.005", 11)); - EXPECT_EQ(String("5.065"), stepUp("0", "100", "0.005", "5.005", 12)); + EXPECT_DECIMAL_STREQ("5.015", stepUp("0", "100", "0.005", "5.005", 2)); + EXPECT_DECIMAL_STREQ("5.06", stepUp("0", "100", "0.005", "5.005", 11)); + EXPECT_DECIMAL_STREQ("5.065", stepUp("0", "100", "0.005", "5.005", 12)); - EXPECT_EQ(String("5.015"), stepUp("4", "9", "0.005", "5.005", 2)); - EXPECT_EQ(String("5.06"), stepUp("4", "9", "0.005", "5.005", 11)); - EXPECT_EQ(String("5.065"), stepUp("4", "9", "0.005", "5.005", 12)); + EXPECT_DECIMAL_STREQ("5.015", stepUp("4", "9", "0.005", "5.005", 2)); + EXPECT_DECIMAL_STREQ("5.06", stepUp("4", "9", "0.005", "5.005", 11)); + EXPECT_DECIMAL_STREQ("5.065", stepUp("4", "9", "0.005", "5.005", 12)); } TEST_F(DecimalTest, RealWorldExampleRangeStepUpStepDown) { - EXPECT_EQ(String("1e+38"), stepUp("0", "1E38", "1", "1E38", 9)); - EXPECT_EQ(String("1e+38"), stepDown("0", "1E38", "1", "1E38", 9)); + EXPECT_DECIMAL_STREQ("1e+38", stepUp("0", "1E38", "1", "1E38", 9)); + EXPECT_DECIMAL_STREQ("1e+38", stepDown("0", "1E38", "1", "1E38", 9)); } TEST_F(DecimalTest, Remainder) @@ -1022,31 +1052,41 @@ TEST_F(DecimalTest, ToDoubleSpecialValues) TEST_F(DecimalTest, ToString) { - EXPECT_EQ(String("0"), Decimal::zero(Positive).toString()); - EXPECT_EQ(String("-0"), Decimal::zero(Negative).toString()); - EXPECT_EQ(String("1"), Decimal(1).toString()); - EXPECT_EQ(String("-1"), Decimal(-1).toString()); - EXPECT_EQ(String("1234567"), Decimal(1234567).toString()); - EXPECT_EQ(String("-1234567"), Decimal(-1234567).toString()); - EXPECT_EQ(String("0.5"), encode(5, -1, Positive).toString()); - EXPECT_EQ(String("-0.5"), encode(5, -1, Negative).toString()); - EXPECT_EQ(String("12.345"), encode(12345, -3, Positive).toString()); - EXPECT_EQ(String("-12.345"), encode(12345, -3, Negative).toString()); - EXPECT_EQ(String("0.12345"), encode(12345, -5, Positive).toString()); - EXPECT_EQ(String("-0.12345"), encode(12345, -5, Negative).toString()); - EXPECT_EQ(String("50"), encode(50, 0, Positive).toString()); - EXPECT_EQ(String("-50"), encode(50, 0, Negative).toString()); - EXPECT_EQ(String("5e+1"), encode(5, 1, Positive).toString()); - EXPECT_EQ(String("-5e+1"), encode(5, 1, Negative).toString()); - EXPECT_EQ(String("5.678e+103"), encode(5678, 100, Positive).toString()); - EXPECT_EQ(String("-5.678e+103"), encode(5678, 100, Negative).toString()); - EXPECT_EQ(String("5.678e-97"), encode(5678, -100, Positive).toString()); - EXPECT_EQ(String("-5.678e-97"), encode(5678, -100, Negative).toString()); + EXPECT_DECIMAL_STREQ("0", Decimal::zero(Positive)); + EXPECT_DECIMAL_STREQ("-0", Decimal::zero(Negative)); + EXPECT_DECIMAL_STREQ("1", Decimal(1)); + EXPECT_DECIMAL_STREQ("-1", Decimal(-1)); + EXPECT_DECIMAL_STREQ("1234567", Decimal(1234567)); + EXPECT_DECIMAL_STREQ("-1234567", Decimal(-1234567)); + EXPECT_DECIMAL_STREQ("0.5", encode(5, -1, Positive)); + EXPECT_DECIMAL_STREQ("-0.5", encode(5, -1, Negative)); + EXPECT_DECIMAL_STREQ("12.345", encode(12345, -3, Positive)); + EXPECT_DECIMAL_STREQ("-12.345", encode(12345, -3, Negative)); + EXPECT_DECIMAL_STREQ("0.12345", encode(12345, -5, Positive)); + EXPECT_DECIMAL_STREQ("-0.12345", encode(12345, -5, Negative)); + EXPECT_DECIMAL_STREQ("50", encode(50, 0, Positive)); + EXPECT_DECIMAL_STREQ("-50", encode(50, 0, Negative)); + EXPECT_DECIMAL_STREQ("5e+1", encode(5, 1, Positive)); + EXPECT_DECIMAL_STREQ("-5e+1", encode(5, 1, Negative)); + EXPECT_DECIMAL_STREQ("5.678e+103", encode(5678, 100, Positive)); + EXPECT_DECIMAL_STREQ("-5.678e+103", encode(5678, 100, Negative)); + EXPECT_DECIMAL_STREQ("5.678e-97", encode(5678, -100, Positive)); + EXPECT_DECIMAL_STREQ("-5.678e-97", encode(5678, -100, Negative)); + EXPECT_DECIMAL_STREQ("8639999913600001", encode(UINT64_C(8639999913600001), 0, Positive)); + EXPECT_DECIMAL_STREQ("9007199254740991", encode((static_cast<uint64_t>(1) << DBL_MANT_DIG) - 1, 0, Positive)); + EXPECT_DECIMAL_STREQ("99999999999999999", encode(UINT64_C(99999999999999999), 0, Positive)); + EXPECT_DECIMAL_STREQ("9.9999999999999999e+17", encode(UINT64_C(99999999999999999), 1, Positive)); + EXPECT_DECIMAL_STREQ("9.9999999999999999e+18", encode(UINT64_C(99999999999999999), 2, Positive)); + EXPECT_DECIMAL_STREQ("1e+16", encode(UINT64_C(99999999999999999), -1, Positive)); + EXPECT_DECIMAL_STREQ("1000000000000000", encode(UINT64_C(99999999999999999), -2, Positive)); + EXPECT_DECIMAL_STREQ("1", encode(UINT64_C(99999999999999999), -17, Positive)); + EXPECT_DECIMAL_STREQ("0.001", encode(UINT64_C(99999999999999999), -20, Positive)); + EXPECT_DECIMAL_STREQ("1e-83", encode(UINT64_C(99999999999999999), -100, Positive)); } TEST_F(DecimalTest, ToStringSpecialValues) { - EXPECT_EQ(String("Infinity"), Decimal::infinity(Positive).toString()); - EXPECT_EQ(String("-Infinity"), Decimal::infinity(Negative).toString()); - EXPECT_EQ(String("NaN"), Decimal::nan().toString()); + EXPECT_DECIMAL_STREQ("Infinity", Decimal::infinity(Positive)); + EXPECT_DECIMAL_STREQ("-Infinity", Decimal::infinity(Negative)); + EXPECT_DECIMAL_STREQ("NaN", Decimal::nan()); } diff --git a/Source/WebKit/chromium/tests/FrameTestHelpers.cpp b/Source/WebKit/chromium/tests/FrameTestHelpers.cpp index a2b1675c0..c3e8bf08d 100644 --- a/Source/WebKit/chromium/tests/FrameTestHelpers.cpp +++ b/Source/WebKit/chromium/tests/FrameTestHelpers.cpp @@ -80,6 +80,7 @@ WebView* createWebViewAndLoad(const std::string& url, bool enableJavascript, Web webViewClient = defaultWebViewClient(); WebView* webView = WebView::create(webViewClient); webView->settings()->setJavaScriptEnabled(enableJavascript); + webView->settings()->setDeviceSupportsMouse(false); webView->initializeMainFrame(webFrameClient); loadFrame(webView->mainFrame(), url); diff --git a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h index ed894cb19..08405ce0a 100644 --- a/Source/WebKit/chromium/tests/IDBFakeBackingStore.h +++ b/Source/WebKit/chromium/tests/IDBFakeBackingStore.h @@ -48,7 +48,8 @@ public: virtual bool putObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const IDBKey&, const String& value, ObjectStoreRecordIdentifier*) OVERRIDE { return false; } virtual void clearObjectStore(int64_t databaseId, int64_t objectStoreId) OVERRIDE { } virtual void deleteObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, const ObjectStoreRecordIdentifier*) OVERRIDE { } - virtual int64_t nextAutoIncrementNumber(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0.0; } + virtual int64_t getKeyGeneratorCurrentNumber(int64_t databaseId, int64_t objectStoreId) OVERRIDE { return 0; } + virtual bool maybeUpdateKeyGeneratorCurrentNumber(int64_t databaseId, int64_t objectStoreId, int64_t newNumber, bool checkCurrent) OVERRIDE { return false; } virtual bool keyExistsInObjectStore(int64_t databaseId, int64_t objectStoreId, const IDBKey&, ObjectStoreRecordIdentifier* foundRecordIdentifier) OVERRIDE { return false; } virtual bool forEachObjectStoreRecord(int64_t databaseId, int64_t objectStoreId, ObjectStoreRecordCallback&) OVERRIDE { return false; } diff --git a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp index fdae37c6a..a794a2846 100644 --- a/Source/WebKit/chromium/tests/LayerChromiumTest.cpp +++ b/Source/WebKit/chromium/tests/LayerChromiumTest.cpp @@ -499,7 +499,7 @@ TEST_F(LayerChromiumTest, checkPropertyChangeCausesCorrectBehavior) EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setIsNonCompositedContent(true)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawOpacity(0.5f)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setClipRect(IntRect(3, 3, 8, 8))); - EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setTargetRenderSurface(0)); + EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setRenderTarget(0)); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawTransform(WebTransformationMatrix())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setScreenSpaceTransform(WebTransformationMatrix())); EXECUTE_AND_VERIFY_SET_NEEDS_COMMIT_BEHAVIOR(0, testLayer->setDrawableContentRect(IntRect(4, 5, 6, 7))); diff --git a/Source/WebKit/chromium/tests/OpenTypeVerticalDataTest.cpp b/Source/WebKit/chromium/tests/OpenTypeVerticalDataTest.cpp new file mode 100644 index 000000000..e05a20541 --- /dev/null +++ b/Source/WebKit/chromium/tests/OpenTypeVerticalDataTest.cpp @@ -0,0 +1,86 @@ +/* + * Copyright (C) 2012 Koji Ishii <kojiishi@gmail.com> + * + * 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" + +#if ENABLE(OPENTYPE_VERTICAL) + +#include "OpenTypeTypes.h" +#include "SharedBuffer.h" +#include <gtest/gtest.h> +#include <wtf/RefPtr.h> + +using namespace WebCore; + +namespace { + +struct TestTable : OpenType::TableBase { + OpenType::Fixed version; + OpenType::Int16 ascender; + + template <typename T> const T* validateOffset(const SharedBuffer& buffer, uint16_t offset) const + { + return TableBase::validateOffset<T>(buffer, offset); + } +}; + +TEST(OpenTypeVerticalDataTest, ValidateTableTest) +{ + RefPtr<SharedBuffer> buffer = SharedBuffer::create(sizeof(TestTable)); + const TestTable* table = OpenType::validateTable<TestTable>(buffer); + EXPECT_TRUE(table); + + buffer = SharedBuffer::create(sizeof(TestTable) - 1); + table = OpenType::validateTable<TestTable>(buffer); + EXPECT_FALSE(table); + + buffer = SharedBuffer::create(sizeof(TestTable) + 1); + table = OpenType::validateTable<TestTable>(buffer); + EXPECT_TRUE(table); +} + +TEST(OpenTypeVerticalDataTest, ValidateOffsetTest) +{ + RefPtr<SharedBuffer> buffer = SharedBuffer::create(sizeof(TestTable)); + const TestTable* table = OpenType::validateTable<TestTable>(buffer); + ASSERT_TRUE(table); + + // Test overflow + EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, -1)); + + // uint8_t is valid for all offsets + for (uint16_t offset = 0; offset < sizeof(TestTable); offset++) + EXPECT_TRUE(table->validateOffset<uint8_t>(*buffer, offset)); + EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, sizeof(TestTable))); + EXPECT_FALSE(table->validateOffset<uint8_t>(*buffer, sizeof(TestTable) + 1)); + + // For uint16_t, the last byte is invalid + for (uint16_t offset = 0; offset < sizeof(TestTable) - 1; offset++) + EXPECT_TRUE(table->validateOffset<uint16_t>(*buffer, offset)); + EXPECT_FALSE(table->validateOffset<uint16_t>(*buffer, sizeof(TestTable) - 1)); +} + +} // namespace + +#endif // ENABLE(OPENTYPE_VERTICAL) |