cc: Use base::Callback approach instead of using WebKit interface.
Instead of having cc/ talk directly to the WebKit::WebLayerScrollClient, we
define a callback in cc/ that it can talk to.
In the compositor_bindings, we pass this callback down to cc, so it can call us back later.
BUG=None
TEST=cc_unittests, webkit_compositor_bindings_unittests
[email protected]
Review URL: https://chromiumcodereview.appspot.com/18139004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@209386 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/cc/DEPS b/cc/DEPS
index d5e7baa..ad58eba 100644
--- a/cc/DEPS
+++ b/cc/DEPS
@@ -13,5 +13,4 @@
# TODO(danakj): Drop dependencies on WebKit Platform API from cc.
"+third_party/WebKit/public/platform/WebGraphicsContext3D.h",
"+third_party/WebKit/public/platform/WebGraphicsMemoryAllocation.h",
- "+third_party/WebKit/public/platform/WebLayerScrollClient.h",
]
diff --git a/cc/layers/layer.cc b/cc/layers/layer.cc
index 270d2cb1..e1d59b7 100644
--- a/cc/layers/layer.cc
+++ b/cc/layers/layer.cc
@@ -17,7 +17,6 @@
#include "cc/output/copy_output_result.h"
#include "cc/trees/layer_tree_host.h"
#include "cc/trees/layer_tree_impl.h"
-#include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "ui/gfx/rect_conversions.h"
@@ -55,8 +54,7 @@
draw_checkerboard_for_missing_tiles_(false),
force_render_surface_(false),
replica_layer_(NULL),
- raster_scale_(0.f),
- layer_scroll_client_(NULL) {
+ raster_scale_(0.f) {
if (layer_id_ < 0) {
s_next_layer_id = 1;
layer_id_ = s_next_layer_id++;
@@ -526,8 +524,8 @@
if (scroll_offset_ == scroll_offset)
return;
scroll_offset_ = scroll_offset;
- if (layer_scroll_client_)
- layer_scroll_client_->didScroll();
+ if (!did_scroll_callback_.is_null())
+ did_scroll_callback_.Run();
// Note: didScroll() could potentially change the layer structure.
// "this" may have been destroyed during the process.
}
diff --git a/cc/layers/layer.h b/cc/layers/layer.h
index 73123b9..ec0c7dc 100644
--- a/cc/layers/layer.h
+++ b/cc/layers/layer.h
@@ -30,10 +30,6 @@
#include "ui/gfx/rect_f.h"
#include "ui/gfx/transform.h"
-namespace WebKit {
-class WebLayerScrollClient;
-}
-
namespace cc {
class Animation;
@@ -233,8 +229,8 @@
return touch_event_handler_region_;
}
- void set_layer_scroll_client(WebKit::WebLayerScrollClient* client) {
- layer_scroll_client_ = client;
+ void set_did_scroll_callback(const base::Closure& callback) {
+ did_scroll_callback_ = callback;
}
void SetDrawCheckerboardForMissingTiles(bool checkerboard);
@@ -486,7 +482,7 @@
ScopedPtrVector<CopyOutputRequest> copy_requests_;
- WebKit::WebLayerScrollClient* layer_scroll_client_;
+ base::Closure did_scroll_callback_;
DrawProperties<Layer, RenderSurface> draw_properties_;
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index 8582d8f5..040fece 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -13,7 +13,6 @@
#include "cc/test/geometry_test_utils.h"
#include "cc/test/layer_tree_test.h"
#include "cc/trees/layer_tree_impl.h"
-#include "third_party/WebKit/public/platform/WebLayerScrollClient.h"
#include "ui/gfx/point_conversions.h"
#include "ui/gfx/size_conversions.h"
#include "ui/gfx/vector2d_conversions.h"
@@ -222,9 +221,7 @@
MULTI_THREAD_TEST_F(LayerTreeHostScrollTestFractionalScroll);
-class LayerTreeHostScrollTestCaseWithChild
- : public LayerTreeHostScrollTest,
- public WebKit::WebLayerScrollClient {
+class LayerTreeHostScrollTestCaseWithChild : public LayerTreeHostScrollTest {
public:
LayerTreeHostScrollTestCaseWithChild()
: initial_offset_(10, 20),
@@ -250,7 +247,9 @@
root_layer->AddChild(root_scroll_layer_);
child_layer_ = ContentLayer::Create(&fake_content_layer_client_);
- child_layer_->set_layer_scroll_client(this);
+ child_layer_->set_did_scroll_callback(
+ base::Bind(&LayerTreeHostScrollTestCaseWithChild::DidScroll,
+ base::Unretained(this)));
child_layer_->SetBounds(gfx::Size(110, 110));
// Scrolls on the child layer will happen at 5, 5. If they are treated
@@ -280,7 +279,7 @@
virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); }
- virtual void didScroll() OVERRIDE {
+ void DidScroll() {
final_scroll_offset_ = expected_scroll_layer_->scroll_offset();
}
@@ -800,16 +799,16 @@
}
protected:
- class FakeWebLayerScrollClient : public WebKit::WebLayerScrollClient {
+ class FakeLayerScrollClient {
public:
- virtual void didScroll() OVERRIDE {
+ void DidScroll() {
owner_->DidScroll(layer_);
}
LayerTreeHostScrollTestLayerStructureChange* owner_;
Layer* layer_;
};
- Layer* CreateScrollLayer(Layer* parent, FakeWebLayerScrollClient* client) {
+ Layer* CreateScrollLayer(Layer* parent, FakeLayerScrollClient* client) {
scoped_refptr<Layer> scroll_layer =
ContentLayer::Create(&fake_content_layer_client_);
scroll_layer->SetBounds(gfx::Size(110, 110));
@@ -818,16 +817,17 @@
scroll_layer->SetIsDrawable(true);
scroll_layer->SetScrollable(true);
scroll_layer->SetMaxScrollOffset(gfx::Vector2d(100, 100));
- scroll_layer->set_layer_scroll_client(client);
+ scroll_layer->set_did_scroll_callback(base::Bind(
+ &FakeLayerScrollClient::DidScroll, base::Unretained(client)));
client->owner_ = this;
client->layer_ = scroll_layer.get();
parent->AddChild(scroll_layer);
return scroll_layer.get();
}
- FakeWebLayerScrollClient root_scroll_layer_client_;
- FakeWebLayerScrollClient sibling_scroll_layer_client_;
- FakeWebLayerScrollClient child_scroll_layer_client_;
+ FakeLayerScrollClient root_scroll_layer_client_;
+ FakeLayerScrollClient sibling_scroll_layer_client_;
+ FakeLayerScrollClient child_scroll_layer_client_;
FakeContentLayerClient fake_content_layer_client_;