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

Unified Diff: chrome/renderer/render_view.cc

Issue 3397008: Skip screen update when the WebView isn't ready to paint. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: took the feedback Created 10 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/render_view.cc
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 95da38238263431dacd9c411746067adf1a5382c..80dcacfe82857fc2616d81724ffe48f9cceebed6 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -5806,6 +5806,42 @@ bool RenderView::IsNonLocalTopLevelNavigation(
return false;
}
+bool RenderView::IsReadyToPaint() const {
+ if (!webview() || !webview()->mainFrame())
+ return false;
+
+ WebDocument doc = webview()->mainFrame()->document();
+
+ // There is no way to detect a paint readiness for non-(X)HTML page;
+ // Just allows to paint.
+ if (!doc.isHTMLDocument() && !doc.isXHTMLDocument())
+ return true;
+
+ // The are some possible strategy to detect readiness:
+ // - (1) Gets ready when the downloading started, or
+ // - (2) Gets ready when the <head> contents are loaded, or
+ // - (3) Gets ready when the whole HTML loaded, or
+ // - (4) Gets ready when (3) plus whole external CSS loaded
+ //
+ // And here is a trade-off.
+ // - Former can start page rendering earlier.
+ // - Later can save page reflow and re-styling, thus avoid flickering.
+ //
+ // Current choice is (2).
+ // More intelligent design might be desirable though.
+
+ // If you have <body>, It is expected that preceding <head> contents
+ // including inline <style> and <script> elements are totally loaded.
+ // Also note that:
+ // - WebKit generates <body> for images and plugins.
+ // - WebKit generates missing <body> for ill-formed HTMLs.
+ // - A <frameset> can be returned for body().
+ if ((doc.isNull() || doc.body().isNull()))
+ return false;
+
+ return true;
+}
+
void RenderView::OnOpenFileSystemRequestComplete(
int request_id, bool accepted, const string16& name,
const string16& root_path) {
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698