summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/nav/WebView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/android/nav/WebView.cpp')
-rw-r--r--Source/WebKit/android/nav/WebView.cpp64
1 files changed, 48 insertions, 16 deletions
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index a528e9a..101e206 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -105,8 +105,7 @@ class WebView
public:
enum FrameCachePermission {
DontAllowNewer,
- AllowNewer,
- AllowNewest
+ AllowNewer
};
enum DrawExtras { // keep this in sync with WebView.java
@@ -332,8 +331,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())
@@ -489,8 +512,23 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In
m_glWebViewState->resetRings();
if (extra) {
if (extra == &m_ring) {
+ WTF::Vector<IntRect> rings;
if (root == m_ring.m_frame)
- m_glWebViewState->setRings(m_ring.rings(), m_ring.m_isPressed);
+ rings = m_ring.rings();
+ else {
+ // TODO: Fix the navcache to work with layers correctly
+ // In the meantime, this works around the bug. However, the rings
+ // it produces are not as nice for some reason, thus we use
+ // m_ring.rings() above for the base layer instead of the below
+ for (size_t i = 0; i < m_ring.m_node->rings().size(); i++) {
+ IntRect rect = m_ring.m_node->rings().at(i);
+ rect = m_ring.m_frame->adjustBounds(m_ring.m_node, rect);
+ rect.inflate(4);
+ rings.append(rect);
+ }
+ }
+ m_glWebViewState->setRings(rings, m_ring.m_isPressed);
+ extra = 0;
} else {
LayerAndroid mainPicture(m_navPictureUI);
PictureSet* content = m_baseLayer->content();
@@ -1290,8 +1328,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 +1340,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();
}