0

Add touchEventHandlerRegion to Layer and LayerImpl

These will be used to keep track of JavaScript touch event handler on the compositor thread
and will be updated accordingly when there is a change involving adding/removing or changing
the layout of the nodes that contain the touch event handlers.

BUG=135818


Review URL: https://chromiumcodereview.appspot.com/11377013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@166561 0039d316-1c4b-4281-b951-d872f2087c98
This commit is contained in:
yusufo@chromium.org
2012-11-08 00:33:34 +00:00
parent 719b781e19
commit 23d56bea2a
5 changed files with 43 additions and 0 deletions

@@ -41,6 +41,7 @@ Layer::Layer()
, m_shouldScrollOnMainThread(false) , m_shouldScrollOnMainThread(false)
, m_haveWheelEventHandlers(false) , m_haveWheelEventHandlers(false)
, m_nonFastScrollableRegionChanged(false) , m_nonFastScrollableRegionChanged(false)
, m_touchEventHandlerRegionChanged(false)
, m_anchorPoint(0.5, 0.5) , m_anchorPoint(0.5, 0.5)
, m_backgroundColor(0) , m_backgroundColor(0)
, m_debugBorderColor(0) , m_debugBorderColor(0)
@@ -459,6 +460,14 @@ void Layer::setNonFastScrollableRegion(const Region& region)
setNeedsCommit(); setNeedsCommit();
} }
void Layer::setTouchEventHandlerRegion(const Region& region)
{
if (m_touchEventHandlerRegion == region)
return;
m_touchEventHandlerRegion = region;
m_touchEventHandlerRegionChanged = true;
}
void Layer::setDrawCheckerboardForMissingTiles(bool checkerboard) void Layer::setDrawCheckerboardForMissingTiles(bool checkerboard)
{ {
if (m_drawCheckerboardForMissingTiles == checkerboard) if (m_drawCheckerboardForMissingTiles == checkerboard)
@@ -579,6 +588,10 @@ void Layer::pushPropertiesTo(LayerImpl* layer)
layer->setNonFastScrollableRegion(m_nonFastScrollableRegion); layer->setNonFastScrollableRegion(m_nonFastScrollableRegion);
m_nonFastScrollableRegionChanged = false; m_nonFastScrollableRegionChanged = false;
} }
if (m_touchEventHandlerRegionChanged) {
layer->setTouchEventHandlerRegion(m_touchEventHandlerRegion);
m_touchEventHandlerRegionChanged = false;
}
layer->setContentsOpaque(m_contentsOpaque); layer->setContentsOpaque(m_contentsOpaque);
if (!opacityIsAnimating()) if (!opacityIsAnimating())
layer->setOpacity(m_opacity); layer->setOpacity(m_opacity);

@@ -147,6 +147,10 @@ public:
void setNonFastScrollableRegionChanged() { m_nonFastScrollableRegionChanged = true; } void setNonFastScrollableRegionChanged() { m_nonFastScrollableRegionChanged = true; }
const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; } const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; }
void setTouchEventHandlerRegion(const Region&);
void setTouchEventHandlerRegionChanged() { m_touchEventHandlerRegionChanged = true; }
const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRegion; }
void setLayerScrollClient(WebKit::WebLayerScrollClient* layerScrollClient) { m_layerScrollClient = layerScrollClient; } void setLayerScrollClient(WebKit::WebLayerScrollClient* layerScrollClient) { m_layerScrollClient = layerScrollClient; }
void setDrawCheckerboardForMissingTiles(bool); void setDrawCheckerboardForMissingTiles(bool);
@@ -350,6 +354,8 @@ private:
bool m_haveWheelEventHandlers; bool m_haveWheelEventHandlers;
Region m_nonFastScrollableRegion; Region m_nonFastScrollableRegion;
bool m_nonFastScrollableRegionChanged; bool m_nonFastScrollableRegionChanged;
Region m_touchEventHandlerRegion;
bool m_touchEventHandlerRegionChanged;
gfx::PointF m_position; gfx::PointF m_position;
gfx::PointF m_anchorPoint; gfx::PointF m_anchorPoint;
SkColor m_backgroundColor; SkColor m_backgroundColor;

@@ -215,6 +215,9 @@ public:
const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; } const Region& nonFastScrollableRegion() const { return m_nonFastScrollableRegion; }
void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableRegion = region; } void setNonFastScrollableRegion(const Region& region) { m_nonFastScrollableRegion = region; }
const Region& touchEventHandlerRegion() const { return m_touchEventHandlerRegion; }
void setTouchEventHandlerRegion(const Region& region) { m_touchEventHandlerRegion = region; }
void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerboardForMissingTiles = checkerboard; } void setDrawCheckerboardForMissingTiles(bool checkerboard) { m_drawCheckerboardForMissingTiles = checkerboard; }
bool drawCheckerboardForMissingTiles() const; bool drawCheckerboardForMissingTiles() const;
@@ -319,6 +322,7 @@ private:
bool m_shouldScrollOnMainThread; bool m_shouldScrollOnMainThread;
bool m_haveWheelEventHandlers; bool m_haveWheelEventHandlers;
Region m_nonFastScrollableRegion; Region m_nonFastScrollableRegion;
Region m_touchEventHandlerRegion;
SkColor m_backgroundColor; SkColor m_backgroundColor;
// Whether the "back" of this layer should draw. // Whether the "back" of this layer should draw.

@@ -410,6 +410,24 @@ WebVector<WebRect> WebLayerImpl::nonFastScrollableRegion() const
return result; return result;
} }
void WebLayerImpl::setTouchEventHandlerRegion(const WebVector<WebRect>& rects)
{
cc::Region region;
for (size_t i = 0; i < rects.size(); ++i)
region.Union(rects[i]);
m_layer->setTouchEventHandlerRegion(region);
}
WebVector<WebRect> WebLayerImpl::touchEventHandlerRegion() const
{
cc::Region::Iterator regionRects(m_layer->touchEventHandlerRegion());
WebVector<WebRect> result(regionRects.size());
for (size_t i = 0; regionRects.has_rect(); regionRects.next(), ++i)
result[i] = regionRects.rect();
return result;
}
void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable) void WebLayerImpl::setIsContainerForFixedPositionLayers(bool enable)
{ {
m_layer->setIsContainerForFixedPositionLayers(enable); m_layer->setIsContainerForFixedPositionLayers(enable);

@@ -88,6 +88,8 @@ public:
virtual bool shouldScrollOnMainThread() const; virtual bool shouldScrollOnMainThread() const;
virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) OVERRIDE; virtual void setNonFastScrollableRegion(const WebVector<WebRect>&) OVERRIDE;
virtual WebVector<WebRect> nonFastScrollableRegion() const; virtual WebVector<WebRect> nonFastScrollableRegion() const;
virtual void setTouchEventHandlerRegion(const WebVector<WebRect>&);
virtual WebVector<WebRect> touchEventHandlerRegion() const;
virtual void setIsContainerForFixedPositionLayers(bool) OVERRIDE; virtual void setIsContainerForFixedPositionLayers(bool) OVERRIDE;
virtual bool isContainerForFixedPositionLayers() const; virtual bool isContainerForFixedPositionLayers() const;
virtual void setFixedToContainerLayer(bool) OVERRIDE; virtual void setFixedToContainerLayer(bool) OVERRIDE;