diff options
| author | Patrick Scott <phanna@android.com> | 2010-08-02 08:09:31 -0400 |
|---|---|---|
| committer | Patrick Scott <phanna@android.com> | 2010-08-02 15:28:47 -0400 |
| commit | ef1adcdfc805d4d13103f6f15cc5b4d96828a60f (patch) | |
| tree | cf24fb4142aa8bd487b7f751c74aa4225967fa47 /WebKit/android/nav/CachedLayer.cpp | |
| parent | 2e79b71868fcdcd0de7c6070e50662d8fa01e4ab (diff) | |
| download | external_webkit-ef1adcdfc805d4d13103f6f15cc5b4d96828a60f.zip external_webkit-ef1adcdfc805d4d13103f6f15cc5b4d96828a60f.tar.gz external_webkit-ef1adcdfc805d4d13103f6f15cc5b4d96828a60f.tar.bz2 | |
Enable navigation in scrollable layers.
EventHandler:
* Added IgnoreClipping in order to touch nodes that are clipped
out.
android_graphics:
* Remember the absolute bounds of the node for invals.
RenderBox:
* Fix a compiler warning.
RenderLayer:
* Do not record the entire layer contents unless the scroll
dimensions are larger than the client dimensions.
* Change isSelfPaintingLayer to check for an overflow clip
instead of the scrollable dimensions since it can be too
early to check at this point.
RenderLayerCompositor:
* Same as RenderLayer for checking the overflow clip.
WebViewCore:
* Scroll the containing layer to the node bounds and offset the
mouse position if scrolled. Once the mouse event is processed,
restore the layer to 0,0.
CacheBuilder:
* The body position is no longer used.
* Do not clip out nodes if the layer is scrollable.
CachedFrame:
* Add unadjustBounds to restore adjusted bounds to their original
position (fixed position elements).
* Call unadjustBounds when a node has been found. This new set of
bounds is passed over to WebViewCore to handle clicks.
* Reject empty node bounds.
CachedLayer:
* Document adjustBounds and add unadjustBounds. Add in the scroll
position to the node bounds.
CachedRoot:
* Unadjust the mouse bounds.
WebView:
* Unadjust the mouse bounds and use the absolute bounds of the ring
during inval.
Bug: 1566791
Change-Id: Ia55f2cbb61869087176d3ff61882e40324614c6a
Diffstat (limited to 'WebKit/android/nav/CachedLayer.cpp')
| -rw-r--r-- | WebKit/android/nav/CachedLayer.cpp | 75 |
1 files changed, 67 insertions, 8 deletions
diff --git a/WebKit/android/nav/CachedLayer.cpp b/WebKit/android/nav/CachedLayer.cpp index 2f6e20a..9c7d59b 100644 --- a/WebKit/android/nav/CachedLayer.cpp +++ b/WebKit/android/nav/CachedLayer.cpp @@ -46,23 +46,67 @@ IntRect CachedLayer::adjustBounds(const LayerAndroid* root, return bounds; } FloatRect temp = bounds; + // First, remove the original offset from the bounds. + temp.move(-mOffset.x(), -mOffset.y()); + + // Next, add in the new position of the layer (could be different due to a + // fixed position layer). const FloatPoint& position = aLayer->getPosition(); temp.move(position.x(), position.y()); + + // Add in any layer translation. const FloatPoint& translation = aLayer->translation(); temp.move(translation.x(), translation.y()); + + // Move the bounds by the layer's internal scroll position. + const SkPoint& scroll = aLayer->scrollPosition(); + temp.move(SkScalarToFloat(-scroll.fX), SkScalarToFloat(-scroll.fY)); + IntRect result = enclosingIntRect(temp); + + // Finally, clip the result to the foreground (this includes the object's + // border which does not scroll). + IntRect clip(aLayer->foregroundClip()); + clip.move(position.x(), position.y()); + result.intersect(clip); + DBG_NAV_LOGD("root=%p aLayer=%p [%d]" - " bounds=(%d,%d,w=%d,h=%d) pos=(%g,%g) trans=(%g,%g)" - " result=(%d,%d,w=%d,h=%d) offset=(%d,%d)", + " bounds=(%d,%d,w=%d,h=%d) trans=(%g,%g)" + " offset=(%d,%d) clip=(%d,%d,w=%d,h=%d)" + " result=(%d,%d,w=%d,h=%d)", root, aLayer, aLayer->uniqueId(), bounds.x(), bounds.y(), bounds.width(), bounds.height(), - position.x(), position.y(), translation.x(), translation.y(), - result.x(), result.y(), result.width(), result.height(), - mOffset.x(), mOffset.y()); - result.move(-mOffset.x(), -mOffset.y()); + translation.x(), translation.y(), mOffset.x(), mOffset.y(), + clip.x(), clip.y(), clip.width(), clip.height(), + result.x(), result.y(), result.width(), result.height()); return result; } +IntRect CachedLayer::unadjustBounds(const LayerAndroid* root, + const IntRect& bounds) const +{ + const LayerAndroid* aLayer = layer(root); + if (!aLayer) + return bounds; + + IntRect temp = bounds; + // Remove the new position (i.e. fixed position elements). + const FloatPoint& position = aLayer->getPosition(); + temp.move(-position.x(), -position.y()); + + // Remove any layer translation. + const FloatPoint& translation = aLayer->translation(); + temp.move(-translation.x(), -translation.y()); + + // Move the bounds by the internal scroll position. + const SkPoint& scroll = aLayer->scrollPosition(); + temp.move(SkScalarRound(scroll.fX), SkScalarRound(scroll.fY)); + + // Move it back to the original offset. + temp.move(mOffset.x(), mOffset.y()); + return temp; +} + const LayerAndroid* CachedLayer::layer(const LayerAndroid* root) const { if (!root || mLayer) @@ -71,11 +115,26 @@ const LayerAndroid* CachedLayer::layer(const LayerAndroid* root) const } // return bounds relative to enclosing layer as recorded when walking the dom -IntRect CachedLayer::localBounds(const IntRect& bounds) const +IntRect CachedLayer::localBounds(const LayerAndroid* root, + const IntRect& bounds) const { IntRect temp = bounds; + // Remove the original offset from the bounds. temp.move(-mOffset.x(), -mOffset.y()); - return temp; + + const LayerAndroid* aLayer = layer(root); + if (aLayer) { + // Move the bounds by the scroll position of the layer. + const SkPoint& scroll = aLayer->scrollPosition(); + temp.move(SkScalarToFloat(-scroll.fX), SkScalarToFloat(-scroll.fY)); + + // Clip by the layer's foreground bounds. Since the bounds have + // already be moved local to the layer, no need to move the foreground + // clip. + temp.intersect(IntRect(aLayer->foregroundClip())); + } + + return enclosingIntRect(temp); } SkPicture* CachedLayer::picture(const LayerAndroid* root) const |
