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

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

Issue 2393673004: reflow comments in core/layout/compositing,core/observer (Closed)
Patch Set: Created 4 years, 2 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/compositing/CompositedLayerMapping.h" 5 #include "core/layout/compositing/CompositedLayerMapping.h"
6 6
7 #include "core/frame/FrameView.h" 7 #include "core/frame/FrameView.h"
8 #include "core/layout/LayoutBoxModelObject.h" 8 #include "core/layout/LayoutBoxModelObject.h"
9 #include "core/layout/LayoutTestHelper.h" 9 #include "core/layout/LayoutTestHelper.h"
10 #include "core/layout/api/LayoutViewItem.h" 10 #include "core/layout/api/LayoutViewItem.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 TEST_F(CompositedLayerMappingTest, TallLayerInterestRect) { 84 TEST_F(CompositedLayerMappingTest, TallLayerInterestRect) {
85 setBodyInnerHTML( 85 setBodyInnerHTML(
86 "<div id='target' style='width: 200px; height: 10000px; will-change: " 86 "<div id='target' style='width: 200px; height: 10000px; will-change: "
87 "transform'></div>"); 87 "transform'></div>");
88 88
89 document().view()->updateAllLifecyclePhases(); 89 document().view()->updateAllLifecyclePhases();
90 Element* element = document().getElementById("target"); 90 Element* element = document().getElementById("target");
91 PaintLayer* paintLayer = 91 PaintLayer* paintLayer =
92 toLayoutBoxModelObject(element->layoutObject())->layer(); 92 toLayoutBoxModelObject(element->layoutObject())->layer();
93 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); 93 ASSERT_TRUE(paintLayer->graphicsLayerBacking());
94 // Screen-space visible content rect is [8, 8, 200, 600]. Mapping back to loca l, adding 4000px in all directions, then 94 // Screen-space visible content rect is [8, 8, 200, 600]. Mapping back to
95 // clipping, yields this rect. 95 // local, adding 4000px in all directions, then clipping, yields this rect.
96 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4592), 96 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4592),
97 recomputeInterestRect(paintLayer->graphicsLayerBacking())); 97 recomputeInterestRect(paintLayer->graphicsLayerBacking()));
98 } 98 }
99 99
100 TEST_F(CompositedLayerMappingTest, TallLayerWholeDocumentInterestRect) { 100 TEST_F(CompositedLayerMappingTest, TallLayerWholeDocumentInterestRect) {
101 setBodyInnerHTML( 101 setBodyInnerHTML(
102 "<div id='target' style='width: 200px; height: 10000px; will-change: " 102 "<div id='target' style='width: 200px; height: 10000px; will-change: "
103 "transform'></div>"); 103 "transform'></div>");
104 104
105 document().settings()->setMainFrameClipsContent(false); 105 document().settings()->setMainFrameClipsContent(false);
(...skipping 20 matching lines...) Expand all
126 "200px;'></div>"); 126 "200px;'></div>");
127 127
128 document().view()->updateAllLifecyclePhases(); 128 document().view()->updateAllLifecyclePhases();
129 document().view()->setScrollPosition(DoublePoint(-5000, 0), 129 document().view()->setScrollPosition(DoublePoint(-5000, 0),
130 ProgrammaticScroll); 130 ProgrammaticScroll);
131 document().view()->updateAllLifecyclePhases(); 131 document().view()->updateAllLifecyclePhases();
132 132
133 PaintLayer* paintLayer = document().layoutViewItem().layer(); 133 PaintLayer* paintLayer = document().layoutViewItem().layer();
134 ASSERT_TRUE(paintLayer->graphicsLayerBacking()); 134 ASSERT_TRUE(paintLayer->graphicsLayerBacking());
135 ASSERT_TRUE(paintLayer->compositedLayerMapping()); 135 ASSERT_TRUE(paintLayer->compositedLayerMapping());
136 // A scroll by -5000px is equivalent to a scroll by (10000 - 5000 - 800)px = 4 200px in non-RTL mode. Expanding 136 // A scroll by -5000px is equivalent to a scroll by (10000 - 5000 - 800)px =
137 // the resulting rect by 4000px in each direction yields this result. 137 // 4200px in non-RTL mode. Expanding the resulting rect by 4000px in each
138 // direction yields this result.
138 EXPECT_RECT_EQ(IntRect(200, 0, 8800, 600), 139 EXPECT_RECT_EQ(IntRect(200, 0, 8800, 600),
139 recomputeInterestRect(paintLayer->graphicsLayerBacking())); 140 recomputeInterestRect(paintLayer->graphicsLayerBacking()));
140 } 141 }
141 142
142 TEST_F(CompositedLayerMappingTest, RotatedInterestRect) { 143 TEST_F(CompositedLayerMappingTest, RotatedInterestRect) {
143 setBodyInnerHTML( 144 setBodyInnerHTML(
144 "<div id='target' style='width: 200px; height: 200px; will-change: " 145 "<div id='target' style='width: 200px; height: 200px; will-change: "
145 "transform; transform: rotateZ(45deg)'></div>"); 146 "transform; transform: rotateZ(45deg)'></div>");
146 147
147 document().view()->updateAllLifecyclePhases(); 148 document().view()->updateAllLifecyclePhases();
148 Element* element = document().getElementById("target"); 149 Element* element = document().getElementById("target");
149 PaintLayer* paintLayer = 150 PaintLayer* paintLayer =
150 toLayoutBoxModelObject(element->layoutObject())->layer(); 151 toLayoutBoxModelObject(element->layoutObject())->layer();
151 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); 152 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
152 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), 153 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200),
153 recomputeInterestRect(paintLayer->graphicsLayerBacking())); 154 recomputeInterestRect(paintLayer->graphicsLayerBacking()));
154 } 155 }
155 156
156 TEST_F(CompositedLayerMappingTest, RotatedInterestRectNear90Degrees) { 157 TEST_F(CompositedLayerMappingTest, RotatedInterestRectNear90Degrees) {
157 setBodyInnerHTML( 158 setBodyInnerHTML(
158 "<div id='target' style='width: 10000px; height: 200px; will-change: " 159 "<div id='target' style='width: 10000px; height: 200px; will-change: "
159 "transform; transform: rotateY(89.9999deg)'></div>"); 160 "transform; transform: rotateY(89.9999deg)'></div>");
160 161
161 document().view()->updateAllLifecyclePhases(); 162 document().view()->updateAllLifecyclePhases();
162 Element* element = document().getElementById("target"); 163 Element* element = document().getElementById("target");
163 PaintLayer* paintLayer = 164 PaintLayer* paintLayer =
164 toLayoutBoxModelObject(element->layoutObject())->layer(); 165 toLayoutBoxModelObject(element->layoutObject())->layer();
165 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); 166 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
166 // Because the layer is rotated to almost 90 degrees, floating-point error lea ds to a reverse-projected rect that is much much larger 167 // Because the layer is rotated to almost 90 degrees, floating-point error
167 // than the original layer size in certain dimensions. In such cases, we often fall back to the 4000px interest rect padding amount. 168 // leads to a reverse-projected rect that is much much larger than the
169 // original layer size in certain dimensions. In such cases, we often fall
170 // back to the 4000px interest rect padding amount.
168 EXPECT_RECT_EQ(IntRect(0, 0, 4000, 200), 171 EXPECT_RECT_EQ(IntRect(0, 0, 4000, 200),
169 recomputeInterestRect(paintLayer->graphicsLayerBacking())); 172 recomputeInterestRect(paintLayer->graphicsLayerBacking()));
170 } 173 }
171 174
172 TEST_F(CompositedLayerMappingTest, 3D90DegRotatedTallInterestRect) { 175 TEST_F(CompositedLayerMappingTest, 3D90DegRotatedTallInterestRect) {
173 // It's rotated 90 degrees about the X axis, which means its visual content re ct is empty, and so the interest rect is the 176 // It's rotated 90 degrees about the X axis, which means its visual content
174 // default (0, 0, 4000, 4000) intersected with the layer bounds. 177 // rect is empty, and so the interest rect is the default (0, 0, 4000, 4000)
178 // intersected with the layer bounds.
175 setBodyInnerHTML( 179 setBodyInnerHTML(
176 "<div id='target' style='width: 200px; height: 10000px; will-change: " 180 "<div id='target' style='width: 200px; height: 10000px; will-change: "
177 "transform; transform: rotateY(90deg)'></div>"); 181 "transform; transform: rotateY(90deg)'></div>");
178 182
179 document().view()->updateAllLifecyclePhases(); 183 document().view()->updateAllLifecyclePhases();
180 Element* element = document().getElementById("target"); 184 Element* element = document().getElementById("target");
181 PaintLayer* paintLayer = 185 PaintLayer* paintLayer =
182 toLayoutBoxModelObject(element->layoutObject())->layer(); 186 toLayoutBoxModelObject(element->layoutObject())->layer();
183 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); 187 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
184 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4000), 188 EXPECT_RECT_EQ(IntRect(0, 0, 200, 4000),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 TEST_F(CompositedLayerMappingTest, WideLayerInterestRect) { 220 TEST_F(CompositedLayerMappingTest, WideLayerInterestRect) {
217 setBodyInnerHTML( 221 setBodyInnerHTML(
218 "<div id='target' style='width: 10000px; height: 200px; will-change: " 222 "<div id='target' style='width: 10000px; height: 200px; will-change: "
219 "transform'></div>"); 223 "transform'></div>");
220 224
221 document().view()->updateAllLifecyclePhases(); 225 document().view()->updateAllLifecyclePhases();
222 Element* element = document().getElementById("target"); 226 Element* element = document().getElementById("target");
223 PaintLayer* paintLayer = 227 PaintLayer* paintLayer =
224 toLayoutBoxModelObject(element->layoutObject())->layer(); 228 toLayoutBoxModelObject(element->layoutObject())->layer();
225 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking()); 229 ASSERT_TRUE(!!paintLayer->graphicsLayerBacking());
226 // Screen-space visible content rect is [8, 8, 800, 200] (the screen is 800x60 0). 230 // Screen-space visible content rect is [8, 8, 800, 200] (the screen is
227 // Mapping back to local, adding 4000px in all directions, then clipping, yiel ds this rect. 231 // 800x600). Mapping back to local, adding 4000px in all directions, then
232 // clipping, yields this rect.
228 EXPECT_RECT_EQ(IntRect(0, 0, 4792, 200), 233 EXPECT_RECT_EQ(IntRect(0, 0, 4792, 200),
229 recomputeInterestRect(paintLayer->graphicsLayerBacking())); 234 recomputeInterestRect(paintLayer->graphicsLayerBacking()));
230 } 235 }
231 236
232 TEST_F(CompositedLayerMappingTest, FixedPositionInterestRect) { 237 TEST_F(CompositedLayerMappingTest, FixedPositionInterestRect) {
233 setBodyInnerHTML( 238 setBodyInnerHTML(
234 "<div id='target' style='width: 300px; height: 400px; will-change: " 239 "<div id='target' style='width: 300px; height: 400px; will-change: "
235 "transform; position: fixed; top: 100px; left: 200px;'></div>"); 240 "transform; position: fixed; top: 100px; left: 200px;'></div>");
236 241
237 document().view()->updateAllLifecyclePhases(); 242 document().view()->updateAllLifecyclePhases();
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 shouldFlattenTransform(*compositedLayerMapping->scrollingLayer())); 360 shouldFlattenTransform(*compositedLayerMapping->scrollingLayer()));
356 EXPECT_TRUE(shouldFlattenTransform( 361 EXPECT_TRUE(shouldFlattenTransform(
357 *compositedLayerMapping->scrollingContentsLayer())); 362 *compositedLayerMapping->scrollingContentsLayer()));
358 } 363 }
359 364
360 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintEmpty) { 365 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintEmpty) {
361 IntSize layerSize(1000, 1000); 366 IntSize layerSize(1000, 1000);
362 // Both empty means there is nothing to do. 367 // Both empty means there is nothing to do.
363 EXPECT_FALSE( 368 EXPECT_FALSE(
364 interestRectChangedEnoughToRepaint(IntRect(), IntRect(), layerSize)); 369 interestRectChangedEnoughToRepaint(IntRect(), IntRect(), layerSize));
365 // Going from empty to non-empty means we must re-record because it could be t he first frame after construction or Clear. 370 // Going from empty to non-empty means we must re-record because it could be
371 // the first frame after construction or Clear.
366 EXPECT_TRUE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(0, 0, 1, 1), 372 EXPECT_TRUE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(0, 0, 1, 1),
367 layerSize)); 373 layerSize));
368 // Going from non-empty to empty is not special-cased. 374 // Going from non-empty to empty is not special-cased.
369 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(0, 0, 1, 1), 375 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(0, 0, 1, 1),
370 IntRect(), layerSize)); 376 IntRect(), layerSize));
371 } 377 }
372 378
373 TEST_F(CompositedLayerMappingTest, 379 TEST_F(CompositedLayerMappingTest,
374 InterestRectChangedEnoughToRepaintNotBigEnough) { 380 InterestRectChangedEnoughToRepaintNotBigEnough) {
375 IntSize layerSize(1000, 1000); 381 IntSize layerSize(1000, 1000);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 "<div id='div' style='width: 100px; height: 10000px'>Text</div>"); 457 "<div id='div' style='width: 100px; height: 10000px'>Text</div>");
452 458
453 document().view()->updateAllLifecyclePhases(); 459 document().view()->updateAllLifecyclePhases();
454 GraphicsLayer* rootScrollingLayer = 460 GraphicsLayer* rootScrollingLayer =
455 document().layoutViewItem().layer()->graphicsLayerBackingForScrolling(); 461 document().layoutViewItem().layer()->graphicsLayerBackingForScrolling();
456 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), 462 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600),
457 previousInterestRect(rootScrollingLayer)); 463 previousInterestRect(rootScrollingLayer));
458 464
459 document().view()->setScrollPosition(IntPoint(0, 300), ProgrammaticScroll); 465 document().view()->setScrollPosition(IntPoint(0, 300), ProgrammaticScroll);
460 document().view()->updateAllLifecyclePhases(); 466 document().view()->updateAllLifecyclePhases();
461 // Still use the previous interest rect because the recomputed rect hasn't cha nged enough. 467 // Still use the previous interest rect because the recomputed rect hasn't
468 // changed enough.
462 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900), 469 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4900),
463 recomputeInterestRect(rootScrollingLayer)); 470 recomputeInterestRect(rootScrollingLayer));
464 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600), 471 EXPECT_RECT_EQ(IntRect(0, 0, 800, 4600),
465 previousInterestRect(rootScrollingLayer)); 472 previousInterestRect(rootScrollingLayer));
466 473
467 document().view()->setScrollPosition(IntPoint(0, 600), ProgrammaticScroll); 474 document().view()->setScrollPosition(IntPoint(0, 600), ProgrammaticScroll);
468 document().view()->updateAllLifecyclePhases(); 475 document().view()->updateAllLifecyclePhases();
469 // Use recomputed interest rect because it changed enough. 476 // Use recomputed interest rect because it changed enough.
470 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), 477 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200),
471 recomputeInterestRect(rootScrollingLayer)); 478 recomputeInterestRect(rootScrollingLayer));
472 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200), 479 EXPECT_RECT_EQ(IntRect(0, 0, 800, 5200),
473 previousInterestRect(rootScrollingLayer)); 480 previousInterestRect(rootScrollingLayer));
474 481
475 document().view()->setScrollPosition(IntPoint(0, 5400), ProgrammaticScroll); 482 document().view()->setScrollPosition(IntPoint(0, 5400), ProgrammaticScroll);
476 document().view()->updateAllLifecyclePhases(); 483 document().view()->updateAllLifecyclePhases();
477 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), 484 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600),
478 recomputeInterestRect(rootScrollingLayer)); 485 recomputeInterestRect(rootScrollingLayer));
479 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), 486 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600),
480 previousInterestRect(rootScrollingLayer)); 487 previousInterestRect(rootScrollingLayer));
481 488
482 document().view()->setScrollPosition(IntPoint(0, 9000), ProgrammaticScroll); 489 document().view()->setScrollPosition(IntPoint(0, 9000), ProgrammaticScroll);
483 document().view()->updateAllLifecyclePhases(); 490 document().view()->updateAllLifecyclePhases();
484 // Still use the previous interest rect because it contains the recomputed int erest rect. 491 // Still use the previous interest rect because it contains the recomputed
492 // interest rect.
485 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000), 493 EXPECT_RECT_EQ(IntRect(0, 5000, 800, 5000),
486 recomputeInterestRect(rootScrollingLayer)); 494 recomputeInterestRect(rootScrollingLayer));
487 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600), 495 EXPECT_RECT_EQ(IntRect(0, 1400, 800, 8600),
488 previousInterestRect(rootScrollingLayer)); 496 previousInterestRect(rootScrollingLayer));
489 497
490 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll); 498 document().view()->setScrollPosition(IntPoint(0, 2000), ProgrammaticScroll);
491 // Use recomputed interest rect because it changed enough. 499 // Use recomputed interest rect because it changed enough.
492 document().view()->updateAllLifecyclePhases(); 500 document().view()->updateAllLifecyclePhases();
493 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600), 501 EXPECT_RECT_EQ(IntRect(0, 0, 800, 6600),
494 recomputeInterestRect(rootScrollingLayer)); 502 recomputeInterestRect(rootScrollingLayer));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 542
535 document().view()->updateAllLifecyclePhases(); 543 document().view()->updateAllLifecyclePhases();
536 Element* scroller = document().getElementById("scroller"); 544 Element* scroller = document().getElementById("scroller");
537 GraphicsLayer* scrollingLayer = 545 GraphicsLayer* scrollingLayer =
538 scroller->layoutBox()->layer()->graphicsLayerBackingForScrolling(); 546 scroller->layoutBox()->layer()->graphicsLayerBackingForScrolling();
539 EXPECT_RECT_EQ(IntRect(0, 0, 400, 4600), 547 EXPECT_RECT_EQ(IntRect(0, 0, 400, 4600),
540 previousInterestRect(scrollingLayer)); 548 previousInterestRect(scrollingLayer));
541 549
542 scroller->setScrollTop(300); 550 scroller->setScrollTop(300);
543 document().view()->updateAllLifecyclePhases(); 551 document().view()->updateAllLifecyclePhases();
544 // Still use the previous interest rect because the recomputed rect hasn't cha nged enough. 552 // Still use the previous interest rect because the recomputed rect hasn't
553 // changed enough.
545 EXPECT_RECT_EQ(IntRect(0, 0, 400, 4900), 554 EXPECT_RECT_EQ(IntRect(0, 0, 400, 4900),
546 recomputeInterestRect(scrollingLayer)); 555 recomputeInterestRect(scrollingLayer));
547 EXPECT_RECT_EQ(IntRect(0, 0, 400, 4600), 556 EXPECT_RECT_EQ(IntRect(0, 0, 400, 4600),
548 previousInterestRect(scrollingLayer)); 557 previousInterestRect(scrollingLayer));
549 558
550 scroller->setScrollTop(600); 559 scroller->setScrollTop(600);
551 document().view()->updateAllLifecyclePhases(); 560 document().view()->updateAllLifecyclePhases();
552 // Use recomputed interest rect because it changed enough. 561 // Use recomputed interest rect because it changed enough.
553 EXPECT_RECT_EQ(IntRect(0, 0, 400, 5200), 562 EXPECT_RECT_EQ(IntRect(0, 0, 400, 5200),
554 recomputeInterestRect(scrollingLayer)); 563 recomputeInterestRect(scrollingLayer));
555 EXPECT_RECT_EQ(IntRect(0, 0, 400, 5200), 564 EXPECT_RECT_EQ(IntRect(0, 0, 400, 5200),
556 previousInterestRect(scrollingLayer)); 565 previousInterestRect(scrollingLayer));
557 566
558 scroller->setScrollTop(5400); 567 scroller->setScrollTop(5400);
559 document().view()->updateAllLifecyclePhases(); 568 document().view()->updateAllLifecyclePhases();
560 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), 569 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600),
561 recomputeInterestRect(scrollingLayer)); 570 recomputeInterestRect(scrollingLayer));
562 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), 571 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600),
563 previousInterestRect(scrollingLayer)); 572 previousInterestRect(scrollingLayer));
564 573
565 scroller->setScrollTop(9000); 574 scroller->setScrollTop(9000);
566 document().view()->updateAllLifecyclePhases(); 575 document().view()->updateAllLifecyclePhases();
567 // Still use the previous interest rect because it contains the recomputed int erest rect. 576 // Still use the previous interest rect because it contains the recomputed
577 // interest rect.
568 EXPECT_RECT_EQ(IntRect(0, 5000, 400, 5000), 578 EXPECT_RECT_EQ(IntRect(0, 5000, 400, 5000),
569 recomputeInterestRect(scrollingLayer)); 579 recomputeInterestRect(scrollingLayer));
570 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), 580 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600),
571 previousInterestRect(scrollingLayer)); 581 previousInterestRect(scrollingLayer));
572 582
573 scroller->setScrollTop(2000); 583 scroller->setScrollTop(2000);
574 // Use recomputed interest rect because it changed enough. 584 // Use recomputed interest rect because it changed enough.
575 document().view()->updateAllLifecyclePhases(); 585 document().view()->updateAllLifecyclePhases();
576 EXPECT_RECT_EQ(IntRect(0, 0, 400, 6600), 586 EXPECT_RECT_EQ(IntRect(0, 0, 400, 6600),
577 recomputeInterestRect(scrollingLayer)); 587 recomputeInterestRect(scrollingLayer));
(...skipping 16 matching lines...) Expand all
594 "</div"); 604 "</div");
595 605
596 document().view()->updateAllLifecyclePhases(); 606 document().view()->updateAllLifecyclePhases();
597 Element* scroller = document().getElementById("scroller"); 607 Element* scroller = document().getElementById("scroller");
598 GraphicsLayer* scrollingLayer = 608 GraphicsLayer* scrollingLayer =
599 scroller->layoutBox()->layer()->graphicsLayerBackingForScrolling(); 609 scroller->layoutBox()->layer()->graphicsLayerBackingForScrolling();
600 610
601 scroller->setScrollTop(5400); 611 scroller->setScrollTop(5400);
602 document().view()->updateAllLifecyclePhases(); 612 document().view()->updateAllLifecyclePhases();
603 scroller->setScrollTop(9400); 613 scroller->setScrollTop(9400);
604 // The above code creates an interest rect bigger than the interest rect if re computed now. 614 // The above code creates an interest rect bigger than the interest rect if
615 // recomputed now.
605 document().view()->updateAllLifecyclePhases(); 616 document().view()->updateAllLifecyclePhases();
606 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), 617 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600),
607 recomputeInterestRect(scrollingLayer)); 618 recomputeInterestRect(scrollingLayer));
608 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600), 619 EXPECT_RECT_EQ(IntRect(0, 1400, 400, 8600),
609 previousInterestRect(scrollingLayer)); 620 previousInterestRect(scrollingLayer));
610 621
611 // Paint invalidation and repaint should change previous paint interest rect. 622 // Paint invalidation and repaint should change previous paint interest rect.
612 document().getElementById("content")->setTextContent("Change"); 623 document().getElementById("content")->setTextContent("Change");
613 document().view()->updateAllLifecyclePhases(); 624 document().view()->updateAllLifecyclePhases();
614 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600), 625 EXPECT_RECT_EQ(IntRect(0, 5400, 400, 4600),
(...skipping 19 matching lines...) Expand all
634 ->visualOverflowRect() 645 ->visualOverflowRect()
635 .size() 646 .size()
636 .height(), 647 .height(),
637 100); 648 100);
638 649
639 CompositedLayerMapping* groupedMapping = document() 650 CompositedLayerMapping* groupedMapping = document()
640 .getElementById("squashed") 651 .getElementById("squashed")
641 ->layoutBox() 652 ->layoutBox()
642 ->layer() 653 ->layer()
643 ->groupedMapping(); 654 ->groupedMapping();
644 // The squashing layer is at (-10000, 190, 10100, 100) in viewport coordinates . 655 // The squashing layer is at (-10000, 190, 10100, 100) in viewport
645 // The following rect is at (-4000, 190, 4100, 100) in viewport coordinates. 656 // coordinates. The following rect is at (-4000, 190, 4100, 100) in viewport
eae 2016/10/05 19:53:00 Breaking after coordinates. here and allowing the
Nico 2016/10/05 19:58:14 Done.
657 // coordinates.
646 EXPECT_RECT_EQ(IntRect(6000, 0, 4100, 100), 658 EXPECT_RECT_EQ(IntRect(6000, 0, 4100, 100),
647 groupedMapping->computeInterestRect( 659 groupedMapping->computeInterestRect(
648 groupedMapping->squashingLayer(), IntRect())); 660 groupedMapping->squashingLayer(), IntRect()));
649 } 661 }
650 662
651 TEST_F(CompositedLayerMappingTest, 663 TEST_F(CompositedLayerMappingTest,
652 InterestRectOfSquashingLayerWithAncestorClip) { 664 InterestRectOfSquashingLayerWithAncestorClip) {
653 setBodyInnerHTML( 665 setBodyInnerHTML(
654 "<style>body { margin: 0; }</style>" 666 "<style>body { margin: 0; }</style>"
655 "<div style='overflow: hidden; width: 400px; height: 400px'>" 667 "<div style='overflow: hidden; width: 400px; height: 400px'>"
656 " <div style='position: relative; backface-visibility: hidden'>" 668 " <div style='position: relative; backface-visibility: hidden'>"
657 " <div style='position: absolute; top: -500px; width: 200px; height: " 669 " <div style='position: absolute; top: -500px; width: 200px; height: "
658 "700px; backface-visibility: hidden'></div>" 670 "700px; backface-visibility: hidden'></div>"
659 // Above overflow:hidden div and two composited layers make the squashing layer a child of an ancestor clipping layer. 671 // Above overflow:hidden div and two composited layers make the squashing
672 // layer a child of an ancestor clipping layer.
660 " <div id='squashed' style='height: 1000px; width: 10000px; right: 0; " 673 " <div id='squashed' style='height: 1000px; width: 10000px; right: 0; "
661 "position: absolute'></div>" 674 "position: absolute'></div>"
662 " </div>" 675 " </div>"
663 "</div>"); 676 "</div>");
664 677
665 CompositedLayerMapping* groupedMapping = document() 678 CompositedLayerMapping* groupedMapping = document()
666 .getElementById("squashed") 679 .getElementById("squashed")
667 ->layoutBox() 680 ->layoutBox()
668 ->layer() 681 ->layer()
669 ->groupedMapping(); 682 ->groupedMapping();
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 EXPECT_RECT_EQ(IntRect(0, 3500, 500, 4500), 741 EXPECT_RECT_EQ(IntRect(0, 3500, 500, 4500),
729 recomputeInterestRect(frameDocument.view() 742 recomputeInterestRect(frameDocument.view()
730 ->layoutViewItem() 743 ->layoutViewItem()
731 .enclosingLayer() 744 .enclosingLayer()
732 ->graphicsLayerBacking())); 745 ->graphicsLayerBacking()));
733 } 746 }
734 747
735 TEST_F(CompositedLayerMappingTest, InterestRectOfIframeWithContentBoxOffset) { 748 TEST_F(CompositedLayerMappingTest, InterestRectOfIframeWithContentBoxOffset) {
736 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com")); 749 document().setBaseURLOverride(KURL(ParsedURLString, "http://test.com"));
737 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true); 750 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(true);
738 // Set a 10px border in order to have a contentBoxOffset for the iframe elemen t. 751 // Set a 10px border in order to have a contentBoxOffset for the iframe
752 // element.
739 setBodyInnerHTML( 753 setBodyInnerHTML(
740 "<style>body { margin: 0; } #frame { border: 10px solid black; } " 754 "<style>body { margin: 0; } #frame { border: 10px solid black; } "
741 "::-webkit-scrollbar { display: none; }</style>" 755 "::-webkit-scrollbar { display: none; }</style>"
742 "<iframe id=frame src='http://test.com' width='500' height='500' " 756 "<iframe id=frame src='http://test.com' width='500' height='500' "
743 "frameBorder='0'>" 757 "frameBorder='0'>"
744 "</iframe>"); 758 "</iframe>");
745 759
746 Document& frameDocument = 760 Document& frameDocument =
747 setupChildIframe("frame", 761 setupChildIframe("frame",
748 "<style>body { margin: 0; } #target { width: 200px; " 762 "<style>body { margin: 0; } #target { width: 200px; "
749 "height: 8000px;}</style> <div id=target></div>"); 763 "height: 8000px;}</style> <div id=target></div>");
750 764
751 document().view()->updateAllLifecyclePhases(); 765 document().view()->updateAllLifecyclePhases();
752 766
753 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the mi ddle. 767 // Scroll 3000 pixels down to bring the scrollable area to somewhere in the
768 // middle.
754 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0), 769 frameDocument.view()->setScrollPosition(DoublePoint(0.0, 3000.0),
755 ProgrammaticScroll); 770 ProgrammaticScroll);
756 document().view()->updateAllLifecyclePhases(); 771 document().view()->updateAllLifecyclePhases();
757 772
758 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer()); 773 ASSERT_TRUE(frameDocument.view()->layoutViewItem().hasLayer());
759 // The width is 485 pixels due to the size of the scrollbar. 774 // The width is 485 pixels due to the size of the scrollbar.
760 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500), 775 EXPECT_RECT_EQ(IntRect(0, 0, 500, 7500),
761 recomputeInterestRect(frameDocument.view() 776 recomputeInterestRect(frameDocument.view()
762 ->layoutViewItem() 777 ->layoutViewItem()
763 .enclosingLayer() 778 .enclosingLayer()
(...skipping 17 matching lines...) Expand all
781 "<div id='spacer' style='height: 2000px'></div>"); 796 "<div id='spacer' style='height: 2000px'></div>");
782 797
783 document().view()->updateAllLifecyclePhases(); 798 document().view()->updateAllLifecyclePhases();
784 799
785 // The translucent fixed box should not be promoted. 800 // The translucent fixed box should not be promoted.
786 Element* element = document().getElementById("translucent"); 801 Element* element = document().getElementById("translucent");
787 PaintLayer* paintLayer = 802 PaintLayer* paintLayer =
788 toLayoutBoxModelObject(element->layoutObject())->layer(); 803 toLayoutBoxModelObject(element->layoutObject())->layer();
789 EXPECT_EQ(NotComposited, paintLayer->compositingState()); 804 EXPECT_EQ(NotComposited, paintLayer->compositingState());
790 805
791 // The opaque fixed box should be promoted and be opaque so that text will be drawn 806 // The opaque fixed box should be promoted and be opaque so that text will be
792 // with subpixel anti-aliasing. 807 // drawn with subpixel anti-aliasing.
793 element = document().getElementById("opaque"); 808 element = document().getElementById("opaque");
794 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer(); 809 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
795 EXPECT_EQ(PaintsIntoOwnBacking, paintLayer->compositingState()); 810 EXPECT_EQ(PaintsIntoOwnBacking, paintLayer->compositingState());
796 EXPECT_TRUE(paintLayer->graphicsLayerBacking()->contentsOpaque()); 811 EXPECT_TRUE(paintLayer->graphicsLayerBacking()->contentsOpaque());
797 812
798 // The opaque fixed box with shadow should not be promoted because the layer w ill 813 // The opaque fixed box with shadow should not be promoted because the layer
799 // include the shadow which is not opaque. 814 // will include the shadow which is not opaque.
800 element = document().getElementById("opaque-with-shadow"); 815 element = document().getElementById("opaque-with-shadow");
801 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer(); 816 paintLayer = toLayoutBoxModelObject(element->layoutObject())->layer();
802 EXPECT_EQ(NotComposited, paintLayer->compositingState()); 817 EXPECT_EQ(NotComposited, paintLayer->compositingState());
803 818
804 document().frame()->settings()->setPreferCompositingToLCDTextEnabled( 819 document().frame()->settings()->setPreferCompositingToLCDTextEnabled(
805 preferCompositing); 820 preferCompositing);
806 } 821 }
807 822
808 TEST_F(CompositedLayerMappingTest, 823 TEST_F(CompositedLayerMappingTest,
809 ScrollingContentsAndForegroundLayerPaintingPhase) { 824 ScrollingContentsAndForegroundLayerPaintingPhase) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 "<div id='container' style='overflow: scroll; width: 300px; height: " 872 "<div id='container' style='overflow: scroll; width: 300px; height: "
858 "300px; border-radius: 5px; background: white; will-change: transform;'>" 873 "300px; border-radius: 5px; background: white; will-change: transform;'>"
859 " <div style='background-color: blue; width: 2000px; height: " 874 " <div style='background-color: blue; width: 2000px; height: "
860 "2000px;'></div>" 875 "2000px;'></div>"
861 "</div>"); 876 "</div>");
862 877
863 PaintLayer* layer = 878 PaintLayer* layer =
864 toLayoutBlock(getLayoutObjectByElementId("container"))->layer(); 879 toLayoutBlock(getLayoutObjectByElementId("container"))->layer();
865 EXPECT_TRUE(layer->canPaintBackgroundOntoScrollingContentsLayer()); 880 EXPECT_TRUE(layer->canPaintBackgroundOntoScrollingContentsLayer());
866 881
867 // We currently don't use composited scrolling when the container has a border -radius 882 // We currently don't use composited scrolling when the container has a
868 // so even though we can paint the background onto the scrolling contents laye r we 883 // border-radius so even though we can paint the background onto the scrolling
869 // don't have a scrolling contents layer to paint into in this case. 884 // contents layer we don't have a scrolling contents layer to paint into in
885 // this case.
870 CompositedLayerMapping* mapping = layer->compositedLayerMapping(); 886 CompositedLayerMapping* mapping = layer->compositedLayerMapping();
871 EXPECT_FALSE(mapping->hasScrollingLayer()); 887 EXPECT_FALSE(mapping->hasScrollingLayer());
872 EXPECT_FALSE(mapping->backgroundPaintsOntoScrollingContentsLayer()); 888 EXPECT_FALSE(mapping->backgroundPaintsOntoScrollingContentsLayer());
873 } 889 }
874 890
875 // Make sure that clipping layers are removed or their masking bit turned off 891 // Make sure that clipping layers are removed or their masking bit turned off
876 // when they're an ancestor of the root scroller element. 892 // when they're an ancestor of the root scroller element.
877 TEST_F(CompositedLayerMappingTest, RootScrollerAncestorsNotClipped) { 893 TEST_F(CompositedLayerMappingTest, RootScrollerAncestorsNotClipped) {
878 NonThrowableExceptionState nonThrow; 894 NonThrowableExceptionState nonThrow;
879 895
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 963
948 // Since there's no need to composite the clip and we prefer LCD text, the 964 // Since there's no need to composite the clip and we prefer LCD text, the
949 // mapping should create an ancestorClippingLayer. 965 // mapping should create an ancestorClippingLayer.
950 ASSERT_TRUE(mapping->scrollingLayer()); 966 ASSERT_TRUE(mapping->scrollingLayer());
951 ASSERT_TRUE(mapping->ancestorClippingLayer()); 967 ASSERT_TRUE(mapping->ancestorClippingLayer());
952 968
953 // Since the clip has a transform it should be composited so there's no 969 // Since the clip has a transform it should be composited so there's no
954 // need for an ancestor clipping layer. 970 // need for an ancestor clipping layer.
955 ASSERT_TRUE(mapping2->scrollingLayer()); 971 ASSERT_TRUE(mapping2->scrollingLayer());
956 972
957 // The third <div> should have a clipping layer since it's composited and clip s 973 // The third <div> should have a clipping layer since it's composited and
958 // composited children. 974 // clips composited children.
959 ASSERT_TRUE(mapping3->clippingLayer()); 975 ASSERT_TRUE(mapping3->clippingLayer());
960 976
961 // All scrolling and clipping layers should have masksToBounds set on them. 977 // All scrolling and clipping layers should have masksToBounds set on them.
962 { 978 {
963 EXPECT_TRUE(mapping->scrollingLayer()->platformLayer()->masksToBounds()); 979 EXPECT_TRUE(mapping->scrollingLayer()->platformLayer()->masksToBounds());
964 EXPECT_TRUE( 980 EXPECT_TRUE(
965 mapping->ancestorClippingLayer()->platformLayer()->masksToBounds()); 981 mapping->ancestorClippingLayer()->platformLayer()->masksToBounds());
966 EXPECT_TRUE(mapping2->scrollingLayer()->platformLayer()->masksToBounds()); 982 EXPECT_TRUE(mapping2->scrollingLayer()->platformLayer()->masksToBounds());
967 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); 983 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds());
968 } 984 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1014 document().view()->updateAllLifecyclePhases(); 1030 document().view()->updateAllLifecyclePhases();
1015 ASSERT_EQ(document().documentElement(), 1031 ASSERT_EQ(document().documentElement(),
1016 rootScrollerController.globalRootScroller()); 1032 rootScrollerController.globalRootScroller());
1017 1033
1018 EXPECT_TRUE(mapping3->clippingLayer()); 1034 EXPECT_TRUE(mapping3->clippingLayer());
1019 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds()); 1035 EXPECT_TRUE(mapping3->clippingLayer()->platformLayer()->masksToBounds());
1020 } 1036 }
1021 } 1037 }
1022 1038
1023 } // namespace blink 1039 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698