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

Side by Side Diff: cc/trees/layer_tree_host_impl.cc

Issue 170743004: Added early out for pinch to prevent crash when no inner scroll layer. (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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 2473 matching lines...) Expand 10 before | Expand all | Expand 10 after
2484 scroll_layer_id_when_mouse_over_scrollbar_ = 0; 2484 scroll_layer_id_when_mouse_over_scrollbar_ = 0;
2485 } 2485 }
2486 2486
2487 return true; 2487 return true;
2488 } 2488 }
2489 2489
2490 return false; 2490 return false;
2491 } 2491 }
2492 2492
2493 void LayerTreeHostImpl::PinchGestureBegin() { 2493 void LayerTreeHostImpl::PinchGestureBegin() {
2494 if (!InnerViewportScrollLayer())
wjmaclean 2014/02/18 21:16:59 Do we really need early outs in PinchGestureBegin(
bokan 2014/02/18 22:12:11 I think it's safer/cleaner not to have any side ef
2495 return;
2496
2494 pinch_gesture_active_ = true; 2497 pinch_gesture_active_ = true;
2495 previous_pinch_anchor_ = gfx::Point(); 2498 previous_pinch_anchor_ = gfx::Point();
2496 client_->RenewTreePriority(); 2499 client_->RenewTreePriority();
2497 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer(); 2500 pinch_gesture_end_should_clear_scrolling_layer_ = !CurrentlyScrollingLayer();
2498 if (active_tree_->OuterViewportScrollLayer()) { 2501 if (active_tree_->OuterViewportScrollLayer()) {
2499 active_tree_->SetCurrentlyScrollingLayer( 2502 active_tree_->SetCurrentlyScrollingLayer(
2500 active_tree_->OuterViewportScrollLayer()); 2503 active_tree_->OuterViewportScrollLayer());
2501 } else { 2504 } else {
2502 active_tree_->SetCurrentlyScrollingLayer( 2505 active_tree_->SetCurrentlyScrollingLayer(
2503 active_tree_->InnerViewportScrollLayer()); 2506 active_tree_->InnerViewportScrollLayer());
2504 } 2507 }
2505 if (top_controls_manager_) 2508 if (top_controls_manager_)
2506 top_controls_manager_->PinchBegin(); 2509 top_controls_manager_->PinchBegin();
2507 } 2510 }
2508 2511
2509 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta, 2512 void LayerTreeHostImpl::PinchGestureUpdate(float magnify_delta,
2510 gfx::Point anchor) { 2513 gfx::Point anchor) {
2514 if (!InnerViewportScrollLayer())
2515 return;
2516
2511 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate"); 2517 TRACE_EVENT0("cc", "LayerTreeHostImpl::PinchGestureUpdate");
2512 2518
2513 DCHECK(InnerViewportScrollLayer());
2514
2515 // Keep the center-of-pinch anchor specified by (x, y) in a stable 2519 // Keep the center-of-pinch anchor specified by (x, y) in a stable
2516 // position over the course of the magnify. 2520 // position over the course of the magnify.
2517 float page_scale_delta = active_tree_->page_scale_delta(); 2521 float page_scale_delta = active_tree_->page_scale_delta();
2518 gfx::PointF previous_scale_anchor = 2522 gfx::PointF previous_scale_anchor =
2519 gfx::ScalePoint(anchor, 1.f / page_scale_delta); 2523 gfx::ScalePoint(anchor, 1.f / page_scale_delta);
2520 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta); 2524 active_tree_->SetPageScaleDelta(page_scale_delta * magnify_delta);
2521 page_scale_delta = active_tree_->page_scale_delta(); 2525 page_scale_delta = active_tree_->page_scale_delta();
2522 gfx::PointF new_scale_anchor = 2526 gfx::PointF new_scale_anchor =
2523 gfx::ScalePoint(anchor, 1.f / page_scale_delta); 2527 gfx::ScalePoint(anchor, 1.f / page_scale_delta);
2524 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor; 2528 gfx::Vector2dF move = previous_scale_anchor - new_scale_anchor;
(...skipping 19 matching lines...) Expand all
2544 InnerViewportScrollLayer()->ScrollBy(unused); 2548 InnerViewportScrollLayer()->ScrollBy(unused);
2545 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset(); 2549 InnerViewportScrollLayer()->ClampScrollToMaxScrollOffset();
2546 } 2550 }
2547 2551
2548 client_->SetNeedsCommitOnImplThread(); 2552 client_->SetNeedsCommitOnImplThread();
2549 SetNeedsRedraw(); 2553 SetNeedsRedraw();
2550 client_->RenewTreePriority(); 2554 client_->RenewTreePriority();
2551 } 2555 }
2552 2556
2553 void LayerTreeHostImpl::PinchGestureEnd() { 2557 void LayerTreeHostImpl::PinchGestureEnd() {
2558 if (!InnerViewportScrollLayer())
2559 return;
2560
2554 pinch_gesture_active_ = false; 2561 pinch_gesture_active_ = false;
2555 if (pinch_gesture_end_should_clear_scrolling_layer_) { 2562 if (pinch_gesture_end_should_clear_scrolling_layer_) {
2556 pinch_gesture_end_should_clear_scrolling_layer_ = false; 2563 pinch_gesture_end_should_clear_scrolling_layer_ = false;
2557 ClearCurrentlyScrollingLayer(); 2564 ClearCurrentlyScrollingLayer();
2558 } 2565 }
2559 if (top_controls_manager_) 2566 if (top_controls_manager_)
2560 top_controls_manager_->PinchEnd(); 2567 top_controls_manager_->PinchEnd();
2561 client_->SetNeedsCommitOnImplThread(); 2568 client_->SetNeedsCommitOnImplThread();
2562 } 2569 }
2563 2570
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
2998 swap_promise_monitor_.erase(monitor); 3005 swap_promise_monitor_.erase(monitor);
2999 } 3006 }
3000 3007
3001 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() { 3008 void LayerTreeHostImpl::NotifySwapPromiseMonitorsOfSetNeedsRedraw() {
3002 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin(); 3009 std::set<SwapPromiseMonitor*>::iterator it = swap_promise_monitor_.begin();
3003 for (; it != swap_promise_monitor_.end(); it++) 3010 for (; it != swap_promise_monitor_.end(); it++)
3004 (*it)->OnSetNeedsRedrawOnImpl(); 3011 (*it)->OnSetNeedsRedrawOnImpl();
3005 } 3012 }
3006 3013
3007 } // namespace cc 3014 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698