OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 #include "core/layout/compositing/CompositedLayerMapping.h" | 6 #include "core/layout/compositing/CompositedLayerMapping.h" |
7 | 7 |
8 #include "core/frame/FrameView.h" | 8 #include "core/frame/FrameView.h" |
9 #include "core/html/HTMLIFrameElement.h" | 9 #include "core/html/HTMLIFrameElement.h" |
10 #include "core/layout/LayoutBoxModelObject.h" | 10 #include "core/layout/LayoutBoxModelObject.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 IntRect recomputeInterestRect(const GraphicsLayer* graphicsLayer) | 27 IntRect recomputeInterestRect(const GraphicsLayer* graphicsLayer) |
28 { | 28 { |
29 return static_cast<CompositedLayerMapping*>(graphicsLayer->client())->re
computeInterestRect(graphicsLayer); | 29 return static_cast<CompositedLayerMapping*>(graphicsLayer->client())->re
computeInterestRect(graphicsLayer); |
30 } | 30 } |
31 | 31 |
32 IntRect computeInterestRect(const CompositedLayerMapping* compositedLayerMap
ping, GraphicsLayer* graphicsLayer, IntRect previousInterestRect) | 32 IntRect computeInterestRect(const CompositedLayerMapping* compositedLayerMap
ping, GraphicsLayer* graphicsLayer, IntRect previousInterestRect) |
33 { | 33 { |
34 return compositedLayerMapping->computeInterestRect(graphicsLayer, previo
usInterestRect); | 34 return compositedLayerMapping->computeInterestRect(graphicsLayer, previo
usInterestRect); |
35 } | 35 } |
36 | 36 |
| 37 bool shouldFlattenTransform(const GraphicsLayer& layer) const |
| 38 { |
| 39 return layer.shouldFlattenTransform(); |
| 40 } |
| 41 |
37 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) | 42 bool interestRectChangedEnoughToRepaint(const IntRect& previousInterestRect,
const IntRect& newInterestRect, const IntSize& layerSize) |
38 { | 43 { |
39 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); | 44 return CompositedLayerMapping::interestRectChangedEnoughToRepaint(previo
usInterestRect, newInterestRect, layerSize); |
40 } | 45 } |
41 | 46 |
42 IntRect previousInterestRect(const GraphicsLayer* graphicsLayer) | 47 IntRect previousInterestRect(const GraphicsLayer* graphicsLayer) |
43 { | 48 { |
44 return graphicsLayer->m_previousInterestRect; | 49 return graphicsLayer->m_previousInterestRect; |
45 } | 50 } |
46 | 51 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 document().view()->updateAllLifecyclePhases(); | 262 document().view()->updateAllLifecyclePhases(); |
258 EXPECT_TRUE(graphicsLayer->maskLayer()); | 263 EXPECT_TRUE(graphicsLayer->maskLayer()); |
259 EXPECT_FALSE(graphicsLayer->contentsClippingMaskLayer()); | 264 EXPECT_FALSE(graphicsLayer->contentsClippingMaskLayer()); |
260 | 265 |
261 videoElement->setAttribute(HTMLNames::styleAttr, styleWithoutClipping); | 266 videoElement->setAttribute(HTMLNames::styleAttr, styleWithoutClipping); |
262 document().view()->updateAllLifecyclePhases(); | 267 document().view()->updateAllLifecyclePhases(); |
263 EXPECT_FALSE(graphicsLayer->maskLayer()); | 268 EXPECT_FALSE(graphicsLayer->maskLayer()); |
264 EXPECT_FALSE(graphicsLayer->contentsClippingMaskLayer()); | 269 EXPECT_FALSE(graphicsLayer->contentsClippingMaskLayer()); |
265 } | 270 } |
266 | 271 |
| 272 TEST_F(CompositedLayerMappingTest, ScrollContentsFlattenForScroller) |
| 273 { |
| 274 setBodyInnerHTML( |
| 275 "<style>div::-webkit-scrollbar{ width: 5px; }</style>" |
| 276 "<div id='scroller' style='width: 100px; height: 100px; overflow: scroll
; will-change: transform'>" |
| 277 "<div style='width: 1000px; height: 1000px;'>Foo</div>Foo</div>"); |
| 278 |
| 279 document().view()->updateAllLifecyclePhases(); |
| 280 Element* element = document().getElementById("scroller"); |
| 281 PaintLayer* paintLayer = toLayoutBoxModelObject(element->layoutObject())->la
yer(); |
| 282 CompositedLayerMapping* compositedLayerMapping = paintLayer->compositedLayer
Mapping(); |
| 283 |
| 284 ASSERT_TRUE(compositedLayerMapping); |
| 285 |
| 286 EXPECT_FALSE(shouldFlattenTransform(*compositedLayerMapping->mainGraphicsLay
er())); |
| 287 EXPECT_FALSE(shouldFlattenTransform(*compositedLayerMapping->scrollingLayer(
))); |
| 288 EXPECT_TRUE(shouldFlattenTransform(*compositedLayerMapping->scrollingContent
sLayer())); |
| 289 } |
| 290 |
267 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintEmpty) | 291 TEST_F(CompositedLayerMappingTest, InterestRectChangedEnoughToRepaintEmpty) |
268 { | 292 { |
269 IntSize layerSize(1000, 1000); | 293 IntSize layerSize(1000, 1000); |
270 // Both empty means there is nothing to do. | 294 // Both empty means there is nothing to do. |
271 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(), layerS
ize)); | 295 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(), layerS
ize)); |
272 // Going from empty to non-empty means we must re-record because it could be
the first frame after construction or Clear. | 296 // Going from empty to non-empty means we must re-record because it could be
the first frame after construction or Clear. |
273 EXPECT_TRUE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(0, 0, 1, 1
), layerSize)); | 297 EXPECT_TRUE(interestRectChangedEnoughToRepaint(IntRect(), IntRect(0, 0, 1, 1
), layerSize)); |
274 // Going from non-empty to empty is not special-cased. | 298 // Going from non-empty to empty is not special-cased. |
275 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(0, 0, 1, 1), IntRect
(), layerSize)); | 299 EXPECT_FALSE(interestRectChangedEnoughToRepaint(IntRect(0, 0, 1, 1), IntRect
(), layerSize)); |
276 } | 300 } |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 ASSERT_TRUE(target); | 542 ASSERT_TRUE(target); |
519 | 543 |
520 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), recomputeInterestRect(target->layout
Object()->enclosingLayer()->graphicsLayerBacking())); | 544 EXPECT_RECT_EQ(IntRect(0, 0, 200, 200), recomputeInterestRect(target->layout
Object()->enclosingLayer()->graphicsLayerBacking())); |
521 | 545 |
522 subframe->detach(FrameDetachType::Remove); | 546 subframe->detach(FrameDetachType::Remove); |
523 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se
tChild(nullptr); | 547 static_cast<SingleChildFrameLoaderClient*>(document().frame()->client())->se
tChild(nullptr); |
524 document().frame()->host()->decrementSubframeCount(); | 548 document().frame()->host()->decrementSubframeCount(); |
525 } | 549 } |
526 | 550 |
527 } // namespace blink | 551 } // namespace blink |
OLD | NEW |