Skip to content

Commit

Permalink
Disable subsequence caching when didLayoutWithPendingStylesheets is t…
Browse files Browse the repository at this point in the history
…rue.

BUG=593758

Review URL: https://codereview.chromium.org/1823353003

Cr-Commit-Position: refs/heads/master@{#382791}
  • Loading branch information
chrishtr authored and Commit bot committed Mar 23, 2016
1 parent 16099ee commit 27c2539
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
12 changes: 9 additions & 3 deletions third_party/WebKit/Source/core/paint/PaintLayerPainter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@

namespace blink {

static inline bool shouldSuppressPaintingLayer(PaintLayer* layer)
static inline bool shouldSuppressPaintingLayer(const PaintLayer& layer)
{
// Avoid painting descendants of the root layer when stylesheets haven't loaded. This eliminates FOUC.
// It's ok not to draw, because later on, when all the stylesheets do load, updateStyleSelector on the Document
// will do a full paintInvalidationForWholeLayoutObject().
if (layer->layoutObject()->document().didLayoutWithPendingStylesheets() && !layer->isRootLayer() && !layer->layoutObject()->isDocumentElement())
if (layer.layoutObject()->document().didLayoutWithPendingStylesheets() && !layer.isRootLayer() && !layer.layoutObject()->isDocumentElement())
return true;

return false;
Expand Down Expand Up @@ -77,7 +77,7 @@ PaintLayerPainter::PaintResult PaintLayerPainter::paintLayer(GraphicsContext& co
if (!m_paintLayer.isSelfPaintingLayer() && !m_paintLayer.hasSelfPaintingLayerDescendant())
return FullyPainted;

if (shouldSuppressPaintingLayer(&m_paintLayer))
if (shouldSuppressPaintingLayer(m_paintLayer))
return FullyPainted;

if (m_paintLayer.layoutObject()->isLayoutView() && toLayoutView(m_paintLayer.layoutObject())->frameView()->shouldThrottleRendering())
Expand Down Expand Up @@ -209,6 +209,12 @@ static bool shouldCreateSubsequence(const PaintLayer& paintLayer, GraphicsContex
if (!PaintLayerStackingNodeIterator(*paintLayer.stackingNode(), AllChildren).next())
return false;

// When in FOUC-avoidance mode, don't cache any subsequences, to avoid having
// to invalidate all of them when leaving this mode. There is an early-out in BlockPainter::paintContents that may result
// in nothing getting painted in thos mode, in addition to early-out logic in PaintLayerPainter.
if (paintLayer.layoutObject()->document().didLayoutWithPendingStylesheets())
return false;

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "core/dom/Document.h"
#include "core/html/HTMLIFrameElement.h"
#include "core/layout/LayoutView.h"
#include "core/paint/PaintLayer.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "web/tests/sim/SimCompositor.h"
#include "web/tests/sim/SimDisplayItemList.h"
Expand Down Expand Up @@ -270,6 +272,14 @@ TEST_F(DocumentLoadingRenderingTest, ShouldNotPaintIframeContentWithPendingSheet
// invalid paint so we shouldn't draw any text.
EXPECT_FALSE(frame2.containsText());

LayoutView* iframeLayoutView = childFrame->contentDocument()->layoutView();
const DisplayItemList& displayItemList = iframeLayoutView->layer()->graphicsLayerBacking()->getPaintController().getDisplayItemList();
// Check that the DisplayItemList has no subsequene caching markers. These are not allowed in pending-style-sheets mode
// since otherwise caching would be incorrect.
ASSERT_EQ(2u, displayItemList.size());
EXPECT_EQ(DisplayItem::DocumentBackground, displayItemList[0].getType());
EXPECT_EQ(DisplayItem::BoxDecorationBackground, displayItemList[1].getType());

// 1 for the main frame background (white),
// 1 for the iframe background (pink)
// 1 for the composited transform layer in the iframe (green).
Expand Down

0 comments on commit 27c2539

Please sign in to comment.