Commit 42e5f477 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Remove scroll_element_id parameter from cc scrollbar constructors

The meaning of the parameter was not obvious at callsites, confusing
with layer's element id. Also the parameter was used in tests only,
and we already have SetScrollElementId() for the same purpose.

Change-Id: I62b0b6ad732389b419f351ac266cfdec73742fdc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1839034
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Auto-Submit: Xianzhu Wang <wangxianzhu@chromium.org>
Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702645}
parent d1830bbc
...@@ -31,17 +31,14 @@ std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl( ...@@ -31,17 +31,14 @@ std::unique_ptr<LayerImpl> PaintedOverlayScrollbarLayer::CreateLayerImpl(
} }
scoped_refptr<PaintedOverlayScrollbarLayer> scoped_refptr<PaintedOverlayScrollbarLayer>
PaintedOverlayScrollbarLayer::Create(std::unique_ptr<Scrollbar> scrollbar, PaintedOverlayScrollbarLayer::Create(std::unique_ptr<Scrollbar> scrollbar) {
ElementId scroll_element_id) { return base::WrapRefCounted(
return base::WrapRefCounted(new PaintedOverlayScrollbarLayer( new PaintedOverlayScrollbarLayer(std::move(scrollbar)));
std::move(scrollbar), scroll_element_id));
} }
PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer( PaintedOverlayScrollbarLayer::PaintedOverlayScrollbarLayer(
std::unique_ptr<Scrollbar> scrollbar, std::unique_ptr<Scrollbar> scrollbar)
ElementId scroll_element_id)
: scrollbar_(std::move(scrollbar)), : scrollbar_(std::move(scrollbar)),
scroll_element_id_(scroll_element_id),
thumb_thickness_(scrollbar_->ThumbThickness()), thumb_thickness_(scrollbar_->ThumbThickness()),
thumb_length_(scrollbar_->ThumbLength()) { thumb_length_(scrollbar_->ThumbLength()) {
DCHECK(scrollbar_->HasThumb()); DCHECK(scrollbar_->HasThumb());
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
namespace cc { namespace cc {
// For composited overlay scrollbars with nine-patch thumb. For overlay
// scrollbars whose thumb is not nine-patch, use PaintedScrollbarLayer.
class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface, class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface,
public Layer { public Layer {
public: public:
...@@ -22,8 +24,7 @@ class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface, ...@@ -22,8 +24,7 @@ class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface,
PaintedOverlayScrollbarLayer& operator=(const PaintedOverlayScrollbarLayer&) = PaintedOverlayScrollbarLayer& operator=(const PaintedOverlayScrollbarLayer&) =
delete; delete;
static scoped_refptr<PaintedOverlayScrollbarLayer> Create( static scoped_refptr<PaintedOverlayScrollbarLayer> Create(
std::unique_ptr<Scrollbar> scrollbar, std::unique_ptr<Scrollbar> scrollbar);
ElementId scroll_element_id = ElementId());
bool OpacityCanAnimateOnImplThread() const override; bool OpacityCanAnimateOnImplThread() const override;
...@@ -36,8 +37,7 @@ class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface, ...@@ -36,8 +37,7 @@ class CC_EXPORT PaintedOverlayScrollbarLayer : public ScrollbarLayerInterface,
void PushPropertiesTo(LayerImpl* layer) override; void PushPropertiesTo(LayerImpl* layer) override;
protected: protected:
PaintedOverlayScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar, explicit PaintedOverlayScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar);
ElementId scroll_element_id);
~PaintedOverlayScrollbarLayer() override; ~PaintedOverlayScrollbarLayer() override;
private: private:
......
...@@ -21,17 +21,13 @@ std::unique_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl( ...@@ -21,17 +21,13 @@ std::unique_ptr<LayerImpl> PaintedScrollbarLayer::CreateLayerImpl(
} }
scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create( scoped_refptr<PaintedScrollbarLayer> PaintedScrollbarLayer::Create(
std::unique_ptr<Scrollbar> scrollbar, std::unique_ptr<Scrollbar> scrollbar) {
ElementId scroll_element_id) { return base::WrapRefCounted(new PaintedScrollbarLayer(std::move(scrollbar)));
return base::WrapRefCounted(
new PaintedScrollbarLayer(std::move(scrollbar), scroll_element_id));
} }
PaintedScrollbarLayer::PaintedScrollbarLayer( PaintedScrollbarLayer::PaintedScrollbarLayer(
std::unique_ptr<Scrollbar> scrollbar, std::unique_ptr<Scrollbar> scrollbar)
ElementId scroll_element_id)
: scrollbar_(std::move(scrollbar)), : scrollbar_(std::move(scrollbar)),
scroll_element_id_(scroll_element_id),
internal_contents_scale_(1.f), internal_contents_scale_(1.f),
supports_drag_snap_back_(false), supports_drag_snap_back_(false),
thumb_thickness_(scrollbar_->ThumbThickness()), thumb_thickness_(scrollbar_->ThumbThickness()),
......
...@@ -19,8 +19,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, ...@@ -19,8 +19,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface,
std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; std::unique_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override;
static scoped_refptr<PaintedScrollbarLayer> Create( static scoped_refptr<PaintedScrollbarLayer> Create(
std::unique_ptr<Scrollbar> scrollbar, std::unique_ptr<Scrollbar> scrollbar);
ElementId element_id = ElementId());
PaintedScrollbarLayer(const PaintedScrollbarLayer&) = delete; PaintedScrollbarLayer(const PaintedScrollbarLayer&) = delete;
PaintedScrollbarLayer& operator=(const PaintedScrollbarLayer&) = delete; PaintedScrollbarLayer& operator=(const PaintedScrollbarLayer&) = delete;
...@@ -40,8 +39,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface, ...@@ -40,8 +39,7 @@ class CC_EXPORT PaintedScrollbarLayer : public ScrollbarLayerInterface,
} }
protected: protected:
PaintedScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar, explicit PaintedScrollbarLayer(std::unique_ptr<Scrollbar> scrollbar);
ElementId scroll_element_id);
~PaintedScrollbarLayer() override; ~PaintedScrollbarLayer() override;
// For unit tests // For unit tests
......
...@@ -147,12 +147,15 @@ class BaseScrollbarLayerTest : public testing::Test { ...@@ -147,12 +147,15 @@ class BaseScrollbarLayerTest : public testing::Test {
scoped_refptr<Layer> child2; scoped_refptr<Layer> child2;
if (use_solid_color_scrollbar) { if (use_solid_color_scrollbar) {
const bool kIsLeftSideVerticalScrollbar = false; const bool kIsLeftSideVerticalScrollbar = false;
child2 = SolidColorScrollbarLayer::Create( child2 = SolidColorScrollbarLayer::Create(scrollbar->Orientation(),
scrollbar->Orientation(), thumb_thickness, track_start, thumb_thickness, track_start,
kIsLeftSideVerticalScrollbar, child1->element_id()); kIsLeftSideVerticalScrollbar);
static_cast<SolidColorScrollbarLayer*>(child2.get())
->SetScrollElementId(child1->element_id());
} else { } else {
child2 = PaintedScrollbarLayer::Create(std::move(scrollbar), child2 = PaintedScrollbarLayer::Create(std::move(scrollbar));
child1->element_id()); static_cast<PaintedScrollbarLayer*>(child2.get())
->SetScrollElementId(child1->element_id());
} }
layer_tree_root->AddChild(child1); layer_tree_root->AddChild(child1);
layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1);
...@@ -207,8 +210,8 @@ TEST_F(ScrollbarLayerTest, RepaintOverlayWhenResourceDisposed) { ...@@ -207,8 +210,8 @@ TEST_F(ScrollbarLayerTest, RepaintOverlayWhenResourceDisposed) {
new FakePaintedOverlayScrollbar); new FakePaintedOverlayScrollbar);
FakePaintedOverlayScrollbar* fake_scrollbar = scrollbar.get(); FakePaintedOverlayScrollbar* fake_scrollbar = scrollbar.get();
scoped_refptr<PaintedOverlayScrollbarLayer> scrollbar_layer = scoped_refptr<PaintedOverlayScrollbarLayer> scrollbar_layer =
PaintedOverlayScrollbarLayer::Create(std::move(scrollbar), PaintedOverlayScrollbarLayer::Create(std::move(scrollbar));
layer_tree_root->element_id()); scrollbar_layer->SetScrollElementId(layer_tree_root->element_id());
// Setup. // Setup.
{ {
...@@ -270,14 +273,14 @@ TEST_F(ScrollbarLayerTest, ScrollElementIdPushedAcrossCommit) { ...@@ -270,14 +273,14 @@ TEST_F(ScrollbarLayerTest, ScrollElementIdPushedAcrossCommit) {
layer_b->SetElementId(LayerIdToElementIdForTesting(layer_b->id())); layer_b->SetElementId(LayerIdToElementIdForTesting(layer_b->id()));
scoped_refptr<PaintedScrollbarLayer> painted_scrollbar_layer = scoped_refptr<PaintedScrollbarLayer> painted_scrollbar_layer =
PaintedScrollbarLayer::Create(std::move(scrollbar1), PaintedScrollbarLayer::Create(std::move(scrollbar1));
layer_a->element_id()); painted_scrollbar_layer->SetScrollElementId(layer_a->element_id());
scoped_refptr<PaintedOverlayScrollbarLayer> painted_overlay_scrollbar_layer = scoped_refptr<PaintedOverlayScrollbarLayer> painted_overlay_scrollbar_layer =
PaintedOverlayScrollbarLayer::Create(std::move(scrollbar2), PaintedOverlayScrollbarLayer::Create(std::move(scrollbar2));
layer_a->element_id()); painted_overlay_scrollbar_layer->SetScrollElementId(layer_a->element_id());
scoped_refptr<SolidColorScrollbarLayer> solid_color_scrollbar_layer = scoped_refptr<SolidColorScrollbarLayer> solid_color_scrollbar_layer =
SolidColorScrollbarLayer::Create(VERTICAL, 1, 1, false, SolidColorScrollbarLayer::Create(VERTICAL, 1, 1, false);
layer_a->element_id()); solid_color_scrollbar_layer->SetScrollElementId(layer_a->element_id());
layer_tree_host_->SetRootLayer(layer_tree_root); layer_tree_host_->SetRootLayer(layer_tree_root);
layer_tree_root->AddChild(layer_a); layer_tree_root->AddChild(layer_a);
...@@ -336,8 +339,9 @@ TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { ...@@ -336,8 +339,9 @@ TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) {
scoped_refptr<Layer> scroll_layer = Layer::Create(); scoped_refptr<Layer> scroll_layer = Layer::Create();
scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
scoped_refptr<Layer> content_layer = Layer::Create(); scoped_refptr<Layer> content_layer = Layer::Create();
scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( scoped_refptr<PaintedScrollbarLayer> scrollbar_layer =
std::move(scrollbar), scroll_layer->element_id()); PaintedScrollbarLayer::Create(std::move(scrollbar));
scrollbar_layer->SetScrollElementId(scroll_layer->element_id());
// Choose bounds to give max_scroll_offset = (30, 50). // Choose bounds to give max_scroll_offset = (30, 50).
layer_tree_root->SetBounds(gfx::Size(70, 150)); layer_tree_root->SetBounds(gfx::Size(70, 150));
...@@ -637,11 +641,12 @@ TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { ...@@ -637,11 +641,12 @@ TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) {
scoped_refptr<Layer> scroll_layer = Layer::Create(); scoped_refptr<Layer> scroll_layer = Layer::Create();
scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
scoped_refptr<Layer> child1 = Layer::Create(); scoped_refptr<Layer> child1 = Layer::Create();
scoped_refptr<Layer> child2;
const bool kIsLeftSideVerticalScrollbar = false; const bool kIsLeftSideVerticalScrollbar = false;
child2 = SolidColorScrollbarLayer::Create( scoped_refptr<SolidColorScrollbarLayer> child2 =
scrollbar->Orientation(), kThumbThickness, kTrackStart, SolidColorScrollbarLayer::Create(scrollbar->Orientation(),
kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); kThumbThickness, kTrackStart,
kIsLeftSideVerticalScrollbar);
child2->SetScrollElementId(scroll_layer->element_id());
scroll_layer->AddChild(child1); scroll_layer->AddChild(child1);
scroll_layer->InsertChild(child2, 1); scroll_layer->InsertChild(child2, 1);
layer_tree_root->AddChild(scroll_layer); layer_tree_root->AddChild(scroll_layer);
...@@ -697,7 +702,8 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerOpacity) { ...@@ -697,7 +702,8 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerOpacity) {
const bool kIsLeftSideVerticalScrollbar = false; const bool kIsLeftSideVerticalScrollbar = false;
scrollbar_layer = SolidColorScrollbarLayer::Create( scrollbar_layer = SolidColorScrollbarLayer::Create(
scrollbar->Orientation(), kThumbThickness, kTrackStart, scrollbar->Orientation(), kThumbThickness, kTrackStart,
kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); kIsLeftSideVerticalScrollbar);
scrollbar_layer->SetScrollElementId(scroll_layer->element_id());
scrollbar_layer->SetElementId(ElementId(300)); scrollbar_layer->SetElementId(ElementId(300));
scroll_layer->AddChild(child1); scroll_layer->AddChild(child1);
scroll_layer->InsertChild(scrollbar_layer, 1); scroll_layer->InsertChild(scrollbar_layer, 1);
...@@ -770,11 +776,12 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerPushProperties) { ...@@ -770,11 +776,12 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerPushProperties) {
scoped_refptr<Layer> scroll_layer = Layer::Create(); scoped_refptr<Layer> scroll_layer = Layer::Create();
scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id())); scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_layer->id()));
scoped_refptr<Layer> child1 = Layer::Create(); scoped_refptr<Layer> child1 = Layer::Create();
scoped_refptr<Layer> scrollbar_layer;
const bool kIsLeftSideVerticalScrollbar = false; const bool kIsLeftSideVerticalScrollbar = false;
scrollbar_layer = SolidColorScrollbarLayer::Create( scoped_refptr<SolidColorScrollbarLayer> scrollbar_layer =
scrollbar->Orientation(), kThumbThickness, kTrackStart, SolidColorScrollbarLayer::Create(scrollbar->Orientation(),
kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); kThumbThickness, kTrackStart,
kIsLeftSideVerticalScrollbar);
scrollbar_layer->SetScrollElementId(scroll_layer->element_id());
scroll_layer->AddChild(child1); scroll_layer->AddChild(child1);
scroll_layer->InsertChild(scrollbar_layer, 1); scroll_layer->InsertChild(scrollbar_layer, 1);
layer_tree_root->AddChild(scroll_layer); layer_tree_root->AddChild(scroll_layer);
...@@ -914,9 +921,11 @@ TEST_F(AuraScrollbarLayerTest, ScrollbarLayerCreateAfterSetScrollable) { ...@@ -914,9 +921,11 @@ TEST_F(AuraScrollbarLayerTest, ScrollbarLayerCreateAfterSetScrollable) {
host_impl->ActivateSyncTree(); host_impl->ActivateSyncTree();
std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); std::unique_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
scoped_refptr<Layer> scrollbar_layer = SolidColorScrollbarLayer::Create( scoped_refptr<SolidColorScrollbarLayer> scrollbar_layer =
scrollbar->Orientation(), kThumbThickness, kTrackStart, SolidColorScrollbarLayer::Create(scrollbar->Orientation(),
kIsLeftSideVerticalScrollbar, scroll_layer->element_id()); kThumbThickness, kTrackStart,
kIsLeftSideVerticalScrollbar);
scrollbar_layer->SetScrollElementId(scroll_layer->element_id());
scroll_layer->InsertChild(scrollbar_layer, 1); scroll_layer->InsertChild(scrollbar_layer, 1);
layer_tree_host_->UpdateLayers(); layer_tree_host_->UpdateLayers();
...@@ -1052,10 +1061,13 @@ class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest { ...@@ -1052,10 +1061,13 @@ class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest {
const bool kIsLeftSideVerticalScrollbar = false; const bool kIsLeftSideVerticalScrollbar = false;
scrollbar_layer = SolidColorScrollbarLayer::Create( scrollbar_layer = SolidColorScrollbarLayer::Create(
scrollbar->Orientation(), kThumbThickness, kTrackStart, scrollbar->Orientation(), kThumbThickness, kTrackStart,
kIsLeftSideVerticalScrollbar, layer_tree_root->element_id()); kIsLeftSideVerticalScrollbar);
static_cast<SolidColorScrollbarLayer*>(scrollbar_layer.get())
->SetScrollElementId(layer_tree_root->element_id());
} else { } else {
scrollbar_layer = PaintedScrollbarLayer::Create( scrollbar_layer = PaintedScrollbarLayer::Create(std::move(scrollbar));
std::move(scrollbar), layer_tree_root->element_id()); static_cast<PaintedScrollbarLayer*>(scrollbar_layer.get())
->SetScrollElementId(layer_tree_root->element_id());
} }
layer_tree_root->AddChild(content_layer); layer_tree_root->AddChild(content_layer);
layer_tree_root->AddChild(scrollbar_layer); layer_tree_root->AddChild(scrollbar_layer);
......
...@@ -15,50 +15,29 @@ std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl( ...@@ -15,50 +15,29 @@ std::unique_ptr<LayerImpl> SolidColorScrollbarLayer::CreateLayerImpl(
LayerTreeImpl* tree_impl) { LayerTreeImpl* tree_impl) {
const bool kIsOverlayScrollbar = true; const bool kIsOverlayScrollbar = true;
return SolidColorScrollbarLayerImpl::Create( return SolidColorScrollbarLayerImpl::Create(
tree_impl, id(), solid_color_scrollbar_layer_inputs_.orientation, tree_impl, id(), orientation_, thumb_thickness_, track_start_,
solid_color_scrollbar_layer_inputs_.thumb_thickness, is_left_side_vertical_scrollbar_, kIsOverlayScrollbar);
solid_color_scrollbar_layer_inputs_.track_start,
solid_color_scrollbar_layer_inputs_.is_left_side_vertical_scrollbar,
kIsOverlayScrollbar);
} }
scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create( scoped_refptr<SolidColorScrollbarLayer> SolidColorScrollbarLayer::Create(
ScrollbarOrientation orientation, ScrollbarOrientation orientation,
int thumb_thickness, int thumb_thickness,
int track_start, int track_start,
bool is_left_side_vertical_scrollbar, bool is_left_side_vertical_scrollbar) {
ElementId scroll_element_id) { return base::WrapRefCounted(
return base::WrapRefCounted(new SolidColorScrollbarLayer( new SolidColorScrollbarLayer(orientation, thumb_thickness, track_start,
orientation, thumb_thickness, track_start, is_left_side_vertical_scrollbar));
is_left_side_vertical_scrollbar, scroll_element_id));
} }
SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs::
SolidColorScrollbarLayerInputs(ScrollbarOrientation orientation,
int thumb_thickness,
int track_start,
bool is_left_side_vertical_scrollbar,
ElementId scroll_element_id)
: scroll_element_id(scroll_element_id),
orientation(orientation),
thumb_thickness(thumb_thickness),
track_start(track_start),
is_left_side_vertical_scrollbar(is_left_side_vertical_scrollbar) {}
SolidColorScrollbarLayer::SolidColorScrollbarLayerInputs::
~SolidColorScrollbarLayerInputs() = default;
SolidColorScrollbarLayer::SolidColorScrollbarLayer( SolidColorScrollbarLayer::SolidColorScrollbarLayer(
ScrollbarOrientation orientation, ScrollbarOrientation orientation,
int thumb_thickness, int thumb_thickness,
int track_start, int track_start,
bool is_left_side_vertical_scrollbar, bool is_left_side_vertical_scrollbar)
ElementId scroll_element_id) : orientation_(orientation),
: solid_color_scrollbar_layer_inputs_(orientation, thumb_thickness_(thumb_thickness),
thumb_thickness, track_start_(track_start),
track_start, is_left_side_vertical_scrollbar_(is_left_side_vertical_scrollbar) {
is_left_side_vertical_scrollbar,
scroll_element_id) {
Layer::SetOpacity(0.f); Layer::SetOpacity(0.f);
SetIsScrollbar(true); SetIsScrollbar(true);
} }
...@@ -78,8 +57,7 @@ void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) { ...@@ -78,8 +57,7 @@ void SolidColorScrollbarLayer::PushPropertiesTo(LayerImpl* layer) {
DCHECK(!scrollbar_layer->HitTestable()); DCHECK(!scrollbar_layer->HitTestable());
scrollbar_layer->SetScrollElementId( scrollbar_layer->SetScrollElementId(scroll_element_id_);
solid_color_scrollbar_layer_inputs_.scroll_element_id);
} }
void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) { void SolidColorScrollbarLayer::SetNeedsDisplayRect(const gfx::Rect& rect) {
...@@ -91,10 +69,10 @@ bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const { ...@@ -91,10 +69,10 @@ bool SolidColorScrollbarLayer::OpacityCanAnimateOnImplThread() const {
} }
void SolidColorScrollbarLayer::SetScrollElementId(ElementId element_id) { void SolidColorScrollbarLayer::SetScrollElementId(ElementId element_id) {
if (element_id == solid_color_scrollbar_layer_inputs_.scroll_element_id) if (element_id == scroll_element_id_)
return; return;
solid_color_scrollbar_layer_inputs_.scroll_element_id = element_id; scroll_element_id_ = element_id;
SetNeedsCommit(); SetNeedsCommit();
} }
......
...@@ -20,8 +20,7 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface, ...@@ -20,8 +20,7 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface,
ScrollbarOrientation orientation, ScrollbarOrientation orientation,
int thumb_thickness, int thumb_thickness,
int track_start, int track_start,
bool is_left_side_vertical_scrollbar, bool is_left_side_vertical_scrollbar);
ElementId scroll_element_id);
SolidColorScrollbarLayer(const SolidColorScrollbarLayer&) = delete; SolidColorScrollbarLayer(const SolidColorScrollbarLayer&) = delete;
SolidColorScrollbarLayer& operator=(const SolidColorScrollbarLayer&) = delete; SolidColorScrollbarLayer& operator=(const SolidColorScrollbarLayer&) = delete;
...@@ -43,30 +42,14 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface, ...@@ -43,30 +42,14 @@ class CC_EXPORT SolidColorScrollbarLayer : public ScrollbarLayerInterface,
SolidColorScrollbarLayer(ScrollbarOrientation orientation, SolidColorScrollbarLayer(ScrollbarOrientation orientation,
int thumb_thickness, int thumb_thickness,
int track_start, int track_start,
bool is_left_side_vertical_scrollbar, bool is_left_side_vertical_scrollbar);
ElementId scroll_element_id);
~SolidColorScrollbarLayer() override; ~SolidColorScrollbarLayer() override;
private: ElementId scroll_element_id_;
friend class LayerSerializationTest; ScrollbarOrientation orientation_;
int thumb_thickness_;
// Encapsulate all data, callbacks, interfaces received from the embedder. int track_start_;
struct SolidColorScrollbarLayerInputs { bool is_left_side_vertical_scrollbar_;
SolidColorScrollbarLayerInputs(ScrollbarOrientation orientation,
int thumb_thickness,
int track_start,
bool is_left_side_vertical_scrollbar,
ElementId scroll_element_id);
~SolidColorScrollbarLayerInputs();
ElementId scroll_element_id;
ScrollbarOrientation orientation;
int thumb_thickness;
int track_start;
bool is_left_side_vertical_scrollbar;
};
SolidColorScrollbarLayerInputs solid_color_scrollbar_layer_inputs_;
}; };
} // namespace cc } // namespace cc
......
...@@ -33,12 +33,12 @@ scoped_refptr<FakePaintedScrollbarLayer> FakePaintedScrollbarLayer::Create( ...@@ -33,12 +33,12 @@ scoped_refptr<FakePaintedScrollbarLayer> FakePaintedScrollbarLayer::Create(
FakePaintedScrollbarLayer::FakePaintedScrollbarLayer( FakePaintedScrollbarLayer::FakePaintedScrollbarLayer(
FakeScrollbar* fake_scrollbar, FakeScrollbar* fake_scrollbar,
ElementId scrolling_element_id) ElementId scroll_element_id)
: PaintedScrollbarLayer(std::unique_ptr<Scrollbar>(fake_scrollbar), : PaintedScrollbarLayer(std::unique_ptr<Scrollbar>(fake_scrollbar)),
scrolling_element_id),
update_count_(0), update_count_(0),
push_properties_count_(0), push_properties_count_(0),
fake_scrollbar_(fake_scrollbar) { fake_scrollbar_(fake_scrollbar) {
SetScrollElementId(scroll_element_id);
SetBounds(gfx::Size(1, 1)); SetBounds(gfx::Size(1, 1));
SetIsDrawable(true); SetIsDrawable(true);
} }
......
...@@ -984,7 +984,8 @@ class LayerTreeHostContextTestDontUseLostResources ...@@ -984,7 +984,8 @@ class LayerTreeHostContextTestDontUseLostResources
scoped_refptr<PaintedScrollbarLayer> scrollbar = scoped_refptr<PaintedScrollbarLayer> scrollbar =
PaintedScrollbarLayer::Create( PaintedScrollbarLayer::Create(
std::unique_ptr<Scrollbar>(new FakeScrollbar), layer->element_id()); std::unique_ptr<Scrollbar>(new FakeScrollbar));
scrollbar->SetScrollElementId(layer->element_id());
scrollbar->SetBounds(gfx::Size(10, 10)); scrollbar->SetBounds(gfx::Size(10, 10));
scrollbar->SetIsDrawable(true); scrollbar->SetIsDrawable(true);
root->AddChild(scrollbar); root->AddChild(scrollbar);
......
...@@ -263,14 +263,14 @@ CreateScrollbarLayer(Scrollbar& scrollbar, float device_scale_factor) { ...@@ -263,14 +263,14 @@ CreateScrollbarLayer(Scrollbar& scrollbar, float device_scale_factor) {
auto layer_group = auto layer_group =
std::make_unique<ScrollingCoordinator::ScrollbarLayerGroup>(); std::make_unique<ScrollingCoordinator::ScrollbarLayerGroup>();
if (theme.UsesOverlayScrollbars() && theme.UsesNinePatchThumbResource()) { if (theme.UsesOverlayScrollbars() && theme.UsesNinePatchThumbResource()) {
auto scrollbar_layer = cc::PaintedOverlayScrollbarLayer::Create( auto scrollbar_layer =
std::move(scrollbar_delegate), /*scroll_element_id=*/cc::ElementId()); cc::PaintedOverlayScrollbarLayer::Create(std::move(scrollbar_delegate));
scrollbar_layer->SetElementId(scrollbar.GetElementId()); scrollbar_layer->SetElementId(scrollbar.GetElementId());
layer_group->scrollbar_layer = scrollbar_layer.get(); layer_group->scrollbar_layer = scrollbar_layer.get();
layer_group->layer = std::move(scrollbar_layer); layer_group->layer = std::move(scrollbar_layer);
} else { } else {
auto scrollbar_layer = cc::PaintedScrollbarLayer::Create( auto scrollbar_layer =
std::move(scrollbar_delegate), /*scroll_element_id=*/cc::ElementId()); cc::PaintedScrollbarLayer::Create(std::move(scrollbar_delegate));
scrollbar_layer->SetElementId(scrollbar.GetElementId()); scrollbar_layer->SetElementId(scrollbar.GetElementId());
layer_group->scrollbar_layer = scrollbar_layer.get(); layer_group->scrollbar_layer = scrollbar_layer.get();
layer_group->layer = std::move(scrollbar_layer); layer_group->layer = std::move(scrollbar_layer);
...@@ -292,7 +292,7 @@ ScrollingCoordinator::CreateSolidColorScrollbarLayer( ...@@ -292,7 +292,7 @@ ScrollingCoordinator::CreateSolidColorScrollbarLayer(
orientation == kHorizontalScrollbar ? cc::HORIZONTAL : cc::VERTICAL; orientation == kHorizontalScrollbar ? cc::HORIZONTAL : cc::VERTICAL;
auto scrollbar_layer = cc::SolidColorScrollbarLayer::Create( auto scrollbar_layer = cc::SolidColorScrollbarLayer::Create(
cc_orientation, thumb_thickness, track_start, cc_orientation, thumb_thickness, track_start,
is_left_side_vertical_scrollbar, cc::ElementId()); is_left_side_vertical_scrollbar);
scrollbar_layer->SetElementId(element_id); scrollbar_layer->SetElementId(element_id);
auto layer_group = std::make_unique<ScrollbarLayerGroup>(); auto layer_group = std::make_unique<ScrollbarLayerGroup>();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment