Changeset 141039 in webkit
- Timestamp:
- Jan 28, 2013 8:16:56 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 13 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r141038 r141039 1 2013-01-28 Simon Fraser <simon.fraser@apple.com> 2 3 position:fixed that doesn't render any content should not force compositing 4 https://bugs.webkit.org/show_bug.cgi?id=108112 5 6 Reviewed by Beth Dakin. 7 8 Change tests to put a background color on position:fixed elements that need to be composited. 9 New test with an empty fixed position element. 10 11 * compositing/layer-creation/fixed-position-change-out-of-view-in-view.html: 12 * compositing/layer-creation/fixed-position-no-content-expected.txt: Added. 13 * compositing/layer-creation/fixed-position-no-content.html: Copied from LayoutTests/compositing/layer-creation/fixed-position-out-of-view.html. 14 * compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html: 15 * compositing/layer-creation/fixed-position-out-of-view-scaled.html: 16 * compositing/layer-creation/fixed-position-out-of-view.html: 17 * platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex.html: 18 * platform/mac/tiled-drawing/fixed/fixed-position-out-of-view.html: 19 1 20 2013-01-28 Keishi Hattori <keishi@webkit.org> 2 21 -
trunk/LayoutTests/compositing/layer-creation/fixed-position-change-out-of-view-in-view.html
r140593 r141039 3 3 <html> 4 4 <head> 5 <style> 6 #fixed1, #fixed2 { 7 background-color: silver; 8 } 9 </style> 5 10 <script type="text/javascript"> 6 11 if (window.testRunner && window.internals) { -
trunk/LayoutTests/compositing/layer-creation/fixed-position-no-content.html
r141038 r141039 6 6 .fixed { 7 7 position: fixed; 8 width: 10px; 9 height: 10px; 8 width: 50px; 9 height: 50px; 10 } 11 12 .absolute { 13 position: absolute; 14 top: 40px; 15 left: 40px; 16 height: 100px; 17 width: 100px; 18 background-color: gray; 10 19 } 11 20 </style> … … 27 36 <body> 28 37 <div style="height: 1000px"> 38 <p>There should be no layers.</p> 29 39 <pre id="layertree"></pre> 30 40 </div> 31 41 32 <!-- Neither of the following elements gets its own layer. --> 33 <div class="fixed" style="z-index: -1"></div> 34 <div class="fixed" style="z-index: -1; top: -100px"></div> 35 <div class="fixed" style="z-index: -1; top: 0px; left: 1000px"></div> 36 37 <!-- This element gets its own layer because it intersects with the viewport. --> 38 <div class="fixed" style="z-index: -1; top: 0px; left: 0px"></div> 42 <!-- This should not be composited --> 43 <div class="fixed" style="top: 10px; left: 10px"></div> 44 <!-- And this should not be promoted into a layer --> 45 <div class="absolute"></div> 39 46 </body> 40 47 </html> -
trunk/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled-scroll.html
r138840 r141039 7 7 width: 10px; 8 8 height: 10px; 9 background-color: silver; 9 10 } 10 11 </style> -
trunk/LayoutTests/compositing/layer-creation/fixed-position-out-of-view-scaled.html
r138840 r141039 7 7 width: 10px; 8 8 height: 10px; 9 background-color: silver; 9 10 } 10 11 </style> -
trunk/LayoutTests/compositing/layer-creation/fixed-position-out-of-view.html
r138840 r141039 8 8 width: 10px; 9 9 height: 10px; 10 background-color: silver; 10 11 } 11 12 </style> -
trunk/LayoutTests/platform/mac/tiled-drawing/fixed/fixed-position-out-of-view-negative-zindex.html
r133536 r141039 8 8 width: 10px; 9 9 height: 10px; 10 background-color: silver; 10 11 } 11 12 </style> -
trunk/LayoutTests/platform/mac/tiled-drawing/fixed/fixed-position-out-of-view.html
r133536 r141039 8 8 width: 10px; 9 9 height: 10px; 10 background-color: silver; 10 11 } 11 12 </style> -
trunk/Source/WebCore/ChangeLog
r141036 r141039 1 2013-01-28 Simon Fraser <simon.fraser@apple.com> 2 3 position:fixed that doesn't render any content should not force compositing 4 https://bugs.webkit.org/show_bug.cgi?id=108112 5 6 Reviewed by Beth Dakin. 7 8 It's not uncommon for pages to have position:fixed elements with no content. 9 When these are behind other elements, they can cause those other elements 10 to become composited, using lots of backing store memory. 11 12 Optimize for the case where the position:fixed element has no rendered 13 content and no children by not making it composited in that case. 14 15 Test: compositing/layer-creation/fixed-position-no-content.html 16 17 * rendering/RenderLayer.cpp: 18 (WebCore::RenderLayer::hasNonEmptyChildRenderers): Moved from RenderLayerBacking.cpp. 19 (WebCore::hasBoxDecorations): Ditto. 20 (WebCore::RenderLayer::hasBoxDecorationsOrBackground): Ditto. 21 (WebCore::RenderLayer::hasVisibleBoxDecorations): Check for visibility:visible, box decorations and 22 overflow controls. 23 (WebCore::RenderLayer::isVisuallyNonEmpty): Returns true if this layer has some visible 24 representation. 25 * rendering/RenderLayer.h: 26 * rendering/RenderLayerBacking.cpp: 27 (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): Need to call updateDescendantDependentFlags() 28 to ensure that the visibility flags are up to date. 29 (WebCore::RenderLayerBacking::updateDrawsContent): Call RenderLayer::hasBoxDecorationsOrBackground() now. 30 (WebCore::RenderLayerBacking::paintsBoxDecorations): Call RenderLayer::hasVisibleBoxDecorations() now. 31 (WebCore::RenderLayerBacking::paintsChildren): Call RenderLayer::hasNonEmptyChildRenderers(). 32 (WebCore::RenderLayerBacking::isSimpleContainerCompositingLayer): Whitespace. 33 (WebCore::RenderLayerBacking::containsPaintedContent): Call RenderLayer::hasBoxDecorationsOrBackground(). 34 (WebCore::RenderLayerBacking::isDirectlyCompositedImage): Ditto. 35 * rendering/RenderLayerBacking.h: 36 (RenderLayerBacking): 37 * rendering/RenderLayerCompositor.cpp: 38 (WebCore::RenderLayerCompositor::requiresCompositingForPosition): If the layer has no content to paint, 39 or visible descendant layers, then don't make it composited. 40 1 41 2013-01-28 Simon Fraser <simon.fraser@apple.com> 2 42 -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r140999 r141039 5405 5405 } 5406 5406 5407 bool RenderLayer::hasNonEmptyChildRenderers() const 5408 { 5409 // Some HTML can cause whitespace text nodes to have renderers, like: 5410 // <div> 5411 // <img src=...> 5412 // </div> 5413 // so test for 0x0 RenderTexts here 5414 for (RenderObject* child = renderer()->firstChild(); child; child = child->nextSibling()) { 5415 if (!child->hasLayer()) { 5416 if (child->isRenderInline() || !child->isBox()) 5417 return true; 5418 5419 if (toRenderBox(child)->width() > 0 || toRenderBox(child)->height() > 0) 5420 return true; 5421 } 5422 } 5423 return false; 5424 } 5425 5426 static bool hasBoxDecorations(const RenderStyle* style) 5427 { 5428 return style->hasBorder() || style->hasBorderRadius() || style->hasOutline() || style->hasAppearance() || style->boxShadow() || style->hasFilter(); 5429 } 5430 5431 bool RenderLayer::hasBoxDecorationsOrBackground() const 5432 { 5433 return hasBoxDecorations(renderer()->style()) || renderer()->hasBackground(); 5434 } 5435 5436 bool RenderLayer::hasVisibleBoxDecorations() const 5437 { 5438 if (!hasVisibleContent()) 5439 return false; 5440 5441 return hasBoxDecorationsOrBackground() || hasOverflowControls(); 5442 } 5443 5444 bool RenderLayer::isVisuallyNonEmpty() const 5445 { 5446 ASSERT(!m_visibleDescendantStatusDirty); 5447 5448 if (hasVisibleContent() && hasNonEmptyChildRenderers()) 5449 return true; 5450 5451 if (renderer()->isReplaced() || renderer()->hasMask()) 5452 return true; 5453 5454 if (hasVisibleBoxDecorations()) 5455 return true; 5456 5457 return false; 5458 } 5459 5407 5460 void RenderLayer::updateStackingContextsAfterStyleChange(const RenderStyle* oldStyle) 5408 5461 { -
trunk/Source/WebCore/rendering/RenderLayer.h
r140999 r141039 474 474 void dirtyVisibleContentStatus(); 475 475 476 bool hasBoxDecorationsOrBackground() const; 477 bool hasVisibleBoxDecorations() const; 478 // Returns true if this layer has visible content (ignoring any child layers). 479 bool isVisuallyNonEmpty() const; 480 // True if this layer container renderers that paint. 481 bool hasNonEmptyChildRenderers() const; 482 476 483 // FIXME: We should ASSERT(!m_hasSelfPaintingLayerDescendantDirty); here but we hit the same bugs as visible content above. 477 484 // Part of the issue is with subtree relayout: we don't check if our ancestors have some descendant flags dirty, missing some updates. -
trunk/Source/WebCore/rendering/RenderLayerBacking.cpp
r140873 r141039 77 77 using namespace HTMLNames; 78 78 79 static bool hasBoxDecorations(const RenderStyle*);80 static bool hasBoxDecorationsOrBackground(const RenderObject*);81 79 static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle*); 82 80 static IntRect clipBox(RenderBox* renderer); … … 475 473 RenderObject* renderer = this->renderer(); 476 474 475 m_owningLayer->updateDescendantDependentFlags(); 477 476 m_owningLayer->updateZOrderLists(); 478 477 … … 913 912 // m_scrollingLayer never has backing store. 914 913 // m_scrollingContentsLayer only needs backing store if the scrolled contents need to paint. 915 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent() && hasBoxDecorationsOrBackground(renderer());914 bool hasNonScrollingPaintedContent = m_owningLayer->hasVisibleContent() && m_owningLayer->hasBoxDecorationsOrBackground(); 916 915 m_graphicsLayer->setDrawsContent(hasNonScrollingPaintedContent); 917 916 … … 1285 1284 } 1286 1285 1287 static bool hasBoxDecorationsOrBackground(const RenderObject* renderer)1288 {1289 return hasBoxDecorations(renderer->style()) || renderer->hasBackground();1290 }1291 1292 1286 static bool hasBoxDecorationsOrBackgroundImage(const RenderStyle* style) 1293 1287 { … … 1366 1360 bool RenderLayerBacking::paintsBoxDecorations() const 1367 1361 { 1368 if (!m_owningLayer->hasVisibleContent()) 1369 return false; 1370 1371 if (!hasBoxDecorationsOrBackground(renderer())) 1362 if (!m_owningLayer->hasVisibleBoxDecorations()) 1372 1363 return false; 1373 1364 … … 1375 1366 return true; 1376 1367 1377 if (m_owningLayer->hasOverflowControls())1378 return true;1379 1380 1368 return false; 1381 1369 } … … 1383 1371 bool RenderLayerBacking::paintsChildren() const 1384 1372 { 1385 if (m_owningLayer->hasVisibleContent() && containsNonEmptyRenderers())1373 if (m_owningLayer->hasVisibleContent() && m_owningLayer->hasNonEmptyChildRenderers()) 1386 1374 return true; 1387 1375 … … 1407 1395 1408 1396 if (renderObject->isReplaced() && !isCompositedPlugin(renderObject)) 1409 1397 return false; 1410 1398 1411 1399 if (paintsBoxDecorations() || paintsChildren()) … … 1440 1428 } 1441 1429 1442 bool RenderLayerBacking::containsNonEmptyRenderers() const1443 {1444 // Some HTML can cause whitespace text nodes to have renderers, like:1445 // <div>1446 // <img src=...>1447 // </div>1448 // so test for 0x0 RenderTexts here1449 for (RenderObject* child = renderer()->firstChild(); child; child = child->nextSibling()) {1450 if (!child->hasLayer()) {1451 if (child->isRenderInline() || !child->isBox())1452 return true;1453 1454 if (toRenderBox(child)->width() > 0 || toRenderBox(child)->height() > 0)1455 return true;1456 }1457 }1458 return false;1459 }1460 1461 1430 // Conservative test for having no rendered children. 1462 1431 bool RenderLayerBacking::hasVisibleNonCompositingDescendantLayers() const … … 1517 1486 #if ENABLE(VIDEO) 1518 1487 if (renderer()->isVideo() && toRenderVideo(renderer())->shouldDisplayVideo()) 1519 return hasBoxDecorationsOrBackground(renderer());1488 return m_owningLayer->hasBoxDecorationsOrBackground(); 1520 1489 #endif 1521 1490 #if PLATFORM(MAC) && USE(CA) && (PLATFORM(IOS) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1070) 1522 1491 #elif ENABLE(WEBGL) || ENABLE(ACCELERATED_2D_CANVAS) 1523 1492 if (isAcceleratedCanvas(renderer())) 1524 return hasBoxDecorationsOrBackground(renderer());1493 return m_owningLayer->hasBoxDecorationsOrBackground(); 1525 1494 #endif 1526 1495 … … 1534 1503 RenderObject* renderObject = renderer(); 1535 1504 1536 if (!renderObject->isImage() || hasBoxDecorationsOrBackground(renderObject) || renderObject->hasClip())1505 if (!renderObject->isImage() || m_owningLayer->hasBoxDecorationsOrBackground() || renderObject->hasClip()) 1537 1506 return false; 1538 1507 -
trunk/Source/WebCore/rendering/RenderLayerBacking.h
r140291 r141039 153 153 154 154 void updateDebugIndicators(bool showBorder, bool showRepaintCounter); 155 155 156 156 // GraphicsLayerClient interface 157 157 virtual bool shouldUseTileCache(const GraphicsLayer*) const OVERRIDE; … … 257 257 void updateContentsRect(bool isSimpleContainer); 258 258 259 bool containsNonEmptyRenderers() const;260 259 bool hasVisibleNonCompositingDescendantLayers() const; 261 260 -
trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp
r140758 r141039 2078 2078 } 2079 2079 } 2080 2081 bool paintsContent = layer->isVisuallyNonEmpty() || layer->hasVisibleDescendant(); 2082 if (!paintsContent) { 2083 // isVisuallyNonEmpty() depends on layout. 2084 m_reevaluateCompositingAfterLayout = true; 2085 return false; 2086 } 2080 2087 2081 2088 return true;
Note: See TracChangeset
for help on using the changeset viewer.