| OLD | NEW |
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <unordered_map> | 7 #include <unordered_map> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 bool use_solid_color_scrollbar, | 145 bool use_solid_color_scrollbar, |
| 146 int thumb_thickness, | 146 int thumb_thickness, |
| 147 int track_start) { | 147 int track_start) { |
| 148 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 148 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 149 scoped_refptr<Layer> child1 = Layer::Create(); | 149 scoped_refptr<Layer> child1 = Layer::Create(); |
| 150 scoped_refptr<Layer> child2; | 150 scoped_refptr<Layer> child2; |
| 151 if (use_solid_color_scrollbar) { | 151 if (use_solid_color_scrollbar) { |
| 152 const bool kIsLeftSideVerticalScrollbar = false; | 152 const bool kIsLeftSideVerticalScrollbar = false; |
| 153 child2 = SolidColorScrollbarLayer::Create( | 153 child2 = SolidColorScrollbarLayer::Create( |
| 154 scrollbar->Orientation(), thumb_thickness, track_start, | 154 scrollbar->Orientation(), thumb_thickness, track_start, |
| 155 kIsLeftSideVerticalScrollbar, child1->id()); | 155 kIsLeftSideVerticalScrollbar, child1->id(), child1->element_id()); |
| 156 } else { | 156 } else { |
| 157 child2 = | 157 child2 = PaintedScrollbarLayer::Create(std::move(scrollbar), child1->id(), |
| 158 PaintedScrollbarLayer::Create(std::move(scrollbar), child1->id()); | 158 child1->element_id()); |
| 159 } | 159 } |
| 160 layer_tree_root->AddChild(child1); | 160 layer_tree_root->AddChild(child1); |
| 161 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); | 161 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); |
| 162 scrollbar_layer_id_ = reverse_order ? child1->id() : child2->id(); | 162 scrollbar_layer_id_ = reverse_order ? child1->id() : child2->id(); |
| 163 host->SetRootLayer(layer_tree_root); | 163 host->SetRootLayer(layer_tree_root); |
| 164 host->BuildPropertyTreesForTesting(); | 164 host->BuildPropertyTreesForTesting(); |
| 165 return host->CommitAndCreateLayerImplTree(); | 165 return host->CommitAndCreateLayerImplTree(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 protected: | 168 protected: |
| (...skipping 23 matching lines...) Expand all Loading... |
| 192 // after its been disposed, even if Blink doesn't think it requires a repaint. | 192 // after its been disposed, even if Blink doesn't think it requires a repaint. |
| 193 // crbug.com/704656. | 193 // crbug.com/704656. |
| 194 TEST_F(ScrollbarLayerTest, RepaintOverlayWhenResourceDisposed) { | 194 TEST_F(ScrollbarLayerTest, RepaintOverlayWhenResourceDisposed) { |
| 195 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 195 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 196 scoped_refptr<Layer> content_layer = Layer::Create(); | 196 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 197 std::unique_ptr<FakePaintedOverlayScrollbar> scrollbar( | 197 std::unique_ptr<FakePaintedOverlayScrollbar> scrollbar( |
| 198 new FakePaintedOverlayScrollbar); | 198 new FakePaintedOverlayScrollbar); |
| 199 FakePaintedOverlayScrollbar* fake_scrollbar = scrollbar.get(); | 199 FakePaintedOverlayScrollbar* fake_scrollbar = scrollbar.get(); |
| 200 scoped_refptr<PaintedOverlayScrollbarLayer> scrollbar_layer = | 200 scoped_refptr<PaintedOverlayScrollbarLayer> scrollbar_layer = |
| 201 PaintedOverlayScrollbarLayer::Create(std::move(scrollbar), | 201 PaintedOverlayScrollbarLayer::Create(std::move(scrollbar), |
| 202 layer_tree_root->id()); | 202 layer_tree_root->id(), |
| 203 layer_tree_root->element_id()); |
| 203 | 204 |
| 204 // Setup. | 205 // Setup. |
| 205 { | 206 { |
| 206 layer_tree_root->AddChild(content_layer); | 207 layer_tree_root->AddChild(content_layer); |
| 207 layer_tree_root->AddChild(scrollbar_layer); | 208 layer_tree_root->AddChild(scrollbar_layer); |
| 208 layer_tree_host_->SetRootLayer(layer_tree_root); | 209 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 209 scrollbar_layer->SetIsDrawable(true); | 210 scrollbar_layer->SetIsDrawable(true); |
| 210 scrollbar_layer->SetBounds(gfx::Size(100, 100)); | 211 scrollbar_layer->SetBounds(gfx::Size(100, 100)); |
| 211 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 212 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| 212 content_layer->SetBounds(gfx::Size(100, 200)); | 213 content_layer->SetBounds(gfx::Size(100, 200)); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); | 287 EXPECT_EQ(InputHandler::SCROLL_IGNORED, status.thread); |
| 287 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, | 288 EXPECT_EQ(MainThreadScrollingReason::kNotScrollable, |
| 288 status.main_thread_scrolling_reasons); | 289 status.main_thread_scrolling_reasons); |
| 289 } | 290 } |
| 290 | 291 |
| 291 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { | 292 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { |
| 292 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); | 293 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar); |
| 293 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 294 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 294 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 295 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 295 scoped_refptr<Layer> content_layer = Layer::Create(); | 296 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 296 scoped_refptr<Layer> scrollbar_layer = | 297 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( |
| 297 PaintedScrollbarLayer::Create(std::move(scrollbar), scroll_layer->id()); | 298 std::move(scrollbar), scroll_layer->id(), scroll_layer->element_id()); |
| 298 | 299 |
| 299 // Choose bounds to give max_scroll_offset = (30, 50). | 300 // Choose bounds to give max_scroll_offset = (30, 50). |
| 300 layer_tree_root->SetBounds(gfx::Size(70, 150)); | 301 layer_tree_root->SetBounds(gfx::Size(70, 150)); |
| 301 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 302 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 302 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 303 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 303 scroll_layer->SetBounds(gfx::Size(100, 200)); | 304 scroll_layer->SetBounds(gfx::Size(100, 200)); |
| 304 content_layer->SetBounds(gfx::Size(100, 200)); | 305 content_layer->SetBounds(gfx::Size(100, 200)); |
| 305 | 306 |
| 306 layer_tree_host_->SetRootLayer(layer_tree_root); | 307 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 307 layer_tree_root->AddChild(scroll_layer); | 308 layer_tree_root->AddChild(scroll_layer); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( \ | 356 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( \ |
| 356 root_clip_layer_impl->layer_tree_impl()->LayerById( \ | 357 root_clip_layer_impl->layer_tree_impl()->LayerById( \ |
| 357 scrollbar_layer->id())); \ | 358 scrollbar_layer->id())); \ |
| 358 } while (false) | 359 } while (false) |
| 359 | 360 |
| 360 TEST_F(ScrollbarLayerTest, UpdatePropertiesOfScrollBarWhenThumbRemoved) { | 361 TEST_F(ScrollbarLayerTest, UpdatePropertiesOfScrollBarWhenThumbRemoved) { |
| 361 scoped_refptr<Layer> root_clip_layer = Layer::Create(); | 362 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
| 362 scoped_refptr<Layer> root_layer = Layer::Create(); | 363 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 363 scoped_refptr<Layer> content_layer = Layer::Create(); | 364 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 364 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 365 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 365 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); | 366 FakePaintedScrollbarLayer::Create(false, true, root_layer->id(), |
| 367 root_layer->element_id()); |
| 366 | 368 |
| 367 root_layer->SetScrollClipLayerId(root_clip_layer->id()); | 369 root_layer->SetScrollClipLayerId(root_clip_layer->id()); |
| 368 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). | 370 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). |
| 369 root_clip_layer->SetBounds(gfx::Size(20, 50)); | 371 root_clip_layer->SetBounds(gfx::Size(20, 50)); |
| 370 root_layer->SetBounds(gfx::Size(100, 50)); | 372 root_layer->SetBounds(gfx::Size(100, 50)); |
| 371 content_layer->SetBounds(gfx::Size(100, 50)); | 373 content_layer->SetBounds(gfx::Size(100, 50)); |
| 372 | 374 |
| 373 layer_tree_host_->SetRootLayer(root_clip_layer); | 375 layer_tree_host_->SetRootLayer(root_clip_layer); |
| 374 root_clip_layer->AddChild(root_layer); | 376 root_clip_layer->AddChild(root_layer); |
| 375 root_layer->AddChild(content_layer); | 377 root_layer->AddChild(content_layer); |
| 376 root_layer->AddChild(scrollbar_layer); | 378 root_layer->AddChild(scrollbar_layer); |
| 377 | 379 |
| 378 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 380 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); |
| 379 scrollbar_layer->SetBounds(gfx::Size(70, 10)); | 381 scrollbar_layer->SetBounds(gfx::Size(70, 10)); |
| 380 scrollbar_layer->SetScrollLayer(root_layer->id()); | 382 scrollbar_layer->SetScrollInfo(root_layer->id(), root_layer->element_id()); |
| 381 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); | 383 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); |
| 382 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); | 384 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); |
| 383 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); | 385 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); |
| 384 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); | 386 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); |
| 385 LayerImpl* root_clip_layer_impl = nullptr; | 387 LayerImpl* root_clip_layer_impl = nullptr; |
| 386 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; | 388 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; |
| 387 | 389 |
| 388 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 390 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
| 389 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), | 391 EXPECT_EQ(gfx::Rect(10, 0, 4, 10).ToString(), |
| 390 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 392 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
| 391 | 393 |
| 392 scrollbar_layer->fake_scrollbar()->set_has_thumb(false); | 394 scrollbar_layer->fake_scrollbar()->set_has_thumb(false); |
| 393 | 395 |
| 394 UPDATE_AND_EXTRACT_LAYER_POINTERS(); | 396 UPDATE_AND_EXTRACT_LAYER_POINTERS(); |
| 395 EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(), | 397 EXPECT_EQ(gfx::Rect(10, 0, 0, 0).ToString(), |
| 396 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 398 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
| 397 } | 399 } |
| 398 | 400 |
| 399 TEST_F(ScrollbarLayerTest, ThumbRect) { | 401 TEST_F(ScrollbarLayerTest, ThumbRect) { |
| 400 scoped_refptr<Layer> root_clip_layer = Layer::Create(); | 402 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
| 401 scoped_refptr<Layer> root_layer = Layer::Create(); | 403 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 402 scoped_refptr<Layer> content_layer = Layer::Create(); | 404 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 403 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 405 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 404 FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); | 406 FakePaintedScrollbarLayer::Create(false, true, root_layer->id(), |
| 407 root_layer->element_id()); |
| 405 | 408 |
| 406 root_layer->SetScrollClipLayerId(root_clip_layer->id()); | 409 root_layer->SetScrollClipLayerId(root_clip_layer->id()); |
| 407 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). | 410 // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). |
| 408 root_clip_layer->SetBounds(gfx::Size(20, 50)); | 411 root_clip_layer->SetBounds(gfx::Size(20, 50)); |
| 409 root_layer->SetBounds(gfx::Size(100, 50)); | 412 root_layer->SetBounds(gfx::Size(100, 50)); |
| 410 content_layer->SetBounds(gfx::Size(100, 50)); | 413 content_layer->SetBounds(gfx::Size(100, 50)); |
| 411 | 414 |
| 412 layer_tree_host_->SetRootLayer(root_clip_layer); | 415 layer_tree_host_->SetRootLayer(root_clip_layer); |
| 413 root_clip_layer->AddChild(root_layer); | 416 root_clip_layer->AddChild(root_layer); |
| 414 root_layer->AddChild(content_layer); | 417 root_layer->AddChild(content_layer); |
| 415 root_layer->AddChild(scrollbar_layer); | 418 root_layer->AddChild(scrollbar_layer); |
| 416 | 419 |
| 417 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 420 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); |
| 418 scrollbar_layer->SetBounds(gfx::Size(70, 10)); | 421 scrollbar_layer->SetBounds(gfx::Size(70, 10)); |
| 419 scrollbar_layer->SetScrollLayer(root_layer->id()); | 422 scrollbar_layer->SetScrollInfo(root_layer->id(), root_layer->element_id()); |
| 420 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); | 423 scrollbar_layer->fake_scrollbar()->set_location(gfx::Point(20, 10)); |
| 421 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); | 424 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(30, 10, 50, 10)); |
| 422 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); | 425 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); |
| 423 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); | 426 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); |
| 424 layer_tree_host_->UpdateLayers(); | 427 layer_tree_host_->UpdateLayers(); |
| 425 LayerImpl* root_clip_layer_impl = nullptr; | 428 LayerImpl* root_clip_layer_impl = nullptr; |
| 426 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; | 429 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; |
| 427 | 430 |
| 428 // Thumb is at the edge of the scrollbar (should be inset to | 431 // Thumb is at the edge of the scrollbar (should be inset to |
| 429 // the start of the track within the scrollbar layer's | 432 // the start of the track within the scrollbar layer's |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 EXPECT_EQ(gfx::Rect(44, 0, 6, 4).ToString(), | 475 EXPECT_EQ(gfx::Rect(44, 0, 6, 4).ToString(), |
| 473 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); | 476 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); |
| 474 } | 477 } |
| 475 | 478 |
| 476 TEST_F(ScrollbarLayerTest, ThumbRectForOverlayLeftSideVerticalScrollbar) { | 479 TEST_F(ScrollbarLayerTest, ThumbRectForOverlayLeftSideVerticalScrollbar) { |
| 477 scoped_refptr<Layer> root_clip_layer = Layer::Create(); | 480 scoped_refptr<Layer> root_clip_layer = Layer::Create(); |
| 478 scoped_refptr<Layer> root_layer = Layer::Create(); | 481 scoped_refptr<Layer> root_layer = Layer::Create(); |
| 479 // Create an overlay left side vertical scrollbar. | 482 // Create an overlay left side vertical scrollbar. |
| 480 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 483 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 481 FakePaintedScrollbarLayer::Create(false, true, VERTICAL, true, true, | 484 FakePaintedScrollbarLayer::Create(false, true, VERTICAL, true, true, |
| 482 root_layer->id()); | 485 root_layer->id(), |
| 486 root_layer->element_id()); |
| 483 root_layer->SetScrollClipLayerId(root_clip_layer->id()); | 487 root_layer->SetScrollClipLayerId(root_clip_layer->id()); |
| 484 root_clip_layer->SetBounds(gfx::Size(50, 20)); | 488 root_clip_layer->SetBounds(gfx::Size(50, 20)); |
| 485 root_layer->SetBounds(gfx::Size(50, 100)); | 489 root_layer->SetBounds(gfx::Size(50, 100)); |
| 486 | 490 |
| 487 layer_tree_host_->SetRootLayer(root_clip_layer); | 491 layer_tree_host_->SetRootLayer(root_clip_layer); |
| 488 root_clip_layer->AddChild(root_layer); | 492 root_clip_layer->AddChild(root_layer); |
| 489 root_layer->AddChild(scrollbar_layer); | 493 root_layer->AddChild(scrollbar_layer); |
| 490 | 494 |
| 491 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); | 495 root_layer->SetScrollOffset(gfx::ScrollOffset(0, 0)); |
| 492 scrollbar_layer->SetBounds(gfx::Size(10, 20)); | 496 scrollbar_layer->SetBounds(gfx::Size(10, 20)); |
| 493 scrollbar_layer->SetScrollLayer(root_layer->id()); | 497 scrollbar_layer->SetScrollInfo(root_layer->id(), root_layer->element_id()); |
| 494 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(0, 0, 10, 20)); | 498 scrollbar_layer->fake_scrollbar()->set_track_rect(gfx::Rect(0, 0, 10, 20)); |
| 495 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); | 499 scrollbar_layer->fake_scrollbar()->set_thumb_thickness(10); |
| 496 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); | 500 scrollbar_layer->fake_scrollbar()->set_thumb_length(4); |
| 497 layer_tree_host_->UpdateLayers(); | 501 layer_tree_host_->UpdateLayers(); |
| 498 LayerImpl* root_clip_layer_impl = nullptr; | 502 LayerImpl* root_clip_layer_impl = nullptr; |
| 499 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; | 503 PaintedScrollbarLayerImpl* scrollbar_layer_impl = nullptr; |
| 500 | 504 |
| 501 // Thumb is at the edge of the scrollbar (should be inset to | 505 // Thumb is at the edge of the scrollbar (should be inset to |
| 502 // the start of the track within the scrollbar layer's | 506 // the start of the track within the scrollbar layer's |
| 503 // position). | 507 // position). |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 596 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 593 | 597 |
| 594 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 598 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 595 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 599 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 596 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 600 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 597 scoped_refptr<Layer> child1 = Layer::Create(); | 601 scoped_refptr<Layer> child1 = Layer::Create(); |
| 598 scoped_refptr<Layer> child2; | 602 scoped_refptr<Layer> child2; |
| 599 const bool kIsLeftSideVerticalScrollbar = false; | 603 const bool kIsLeftSideVerticalScrollbar = false; |
| 600 child2 = SolidColorScrollbarLayer::Create( | 604 child2 = SolidColorScrollbarLayer::Create( |
| 601 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 605 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 602 kIsLeftSideVerticalScrollbar, scroll_layer->id()); | 606 kIsLeftSideVerticalScrollbar, scroll_layer->id(), |
| 607 scroll_layer->element_id()); |
| 603 scroll_layer->AddChild(child1); | 608 scroll_layer->AddChild(child1); |
| 604 scroll_layer->InsertChild(child2, 1); | 609 scroll_layer->InsertChild(child2, 1); |
| 605 layer_tree_root->AddChild(scroll_layer); | 610 layer_tree_root->AddChild(scroll_layer); |
| 606 layer_tree_host_->SetRootLayer(layer_tree_root); | 611 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 607 | 612 |
| 608 // Choose layer bounds to give max_scroll_offset = (8, 8). | 613 // Choose layer bounds to give max_scroll_offset = (8, 8). |
| 609 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 614 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 610 scroll_layer->SetBounds(gfx::Size(10, 10)); | 615 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 611 | 616 |
| 612 layer_tree_host_->UpdateLayers(); | 617 layer_tree_host_->UpdateLayers(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 649 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 645 | 650 |
| 646 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 651 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 647 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 652 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 648 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 653 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 649 scoped_refptr<Layer> child1 = Layer::Create(); | 654 scoped_refptr<Layer> child1 = Layer::Create(); |
| 650 scoped_refptr<Layer> scrollbar_layer; | 655 scoped_refptr<Layer> scrollbar_layer; |
| 651 const bool kIsLeftSideVerticalScrollbar = false; | 656 const bool kIsLeftSideVerticalScrollbar = false; |
| 652 scrollbar_layer = SolidColorScrollbarLayer::Create( | 657 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 653 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 658 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 654 kIsLeftSideVerticalScrollbar, scroll_layer->id()); | 659 kIsLeftSideVerticalScrollbar, scroll_layer->id(), |
| 660 scroll_layer->element_id()); |
| 655 scroll_layer->AddChild(child1); | 661 scroll_layer->AddChild(child1); |
| 656 scroll_layer->InsertChild(scrollbar_layer, 1); | 662 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 657 layer_tree_root->AddChild(scroll_layer); | 663 layer_tree_root->AddChild(scroll_layer); |
| 658 layer_tree_host_->SetRootLayer(layer_tree_root); | 664 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 659 | 665 |
| 660 // Choose layer bounds to give max_scroll_offset = (8, 8). | 666 // Choose layer bounds to give max_scroll_offset = (8, 8). |
| 661 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 667 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 662 scroll_layer->SetBounds(gfx::Size(10, 10)); | 668 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 663 | 669 |
| 664 // Building property trees twice shouldn't change the size of | 670 // Building property trees twice shouldn't change the size of |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); | 731 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); |
| 726 | 732 |
| 727 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 733 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 728 scoped_refptr<Layer> scroll_layer = Layer::Create(); | 734 scoped_refptr<Layer> scroll_layer = Layer::Create(); |
| 729 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 735 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 730 scoped_refptr<Layer> child1 = Layer::Create(); | 736 scoped_refptr<Layer> child1 = Layer::Create(); |
| 731 scoped_refptr<Layer> scrollbar_layer; | 737 scoped_refptr<Layer> scrollbar_layer; |
| 732 const bool kIsLeftSideVerticalScrollbar = false; | 738 const bool kIsLeftSideVerticalScrollbar = false; |
| 733 scrollbar_layer = SolidColorScrollbarLayer::Create( | 739 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 734 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 740 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 735 kIsLeftSideVerticalScrollbar, scroll_layer->id()); | 741 kIsLeftSideVerticalScrollbar, scroll_layer->id(), |
| 742 scroll_layer->element_id()); |
| 736 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); | 743 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); |
| 737 scroll_layer->AddChild(child1); | 744 scroll_layer->AddChild(child1); |
| 738 scroll_layer->InsertChild(scrollbar_layer, 1); | 745 scroll_layer->InsertChild(scrollbar_layer, 1); |
| 739 layer_tree_root->AddChild(scroll_layer); | 746 layer_tree_root->AddChild(scroll_layer); |
| 740 layer_tree_host_->SetRootLayer(layer_tree_root); | 747 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 741 | 748 |
| 742 layer_tree_root->SetBounds(gfx::Size(2, 2)); | 749 layer_tree_root->SetBounds(gfx::Size(2, 2)); |
| 743 scroll_layer->SetBounds(gfx::Size(10, 10)); | 750 scroll_layer->SetBounds(gfx::Size(10, 10)); |
| 744 layer_tree_host_->UpdateLayers(); | 751 layer_tree_host_->UpdateLayers(); |
| 745 layer_tree_host_->CommitAndCreateLayerImplTree(); | 752 layer_tree_host_->CommitAndCreateLayerImplTree(); |
| 746 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); | 753 LayerTreeHostImpl* host_impl = layer_tree_host_->host_impl(); |
| 747 EXPECT_TRUE(host_impl->ScrollbarAnimationControllerForId(scroll_layer->id())); | 754 EXPECT_TRUE(host_impl->ScrollbarAnimationControllerForElementId( |
| 755 scroll_layer->element_id())); |
| 748 | 756 |
| 749 scroll_layer->SetBounds(gfx::Size(20, 20)); | 757 scroll_layer->SetBounds(gfx::Size(20, 20)); |
| 750 scroll_layer->SetForceRenderSurfaceForTesting(true); | 758 scroll_layer->SetForceRenderSurfaceForTesting(true); |
| 751 layer_tree_host_->UpdateLayers(); | 759 layer_tree_host_->UpdateLayers(); |
| 752 host_impl->CreatePendingTree(); | 760 host_impl->CreatePendingTree(); |
| 753 layer_tree_host_->CommitAndCreatePendingTree(); | 761 layer_tree_host_->CommitAndCreatePendingTree(); |
| 754 host_impl->ActivateSyncTree(); | 762 host_impl->ActivateSyncTree(); |
| 755 EffectNode* node = | 763 EffectNode* node = |
| 756 host_impl->active_tree()->property_trees()->effect_tree.Node( | 764 host_impl->active_tree()->property_trees()->effect_tree.Node( |
| 757 scrollbar_layer->effect_tree_index()); | 765 scrollbar_layer->effect_tree_index()); |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 872 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); | 880 std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); |
| 873 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 881 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 874 scoped_refptr<Layer> content_layer = Layer::Create(); | 882 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 875 scoped_refptr<Layer> scrollbar_layer; | 883 scoped_refptr<Layer> scrollbar_layer; |
| 876 if (use_solid_color_scrollbar) { | 884 if (use_solid_color_scrollbar) { |
| 877 const int kThumbThickness = 3; | 885 const int kThumbThickness = 3; |
| 878 const int kTrackStart = 0; | 886 const int kTrackStart = 0; |
| 879 const bool kIsLeftSideVerticalScrollbar = false; | 887 const bool kIsLeftSideVerticalScrollbar = false; |
| 880 scrollbar_layer = SolidColorScrollbarLayer::Create( | 888 scrollbar_layer = SolidColorScrollbarLayer::Create( |
| 881 scrollbar->Orientation(), kThumbThickness, kTrackStart, | 889 scrollbar->Orientation(), kThumbThickness, kTrackStart, |
| 882 kIsLeftSideVerticalScrollbar, layer_tree_root->id()); | 890 kIsLeftSideVerticalScrollbar, layer_tree_root->id(), |
| 891 layer_tree_root->element_id()); |
| 883 } else { | 892 } else { |
| 884 scrollbar_layer = PaintedScrollbarLayer::Create(std::move(scrollbar), | 893 scrollbar_layer = PaintedScrollbarLayer::Create( |
| 885 layer_tree_root->id()); | 894 std::move(scrollbar), layer_tree_root->id(), |
| 895 layer_tree_root->element_id()); |
| 886 } | 896 } |
| 887 layer_tree_root->AddChild(content_layer); | 897 layer_tree_root->AddChild(content_layer); |
| 888 layer_tree_root->AddChild(scrollbar_layer); | 898 layer_tree_root->AddChild(scrollbar_layer); |
| 889 | 899 |
| 890 layer_tree_host_->SetRootLayer(layer_tree_root); | 900 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 891 | 901 |
| 892 scrollbar_layer->SetIsDrawable(true); | 902 scrollbar_layer->SetIsDrawable(true); |
| 893 scrollbar_layer->SetBounds(gfx::Size(100, 100)); | 903 scrollbar_layer->SetBounds(gfx::Size(100, 100)); |
| 894 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20)); | 904 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20)); |
| 895 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 905 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 934 bool use_solid_color_scrollbars = true; | 944 bool use_solid_color_scrollbars = true; |
| 935 TestResourceUpload(0, 0, 0, 0, use_solid_color_scrollbars); | 945 TestResourceUpload(0, 0, 0, 0, use_solid_color_scrollbars); |
| 936 TestResourceUpload(1, 0, 0, 0, use_solid_color_scrollbars); | 946 TestResourceUpload(1, 0, 0, 0, use_solid_color_scrollbars); |
| 937 } | 947 } |
| 938 | 948 |
| 939 TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TestResourceUpdate) { | 949 TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TestResourceUpdate) { |
| 940 gfx::Point scrollbar_location(0, 185); | 950 gfx::Point scrollbar_location(0, 185); |
| 941 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 951 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 942 scoped_refptr<Layer> content_layer = Layer::Create(); | 952 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 943 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 953 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 944 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); | 954 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id(), |
| 955 layer_tree_root->element_id()); |
| 945 | 956 |
| 946 layer_tree_root->AddChild(content_layer); | 957 layer_tree_root->AddChild(content_layer); |
| 947 layer_tree_root->AddChild(scrollbar_layer); | 958 layer_tree_root->AddChild(scrollbar_layer); |
| 948 | 959 |
| 949 layer_tree_host_->SetRootLayer(layer_tree_root); | 960 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 950 | 961 |
| 951 scrollbar_layer->SetIsDrawable(true); | 962 scrollbar_layer->SetIsDrawable(true); |
| 952 scrollbar_layer->SetBounds(gfx::Size(100, 15)); | 963 scrollbar_layer->SetBounds(gfx::Size(100, 15)); |
| 953 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location)); | 964 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location)); |
| 954 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 965 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1094 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); | 1105 testing::Mock::VerifyAndClearExpectations(layer_tree_host_.get()); |
| 1095 } | 1106 } |
| 1096 | 1107 |
| 1097 class ScaledScrollbarLayerTestResourceCreation : public ScrollbarLayerTest { | 1108 class ScaledScrollbarLayerTestResourceCreation : public ScrollbarLayerTest { |
| 1098 public: | 1109 public: |
| 1099 void TestResourceUpload(float test_scale) { | 1110 void TestResourceUpload(float test_scale) { |
| 1100 gfx::Point scrollbar_location(0, 185); | 1111 gfx::Point scrollbar_location(0, 185); |
| 1101 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 1112 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 1102 scoped_refptr<Layer> content_layer = Layer::Create(); | 1113 scoped_refptr<Layer> content_layer = Layer::Create(); |
| 1103 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 1114 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 1104 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); | 1115 FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id(), |
| 1116 layer_tree_root->element_id()); |
| 1105 | 1117 |
| 1106 layer_tree_root->AddChild(content_layer); | 1118 layer_tree_root->AddChild(content_layer); |
| 1107 layer_tree_root->AddChild(scrollbar_layer); | 1119 layer_tree_root->AddChild(scrollbar_layer); |
| 1108 | 1120 |
| 1109 layer_tree_host_->SetRootLayer(layer_tree_root); | 1121 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 1110 | 1122 |
| 1111 scrollbar_layer->SetIsDrawable(true); | 1123 scrollbar_layer->SetIsDrawable(true); |
| 1112 scrollbar_layer->SetBounds(gfx::Size(100, 15)); | 1124 scrollbar_layer->SetBounds(gfx::Size(100, 15)); |
| 1113 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location)); | 1125 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_location)); |
| 1114 layer_tree_root->SetBounds(gfx::Size(100, 200)); | 1126 layer_tree_root->SetBounds(gfx::Size(100, 200)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1164 } | 1176 } |
| 1165 | 1177 |
| 1166 class ScaledScrollbarLayerTestScaledRasterization : public ScrollbarLayerTest { | 1178 class ScaledScrollbarLayerTestScaledRasterization : public ScrollbarLayerTest { |
| 1167 public: | 1179 public: |
| 1168 void TestScale(const gfx::Rect& scrollbar_rect, float test_scale) { | 1180 void TestScale(const gfx::Rect& scrollbar_rect, float test_scale) { |
| 1169 bool paint_during_update = true; | 1181 bool paint_during_update = true; |
| 1170 bool has_thumb = false; | 1182 bool has_thumb = false; |
| 1171 scoped_refptr<Layer> layer_tree_root = Layer::Create(); | 1183 scoped_refptr<Layer> layer_tree_root = Layer::Create(); |
| 1172 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = | 1184 scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = |
| 1173 FakePaintedScrollbarLayer::Create(paint_during_update, has_thumb, | 1185 FakePaintedScrollbarLayer::Create(paint_during_update, has_thumb, |
| 1174 layer_tree_root->id()); | 1186 layer_tree_root->id(), |
| 1187 layer_tree_root->element_id()); |
| 1175 | 1188 |
| 1176 layer_tree_root->AddChild(scrollbar_layer); | 1189 layer_tree_root->AddChild(scrollbar_layer); |
| 1177 | 1190 |
| 1178 layer_tree_host_->SetRootLayer(layer_tree_root); | 1191 layer_tree_host_->SetRootLayer(layer_tree_root); |
| 1179 | 1192 |
| 1180 scrollbar_layer->SetBounds(scrollbar_rect.size()); | 1193 scrollbar_layer->SetBounds(scrollbar_rect.size()); |
| 1181 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_rect.origin())); | 1194 scrollbar_layer->SetPosition(gfx::PointF(scrollbar_rect.origin())); |
| 1182 scrollbar_layer->fake_scrollbar()->set_location(scrollbar_rect.origin()); | 1195 scrollbar_layer->fake_scrollbar()->set_location(scrollbar_rect.origin()); |
| 1183 scrollbar_layer->fake_scrollbar()->set_track_rect(scrollbar_rect); | 1196 scrollbar_layer->fake_scrollbar()->set_track_rect(scrollbar_rect); |
| 1184 scrollbar_layer->set_visible_layer_rect(scrollbar_rect); | 1197 scrollbar_layer->set_visible_layer_rect(scrollbar_rect); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); | 1248 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); |
| 1236 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); | 1249 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); |
| 1237 | 1250 |
| 1238 // Horizontal Scrollbars. | 1251 // Horizontal Scrollbars. |
| 1239 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); | 1252 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); |
| 1240 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); | 1253 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); |
| 1241 } | 1254 } |
| 1242 | 1255 |
| 1243 } // namespace | 1256 } // namespace |
| 1244 } // namespace cc | 1257 } // namespace cc |
| OLD | NEW |