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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 153913004: gesture-nav: Use a WebContentsObserver to more reliably dismiss the navigation overlay. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 10 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 accept_return_character_(false), 479 accept_return_character_(false),
480 last_output_surface_id_(0), 480 last_output_surface_id_(0),
481 pending_delegated_ack_count_(0), 481 pending_delegated_ack_count_(0),
482 skipped_frames_(false), 482 skipped_frames_(false),
483 last_swapped_surface_scale_factor_(1.f), 483 last_swapped_surface_scale_factor_(1.f),
484 paint_canvas_(NULL), 484 paint_canvas_(NULL),
485 synthetic_move_sent_(false), 485 synthetic_move_sent_(false),
486 accelerated_compositing_state_changed_(false), 486 accelerated_compositing_state_changed_(false),
487 can_lock_compositor_(YES), 487 can_lock_compositor_(YES),
488 cursor_visibility_state_in_renderer_(UNKNOWN), 488 cursor_visibility_state_in_renderer_(UNKNOWN),
489 paint_observer_(NULL),
490 touch_editing_client_(NULL), 489 touch_editing_client_(NULL),
491 delegated_frame_evictor_(new DelegatedFrameEvictor(this)), 490 delegated_frame_evictor_(new DelegatedFrameEvictor(this)),
492 weak_ptr_factory_(this) { 491 weak_ptr_factory_(this) {
493 host_->SetView(this); 492 host_->SetView(this);
494 window_observer_.reset(new WindowObserver(this)); 493 window_observer_.reset(new WindowObserver(this));
495 aura::client::SetTooltipText(window_, &tooltip_); 494 aura::client::SetTooltipText(window_, &tooltip_);
496 aura::client::SetActivationDelegate(window_, this); 495 aura::client::SetActivationDelegate(window_, this);
497 aura::client::SetActivationChangeObserver(window_, this); 496 aura::client::SetActivationChangeObserver(window_, this);
498 aura::client::SetFocusChangeObserver(window_, this); 497 aura::client::SetFocusChangeObserver(window_, this);
499 gfx::Screen::GetScreenFor(window_)->AddObserver(this); 498 gfx::Screen::GetScreenFor(window_)->AddObserver(this);
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 909
911 void RenderWidgetHostViewAura::UpdateCursor(const WebCursor& cursor) { 910 void RenderWidgetHostViewAura::UpdateCursor(const WebCursor& cursor) {
912 current_cursor_ = cursor; 911 current_cursor_ = cursor;
913 const gfx::Display display = gfx::Screen::GetScreenFor(window_)-> 912 const gfx::Display display = gfx::Screen::GetScreenFor(window_)->
914 GetDisplayNearestWindow(window_); 913 GetDisplayNearestWindow(window_);
915 current_cursor_.SetDisplayInfo(display); 914 current_cursor_.SetDisplayInfo(display);
916 UpdateCursorIfOverSelf(); 915 UpdateCursorIfOverSelf();
917 } 916 }
918 917
919 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) { 918 void RenderWidgetHostViewAura::SetIsLoading(bool is_loading) {
920 if (is_loading_ && !is_loading && paint_observer_)
921 paint_observer_->OnPageLoadComplete();
922 is_loading_ = is_loading; 919 is_loading_ = is_loading;
923 UpdateCursorIfOverSelf(); 920 UpdateCursorIfOverSelf();
924 } 921 }
925 922
926 void RenderWidgetHostViewAura::TextInputTypeChanged( 923 void RenderWidgetHostViewAura::TextInputTypeChanged(
927 ui::TextInputType type, 924 ui::TextInputType type,
928 ui::TextInputMode input_mode, 925 ui::TextInputMode input_mode,
929 bool can_compose_inline) { 926 bool can_compose_inline) {
930 if (text_input_type_ != type || 927 if (text_input_type_ != type ||
931 text_input_mode_ != input_mode || 928 text_input_mode_ != input_mode ||
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1490 window_->layer()->SetShowDelegatedContent(frame_provider_.get(), 1487 window_->layer()->SetShowDelegatedContent(frame_provider_.get(),
1491 frame_size_in_dip); 1488 frame_size_in_dip);
1492 } else { 1489 } else {
1493 frame_provider_->SetFrameData(frame_data.Pass()); 1490 frame_provider_->SetFrameData(frame_data.Pass());
1494 } 1491 }
1495 } 1492 }
1496 released_front_lock_ = NULL; 1493 released_front_lock_ = NULL;
1497 current_frame_size_ = frame_size_in_dip; 1494 current_frame_size_ = frame_size_in_dip;
1498 CheckResizeLock(); 1495 CheckResizeLock();
1499 1496
1500 if (paint_observer_)
1501 paint_observer_->OnUpdateCompositorContent();
1502 window_->SchedulePaintInRect(damage_rect_in_dip); 1497 window_->SchedulePaintInRect(damage_rect_in_dip);
1503 1498
1504 pending_delegated_ack_count_++; 1499 pending_delegated_ack_count_++;
1505 1500
1506 ui::Compositor* compositor = GetCompositor(); 1501 ui::Compositor* compositor = GetCompositor();
1507 if (!compositor) { 1502 if (!compositor) {
1508 SendDelegatedFrameAck(output_surface_id); 1503 SendDelegatedFrameAck(output_surface_id);
1509 } else { 1504 } else {
1510 for (size_t i = 0; i < latency_info.size(); i++) 1505 for (size_t i = 0; i < latency_info.size(); i++)
1511 compositor->SetLatencyInfo(latency_info[i]); 1506 compositor->SetLatencyInfo(latency_info[i]);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
1606 1601
1607 ui::Compositor* compositor = GetCompositor(); 1602 ui::Compositor* compositor = GetCompositor();
1608 if (compositor) { 1603 if (compositor) {
1609 for (size_t i = 0; i < latency_info.size(); i++) 1604 for (size_t i = 0; i < latency_info.size(); i++)
1610 compositor->SetLatencyInfo(latency_info[i]); 1605 compositor->SetLatencyInfo(latency_info[i]);
1611 AddOnCommitCallbackAndDisableLocks( 1606 AddOnCommitCallbackAndDisableLocks(
1612 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck, 1607 base::Bind(&RenderWidgetHostViewAura::SendSoftwareFrameAck,
1613 AsWeakPtr(), 1608 AsWeakPtr(),
1614 output_surface_id)); 1609 output_surface_id));
1615 } 1610 }
1616 if (paint_observer_)
1617 paint_observer_->OnUpdateCompositorContent();
1618 DidReceiveFrameFromRenderer(); 1611 DidReceiveFrameFromRenderer();
1619 1612
1620 software_frame_manager_->SwapToNewFrameComplete(!host_->is_hidden()); 1613 software_frame_manager_->SwapToNewFrameComplete(!host_->is_hidden());
1621 } 1614 }
1622 1615
1623 void RenderWidgetHostViewAura::SendSoftwareFrameAck(uint32 output_surface_id) { 1616 void RenderWidgetHostViewAura::SendSoftwareFrameAck(uint32 output_surface_id) {
1624 unsigned software_frame_id = 0; 1617 unsigned software_frame_id = 0;
1625 if (released_software_frame_ && 1618 if (released_software_frame_ &&
1626 released_software_frame_->output_surface_id == output_surface_id) { 1619 released_software_frame_->output_surface_id == output_surface_id) {
1627 software_frame_id = released_software_frame_->frame_id; 1620 software_frame_id = released_software_frame_->frame_id;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
1776 surface_size_in_pixel.height() - 1769 surface_size_in_pixel.height() -
1777 damage_rect.y() - damage_rect.height(), 1770 damage_rect.y() - damage_rect.height(),
1778 damage_rect.width(), 1771 damage_rect.width(),
1779 damage_rect.height())); 1772 damage_rect.height()));
1780 1773
1781 // Damage may not have been DIP aligned, so inflate damage to compensate 1774 // Damage may not have been DIP aligned, so inflate damage to compensate
1782 // for any round-off error. 1775 // for any round-off error.
1783 rect_to_paint.Inset(-1, -1); 1776 rect_to_paint.Inset(-1, -1);
1784 rect_to_paint.Intersect(window_->bounds()); 1777 rect_to_paint.Intersect(window_->bounds());
1785 1778
1786 if (paint_observer_)
1787 paint_observer_->OnUpdateCompositorContent();
1788 window_->SchedulePaintInRect(rect_to_paint); 1779 window_->SchedulePaintInRect(rect_to_paint);
1789 for (size_t i = 0; i < latency_info.size(); i++) 1780 for (size_t i = 0; i < latency_info.size(); i++)
1790 compositor->SetLatencyInfo(latency_info[i]); 1781 compositor->SetLatencyInfo(latency_info[i]);
1791 } 1782 }
1792 1783
1793 SwapBuffersCompleted(ack_callback, previous_texture); 1784 SwapBuffersCompleted(ack_callback, previous_texture);
1794 } 1785 }
1795 1786
1796 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer( 1787 void RenderWidgetHostViewAura::AcceleratedSurfacePostSubBuffer(
1797 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel, 1788 const GpuHostMsg_AcceleratedSurfacePostSubBuffer_Params& params_in_pixel,
(...skipping 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
2606 2597
2607 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { 2598 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) {
2608 bool has_backing_store = !!host_->GetBackingStore(false); 2599 bool has_backing_store = !!host_->GetBackingStore(false);
2609 if (has_backing_store) { 2600 if (has_backing_store) {
2610 paint_canvas_ = canvas; 2601 paint_canvas_ = canvas;
2611 BackingStoreAura* backing_store = static_cast<BackingStoreAura*>( 2602 BackingStoreAura* backing_store = static_cast<BackingStoreAura*>(
2612 host_->GetBackingStore(true)); 2603 host_->GetBackingStore(true));
2613 paint_canvas_ = NULL; 2604 paint_canvas_ = NULL;
2614 backing_store->SkiaShowRect(gfx::Point(), canvas); 2605 backing_store->SkiaShowRect(gfx::Point(), canvas);
2615 2606
2616 if (paint_observer_)
2617 paint_observer_->OnPaintComplete();
2618 ui::Compositor* compositor = GetCompositor(); 2607 ui::Compositor* compositor = GetCompositor();
2619 if (compositor) { 2608 if (compositor) {
2620 for (size_t i = 0; i < software_latency_info_.size(); i++) 2609 for (size_t i = 0; i < software_latency_info_.size(); i++)
2621 compositor->SetLatencyInfo(software_latency_info_[i]); 2610 compositor->SetLatencyInfo(software_latency_info_[i]);
2622 } 2611 }
2623 software_latency_info_.clear(); 2612 software_latency_info_.clear();
2624 } else { 2613 } else {
2625 // For non-opaque windows, we don't draw anything, since we depend on the 2614 // For non-opaque windows, we don't draw anything, since we depend on the
2626 // canvas coming from the compositor to already be initialized as 2615 // canvas coming from the compositor to already be initialized as
2627 // transparent. 2616 // transparent.
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 } 3186 }
3198 } 3187 }
3199 3188
3200 void RenderWidgetHostViewAura::OnCompositingStarted( 3189 void RenderWidgetHostViewAura::OnCompositingStarted(
3201 ui::Compositor* compositor, base::TimeTicks start_time) { 3190 ui::Compositor* compositor, base::TimeTicks start_time) {
3202 last_draw_ended_ = start_time; 3191 last_draw_ended_ = start_time;
3203 } 3192 }
3204 3193
3205 void RenderWidgetHostViewAura::OnCompositingEnded( 3194 void RenderWidgetHostViewAura::OnCompositingEnded(
3206 ui::Compositor* compositor) { 3195 ui::Compositor* compositor) {
3207 if (paint_observer_)
3208 paint_observer_->OnCompositingComplete();
3209 } 3196 }
3210 3197
3211 void RenderWidgetHostViewAura::OnCompositingAborted( 3198 void RenderWidgetHostViewAura::OnCompositingAborted(
3212 ui::Compositor* compositor) { 3199 ui::Compositor* compositor) {
3213 } 3200 }
3214 3201
3215 void RenderWidgetHostViewAura::OnCompositingLockStateChanged( 3202 void RenderWidgetHostViewAura::OnCompositingLockStateChanged(
3216 ui::Compositor* compositor) { 3203 ui::Compositor* compositor) {
3217 // A compositor lock that is part of a resize lock timed out. We 3204 // A compositor lock that is part of a resize lock timed out. We
3218 // should display a renderer frame. 3205 // should display a renderer frame.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
3304 // are using is becoming invalid. This sends pending ACKs and needs to happen 3291 // are using is becoming invalid. This sends pending ACKs and needs to happen
3305 // after calling UpdateExternalTexture() which syncs with the impl thread. 3292 // after calling UpdateExternalTexture() which syncs with the impl thread.
3306 RunOnCommitCallbacks(); 3293 RunOnCommitCallbacks();
3307 host_->ScheduleComposite(); 3294 host_->ScheduleComposite();
3308 } 3295 }
3309 3296
3310 //////////////////////////////////////////////////////////////////////////////// 3297 ////////////////////////////////////////////////////////////////////////////////
3311 // RenderWidgetHostViewAura, private: 3298 // RenderWidgetHostViewAura, private:
3312 3299
3313 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 3300 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
3314 if (paint_observer_)
3315 paint_observer_->OnViewDestroyed();
3316 if (touch_editing_client_) 3301 if (touch_editing_client_)
3317 touch_editing_client_->OnViewDestroyed(); 3302 touch_editing_client_->OnViewDestroyed();
3318 3303
3319 ImageTransportFactory::GetInstance()->RemoveObserver(this); 3304 ImageTransportFactory::GetInstance()->RemoveObserver(this);
3320 3305
3321 window_observer_.reset(); 3306 window_observer_.reset();
3322 if (window_->GetDispatcher()) 3307 if (window_->GetDispatcher())
3323 window_->GetDispatcher()->RemoveRootWindowObserver(this); 3308 window_->GetDispatcher()->RemoveRootWindowObserver(this);
3324 UnlockMouse(); 3309 UnlockMouse();
3325 if (popup_parent_host_view_) { 3310 if (popup_parent_host_view_) {
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
3576 RenderWidgetHost* widget) { 3561 RenderWidgetHost* widget) {
3577 return new RenderWidgetHostViewAura(widget); 3562 return new RenderWidgetHostViewAura(widget);
3578 } 3563 }
3579 3564
3580 // static 3565 // static
3581 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { 3566 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) {
3582 GetScreenInfoForWindow(results, NULL); 3567 GetScreenInfoForWindow(results, NULL);
3583 } 3568 }
3584 3569
3585 } // namespace content 3570 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698