summaryrefslogtreecommitdiffstats
path: root/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
diff options
context:
space:
mode:
authorPatrick Scott <phanna@android.com>2010-12-09 18:12:20 -0500
committerPatrick Scott <phanna@android.com>2010-12-13 08:23:29 -0500
commitfe812d40b53dc52d5c929e39b5e293af8b6cb4e4 (patch)
tree81002048cd73d5fa21b7cac3b047c2f1b1755b64 /WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
parent83ddee4501f0c2f48d1073e0185a2fb0a732c929 (diff)
downloadexternal_webkit-fe812d40b53dc52d5c929e39b5e293af8b6cb4e4.zip
external_webkit-fe812d40b53dc52d5c929e39b5e293af8b6cb4e4.tar.gz
external_webkit-fe812d40b53dc52d5c929e39b5e293af8b6cb4e4.tar.bz2
Fix hit testing inside layers.
* Prevent asking for a sync in GraphicsLayerAndroid if some property has not changed. * Remove scrolling logic from LayerAndroid and create a subclass for scrollable layers. * Report the scrolling limits to the layer in order to scroll iframes (not turned on) and to avoid computing them each time the layer is scrolled. * Change the foreground rect calculations to better match the non-overflow case. * During hit testing, intersect the hitTestClip with the foreground and background to prevent false positives in the layer. * Prepare for iframe scrolling by adding code to trigger compositing for iframes. This currently works great except for navigation so it disabled for now. Bug: 3258631 Change-Id: I0da2d8dbe25376c6aa4f485c9350048c82c6f563
Diffstat (limited to 'WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp')
-rw-r--r--WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp69
1 files changed, 50 insertions, 19 deletions
diff --git a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
index fe7b132..0fdbc21 100644
--- a/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
+++ b/WebCore/platform/graphics/android/GraphicsLayerAndroid.cpp
@@ -32,6 +32,7 @@
#include "RenderView.h"
#include "RotateTransformOperation.h"
#include "ScaleTransformOperation.h"
+#include "ScrollableLayerAndroid.h"
#include "SkCanvas.h"
#include "TransformationMatrix.h"
#include "TranslateTransformOperation.h"
@@ -263,6 +264,8 @@ void GraphicsLayerAndroid::updateFixedPosition()
void GraphicsLayerAndroid::setPosition(const FloatPoint& point)
{
+ if (point == m_currentPosition)
+ return;
m_currentPosition = point;
m_needsDisplay = true;
#ifdef LAYER_DEBUG_2
@@ -276,6 +279,8 @@ void GraphicsLayerAndroid::setPosition(const FloatPoint& point)
void GraphicsLayerAndroid::setAnchorPoint(const FloatPoint3D& point)
{
+ if (point == m_anchorPoint)
+ return;
GraphicsLayer::setAnchorPoint(point);
m_contentLayer->setAnchorPoint(point.x(), point.y());
askForSync();
@@ -283,14 +288,13 @@ void GraphicsLayerAndroid::setAnchorPoint(const FloatPoint3D& point)
void GraphicsLayerAndroid::setSize(const FloatSize& size)
{
- if ((size.width() != m_size.width())
- || (size.height() != m_size.height())) {
- MLOG("(%x) setSize (%.2f,%.2f)", this, size.width(), size.height());
- GraphicsLayer::setSize(size);
- m_contentLayer->setSize(size.width(), size.height());
- updateFixedPosition();
- askForSync();
- }
+ if (size == m_size)
+ return;
+ MLOG("(%x) setSize (%.2f,%.2f)", this, size.width(), size.height());
+ GraphicsLayer::setSize(size);
+ m_contentLayer->setSize(size.width(), size.height());
+ updateFixedPosition();
+ askForSync();
}
void GraphicsLayerAndroid::setTransform(const TransformationMatrix& t)
@@ -329,7 +333,7 @@ void GraphicsLayerAndroid::setChildrenTransform(const TransformationMatrix& t)
void GraphicsLayerAndroid::setMaskLayer(GraphicsLayer* layer)
{
if (layer == m_maskLayer)
- return;
+ return;
GraphicsLayer::setMaskLayer(layer);
m_needsSyncMask = true;
@@ -338,6 +342,8 @@ void GraphicsLayerAndroid::setMaskLayer(GraphicsLayer* layer)
void GraphicsLayerAndroid::setMasksToBounds(bool masksToBounds)
{
+ if (masksToBounds == m_masksToBounds)
+ return;
GraphicsLayer::setMasksToBounds(masksToBounds);
m_needsSyncMask = true;
askForSync();
@@ -345,20 +351,30 @@ void GraphicsLayerAndroid::setMasksToBounds(bool masksToBounds)
void GraphicsLayerAndroid::setDrawsContent(bool drawsContent)
{
+ if (drawsContent == m_drawsContent)
+ return;
GraphicsLayer::setDrawsContent(drawsContent);
if (m_contentLayer->isRootLayer())
return;
if (m_drawsContent) {
#if ENABLE(ANDROID_OVERFLOW_SCROLL)
RenderLayer* layer = renderLayerFromClient(m_client);
- if (layer && layer->hasOverflowScroll() && !m_foregroundLayer) {
- m_foregroundLayer = new LayerAndroid(false);
- m_foregroundLayer->setContentScrollable(true);
- m_foregroundClipLayer = new LayerAndroid(false);
- m_foregroundClipLayer->setMasksToBounds(true);
-
- m_foregroundClipLayer->addChild(m_foregroundLayer);
- m_contentLayer->addChild(m_foregroundClipLayer);
+ if (layer) {
+ if (layer->hasOverflowScroll() && !m_foregroundLayer) {
+ m_foregroundLayer = new ScrollableLayerAndroid();
+ m_foregroundClipLayer = new LayerAndroid(false);
+ m_foregroundClipLayer->setMasksToBounds(true);
+
+ m_foregroundClipLayer->addChild(m_foregroundLayer);
+ m_contentLayer->addChild(m_foregroundClipLayer);
+ } else if (false /* FIXME: disable until navigation is fixed */ &&
+ layer->isRootLayer() &&
+ layer->renderer()->frame()->ownerRenderer()) {
+ // Replace the content layer with a scrollable layer.
+ LayerAndroid* layer = new ScrollableLayerAndroid(*m_contentLayer);
+ m_contentLayer->unref();
+ m_contentLayer = layer;
+ }
}
#endif
@@ -370,6 +386,8 @@ void GraphicsLayerAndroid::setDrawsContent(bool drawsContent)
void GraphicsLayerAndroid::setBackgroundColor(const Color& color)
{
+ if (color == m_backgroundColor)
+ return;
LOG("(%x) setBackgroundColor", this);
GraphicsLayer::setBackgroundColor(color);
SkColor c = SkColorSetARGB(color.alpha(), color.red(), color.green(), color.blue());
@@ -387,6 +405,8 @@ void GraphicsLayerAndroid::clearBackgroundColor()
void GraphicsLayerAndroid::setContentsOpaque(bool opaque)
{
+ if (opaque == m_contentsOpaque)
+ return;
LOG("(%x) setContentsOpaque (%d)", this, opaque);
GraphicsLayer::setContentsOpaque(opaque);
m_haveContents = true;
@@ -449,6 +469,7 @@ bool GraphicsLayerAndroid::repaint()
// with SkPicture, we request the entire layer's content.
IntRect layerBounds(0, 0, m_size.width(), m_size.height());
+ RenderLayer* layer = renderLayerFromClient(m_client);
if (m_foregroundLayer) {
PaintingPhase phase(this);
// Paint the background into a separate context.
@@ -456,7 +477,6 @@ bool GraphicsLayerAndroid::repaint()
if (!paintContext(m_contentLayer->recordContext(), layerBounds))
return false;
- RenderLayer* layer = renderLayerFromClient(m_client);
// Construct the foreground layer and draw.
RenderBox* box = layer->renderBox();
int outline = box->view()->maximalOutlineSize();
@@ -485,11 +505,20 @@ bool GraphicsLayerAndroid::repaint()
// Need to offset the foreground layer by the clip layer in order
// for the contents to be in the correct position.
m_foregroundLayer->setPosition(-x, -y);
+ // Set the scrollable bounds of the layer.
+ m_foregroundLayer->setScrollLimits(-x, -y, m_size.width(), m_size.height());
} else {
// If there is no contents clip, we can draw everything into one
// picture.
if (!paintContext(m_contentLayer->recordContext(), layerBounds))
return false;
+ // Check for a scrollable iframe and report the scrolling
+ // limits based on the view size.
+ if (m_contentLayer->contentIsScrollable()) {
+ FrameView* view = layer->renderer()->frame()->view();
+ static_cast<ScrollableLayerAndroid*>(m_contentLayer)->setScrollLimits(
+ m_position.x(), m_position.y(), view->layoutWidth(), view->layoutHeight());
+ }
}
TLOG("(%x) repaint() on (%.2f,%.2f) contentlayer(%.2f,%.2f,%.2f,%.2f)paintGraphicsLayer called!",
@@ -579,7 +608,7 @@ bool GraphicsLayerAndroid::addAnimation(const KeyframeValueList& valueList,
double beginTime)
{
if (!anim || anim->isEmptyOrZeroDuration() || valueList.size() != 2)
- return false;
+ return false;
bool createdAnimations = false;
if (valueList.property() == AnimatedPropertyWebkitTransform) {
@@ -882,6 +911,8 @@ void GraphicsLayerAndroid::setDebugBorder(const Color& color, float borderWidth)
void GraphicsLayerAndroid::setZPosition(float position)
{
+ if (position == m_zPosition)
+ return;
LOG("(%x) setZPosition: %.2f", this, position);
GraphicsLayer::setZPosition(position);
askForSync();