| OLD | NEW |
| 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 DCHECK(layer_tree_impl()->IsActiveTree()); | 338 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 339 | 339 |
| 340 if (sent_scroll_delta_ == sent_scroll_delta) | 340 if (sent_scroll_delta_ == sent_scroll_delta) |
| 341 return; | 341 return; |
| 342 | 342 |
| 343 sent_scroll_delta_ = sent_scroll_delta; | 343 sent_scroll_delta_ = sent_scroll_delta; |
| 344 } | 344 } |
| 345 | 345 |
| 346 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { | 346 gfx::Vector2dF LayerImpl::ScrollBy(gfx::Vector2dF scroll) { |
| 347 DCHECK(scrollable()); | 347 DCHECK(scrollable()); |
| 348 gfx::Vector2dF scroll_hidden; | |
| 349 if (!user_scrollable_horizontal_) { | |
| 350 scroll_hidden.set_x(scroll.x()); | |
| 351 scroll.set_x(0.f); | |
| 352 } | |
| 353 if (!user_scrollable_vertical_) { | |
| 354 scroll_hidden.set_y(scroll.y()); | |
| 355 scroll.set_y(0.f); | |
| 356 } | |
| 357 | |
| 358 gfx::Vector2dF min_delta = -scroll_offset_; | 348 gfx::Vector2dF min_delta = -scroll_offset_; |
| 359 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; | 349 gfx::Vector2dF max_delta = max_scroll_offset_ - scroll_offset_; |
| 360 // Clamp new_delta so that position + delta stays within scroll bounds. | 350 // Clamp new_delta so that position + delta stays within scroll bounds. |
| 361 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); | 351 gfx::Vector2dF new_delta = (ScrollDelta() + scroll); |
| 362 new_delta.SetToMax(min_delta); | 352 new_delta.SetToMax(min_delta); |
| 363 new_delta.SetToMin(max_delta); | 353 new_delta.SetToMin(max_delta); |
| 364 gfx::Vector2dF unscrolled = | 354 gfx::Vector2dF unscrolled = |
| 365 ScrollDelta() + scroll + scroll_hidden - new_delta; | 355 ScrollDelta() + scroll - new_delta; |
| 366 SetScrollDelta(new_delta); | 356 SetScrollDelta(new_delta); |
| 367 return unscrolled; | 357 return unscrolled; |
| 368 } | 358 } |
| 369 | 359 |
| 370 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { | 360 void LayerImpl::ApplySentScrollDeltasFromAbortedCommit() { |
| 371 // Pending tree never has sent scroll deltas | 361 // Pending tree never has sent scroll deltas |
| 372 DCHECK(layer_tree_impl()->IsActiveTree()); | 362 DCHECK(layer_tree_impl()->IsActiveTree()); |
| 373 | 363 |
| 374 // Apply sent scroll deltas to scroll position / scroll delta as if the | 364 // Apply sent scroll deltas to scroll position / scroll delta as if the |
| 375 // main thread had applied them and then committed those values. | 365 // main thread had applied them and then committed those values. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 return InputHandler::ScrollIgnored; | 446 return InputHandler::ScrollIgnored; |
| 457 } | 447 } |
| 458 | 448 |
| 459 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { | 449 if (max_scroll_offset_.x() <= 0 && max_scroll_offset_.y() <= 0) { |
| 460 TRACE_EVENT0("cc", | 450 TRACE_EVENT0("cc", |
| 461 "LayerImpl::tryScroll: Ignored. Technically scrollable," | 451 "LayerImpl::tryScroll: Ignored. Technically scrollable," |
| 462 " but has no affordance in either direction."); | 452 " but has no affordance in either direction."); |
| 463 return InputHandler::ScrollIgnored; | 453 return InputHandler::ScrollIgnored; |
| 464 } | 454 } |
| 465 | 455 |
| 466 if (!user_scrollable_horizontal_ && !user_scrollable_vertical_) { | |
| 467 TRACE_EVENT0("cc", | |
| 468 "LayerImpl::TryScroll: Ignored. User gesture is not allowed" | |
| 469 " to scroll this layer."); | |
| 470 return InputHandler::ScrollIgnored; | |
| 471 } | |
| 472 | |
| 473 return InputHandler::ScrollStarted; | 456 return InputHandler::ScrollStarted; |
| 474 } | 457 } |
| 475 | 458 |
| 476 bool LayerImpl::DrawCheckerboardForMissingTiles() const { | 459 bool LayerImpl::DrawCheckerboardForMissingTiles() const { |
| 477 return draw_checkerboard_for_missing_tiles_ && | 460 return draw_checkerboard_for_missing_tiles_ && |
| 478 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; | 461 !layer_tree_impl()->settings().background_color_instead_of_checkerboard; |
| 479 } | 462 } |
| 480 | 463 |
| 481 gfx::Rect LayerImpl::LayerRectToContentRect( | 464 gfx::Rect LayerImpl::LayerRectToContentRect( |
| 482 const gfx::RectF& layer_rect) const { | 465 const gfx::RectF& layer_rect) const { |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 | 1318 |
| 1336 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } | 1319 size_t LayerImpl::GPUMemoryUsageInBytes() const { return 0; } |
| 1337 | 1320 |
| 1338 scoped_ptr<base::Value> LayerImpl::AsValue() const { | 1321 scoped_ptr<base::Value> LayerImpl::AsValue() const { |
| 1339 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); | 1322 scoped_ptr<base::DictionaryValue> state(new base::DictionaryValue()); |
| 1340 AsValueInto(state.get()); | 1323 AsValueInto(state.get()); |
| 1341 return state.PassAs<base::Value>(); | 1324 return state.PassAs<base::Value>(); |
| 1342 } | 1325 } |
| 1343 | 1326 |
| 1344 } // namespace cc | 1327 } // namespace cc |
| OLD | NEW |