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

Side by Side Diff: cc/layers/layer_impl.cc

Issue 30793002: cc: Do not allow gesture-scrolling 'overflow[-{x|y}]:hidden' layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 7 years, 2 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 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/layers/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "cc/animation/animation_registrar.h" 9 #include "cc/animation/animation_registrar.h"
10 #include "cc/animation/scrollbar_animation_controller.h" 10 #include "cc/animation/scrollbar_animation_controller.h"
(...skipping 24 matching lines...) Expand all
35 mask_layer_id_(-1), 35 mask_layer_id_(-1),
36 replica_layer_id_(-1), 36 replica_layer_id_(-1),
37 layer_id_(id), 37 layer_id_(id),
38 layer_tree_impl_(tree_impl), 38 layer_tree_impl_(tree_impl),
39 anchor_point_(0.5f, 0.5f), 39 anchor_point_(0.5f, 0.5f),
40 anchor_point_z_(0.f), 40 anchor_point_z_(0.f),
41 scroll_offset_delegate_(NULL), 41 scroll_offset_delegate_(NULL),
42 scrollable_(false), 42 scrollable_(false),
43 should_scroll_on_main_thread_(false), 43 should_scroll_on_main_thread_(false),
44 have_wheel_event_handlers_(false), 44 have_wheel_event_handlers_(false),
45 user_scrollable_horizontal_(true),
46 user_scrollable_vertical_(true),
45 background_color_(0), 47 background_color_(0),
46 stacking_order_changed_(false), 48 stacking_order_changed_(false),
47 double_sided_(true), 49 double_sided_(true),
48 layer_property_changed_(false), 50 layer_property_changed_(false),
49 masks_to_bounds_(false), 51 masks_to_bounds_(false),
50 contents_opaque_(false), 52 contents_opaque_(false),
51 opacity_(1.0), 53 opacity_(1.0),
52 preserves_3d_(false), 54 preserves_3d_(false),
53 use_parent_backface_visibility_(false), 55 use_parent_backface_visibility_(false),
54 draw_checkerboard_for_missing_tiles_(false), 56 draw_checkerboard_for_missing_tiles_(false),
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 DCHECK(layer_tree_impl()->IsActiveTree()); 336 DCHECK(layer_tree_impl()->IsActiveTree());
335 337
336 if (sent_scroll_delta_ == sent_scroll_delta) 338 if (sent_scroll_delta_ == sent_scroll_delta)
337 return; 339 return;
338 340
339 sent_scroll_delta_ = sent_scroll_delta; 341 sent_scroll_delta_ = sent_scroll_delta;
340 } 342 }
341 343
342 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { 344 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) {
343 DCHECK(scrollable()); 345 DCHECK(scrollable());
346 gfx::Vector2dF scroll_hidden;
347 if (!user_scrollable_horizontal_) {
348 scroll_hidden.set_x(scroll.x());
349 scroll.set_x(0.f);
350 }
351 if (!user_scrollable_vertical_) {
352 scroll_hidden.set_y(scroll.y());
353 scroll.set_y(0.f);
354 }
344 355
345 gfx::Vector2dF min_delta = -scroll_offset_; 356 gfx::Vector2dF min_delta = -scroll_offset_;
346 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; 357 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_;
347 // Clamp new_delta so that position + delta stays within scroll bounds. 358 // Clamp new_delta so that position + delta stays within scroll bounds.
348 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); 359 gfx::Vector2dF new_delta = (ScrollDelta() + scroll);
349 new_delta.SetToMax(min_delta); 360 new_delta.SetToMax(min_delta);
350 new_delta.SetToMin(max_delta); 361 new_delta.SetToMin(max_delta);
351 gfx::Vector2dF unscrolled = ScrollDelta() + scroll - new_delta; 362 gfx::Vector2dF unscrolled =
363 ScrollDelta() + scroll + scroll_hidden - new_delta;
352 SetScrollDelta(new_delta); 364 SetScrollDelta(new_delta);
353 return unscrolled; 365 return unscrolled;
354 } 366 }
355 367
356 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { 368 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() {
357 // Pending tree never has sent scroll deltas 369 // Pending tree never has sent scroll deltas
358 DCHECK(layer_tree_impl()->IsActiveTree()); 370 DCHECK(layer_tree_impl()->IsActiveTree());
359 371
360 // Apply sent scroll deltas to scroll position / scroll delta as if the 372 // Apply sent scroll deltas to scroll position / scroll delta as if the
361 // main thread had applied them and then committed those values. 373 // main thread had applied them and then committed those values.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 return InputHandler::ScrollIgnored; 454 return InputHandler::ScrollIgnored;
443 } 455 }
444 456
445 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { 457 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) {
446 TRACE_EVENT0("cc", 458 TRACE_EVENT0("cc",
447 "LayerImpl::tryScroll: Ignored. Technically scrollable," 459 "LayerImpl::tryScroll: Ignored. Technically scrollable,"
448 " but has no affordance in either direction."); 460 " but has no affordance in either direction.");
449 return InputHandler::ScrollIgnored; 461 return InputHandler::ScrollIgnored;
450 } 462 }
451 463
464 if (!user_scrollable_horizontal_ && !user_scrollable_vertical_)
465 return InputHandler::ScrollIgnored;
jamesr 2013/10/21 22:36:34 nit: it'd be useful to TRACE_EVENT this bail-out l
sadrul 2013/10/21 23:11:17 Done.
466
452 return InputHandler::ScrollStarted; 467 return InputHandler::ScrollStarted;
453 } 468 }
454 469
455 bool LayerImpl::DrawCheckerboardForMissingTiles() const { 470 bool LayerImpl::DrawCheckerboardForMissingTiles() const {
456 return draw_checkerboard_for_missing_tiles_ && 471 return draw_checkerboard_for_missing_tiles_ &&
457 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; 472 !layer_tree_impl()->settings().background_color_instead_of_checkerboard;
458 } 473 }
459 474
460 gfx::Rect LayerImpl::LayerRectToContentRect( 475 gfx::Rect LayerImpl::LayerRectToContentRect(
461 const gfx::RectF& layer_rect) const { 476 const gfx::RectF& layer_rect) const {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 layer->SetIsContainerForFixedPositionLayers( 522 layer->SetIsContainerForFixedPositionLayers(
508 is_container_for_fixed_position_layers_); 523 is_container_for_fixed_position_layers_);
509 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_); 524 layer->SetFixedContainerSizeDelta(fixed_container_size_delta_);
510 layer->SetPositionConstraint(position_constraint_); 525 layer->SetPositionConstraint(position_constraint_);
511 layer->SetPreserves3d(preserves_3d()); 526 layer->SetPreserves3d(preserves_3d());
512 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_); 527 layer->SetUseParentBackfaceVisibility(use_parent_backface_visibility_);
513 layer->SetSublayerTransform(sublayer_transform_); 528 layer->SetSublayerTransform(sublayer_transform_);
514 layer->SetTransform(transform_); 529 layer->SetTransform(transform_);
515 530
516 layer->SetScrollable(scrollable_); 531 layer->SetScrollable(scrollable_);
532 layer->SetUserScrollable(user_scrollable_horizontal_,
533 user_scrollable_vertical_);
517 layer->SetScrollOffsetAndDelta( 534 layer->SetScrollOffsetAndDelta(
518 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta()); 535 scroll_offset_, layer->ScrollDelta() - layer->sent_scroll_delta());
519 layer->SetSentScrollDelta(gfx::Vector2d()); 536 layer->SetSentScrollDelta(gfx::Vector2d());
520 537
521 layer->SetMaxScrollOffset(max_scroll_offset_); 538 layer->SetMaxScrollOffset(max_scroll_offset_);
522 539
523 LayerImpl* scroll_parent = NULL; 540 LayerImpl* scroll_parent = NULL;
524 if (scroll_parent_) 541 if (scroll_parent_)
525 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id()); 542 scroll_parent = layer->layer_tree_impl()->LayerById(scroll_parent_->id());
526 543
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
1305 1322
1306 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } 1323 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; }
1307 1324
1308 scoped_ptr<base::Value> LayerImpl::AsValue() const { 1325 scoped_ptr<base::Value> LayerImpl::AsValue() const {
1309 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); 1326 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue());
1310 AsValueInto(state.get()); 1327 AsValueInto(state.get());
1311 return state.PassAs<base::Value>(); 1328 return state.PassAs<base::Value>();
1312 } 1329 }
1313 1330
1314 } // namespace cc 1331 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698