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

Side by Side Diff: content/browser/web_contents/aura/overscroll_navigation_overlay.cc

Issue 217373003: Dismissing the GestureNav overlay after the first non-empty paint to improve UX/responsiveness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updating unit tests. Created 6 years, 8 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 | « no previous file | content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "content/browser/web_contents/aura/overscroll_navigation_overlay.h" 5 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h"
6 6
7 #include "content/browser/frame_host/navigation_entry_impl.h" 7 #include "content/browser/frame_host/navigation_entry_impl.h"
8 #include "content/browser/renderer_host/render_view_host_impl.h" 8 #include "content/browser/renderer_host/render_view_host_impl.h"
9 #include "content/browser/web_contents/aura/image_window_delegate.h" 9 #include "content/browser/web_contents/aura/image_window_delegate.h"
10 #include "content/browser/web_contents/web_contents_impl.h" 10 #include "content/browser/web_contents/web_contents_impl.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } else { 149 } else {
150 window_slider_.reset(); 150 window_slider_.reset();
151 } 151 }
152 } 152 }
153 153
154 void OverscrollNavigationOverlay::SetupForTesting() { 154 void OverscrollNavigationOverlay::SetupForTesting() {
155 need_paint_update_ = false; 155 need_paint_update_ = false;
156 } 156 }
157 157
158 void OverscrollNavigationOverlay::StopObservingIfDone() { 158 void OverscrollNavigationOverlay::StopObservingIfDone() {
159 // If there is a screenshot displayed in the overlay window, then wait for 159 // Hide this view as soon as there is any non-empty paint notification.
160 // the navigated page to complete loading and some paint update before 160 if ((need_paint_update_ && !received_paint_update_)) {
161 // hiding the overlay.
162 // If there is no screenshot in the overlay window, then hide this view
163 // as soon as there is any new painting notification.
164 if ((need_paint_update_ && !received_paint_update_) ||
165 (image_delegate_->has_image() && !loading_complete_)) {
166 return; 161 return;
167 } 162 }
168 163
169 // If a slide is in progress, then do not destroy the window or the slide. 164 // If a slide is in progress, then do not destroy the window or the slide.
170 if (window_slider_.get() && window_slider_->IsSlideInProgress()) 165 if (window_slider_.get() && window_slider_->IsSlideInProgress())
171 return; 166 return;
172 167
173 scoped_ptr<ui::Layer> layer; 168 scoped_ptr<ui::Layer> layer;
174 if (window_.get()) { 169 if (window_.get()) {
175 layer.reset(window_->AcquireLayer()); 170 layer.reset(window_->AcquireLayer());
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 StopObservingIfDone(); 301 StopObservingIfDone();
307 } 302 }
308 } 303 }
309 304
310 void OverscrollNavigationOverlay::DocumentOnLoadCompletedInMainFrame( 305 void OverscrollNavigationOverlay::DocumentOnLoadCompletedInMainFrame(
311 int32 page_id) { 306 int32 page_id) {
312 // Use the last committed entry rather than the active one, in case a 307 // Use the last committed entry rather than the active one, in case a
313 // pending entry has been created. 308 // pending entry has been created.
314 int committed_entry_id = 309 int committed_entry_id =
315 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); 310 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID();
316 // For the purposes of dismissing the overlay - consider the loading completed 311 // Consider the loading completed once the main frame has loaded.
317 // once the main frame has loaded.
318 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { 312 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) {
sky 2014/04/01 20:10:23 nit: no {}
319 loading_complete_ = true; 313 loading_complete_ = true;
320 StopObservingIfDone();
321 } 314 }
322 } 315 }
323 316
324 void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint(int32 page_id) { 317 void OverscrollNavigationOverlay::DidFirstVisuallyNonEmptyPaint(int32 page_id) {
325 int visible_entry_id = 318 int visible_entry_id =
326 web_contents_->GetController().GetVisibleEntry()->GetUniqueID(); 319 web_contents_->GetController().GetVisibleEntry()->GetUniqueID();
327 if (visible_entry_id == pending_entry_id_ || !pending_entry_id_) { 320 if (visible_entry_id == pending_entry_id_ || !pending_entry_id_) {
328 received_paint_update_ = true; 321 received_paint_update_ = true;
329 StopObservingIfDone(); 322 StopObservingIfDone();
330 } 323 }
331 } 324 }
332 325
333 void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) { 326 void OverscrollNavigationOverlay::DidStopLoading(RenderViewHost* host) {
334 // Use the last committed entry rather than the active one, in case a 327 // Use the last committed entry rather than the active one, in case a
335 // pending entry has been created. 328 // pending entry has been created.
336 int committed_entry_id = 329 int committed_entry_id =
337 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID(); 330 web_contents_->GetController().GetLastCommittedEntry()->GetUniqueID();
338 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) { 331 if (committed_entry_id == pending_entry_id_ || !pending_entry_id_) {
339 loading_complete_ = true; 332 loading_complete_ = true;
340 if (!received_paint_update_) { 333 if (!received_paint_update_) {
341 // Force a repaint after the page is loaded. 334 // Force a repaint after the page is loaded.
342 RenderViewHostImpl* view = static_cast<RenderViewHostImpl*>(host); 335 RenderViewHostImpl* view = static_cast<RenderViewHostImpl*>(host);
343 view->ScheduleComposite(); 336 view->ScheduleComposite();
344 } 337 }
345 StopObservingIfDone();
346 } 338 }
347 } 339 }
348 340
349 bool OverscrollNavigationOverlay::OnMessageReceived( 341 bool OverscrollNavigationOverlay::OnMessageReceived(
350 const IPC::Message& message) { 342 const IPC::Message& message) {
351 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 343 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
352 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message) 344 IPC_BEGIN_MESSAGE_MAP(OverscrollNavigationOverlay, message)
353 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) 345 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect)
354 IPC_END_MESSAGE_MAP() 346 IPC_END_MESSAGE_MAP()
355 return false; 347 return false;
356 } 348 }
357 349
358 } // namespace content 350 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/web_contents/aura/overscroll_navigation_overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698