Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/Source/core/layout/VisualRectMappingTest.cpp

Issue 2808613002: Apply container offset and scroll between transform and container perspective. (Closed)
Patch Set: none Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/layout/LayoutTestHelper.h" 5 #include "core/layout/LayoutTestHelper.h"
6 #include "core/layout/LayoutView.h" 6 #include "core/layout/LayoutView.h"
7 #include "core/layout/PaintInvalidationState.h" 7 #include "core/layout/PaintInvalidationState.h"
8 #include "core/paint/PaintLayer.h" 8 #include "core/paint/PaintLayer.h"
9 #include "core/paint/PaintPropertyTreePrinter.h" 9 #include "core/paint/PaintPropertyTreePrinter.h"
10 #include "platform/graphics/paint/GeometryMapper.h" 10 #include "platform/graphics/paint/GeometryMapper.h"
(...skipping 17 matching lines...) Expand all
28 object.ContainerForPaintInvalidation(); 28 object.ContainerForPaintInvalidation();
29 29
30 CheckVisualRect(object, paint_invalidation_container, rect, 30 CheckVisualRect(object, paint_invalidation_container, rect,
31 object.VisualRect(), true); 31 object.VisualRect(), true);
32 } 32 }
33 33
34 void CheckVisualRect(const LayoutObject& object, 34 void CheckVisualRect(const LayoutObject& object,
35 const LayoutBoxModelObject& ancestor, 35 const LayoutBoxModelObject& ancestor,
36 const LayoutRect& local_rect, 36 const LayoutRect& local_rect,
37 const LayoutRect& expected_visual_rect, 37 const LayoutRect& expected_visual_rect,
38 bool adjust_for_backing = false) { 38 bool adjust_for_backing = false,
39 bool allow_empty_cache_slot = true) {
39 LayoutRect slow_map_rect = local_rect; 40 LayoutRect slow_map_rect = local_rect;
40 object.MapToVisualRectInAncestorSpace(&ancestor, slow_map_rect); 41 object.MapToVisualRectInAncestorSpace(&ancestor, slow_map_rect);
41 if (slow_map_rect.IsEmpty() && object.VisualRect().IsEmpty()) 42 if (allow_empty_cache_slot && slow_map_rect.IsEmpty() &&
43 object.VisualRect().IsEmpty())
42 return; 44 return;
43 45
44 FloatClipRect geometry_mapper_rect((FloatRect(local_rect))); 46 FloatClipRect geometry_mapper_rect((FloatRect(local_rect)));
45 if (object.PaintProperties() || object.LocalBorderBoxProperties()) { 47 if (object.PaintProperties() || object.LocalBorderBoxProperties()) {
46 geometry_mapper_rect.MoveBy(FloatPoint(object.PaintOffset())); 48 geometry_mapper_rect.MoveBy(FloatPoint(object.PaintOffset()));
47 GeometryMapper::SourceToDestinationVisualRect( 49 GeometryMapper::SourceToDestinationVisualRect(
48 *object.LocalBorderBoxProperties(), *ancestor.ContentsProperties(), 50 *object.LocalBorderBoxProperties(), *ancestor.ContentsProperties(),
49 geometry_mapper_rect); 51 geometry_mapper_rect);
50 geometry_mapper_rect.MoveBy(-FloatPoint(ancestor.PaintOffset())); 52 geometry_mapper_rect.MoveBy(-FloatPoint(ancestor.PaintOffset()));
51 } 53 }
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 TransformationMatrix target_matrix; 830 TransformationMatrix target_matrix;
829 // getTransformfromContainter includes transform and perspective matrix 831 // getTransformfromContainter includes transform and perspective matrix
830 // of the container. 832 // of the container.
831 target->GetTransformFromContainer(container, LayoutSize(), target_matrix); 833 target->GetTransformFromContainer(container, LayoutSize(), target_matrix);
832 matrix *= target_matrix; 834 matrix *= target_matrix;
833 LayoutRect output(matrix.MapRect(FloatRect(original_rect))); 835 LayoutRect output(matrix.MapRect(FloatRect(original_rect)));
834 836
835 CheckVisualRect(*target, *target->View(), original_rect, output); 837 CheckVisualRect(*target, *target->View(), original_rect, output);
836 } 838 }
837 839
840 TEST_F(VisualRectMappingTest, PerspectivePlusScroll) {
841 EnableCompositing();
842 SetBodyInnerHTML(
843 "<style>"
844 "* { margin: 0; }"
845 "#container {"
846 " perspective: 100px;"
847 " width: 100px; height: 100px;"
848 " overflow: scroll;"
849 "}"
850 "#target {"
851 " transform: rotatex(45eg);"
852 " background: lightblue;"
853 " width: 100px; height: 100px;"
854 "}"
855 "#spacer {"
856 " width: 10px; height:2000px;"
857 "}"
858 "</style>"
859 "<div id='container'>"
860 " <div id='target'></div>"
861 " <div id='spacer'></div>"
862 "</div>");
863 LayoutBlock* container =
864 ToLayoutBlock(GetLayoutObjectByElementId("container"));
865 ToElement(container->GetNode())->scrollTo(0, 5);
866 GetDocument().View()->UpdateAllLifecyclePhases();
867
868 LayoutBlock* target = ToLayoutBlock(GetLayoutObjectByElementId("target"));
869 LayoutRect originalRect(0, 0, 100, 100);
870 TransformationMatrix transform;
871 target->GetTransformFromContainer(
872 container, target->OffsetFromContainer(container), transform);
873 transform.FlattenTo2d();
874
875 LayoutRect output(transform.MapRect(FloatRect(originalRect)));
876 output.Intersect(container->ClippingRect());
877 CheckVisualRect(*target, *target->View(), originalRect, output, false, false);
878 }
879
838 } // namespace blink 880 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/LayoutObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698