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/DrawExtra.cpp8
-rw-r--r--Source/WebKit/android/nav/DrawExtra.h3
-rw-r--r--Source/WebKit/android/nav/SelectText.h10
-rw-r--r--Source/WebKit/android/nav/WebView.cpp71
4 files changed, 87 insertions, 5 deletions
diff --git a/Source/WebKit/android/nav/DrawExtra.cpp b/Source/WebKit/android/nav/DrawExtra.cpp
index 2f57dc1..a7d686c 100644
--- a/Source/WebKit/android/nav/DrawExtra.cpp
+++ b/Source/WebKit/android/nav/DrawExtra.cpp
@@ -52,7 +52,8 @@ SkRegion* RegionLayerDrawExtra::getHighlightRegionsForLayer(const LayerAndroid*
}
void RegionLayerDrawExtra::addHighlightRegion(const LayerAndroid* layer, const Vector<IntRect>& rects,
- const IntPoint& additionalOffset)
+ const IntPoint& additionalOffset,
+ const IntRect& clipRect)
{
if (rects.isEmpty())
return;
@@ -66,6 +67,11 @@ void RegionLayerDrawExtra::addHighlightRegion(const LayerAndroid* layer, const V
WebViewCore::layerToAbsoluteOffset(layer, offset);
for (size_t i = 0; i < rects.size(); i++) {
IntRect r = rects.at(i);
+ if (!clipRect.isEmpty()) {
+ r.intersect(clipRect);
+ if (r.isEmpty())
+ continue; // don't add it to the region
+ }
r.move(-offset.x(), -offset.y());
region->op(r.x(), r.y(), r.maxX(), r.maxY(), SkRegion::kUnion_Op);
}
diff --git a/Source/WebKit/android/nav/DrawExtra.h b/Source/WebKit/android/nav/DrawExtra.h
index cc94476..1850b6b 100644
--- a/Source/WebKit/android/nav/DrawExtra.h
+++ b/Source/WebKit/android/nav/DrawExtra.h
@@ -65,7 +65,8 @@ public:
virtual ~RegionLayerDrawExtra();
void addHighlightRegion(const LayerAndroid* layer, const Vector<IntRect>& rects,
- const IntPoint& additionalOffset = IntPoint());
+ const IntPoint& additionalOffset = IntPoint(),
+ const IntRect& clipRect = IntRect());
virtual void draw(SkCanvas*, LayerAndroid*);
virtual void drawGL(GLExtras*, const LayerAndroid*);
diff --git a/Source/WebKit/android/nav/SelectText.h b/Source/WebKit/android/nav/SelectText.h
index aaaf3bb..8f7592d 100644
--- a/Source/WebKit/android/nav/SelectText.h
+++ b/Source/WebKit/android/nav/SelectText.h
@@ -35,8 +35,13 @@ namespace android {
class SelectText : public RegionLayerDrawExtra {
public:
enum HandleId {
+ BaseHandle = 0,
+ ExtentHandle = 1,
+ };
+ enum HandleType {
LeftHandle = 0,
- RightHandle = 1,
+ CenterHandle = 1,
+ RightHandle = 2,
};
IntRect& caretRect(HandleId id) { return m_caretRects[id]; }
@@ -48,11 +53,14 @@ public:
void setText(const String& text) { m_text = text.threadsafeCopy(); }
String& getText() { return m_text; }
+ HandleType getHandleType(HandleId id) { return m_handleType[id]; }
+ void setHandleType(HandleId id, HandleType type) { m_handleType[id] = type; }
private:
IntRect m_caretRects[2];
IntRect m_textRects[2];
int m_caretLayerId[2];
+ HandleType m_handleType[2];
String m_text;
};
diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp
index a67b5fd..c708c25 100644
--- a/Source/WebKit/android/nav/WebView.cpp
+++ b/Source/WebKit/android/nav/WebView.cpp
@@ -32,6 +32,7 @@
#include "BaseLayerAndroid.h"
#include "BaseRenderer.h"
#include "DrawExtra.h"
+#include "DumpLayer.h"
#include "Frame.h"
#include "GLWebViewState.h"
#include "GraphicsJNI.h"
@@ -716,7 +717,7 @@ void findMaxVisibleRect(int movingLayerId, SkIRect& visibleContentRect)
if (findMaskedRectsForLayer(m_baseLayer, rects, movingLayerId)) {
float maxSize = 0.0;
const FloatRect* largest = 0;
- for (int i = 0; i < rects.size(); i++) {
+ for (unsigned int i = 0; i < rects.size(); i++) {
const FloatRect& rect = rects[i];
float size = rect.width() * rect.height();
if (size > maxSize) {
@@ -731,6 +732,29 @@ void findMaxVisibleRect(int movingLayerId, SkIRect& visibleContentRect)
}
}
+bool isHandleLeft(SelectText::HandleId handleId)
+{
+ SelectText* selectText = static_cast<SelectText*>(getDrawExtra(DrawExtrasSelection));
+ if (!selectText)
+ return (handleId == SelectText::BaseHandle);
+
+ return (selectText->getHandleType(handleId) == SelectText::LeftHandle);
+}
+
+bool isPointVisible(int layerId, int contentX, int contentY)
+{
+ bool isVisible = true;
+ const TransformationMatrix* transform = getLayerTransform(layerId);
+ if (transform) {
+ // layer is guaranteed to be non-NULL because of getLayerTransform
+ LayerAndroid* layer = m_baseLayer->findById(layerId);
+ IntRect rect = layer->visibleContentArea();
+ rect = transform->mapRect(rect);
+ isVisible = rect.contains(contentX, contentY);
+ }
+ return isVisible;
+}
+
private: // local state for WebView
bool m_isDrawingPaused;
// private to getFrameCache(); other functions operate in a different thread
@@ -972,6 +996,28 @@ static void nativeCopyBaseContentToPicture(JNIEnv *env, jobject obj, jobject pic
GET_NATIVE_VIEW(env, obj)->copyBaseContentToPicture(picture);
}
+static jboolean nativeDumpLayerContentToPicture(JNIEnv *env, jobject obj, jint instance,
+ jstring jclassName, jint layerId, jobject pict)
+{
+ bool success = false;
+ SkPicture* picture = GraphicsJNI::getNativePicture(env, pict);
+ std::string classname = jstringToStdString(env, jclassName);
+ BaseLayerAndroid* baseLayer = reinterpret_cast<WebView*>(instance)->getBaseLayer();
+ LayerAndroid* layer = baseLayer->findById(layerId);
+ SkSafeRef(layer);
+ if (layer && layer->subclassName() == classname) {
+ LayerContent* content = layer->content();
+ if (content) {
+ SkCanvas* canvas = picture->beginRecording(content->width(), content->height());
+ content->draw(canvas);
+ picture->endRecording();
+ success = true;
+ }
+ }
+ SkSafeUnref(layer);
+ return success;
+}
+
static bool nativeHasContent(JNIEnv *env, jobject obj)
{
return GET_NATIVE_VIEW(env, obj)->hasContent();
@@ -1164,7 +1210,8 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
if (baseLayer) {
FILE* file = fopen(LAYERS_TREE_LOG_FILE,"w");
if (file) {
- baseLayer->dumpLayers(file, 0);
+ WebCore::FileLayerDumper dumper(file);
+ baseLayer->dumpLayers(&dumper);
fclose(file);
}
}
@@ -1288,6 +1335,20 @@ static void nativeFindMaxVisibleRect(JNIEnv *env, jobject obj, jint nativeView,
GraphicsJNI::irect_to_jrect(nativeRect, env, visibleContentRect);
}
+static bool nativeIsHandleLeft(JNIEnv *env, jobject obj, jint nativeView,
+ jint handleId)
+{
+ WebView* webview = reinterpret_cast<WebView*>(nativeView);
+ return webview->isHandleLeft(static_cast<SelectText::HandleId>(handleId));
+}
+
+static bool nativeIsPointVisible(JNIEnv *env, jobject obj, jint nativeView,
+ jint layerId, jint contentX, jint contentY)
+{
+ WebView* webview = reinterpret_cast<WebView*>(nativeView);
+ return webview->isPointVisible(layerId, contentX, contentY);
+}
+
/*
* JNI registration
*/
@@ -1318,6 +1379,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeGetBaseLayer },
{ "nativeCopyBaseContentToPicture", "(Landroid/graphics/Picture;)V",
(void*) nativeCopyBaseContentToPicture },
+ { "nativeDumpLayerContentToPicture", "(ILjava/lang/String;ILandroid/graphics/Picture;)Z",
+ (void*) nativeDumpLayerContentToPicture },
{ "nativeHasContent", "()Z",
(void*) nativeHasContent },
{ "nativeDiscardAllTextures", "()V",
@@ -1366,6 +1429,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeSetHwAccelerated },
{ "nativeFindMaxVisibleRect", "(IILandroid/graphics/Rect;)V",
(void*) nativeFindMaxVisibleRect },
+ { "nativeIsHandleLeft", "(II)Z",
+ (void*) nativeIsHandleLeft },
+ { "nativeIsPointVisible", "(IIII)Z",
+ (void*) nativeIsPointVisible },
};
int registerWebView(JNIEnv* env)