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

Side by Side Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2823873002: Fixed the paint supression to track only render-blocking stylesheets
Patch Set: Fixed stylesheet check Created 3 years, 7 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 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All
7 * rights reserved. 7 * rights reserved.
8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 8 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
9 * (http://www.torchmobile.com/) 9 * (http://www.torchmobile.com/)
10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 10 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
(...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after
2282 Markers().InvalidateRectsForAllMarkers(); 2282 Markers().InvalidateRectsForAllMarkers();
2283 2283
2284 // The layout system may perform layouts with pending stylesheets. When 2284 // The layout system may perform layouts with pending stylesheets. When
2285 // recording first layout time, we ignore these layouts, since painting is 2285 // recording first layout time, we ignore these layouts, since painting is
2286 // suppressed for them. We're interested in tracking the time of the 2286 // suppressed for them. We're interested in tracking the time of the
2287 // first real or 'paintable' layout. 2287 // first real or 'paintable' layout.
2288 // TODO(esprehn): This doesn't really make sense, why not track the first 2288 // TODO(esprehn): This doesn't really make sense, why not track the first
2289 // beginFrame? This will catch the first layout in a page that does lots 2289 // beginFrame? This will catch the first layout in a page that does lots
2290 // of layout thrashing even though that layout might not be followed by 2290 // of layout thrashing even though that layout might not be followed by
2291 // a paint for many seconds. 2291 // a paint for many seconds.
2292 if (IsRenderingReady() && body() && 2292 if (IsRenderingReady() && body() && !HasPendingRenderBlockingSheets()) {
2293 !GetStyleEngine().HasPendingScriptBlockingSheets()) {
2294 if (!document_timing_.FirstLayout()) 2293 if (!document_timing_.FirstLayout())
2295 document_timing_.MarkFirstLayout(); 2294 document_timing_.MarkFirstLayout();
2296 } 2295 }
2297 2296
2298 root_scroller_controller_->DidUpdateLayout(); 2297 root_scroller_controller_->DidUpdateLayout();
2299 } 2298 }
2300 2299
2301 void Document::ClearFocusedElementSoon() { 2300 void Document::ClearFocusedElementSoon() {
2302 if (!clear_focused_element_timer_.IsActive()) 2301 if (!clear_focused_element_timer_.IsActive())
2303 clear_focused_element_timer_.StartOneShot(0, BLINK_FROM_HERE); 2302 clear_focused_element_timer_.StartOneShot(0, BLINK_FROM_HERE);
2304 } 2303 }
2305 2304
2306 void Document::ClearFocusedElementTimerFired(TimerBase*) { 2305 void Document::ClearFocusedElementTimerFired(TimerBase*) {
2307 UpdateStyleAndLayoutTree(); 2306 UpdateStyleAndLayoutTree();
2308 2307
2309 if (focused_element_ && !focused_element_->IsFocusable()) 2308 if (focused_element_ && !focused_element_->IsFocusable())
2310 focused_element_->blur(); 2309 focused_element_->blur();
2311 } 2310 }
2312 2311
2313 // FIXME: This is a bad idea and needs to be removed eventually. 2312 // FIXME: This is a bad idea and needs to be removed eventually.
2314 // Other browsers load stylesheets before they continue parsing the web page. 2313 // Other browsers load stylesheets before they continue parsing the web page.
2315 // Since we don't, we can run JavaScript code that needs answers before the 2314 // Since we don't, we can run JavaScript code that needs answers before the
2316 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets 2315 // stylesheets are loaded. Doing a layout ignoring the pending stylesheets
2317 // lets us get reasonable answers. The long term solution to this problem is 2316 // lets us get reasonable answers. The long term solution to this problem is
2318 // to instead suspend JavaScript execution. 2317 // to instead suspend JavaScript execution.
2319 void Document::UpdateStyleAndLayoutTreeIgnorePendingStylesheets() { 2318 void Document::UpdateStyleAndLayoutTreeIgnorePendingStylesheets() {
2320 StyleEngine::IgnoringPendingStylesheet ignoring(GetStyleEngine()); 2319 StyleEngine::IgnoringPendingStylesheet ignoring(GetStyleEngine());
2321 2320
2322 if (GetStyleEngine().HasPendingScriptBlockingSheets()) { 2321 if (HasPendingRenderBlockingSheets()) {
2323 // FIXME: We are willing to attempt to suppress painting with outdated style 2322 // FIXME: We are willing to attempt to suppress painting with outdated style
2324 // info only once. Our assumption is that it would be dangerous to try to 2323 // info only once. Our assumption is that it would be dangerous to try to
2325 // stop it a second time, after page content has already been loaded and 2324 // stop it a second time, after page content has already been loaded and
2326 // displayed with accurate style information. (Our suppression involves 2325 // displayed with accurate style information. (Our suppression involves
2327 // blanking the whole page at the moment. If it were more refined, we might 2326 // blanking the whole page at the moment. If it were more refined, we might
2328 // be able to do something better.) It's worth noting though that this 2327 // be able to do something better.) It's worth noting though that this
2329 // entire method is a hack, since what we really want to do is suspend JS 2328 // entire method is a hack, since what we really want to do is suspend JS
2330 // instead of doing a layout with inaccurate information. 2329 // instead of doing a layout with inaccurate information.
2331 HTMLElement* body_element = body(); 2330 HTMLElement* body_element = body();
2332 if (body_element && !body_element->GetLayoutObject() && 2331 if (body_element && !body_element->GetLayoutObject() &&
(...skipping 1715 matching lines...) Expand 10 before | Expand all | Expand 10 after
4048 EnsureStyleResolver().ClearResizedForViewportUnits(); 4047 EnsureStyleResolver().ClearResizedForViewportUnits();
4049 } 4048 }
4050 4049
4051 void Document::StyleResolverMayHaveChanged() { 4050 void Document::StyleResolverMayHaveChanged() {
4052 if (HasNodesWithPlaceholderStyle()) { 4051 if (HasNodesWithPlaceholderStyle()) {
4053 SetNeedsStyleRecalc(kSubtreeStyleChange, 4052 SetNeedsStyleRecalc(kSubtreeStyleChange,
4054 StyleChangeReasonForTracing::Create( 4053 StyleChangeReasonForTracing::Create(
4055 StyleChangeReason::kCleanupPlaceholderStyles)); 4054 StyleChangeReason::kCleanupPlaceholderStyles));
4056 } 4055 }
4057 4056
4058 if (DidLayoutWithPendingStylesheets() && 4057 if (DidLayoutWithPendingStylesheets() && !HasPendingRenderBlockingSheets()) {
4059 !GetStyleEngine().HasPendingScriptBlockingSheets()) {
4060 // We need to manually repaint because we avoid doing all repaints in layout 4058 // We need to manually repaint because we avoid doing all repaints in layout
4061 // or style recalc while sheets are still loading to avoid FOUC. 4059 // or style recalc while sheets are still loading to avoid FOUC.
4062 pending_sheet_layout_ = kIgnoreLayoutWithPendingSheets; 4060 pending_sheet_layout_ = kIgnoreLayoutWithPendingSheets;
4063 4061
4064 DCHECK(!GetLayoutViewItem().IsNull() || ImportsController()); 4062 DCHECK(!GetLayoutViewItem().IsNull() || ImportsController());
4065 if (!GetLayoutViewItem().IsNull()) 4063 if (!GetLayoutViewItem().IsNull())
4066 GetLayoutViewItem().InvalidatePaintForViewAndCompositedLayers(); 4064 GetLayoutViewItem().InvalidatePaintForViewAndCompositedLayers();
4067 } 4065 }
4068 } 4066 }
4069 4067
(...skipping 2358 matching lines...) Expand 10 before | Expand all | Expand 10 after
6428 // change active state. 6426 // change active state.
6429 if (element == ancestor_element) 6427 if (element == ancestor_element)
6430 saw_common_ancestor = true; 6428 saw_common_ancestor = true;
6431 if (allow_active_changes) 6429 if (allow_active_changes)
6432 element->SetActive(true); 6430 element->SetActive(true);
6433 if (!saw_common_ancestor || element == hover_element_) 6431 if (!saw_common_ancestor || element == hover_element_)
6434 element->SetHovered(true); 6432 element->SetHovered(true);
6435 } 6433 }
6436 } 6434 }
6437 6435
6436 bool Document::HasPendingRenderBlockingSheets() const {
6437 if (RuntimeEnabledFeatures::cssInBodyDoesNotBlockPaintEnabled())
6438 return style_engine_->HasPendingRenderBlockingSheets();
6439 return style_engine_->HasPendingScriptBlockingSheets();
6440 }
6441
6438 bool Document::HaveScriptBlockingStylesheetsLoaded() const { 6442 bool Document::HaveScriptBlockingStylesheetsLoaded() const {
6439 return style_engine_->HaveScriptBlockingStylesheetsLoaded(); 6443 return style_engine_->HaveScriptBlockingStylesheetsLoaded();
6440 } 6444 }
6441 6445
6442 bool Document::HaveRenderBlockingStylesheetsLoaded() const { 6446 bool Document::HaveRenderBlockingStylesheetsLoaded() const {
6443 if (RuntimeEnabledFeatures::cssInBodyDoesNotBlockPaintEnabled()) 6447 if (RuntimeEnabledFeatures::cssInBodyDoesNotBlockPaintEnabled())
6444 return style_engine_->HaveRenderBlockingStylesheetsLoaded(); 6448 return style_engine_->HaveRenderBlockingStylesheetsLoaded();
6445 return style_engine_->HaveScriptBlockingStylesheetsLoaded(); 6449 return style_engine_->HaveScriptBlockingStylesheetsLoaded();
6446 } 6450 }
6447 6451
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
6790 } 6794 }
6791 6795
6792 void showLiveDocumentInstances() { 6796 void showLiveDocumentInstances() {
6793 WeakDocumentSet& set = liveDocumentSet(); 6797 WeakDocumentSet& set = liveDocumentSet();
6794 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 6798 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
6795 for (blink::Document* document : set) 6799 for (blink::Document* document : set)
6796 fprintf(stderr, "- Document %p URL: %s\n", document, 6800 fprintf(stderr, "- Document %p URL: %s\n", document,
6797 document->Url().GetString().Utf8().data()); 6801 document->Url().GetString().Utf8().data());
6798 } 6802 }
6799 #endif 6803 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/web/tests/WebMeaningfulLayoutsTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698