summaryrefslogtreecommitdiffstats
path: root/Source/WebKit/android/nav
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebKit/android/nav')
-rw-r--r--Source/WebKit/android/nav/CachedRoot.cpp12
-rw-r--r--Source/WebKit/android/nav/CachedRoot.h2
-rw-r--r--Source/WebKit/android/nav/FindCanvas.cpp21
-rw-r--r--Source/WebKit/android/nav/FindCanvas.h11
-rw-r--r--Source/WebKit/android/nav/WebView.cpp25
5 files changed, 51 insertions, 20 deletions
diff --git a/Source/WebKit/android/nav/CachedRoot.cpp b/Source/WebKit/android/nav/CachedRoot.cpp
index 2371c4f..ddebaba 100644
--- a/Source/WebKit/android/nav/CachedRoot.cpp
+++ b/Source/WebKit/android/nav/CachedRoot.cpp
@@ -29,7 +29,6 @@
#include "CachedInput.h"
#include "CachedLayer.h"
#include "CachedNode.h"
-#include "FindCanvas.h"
#include "FloatRect.h"
#include "LayerAndroid.h"
#include "ParseCanvas.h"
@@ -1141,17 +1140,6 @@ bool CachedRoot::checkRings(SkPicture* picture, const CachedNode* node,
return result;
}
-void CachedRoot::draw(FindCanvas& canvas) const
-{
- canvas.setLayerId(-1); // overlays change the ID as their pictures draw
- canvas.drawPicture(*mPicture);
-#if USE(ACCELERATED_COMPOSITING)
- if (!mRootLayer)
- return;
- canvas.drawLayers(mRootLayer);
-#endif
-}
-
const CachedNode* CachedRoot::findAt(const WebCore::IntRect& rect,
const CachedFrame** framePtr, int* x, int* y, bool checkForHidden) const
{
diff --git a/Source/WebKit/android/nav/CachedRoot.h b/Source/WebKit/android/nav/CachedRoot.h
index 65c6062..dc055a5 100644
--- a/Source/WebKit/android/nav/CachedRoot.h
+++ b/Source/WebKit/android/nav/CachedRoot.h
@@ -42,7 +42,6 @@ namespace android {
class CachedHistory;
class CachedNode;
-class FindCanvas;
class CachedRoot : public CachedFrame {
public:
@@ -57,7 +56,6 @@ public:
WebCore::IntPoint cursorLocation() const;
int documentHeight() { return mContents.height(); }
int documentWidth() { return mContents.width(); }
- void draw(FindCanvas& ) const;
const CachedNode* findAt(const WebCore::IntRect& , const CachedFrame** ,
int* x, int* y, bool checkForHidden) const;
const WebCore::IntRect& focusBounds() const { return mFocusBounds; }
diff --git a/Source/WebKit/android/nav/FindCanvas.cpp b/Source/WebKit/android/nav/FindCanvas.cpp
index 1ae4f9b..a61b73b 100644
--- a/Source/WebKit/android/nav/FindCanvas.cpp
+++ b/Source/WebKit/android/nav/FindCanvas.cpp
@@ -254,15 +254,19 @@ SkRect FindCanvas::addMatchPosH(int index,
return r;
}
-void FindCanvas::drawLayers(LayerAndroid* layer) {
+void FindCanvas::drawLayers(LayerAndroid* layer, FindOnPage& findOnPage) {
#if USE(ACCELERATED_COMPOSITING)
+ int layerId = layer->uniqueId();
+ unsigned matchesBegin = found();
SkPicture* picture = layer->picture();
if (picture) {
- setLayerId(layer->uniqueId());
+ setLayerId(layerId);
drawPicture(*picture);
}
+ findOnPage.setLayerMatchRange(layerId,
+ std::pair<unsigned, unsigned>(matchesBegin, found()));
for (int i = 0; i < layer->countChildren(); i++)
- drawLayers(layer->getChild(i));
+ drawLayers(layer->getChild(i), findOnPage);
#endif
}
@@ -697,4 +701,15 @@ void FindOnPage::setMatches(WTF::Vector<MatchInfo>* matches)
}
}
+std::pair<unsigned, unsigned> FindOnPage::getLayerMatchRange(int layerId) const
+{
+ return m_layerMatchRangeMap.get(layerId);
+}
+
+void FindOnPage::setLayerMatchRange(int layerId,
+ const std::pair<unsigned, unsigned> range)
+{
+ m_layerMatchRangeMap.set(layerId, range);
+}
+
}
diff --git a/Source/WebKit/android/nav/FindCanvas.h b/Source/WebKit/android/nav/FindCanvas.h
index 0fa095c..939e568 100644
--- a/Source/WebKit/android/nav/FindCanvas.h
+++ b/Source/WebKit/android/nav/FindCanvas.h
@@ -37,8 +37,10 @@
#include <unicode/umachine.h>
#include <wtf/Vector.h>
+#include <wtf/HashMap.h>
namespace android {
+class FindOnPage;
// Stores both region information and an SkPicture of the match, so that the
// region can be drawn, followed by drawing the matching text on top of it.
@@ -141,7 +143,7 @@ public:
const SkPaint& paint) {
}
- void drawLayers(LayerAndroid*);
+ void drawLayers(LayerAndroid* rootLayer, FindOnPage& findOnPage);
int found() const { return mNumFound; }
void setLayerId(int layerId) { mLayerId = layerId; }
@@ -235,11 +237,18 @@ public:
bool isCurrentLocationValid() { return m_hasCurrentLocation; }
void setMatches(WTF::Vector<MatchInfo>* matches);
WTF::Vector<MatchInfo>* matches() { return m_matches; }
+
+ // Some functions to determine which matches belong to which layers.
+ std::pair<unsigned, unsigned> getLayerMatchRange(int layerId) const;
+ void setLayerMatchRange(int layerId,
+ const std::pair<unsigned, unsigned> range);
+
private:
void drawMatch(const SkRegion& region, SkCanvas* canvas, bool focused);
void setUpFindPaint();
void storeCurrentMatchLocation();
WTF::Vector<MatchInfo>* m_matches;
+ WTF::HashMap< int, std::pair<unsigned, unsigned> > m_layerMatchRangeMap;
// Stores the location of the current match.
SkIPoint m_currentMatchLocation;
// Tells whether the value in m_currentMatchLocation is valid.
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index c94301b..64ab9d9 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -308,8 +308,12 @@ void scrollToCurrentMatch()
SkRect matchBounds = m_findOnPage.currentMatchBounds();
LayerAndroid* rootLayer = getFrameCache(DontAllowNewer)->rootLayer();
+ if (!rootLayer)
+ return;
+
Layer* layerContainingMatch = rootLayer->findById(m_findOnPage.currentMatchLayerId());
- ASSERT(layerContainingMatch);
+ if (!layerContainingMatch)
+ return;
// If the match is in a fixed position layer, there's nothing to do.
if (layerContainingMatch->shouldInheritFromRootTransform())
@@ -1514,6 +1518,10 @@ void setVisibleRect(SkRect& visibleRect) {
m_visibleRect = visibleRect;
}
+FindOnPage& findOnPage() {
+ return m_findOnPage;
+}
+
bool m_isDrawingPaused;
private: // local state for WebView
// private to getFrameCache(); other functions operate in a different thread
@@ -2319,7 +2327,20 @@ static int nativeFindAll(JNIEnv *env, jobject obj, jstring findLower,
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, width, height);
canvas.setBitmapDevice(bitmap);
- root->draw(canvas);
+ FindOnPage& findOnPage = view->findOnPage();
+ BaseLayerAndroid* baseLayer = view->getBaseLayer();
+ if (baseLayer) {
+ canvas.setLayerId(-1);
+ unsigned matchesBegin = canvas.found();
+ baseLayer->drawCanvas(&canvas);
+ findOnPage.setLayerMatchRange(-1,
+ std::pair<unsigned, unsigned>(matchesBegin, canvas.found()));
+ }
+#if USE(ACCELERATED_COMPOSITING)
+ LayerAndroid* compositeLayer = view->compositeRoot();
+ if (compositeLayer)
+ canvas.drawLayers(compositeLayer, findOnPage);
+#endif
WTF::Vector<MatchInfo>* matches = canvas.detachMatches();
// With setMatches, the WebView takes ownership of matches
view->setMatches(matches, sameAsLastSearch);