summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/WebCore/platform/graphics/android/TransferQueue.cpp2
-rw-r--r--Source/WebKit/android/jni/PictureSet.cpp21
-rw-r--r--Source/WebKit/android/nav/FindCanvas.cpp7
-rw-r--r--Source/WebKit/android/nav/FindCanvas.h3
-rw-r--r--Source/WebKit/android/nav/WebView.cpp44
5 files changed, 43 insertions, 34 deletions
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
index 918d484..02427e4 100644
--- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp
+++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp
@@ -455,7 +455,7 @@ void TransferQueue::restoreGLState()
if (m_GLStateBeforeBlit.scissor[0])
glEnable(GL_SCISSOR_TEST);
- if (m_GLStateBeforeBlit.depth)
+ if (m_GLStateBeforeBlit.depth[0])
glEnable(GL_DEPTH_TEST);
glClearColor(m_GLStateBeforeBlit.clearColor[0],
diff --git a/Source/WebKit/android/jni/PictureSet.cpp b/Source/WebKit/android/jni/PictureSet.cpp
index e6a9ed5..f61e0f1 100644
--- a/Source/WebKit/android/jni/PictureSet.cpp
+++ b/Source/WebKit/android/jni/PictureSet.cpp
@@ -356,23 +356,10 @@ void PictureSet::splitAdd(const SkIRect& rect)
SkIRect newRect;
int deltaX = i * maxSize;
int deltaY = j * maxSize;
- int left, top, right, bottom;
- if (i == firstTileX)
- left = rect.fLeft;
- else
- left = 0;
- if (j == firstTileY)
- top = rect.fTop;
- else
- top = 0;
- if (i == lastTileX)
- right = rect.fRight % maxSize;
- else
- right = maxSize;
- if (j == lastTileY)
- bottom = rect.fBottom % maxSize;
- else
- bottom = maxSize;
+ int left = (i == firstTileX) ? rect.fLeft - deltaX : 0;
+ int top = (j == firstTileY) ? rect.fTop - deltaY : 0;
+ int right = (i == lastTileX) ? rect.fRight % maxSize : maxSize;
+ int bottom = (j == lastTileY) ? rect.fBottom % maxSize : maxSize;
newRect.set(left, top, right, bottom);
addToBucket(bucket, deltaX, deltaY, newRect);
diff --git a/Source/WebKit/android/nav/FindCanvas.cpp b/Source/WebKit/android/nav/FindCanvas.cpp
index 2d310b3..38fb71e 100644
--- a/Source/WebKit/android/nav/FindCanvas.cpp
+++ b/Source/WebKit/android/nav/FindCanvas.cpp
@@ -532,9 +532,6 @@ IntRect FindOnPage::currentMatchBounds() const {
if (!m_matches || !m_matches->size())
return noBounds;
MatchInfo& info = (*m_matches)[m_findIndex];
- // FIXME: this should test if the match in the layer is visible
- if (info.isInLayer())
- return noBounds;
return info.getLocation().getBounds();
}
@@ -545,6 +542,10 @@ bool FindOnPage::currentMatchIsInLayer() const {
return info.isInLayer();
}
+int FindOnPage::currentMatchLayerId() const {
+ return (*m_matches)[m_findIndex].layerId();
+}
+
// This function is only used by findNext and setMatches. In it, we store
// upper left corner of the match specified by m_findIndex in
// m_currentMatchLocation.
diff --git a/Source/WebKit/android/nav/FindCanvas.h b/Source/WebKit/android/nav/FindCanvas.h
index 76ee1e2..f693a3f 100644
--- a/Source/WebKit/android/nav/FindCanvas.h
+++ b/Source/WebKit/android/nav/FindCanvas.h
@@ -227,6 +227,9 @@ public:
IntRect currentMatchBounds() const;
int currentMatchIndex() const { return m_findIndex; }
bool currentMatchIsInLayer() const;
+ // This requires the current match to be in a layer. See
+ // currentMatchIsInLayer().
+ int currentMatchLayerId() const;
virtual void draw(SkCanvas* , LayerAndroid* , IntRect* );
void findNext(bool forward);
bool isCurrentLocationValid() { return m_hasCurrentLocation; }
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index a528e9a..becc3ed 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -332,8 +332,32 @@ void nativeRecordButtons(bool hasFocus, bool pressed, bool invalidate)
}
}
-// The caller has already determined that the desired document rect corresponds
-// to the main picture, and not a layer
+void scrollToCurrentMatch()
+{
+ if (!m_findOnPage.currentMatchIsInLayer()) {
+ scrollRectOnScreen(m_findOnPage.currentMatchBounds());
+ return;
+ }
+
+ SkRect matchBounds = m_findOnPage.currentMatchBounds();
+ const LayerAndroid* rootLayer = getFrameCache(DontAllowNewer)->rootLayer();
+ const Layer* layerContainingMatch = rootLayer->findById(m_findOnPage.currentMatchLayerId());
+ ASSERT(layerContainingMatch);
+
+ // FIXME: If the match is in a scrollable layer or a child of such a layer,
+ // we may need to scroll these layers to make sure the match is visible.
+ // See http://b/5262656.
+
+ // Convert matchBounds to the global space so we can scroll the main page.
+ SkMatrix transform;
+ layerContainingMatch->localToGlobal(&transform);
+ SkRect transformedMatchBounds;
+ transform.mapRect(&transformedMatchBounds, matchBounds);
+ SkIRect roundedTransformedMatchBounds;
+ transformedMatchBounds.roundOut(&roundedTransformedMatchBounds);
+ scrollRectOnScreen(roundedTransformedMatchBounds);
+}
+
void scrollRectOnScreen(const IntRect& rect)
{
if (rect.isEmpty())
@@ -1290,8 +1314,7 @@ void sendMotionUp(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y
void findNext(bool forward)
{
m_findOnPage.findNext(forward);
- if (!m_findOnPage.currentMatchIsInLayer())
- scrollRectOnScreen(m_findOnPage.currentMatchBounds());
+ scrollToCurrentMatch();
viewInvalidate();
}
@@ -1303,21 +1326,16 @@ void setMatches(WTF::Vector<MatchInfo>* matches, jboolean sameAsLastSearch)
// location to determine whether to scroll. If the same word is found
// in the same place, then do not scroll.
IntRect oldLocation;
- bool checkAgainstOldLocation;
+ bool checkAgainstOldLocation = false;
if (sameAsLastSearch && m_findOnPage.isCurrentLocationValid()) {
oldLocation = m_findOnPage.currentMatchBounds();
checkAgainstOldLocation = true;
- } else
- checkAgainstOldLocation = false;
+ }
m_findOnPage.setMatches(matches);
- if (!checkAgainstOldLocation
- || oldLocation != m_findOnPage.currentMatchBounds()) {
- // FIXME: Need to scroll if the match is in a layer.
- if (!m_findOnPage.currentMatchIsInLayer())
- scrollRectOnScreen(m_findOnPage.currentMatchBounds());
- }
+ if (!checkAgainstOldLocation || oldLocation != m_findOnPage.currentMatchBounds())
+ scrollToCurrentMatch();
viewInvalidate();
}