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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « chrome/renderer/render_view.h ('k') | chrome/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/renderer/render_view.h" 5 #include "chrome/renderer/render_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 5788 matching lines...) Expand 10 before | Expand all | Expand 10 after
5799 return true; 5799 return true;
5800 } 5800 }
5801 } 5801 }
5802 5802
5803 if (url.GetOrigin() != GURL(opener->url()).GetOrigin()) 5803 if (url.GetOrigin() != GURL(opener->url()).GetOrigin())
5804 return true; 5804 return true;
5805 } 5805 }
5806 return false; 5806 return false;
5807 } 5807 }
5808 5808
5809 bool RenderView::IsReadyToPaint() const {
5810 if (!webview() || !webview()->mainFrame())
5811 return false;
5812
5813 WebDocument doc = webview()->mainFrame()->document();
5814
5815 // There is no way to detect a paint readiness for non-(X)HTML page;
5816 // Just allows to paint.
5817 if (!doc.isHTMLDocument() && !doc.isXHTMLDocument())
5818 return true;
5819
5820 // The are some possible strategy to detect readiness:
5821 // - (1) Gets ready when the downloading started, or
5822 // - (2) Gets ready when the <head> contents are loaded, or
5823 // - (3) Gets ready when the whole HTML loaded, or
5824 // - (4) Gets ready when (3) plus whole external CSS loaded
5825 //
5826 // And here is a trade-off.
5827 // - Former can start page rendering earlier.
5828 // - Later can save page reflow and re-styling, thus avoid flickering.
5829 //
5830 // Current choice is (2).
5831 // More intelligent design might be desirable though.
5832
5833 // If you have <body>, It is expected that preceding <head> contents
5834 // including inline <style> and <script> elements are totally loaded.
5835 // Also note that:
5836 // - WebKit generates <body> for images and plugins.
5837 // - WebKit generates missing <body> for ill-formed HTMLs.
5838 // - A <frameset> can be returned for body().
5839 if ((doc.isNull() || doc.body().isNull()))
5840 return false;
5841
5842 return true;
5843 }
5844
5809 void RenderView::OnOpenFileSystemRequestComplete( 5845 void RenderView::OnOpenFileSystemRequestComplete(
5810 int request_id, bool accepted, const string16& name, 5846 int request_id, bool accepted, const string16& name,
5811 const string16& root_path) { 5847 const string16& root_path) {
5812 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup( 5848 PendingOpenFileSystem* request = pending_file_system_requests_.Lookup(
5813 request_id); 5849 request_id);
5814 DCHECK(request); 5850 DCHECK(request);
5815 if (accepted) 5851 if (accepted)
5816 request->callbacks->didOpenFileSystem(name, root_path); 5852 request->callbacks->didOpenFileSystem(name, root_path);
5817 else 5853 else
5818 request->callbacks->didFail(WebKit::WebFileErrorSecurity); 5854 request->callbacks->didFail(WebKit::WebFileErrorSecurity);
5819 request->callbacks = NULL; 5855 request->callbacks = NULL;
5820 pending_file_system_requests_.Remove(request_id); 5856 pending_file_system_requests_.Remove(request_id);
5821 } 5857 }
5822 5858
5823 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code, 5859 void RenderView::OnAsyncFileOpened(base::PlatformFileError error_code,
5824 IPC::PlatformFileForTransit file_for_transit, 5860 IPC::PlatformFileForTransit file_for_transit,
5825 int message_id) { 5861 int message_id) {
5826 pepper_delegate_.OnAsyncFileOpened( 5862 pepper_delegate_.OnAsyncFileOpened(
5827 error_code, 5863 error_code,
5828 IPC::PlatformFileForTransitToPlatformFile(file_for_transit), 5864 IPC::PlatformFileForTransitToPlatformFile(file_for_transit),
5829 message_id); 5865 message_id);
5830 } 5866 }
OLDNEW
« 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