From 5065a677456ac1cb630e5271e781b2aa796af7a5 Mon Sep 17 00:00:00 2001 From: Cary Clark Date: Fri, 5 Mar 2010 17:51:19 -0500 Subject: scroll into view considers layers LayerAndroid.* - Add a utility that takes the given rectangle and subtracts layers that overlay it. FindCanvas.* - Add function that returns if the current match is on the main page or in a layer. WebView.cpp - Add jni caller for WebView.java calcOurContentVisibleRect. Call it instead of getVisibleRect, which has the side effect of sending messages back to webkit. - Remove jni caller for getViewMetrics, since it is redundant. - Only call scrollRectOnScreen for non-layers. companion fix in framework/base http://b/2485168 --- WebCore/platform/graphics/android/LayerAndroid.cpp | 32 ++++++++++++++++++++++ WebCore/platform/graphics/android/LayerAndroid.h | 4 +++ 2 files changed, 36 insertions(+) (limited to 'WebCore/platform') diff --git a/WebCore/platform/graphics/android/LayerAndroid.cpp b/WebCore/platform/graphics/android/LayerAndroid.cpp index c0851dd..b0c2629 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.cpp +++ b/WebCore/platform/graphics/android/LayerAndroid.cpp @@ -349,6 +349,38 @@ bool LayerAndroid::prepareContext(bool force) return m_recordingPicture; } +SkRect LayerAndroid::subtractLayers(const SkRect& visibleRect) const +{ + SkRect result; + if (m_recordingPicture) { + SkRect globalRect = bounds(); + globalRect.offset(-getPosition()); // localToGlobal adds in position + SkMatrix globalMatrix; + localToGlobal(&globalMatrix); + globalMatrix.mapRect(&globalRect); + SkIRect roundedGlobal; + globalRect.round(&roundedGlobal); + SkIRect iVisibleRect; + visibleRect.round(&iVisibleRect); + SkRegion visRegion(iVisibleRect); + visRegion.op(roundedGlobal, SkRegion::kDifference_Op); + result.set(visRegion.getBounds()); +#if DEBUG_NAV_UI + SkDebugf("%s visibleRect=(%g,%g,r=%g,b=%g) globalRect=(%g,%g,r=%g,b=%g)" + "result=(%g,%g,r=%g,b=%g)", __FUNCTION__, + visibleRect.fLeft, visibleRect.fTop, + visibleRect.fRight, visibleRect.fBottom, + globalRect.fLeft, globalRect.fTop, + globalRect.fRight, globalRect.fBottom, + result.fLeft, result.fTop, result.fRight, result.fBottom); +#endif + } else + result = visibleRect; + for (int i = 0; i < countChildren(); i++) + result = getChild(i)->subtractLayers(result); + return result; +} + // Debug tools : dump the layers tree in a file. // The format is simple: // properties have the form: key = value; diff --git a/WebCore/platform/graphics/android/LayerAndroid.h b/WebCore/platform/graphics/android/LayerAndroid.h index 3cd7e36..2554fb9 100644 --- a/WebCore/platform/graphics/android/LayerAndroid.h +++ b/WebCore/platform/graphics/android/LayerAndroid.h @@ -119,6 +119,10 @@ public: SkPicture* picture() const { return m_recordingPicture; } + // remove layers bounds from visible rectangle to show what can be + // scrolled into view; returns original minus layer bounds in global space. + SkRect subtractLayers(const SkRect& visibleRect) const; + void dumpLayers(FILE*, int indentLevel) const; void dumpToLog() const; -- cgit v1.1