summaryrefslogtreecommitdiffstats
path: root/WebKit/android/nav/WebView.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/nav/WebView.cpp')
-rw-r--r--WebKit/android/nav/WebView.cpp475
1 files changed, 342 insertions, 133 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index 913c4ba..de9e3ea 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -29,11 +29,10 @@
#include "AndroidAnimation.h"
#include "AndroidLog.h"
-#include "AtomicString.h"
+#include "BaseLayerAndroid.h"
#include "CachedFrame.h"
#include "CachedNode.h"
#include "CachedRoot.h"
-#include "CString.h"
#include "DrawExtra.h"
#include "FindCanvas.h"
#include "Frame.h"
@@ -54,7 +53,9 @@
#ifdef ANDROID_INSTRUMENT
#include "TimeCounter.h"
#endif
+#include "TilesManager.h"
#include "WebCoreJni.h"
+#include "WebRequestContext.h"
#include "WebViewCore.h"
#include "android_graphics.h"
@@ -68,6 +69,8 @@
#include <JNIHelp.h>
#include <jni.h>
#include <ui/KeycodeLabels.h>
+#include <wtf/text/AtomicString.h>
+#include <wtf/text/CString.h>
namespace android {
@@ -104,7 +107,6 @@ enum DrawExtras { // keep this in sync with WebView.java
struct JavaGlue {
jweak m_obj;
jmethodID m_calcOurContentVisibleRectF;
- jmethodID m_clearTextEntry;
jmethodID m_overrideLoading;
jmethodID m_scrollBy;
jmethodID m_sendMoveFocus;
@@ -140,7 +142,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
m_javaGlue.m_obj = env->NewWeakGlobalRef(javaWebView);
m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(IIZ)Z");
m_javaGlue.m_calcOurContentVisibleRectF = GetJMethod(env, clazz, "calcOurContentVisibleRectF", "(Landroid/graphics/RectF;)V");
- m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "(Z)V");
m_javaGlue.m_overrideLoading = GetJMethod(env, clazz, "overrideLoading", "(Ljava/lang/String;)V");
m_javaGlue.m_sendMoveFocus = GetJMethod(env, clazz, "sendMoveFocus", "(II)V");
m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V");
@@ -173,11 +174,10 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
m_navPictureUI = 0;
m_generation = 0;
m_heightCanMeasure = false;
- m_ring.m_followedLink = false;
m_lastDx = 0;
m_lastDxTime = 0;
m_ringAnimationEnd = 0;
- m_rootLayer = 0;
+ m_baseLayer = 0;
}
~WebView()
@@ -190,7 +190,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) :
}
delete m_frameCacheUI;
delete m_navPictureUI;
- delete m_rootLayer;
+ delete m_baseLayer;
}
WebViewCore* getWebViewCore() const {
@@ -221,15 +221,6 @@ void hideCursor()
viewInvalidate();
}
-void clearTextEntry()
-{
- DEBUG_NAV_UI_LOGD("%s", __FUNCTION__);
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- env->CallVoidMethod(m_javaGlue.object(env).get(),
- m_javaGlue.m_clearTextEntry, true);
- checkException(env);
-}
-
#if DUMP_NAV_CACHE
void debugDump()
{
@@ -276,7 +267,7 @@ void nativeRecordButtons(bool hasFocus, bool pressed, bool invalidate)
// button
if (!hasFocus) {
state = WebCore::RenderSkinAndroid::kNormal;
- } else if (m_ring.m_followedLink || pressed) {
+ } else if (pressed || m_ring.m_isPressed) {
state = WebCore::RenderSkinAndroid::kPressed;
} else {
state = WebCore::RenderSkinAndroid::kFocused;
@@ -303,10 +294,11 @@ void scrollRectOnScreen(const IntRect& rect)
SkRect visible;
calcOurContentVisibleRect(&visible);
#if USE(ACCELERATED_COMPOSITING)
- if (m_rootLayer) {
- m_rootLayer->updateFixedLayersPositions(visible);
- m_rootLayer->updatePositions();
- visible = m_rootLayer->subtractLayers(visible);
+ LayerAndroid* root = compositeRoot();
+ if (root) {
+ root->updateFixedLayersPositions(visible);
+ root->updatePositions();
+ visible = root->subtractLayers(visible);
}
#endif
int dx = 0;
@@ -350,7 +342,7 @@ void calcOurContentVisibleRect(SkRect* r)
void resetCursorRing()
{
- m_ring.m_followedLink = false;
+ m_ringAnimationEnd = 0;
m_viewImpl->m_hasCursorBounds = false;
}
@@ -372,36 +364,101 @@ bool drawCursorPreamble(CachedRoot* root)
m_ring.m_root = root;
m_ring.m_frame = frame;
m_ring.m_node = node;
+ SkMSec time = SkTime::GetMSecs();
+ m_ring.m_isPressed = time < m_ringAnimationEnd
+ && m_ringAnimationEnd != UINT_MAX;
return true;
}
void drawCursorPostamble()
{
- if (!m_ring.m_isButton && m_ring.m_flavor < CursorRing::NORMAL_ANIMATING)
+ if (m_ringAnimationEnd == UINT_MAX)
return;
SkMSec time = SkTime::GetMSecs();
if (time < m_ringAnimationEnd) {
// views assume that inval bounds coordinates are non-negative
WebCore::IntRect invalBounds(0, 0, INT_MAX, INT_MAX);
- invalBounds.intersect(m_ring.m_bounds);
+ invalBounds.intersect(m_ring.m_absBounds);
postInvalidateDelayed(m_ringAnimationEnd - time, invalBounds);
} else {
- if (m_ring.m_followedLink)
- hideCursor();
- m_ring.m_followedLink = false;
- m_ring.m_flavor = static_cast<CursorRing::Flavor>
- (m_ring.m_flavor - CursorRing::NORMAL_ANIMATING);
+ hideCursor();
}
}
-void drawExtras(SkCanvas* canvas, int extras)
+bool drawGL(WebCore::IntRect& viewRect, float scale, int extras)
{
+#if USE(ACCELERATED_COMPOSITING)
+ if (!m_baseLayer)
+ return false;
+
+ m_glWebViewState.resetExtra(false);
CachedRoot* root = getFrameCache(AllowNewer);
if (!root) {
DBG_NAV_LOG("!root");
if (extras == DrawExtrasCursorRing)
resetCursorRing();
- return;
+ return false;
+ }
+ DrawExtra* extra = 0;
+ switch (extras) {
+ case DrawExtrasFind:
+ extra = &m_findOnPage;
+ break;
+ case DrawExtrasSelection:
+ extra = &m_selectText;
+ break;
+ case DrawExtrasCursorRing:
+ if (drawCursorPreamble(root) && m_ring.setup()) {
+ if (!m_ring.m_isButton)
+ extra = &m_ring;
+ drawCursorPostamble();
+ }
+ break;
+ default:
+ ;
+ }
+
+ unsigned int pic = m_glWebViewState.currentPictureCounter();
+ if (extra) {
+ LayerAndroid* mainPicture = new LayerAndroid(m_navPictureUI);
+ m_glWebViewState.setExtra(extra, mainPicture);
+ } else {
+ m_glWebViewState.resetExtra(true);
+ }
+
+ SkRect visibleRect;
+ calcOurContentVisibleRect(&visibleRect);
+ bool ret = m_baseLayer->drawGL(viewRect, visibleRect, scale);
+ if (ret || m_glWebViewState.currentPictureCounter() != pic)
+ return true;
+#endif
+ return false;
+}
+
+PictureSet* draw(SkCanvas* canvas, SkColor bgColor, int extras, bool split)
+{
+ PictureSet* ret = 0;
+ if (!m_baseLayer) {
+ canvas->drawColor(bgColor);
+ return ret;
+ }
+
+ // draw the content of the base layer first
+ PictureSet* content = m_baseLayer->content();
+ int sc = canvas->save(SkCanvas::kClip_SaveFlag);
+ canvas->clipRect(SkRect::MakeLTRB(0, 0, content->width(),
+ content->height()), SkRegion::kDifference_Op);
+ canvas->drawColor(bgColor);
+ canvas->restoreToCount(sc);
+ if (content->draw(canvas))
+ ret = split ? new PictureSet(*content) : 0;
+
+ CachedRoot* root = getFrameCache(AllowNewer);
+ if (!root) {
+ DBG_NAV_LOG("!root");
+ if (extras == DrawExtrasCursorRing)
+ resetCursorRing();
+ return ret;
}
LayerAndroid mainPicture(m_navPictureUI);
DrawExtra* extra = 0;
@@ -425,22 +482,24 @@ void drawExtras(SkCanvas* canvas, int extras)
if (extra)
extra->draw(canvas, &mainPicture);
#if USE(ACCELERATED_COMPOSITING)
- if (!m_rootLayer)
- return;
- m_rootLayer->setExtra(extra);
+ LayerAndroid* compositeLayer = compositeRoot();
+ if (!compositeLayer)
+ return ret;
+ compositeLayer->setExtra(extra);
SkRect visible;
calcOurContentVisibleRect(&visible);
// call this to be sure we've adjusted for any scrolling or animations
// before we actually draw
- m_rootLayer->updateFixedLayersPositions(visible);
- m_rootLayer->updatePositions();
- // We have to set the canvas' matrix on the root layer
+ compositeLayer->updateFixedLayersPositions(visible);
+ compositeLayer->updatePositions();
+ // We have to set the canvas' matrix on the base layer
// (to have fixed layers work as intended)
SkAutoCanvasRestore restore(canvas, true);
- m_rootLayer->setMatrix(canvas->getTotalMatrix());
+ m_baseLayer->setMatrix(canvas->getTotalMatrix());
canvas->resetMatrix();
- m_rootLayer->draw(canvas);
+ m_baseLayer->draw(canvas);
#endif
+ return ret;
}
@@ -565,7 +624,7 @@ CachedRoot* getFrameCache(FrameCachePermission allowNewer)
m_viewImpl->m_navPictureKit = 0;
m_viewImpl->gFrameCacheMutex.unlock();
if (m_frameCacheUI)
- m_frameCacheUI->setRootLayer(m_rootLayer);
+ m_frameCacheUI->setRootLayer(compositeRoot());
#if USE(ACCELERATED_COMPOSITING)
if (layerId >= 0) {
SkRect visible;
@@ -658,10 +717,10 @@ static CachedFrame::Direction KeyToDirection(int32_t keyCode)
}
}
-WebCore::String imageURI(int x, int y)
+WTF::String imageURI(int x, int y)
{
const CachedRoot* root = getFrameCache(DontAllowNewer);
- return root ? root->imageURI(x, y) : WebCore::String();
+ return root ? root->imageURI(x, y) : WTF::String();
}
bool cursorWantsKeyEvents()
@@ -701,8 +760,6 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll)
int dx = 0;
int dy = 0;
int counter = count;
- if (!cursor || !m_ring.m_followedLink)
- root->setScrollOnly(m_ring.m_followedLink);
while (--counter >= 0) {
WebCore::IntPoint scroll = WebCore::IntPoint(0, 0);
cachedNode = root->moveCursor(direction, &cachedFrame, &scroll);
@@ -734,13 +791,13 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll)
}
bool result = false;
if (cachedNode) {
+ showCursorUntimed();
m_viewImpl->updateCursorBounds(root, cachedFrame, cachedNode);
root->setCursor(const_cast<CachedFrame*>(cachedFrame),
const_cast<CachedNode*>(cachedNode));
bool disableFocusController = cachedNode != root->currentFocus()
&& cachedNode->wantsKeyEvents();
sendMoveMouseIfLatest(disableFocusController);
- viewInvalidate();
} else {
int docHeight = root->documentHeight();
int docWidth = root->documentWidth();
@@ -807,34 +864,19 @@ void selectBestAt(const WebCore::IntRect& rect)
m_viewImpl->m_hasCursorBounds = false;
if (root)
root->setCursor(0, 0);
+ viewInvalidate();
} else {
DBG_NAV_LOGD("CachedNode:%p (%d)", node, node->index());
- root->rootHistory()->setMouseBounds(node->bounds(frame));
+ WebCore::IntRect bounds = node->bounds(frame);
+ root->rootHistory()->setMouseBounds(frame->unadjustBounds(node, bounds));
m_viewImpl->updateCursorBounds(root, frame, node);
+ showCursorTimed();
root->setCursor(const_cast<CachedFrame*>(frame),
const_cast<CachedNode*>(node));
}
sendMoveMouseIfLatest(false);
- viewInvalidate();
-}
-
-WebCore::IntRect getNavBounds()
-{
- CachedRoot* root = getFrameCache(DontAllowNewer);
- return root ? root->rootHistory()->navBounds() :
- WebCore::IntRect(0, 0, 0, 0);
}
-void setNavBounds(const WebCore::IntRect& rect)
-{
- CachedRoot* root = getFrameCache(DontAllowNewer);
- if (!root)
- return;
- root->rootHistory()->setNavBounds(rect);
-}
-
-
-
const CachedNode* m_cacheHitNode;
const CachedFrame* m_cacheHitFrame;
@@ -851,7 +893,6 @@ bool pointInNavCache(int x, int y, int slop)
bool motionUp(int x, int y, int slop)
{
bool pageScrolled = false;
- m_ring.m_followedLink = false;
IntRect rect = IntRect(x - slop, y - slop, slop * 2, slop * 2);
int rx, ry;
CachedRoot* root = getFrameCache(AllowNewer);
@@ -859,9 +900,10 @@ bool motionUp(int x, int y, int slop)
return 0;
const CachedFrame* frame = 0;
const CachedNode* result = findAt(root, rect, &frame, &rx, &ry);
+ CachedHistory* history = root->rootHistory();
if (!result) {
DBG_NAV_LOGD("no nodes found root=%p", root);
- setNavBounds(rect);
+ history->setNavBounds(rect);
m_viewImpl->m_hasCursorBounds = false;
root->hideCursor();
int dx = root->checkForCenter(x, y);
@@ -872,33 +914,46 @@ bool motionUp(int x, int y, int slop)
sendMotionUp(frame ? (WebCore::Frame*) frame->framePointer() : 0,
0, x, y);
viewInvalidate();
- clearTextEntry();
return pageScrolled;
}
DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result,
result->index(), x, y, rx, ry);
+ // No need to call unadjustBounds below. rx and ry are already adjusted to
+ // the absolute position of the node.
WebCore::IntRect navBounds = WebCore::IntRect(rx, ry, 1, 1);
- setNavBounds(navBounds);
- root->rootHistory()->setMouseBounds(navBounds);
+ history->setNavBounds(navBounds);
+ history->setMouseBounds(navBounds);
m_viewImpl->updateCursorBounds(root, frame, result);
root->setCursor(const_cast<CachedFrame*>(frame),
const_cast<CachedNode*>(result));
- bool syntheticLink = result->isSyntheticLink();
- if (!syntheticLink) {
+ if (result->isSyntheticLink())
+ overrideUrlLoading(result->getExport());
+ else {
sendMotionUp(
(WebCore::Frame*) frame->framePointer(),
(WebCore::Node*) result->nodePointer(), rx, ry);
}
- viewInvalidate();
- if (!result->isTextInput()) {
- clearTextEntry();
- setFollowedLink(true);
- if (syntheticLink)
- overrideUrlLoading(result->getExport());
- }
+ if (result->isTextInput() || result->isSelect()
+ || result->isContentEditable()) {
+ showCursorUntimed();
+ } else
+ showCursorTimed();
return pageScrolled;
}
+const LayerAndroid* scrollableLayer(int x, int y)
+{
+#if ENABLE(ANDROID_OVERFLOW_SCROLL) && USE(ACCELERATED_COMPOSITING)
+ const LayerAndroid* root = compositeRoot();
+ if (!root)
+ return 0;
+ const LayerAndroid* result = root->find(x, y);
+ if (result != 0 && result->contentIsScrollable())
+ return result;
+#endif
+ return 0;
+}
+
int getBlockLeftEdge(int x, int y, float scale)
{
CachedRoot* root = getFrameCache(AllowNewer);
@@ -907,7 +962,7 @@ int getBlockLeftEdge(int x, int y, float scale)
return -1;
}
-void overrideUrlLoading(const WebCore::String& url)
+void overrideUrlLoading(const WTF::String& url)
{
JNIEnv* env = JSC::Bindings::getJNIEnv();
jstring jName = env->NewString((jchar*) url.characters(), url.length());
@@ -928,12 +983,19 @@ void setFindIsEmpty()
m_findOnPage.clearCurrentLocation();
}
-void setFollowedLink(bool followed)
+void showCursorTimed()
{
- if ((m_ring.m_followedLink = followed) != false) {
- m_ringAnimationEnd = SkTime::GetMSecs() + 500;
- viewInvalidate();
- }
+ DBG_NAV_LOG("");
+ m_ringAnimationEnd = SkTime::GetMSecs() + 500;
+ viewInvalidate();
+}
+
+void showCursorUntimed()
+{
+ DBG_NAV_LOG("");
+ m_ring.m_isPressed = false;
+ m_ringAnimationEnd = UINT_MAX;
+ viewInvalidate();
}
void setHeightCanMeasure(bool measure)
@@ -1169,20 +1231,74 @@ int moveGeneration()
return m_viewImpl->m_moveGeneration;
}
-LayerAndroid* rootLayer() const
+LayerAndroid* compositeRoot() const
+{
+ LOG_ASSERT(!m_baseLayer || m_baseLayer->countChildren() == 1,
+ "base layer can't have more than one child %s", __FUNCTION__);
+ if (m_baseLayer && m_baseLayer->countChildren() == 1)
+ return static_cast<LayerAndroid*>(m_baseLayer->getChild(0));
+ else
+ return 0;
+}
+
+static void copyScrollPositionRecursive(const LayerAndroid* from,
+ LayerAndroid* root)
{
- return m_rootLayer;
+ if (!from || !root)
+ return;
+ for (int i = 0; i < from->countChildren(); i++) {
+ const LayerAndroid* l = from->getChild(i);
+ if (l->contentIsScrollable()) {
+ LayerAndroid* match =
+ const_cast<LayerAndroid*>(root->findById(l->uniqueId()));
+ if (match != 0)
+ match->setScrollPosition(l->scrollPosition());
+ }
+ copyScrollPositionRecursive(l, root);
+ }
}
-void setRootLayer(LayerAndroid* layer)
+void setBaseLayer(BaseLayerAndroid* layer, WebCore::IntRect& rect)
{
- delete m_rootLayer;
- m_rootLayer = layer;
+#if USE(ACCELERATED_COMPOSITING)
+ m_glWebViewState.setBaseLayer(layer, rect);
+#endif
+
+ if (layer) {
+ copyScrollPositionRecursive(compositeRoot(),
+ static_cast<LayerAndroid*>(layer->getChild(0)));
+ }
+ delete m_baseLayer;
+ m_baseLayer = layer;
CachedRoot* root = getFrameCache(DontAllowNewer);
if (!root)
return;
root->resetLayers();
- root->setRootLayer(m_rootLayer);
+ root->setRootLayer(compositeRoot());
+}
+
+void replaceBaseContent(PictureSet* set)
+{
+ if (!m_baseLayer)
+ return;
+ m_baseLayer->setContent(*set);
+ delete set;
+}
+
+void copyBaseContentToPicture(SkPicture* picture)
+{
+ if (!m_baseLayer)
+ return;
+ PictureSet* content = m_baseLayer->content();
+ content->draw(picture->beginRecording(content->width(), content->height(),
+ SkPicture::kUsePathBoundsForClip_RecordingFlag));
+ picture->endRecording();
+}
+
+bool hasContent() {
+ if (!m_baseLayer)
+ return false;
+ return !m_baseLayer->content()->isEmpty();
}
private: // local state for WebView
@@ -1199,13 +1315,16 @@ private: // local state for WebView
SelectText m_selectText;
FindOnPage m_findOnPage;
CursorRing m_ring;
- LayerAndroid* m_rootLayer;
+ BaseLayerAndroid* m_baseLayer;
+#if USE(ACCELERATED_COMPOSITING)
+ GLWebViewState m_glWebViewState;
+#endif
}; // end of WebView class
/*
* Native JNI methods
*/
-static jstring WebCoreStringToJString(JNIEnv *env, WebCore::String string)
+static jstring WebCoreStringToJString(JNIEnv *env, WTF::String string)
{
int length = string.length();
if (!length)
@@ -1332,6 +1451,19 @@ static const CachedInput* getInputCandidate(JNIEnv *env, jobject obj)
return cursor ? frame->textInput(cursor) : 0;
}
+static jboolean nativePageShouldHandleShiftAndArrows(JNIEnv *env, jobject obj)
+{
+ const CachedNode* focus = getFocusNode(env, obj);
+ if (!focus) return false;
+ // Plugins handle shift and arrows whether or not they have focus.
+ if (focus->isPlugin()) return true;
+ const CachedNode* cursor = getCursorNode(env, obj);
+ // ContentEditable nodes should only receive shift and arrows if they have
+ // both the cursor and the focus.
+ return cursor && cursor->nodePointer() == focus->nodePointer()
+ && cursor->isContentEditable();
+}
+
static jboolean nativeCursorMatchesFocus(JNIEnv *env, jobject obj)
{
const CachedNode* cursor = getCursorNode(env, obj);
@@ -1403,7 +1535,7 @@ static jobject nativeCursorText(JNIEnv *env, jobject obj)
const CachedNode* node = getCursorNode(env, obj);
if (!node)
return 0;
- WebCore::String value = node->getExport();
+ WTF::String value = node->getExport();
return !value.isEmpty() ? env->NewString((jchar *)value.characters(),
value.length()) : 0;
}
@@ -1417,35 +1549,58 @@ static void nativeDebugDump(JNIEnv *env, jobject obj)
#endif
}
-static void nativeDrawExtras(JNIEnv *env, jobject obj, jobject canv, jint extras)
-{
+static jint nativeDraw(JNIEnv *env, jobject obj, jobject canv, jint color,
+ jint extras, jboolean split) {
SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv);
- GET_NATIVE_VIEW(env, obj)->drawExtras(canvas, extras);
+ return reinterpret_cast<jint>(GET_NATIVE_VIEW(env, obj)->draw(canvas, color, extras, split));
+}
+
+static bool nativeDrawGL(JNIEnv *env, jobject obj, jobject jrect,
+ jfloat scale, jint extras)
+{
+ WebCore::IntRect viewRect = jrect_to_webrect(env, jrect);
+ return GET_NATIVE_VIEW(env, obj)->drawGL(viewRect, scale, extras);
}
static bool nativeEvaluateLayersAnimations(JNIEnv *env, jobject obj)
{
#if USE(ACCELERATED_COMPOSITING)
- const LayerAndroid* root = GET_NATIVE_VIEW(env, obj)->rootLayer();
+ const LayerAndroid* root = GET_NATIVE_VIEW(env, obj)->compositeRoot();
if (root)
return root->evaluateAnimations();
#endif
return false;
}
-static void nativeSetRootLayer(JNIEnv *env, jobject obj, jint layer)
+static void nativeSetBaseLayer(JNIEnv *env, jobject obj, jint layer, jobject jrect)
{
-#if USE(ACCELERATED_COMPOSITING)
- LayerAndroid* layerImpl = reinterpret_cast<LayerAndroid*>(layer);
- GET_NATIVE_VIEW(env, obj)->setRootLayer(layerImpl);
-#endif
+ BaseLayerAndroid* layerImpl = reinterpret_cast<BaseLayerAndroid*>(layer);
+ WebCore::IntRect rect = jrect_to_webrect(env, jrect);
+ GET_NATIVE_VIEW(env, obj)->setBaseLayer(layerImpl, rect);
+}
+
+static void nativeReplaceBaseContent(JNIEnv *env, jobject obj, jint content)
+{
+ PictureSet* set = reinterpret_cast<PictureSet*>(content);
+ GET_NATIVE_VIEW(env, obj)->replaceBaseContent(set);
+}
+
+static void nativeCopyBaseContentToPicture(JNIEnv *env, jobject obj, jobject pict)
+{
+ SkPicture* picture = GraphicsJNI::getNativePicture(env, pict);
+ GET_NATIVE_VIEW(env, obj)->copyBaseContentToPicture(picture);
+}
+
+static bool nativeHasContent(JNIEnv *env, jobject obj)
+{
+ return GET_NATIVE_VIEW(env, obj)->hasContent();
}
static jobject nativeImageURI(JNIEnv *env, jobject obj, jint x, jint y)
{
WebView* view = GET_NATIVE_VIEW(env, obj);
LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
- WebCore::String uri = view->imageURI(x, y);
+ WTF::String uri = view->imageURI(x, y);
jstring ret = 0;
unsigned len = uri.length();
if (len) {
@@ -1497,7 +1652,7 @@ static jobject nativeFocusCandidateName(JNIEnv *env, jobject obj)
const CachedInput* input = getInputCandidate(env, obj);
if (!input)
return 0;
- const WebCore::String& name = input->name();
+ const WTF::String& name = input->name();
return env->NewString((jchar*)name.characters(), name.length());
}
@@ -1540,7 +1695,7 @@ static jobject nativeFocusCandidateText(JNIEnv *env, jobject obj)
const CachedNode* node = getFocusCandidate(env, obj, 0);
if (!node)
return 0;
- WebCore::String value = node->getExport();
+ WTF::String value = node->getExport();
return !value.isEmpty() ? env->NewString((jchar *)value.characters(),
value.length()) : 0;
}
@@ -1643,7 +1798,7 @@ static jobject nativeSubtractLayers(JNIEnv* env, jobject obj, jobject jrect)
{
SkIRect irect = jrect_to_webrect(env, jrect);
#if USE(ACCELERATED_COMPOSITING)
- LayerAndroid* root = GET_NATIVE_VIEW(env, obj)->rootLayer();
+ LayerAndroid* root = GET_NATIVE_VIEW(env, obj)->compositeRoot();
if (root) {
SkRect rect;
rect.set(irect);
@@ -1717,11 +1872,9 @@ static void nativeSetFindIsEmpty(JNIEnv *env, jobject obj)
GET_NATIVE_VIEW(env, obj)->setFindIsEmpty();
}
-static void nativeSetFollowedLink(JNIEnv *env, jobject obj, bool followed)
+static void nativeShowCursorTimed(JNIEnv *env, jobject obj)
{
- WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
- view->setFollowedLink(followed);
+ GET_NATIVE_VIEW(env, obj)->showCursorTimed();
}
static void nativeSetHeightCanMeasure(JNIEnv *env, jobject obj, bool measure)
@@ -1827,7 +1980,7 @@ static void nativeUpdateCachedTextfield(JNIEnv *env, jobject obj, jstring update
const CachedNode* cachedFocusNode = root->currentFocus();
if (!cachedFocusNode || !cachedFocusNode->isTextInput())
return;
- WebCore::String webcoreString = to_string(env, updatedText);
+ WTF::String webcoreString = to_string(env, updatedText);
(const_cast<CachedNode*>(cachedFocusNode))->setExport(webcoreString);
root->setTextGeneration(generation);
checkException(env);
@@ -1867,8 +2020,9 @@ static bool nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj)
if (!next)
return false;
const WebCore::IntRect& bounds = next->bounds(frame);
- root->rootHistory()->setMouseBounds(bounds);
+ root->rootHistory()->setMouseBounds(frame->unadjustBounds(next, bounds));
view->getWebViewCore()->updateCursorBounds(root, frame, next);
+ view->showCursorUntimed();
root->setCursor(const_cast<CachedFrame*>(frame),
const_cast<CachedNode*>(next));
view->sendMoveFocus(static_cast<WebCore::Frame*>(frame->framePointer()),
@@ -1892,6 +2046,24 @@ static void nativeMoveSelection(JNIEnv *env, jobject obj, int x, int y)
GET_NATIVE_VIEW(env, obj)->moveSelection(x, y);
}
+static jboolean nativeCleanupPrivateBrowsingFiles(
+ JNIEnv *env, jobject obj, jstring databaseDirectoryJString, jstring cacheDirectoryJString) {
+#if USE(CHROME_NETWORK_STACK)
+ jboolean isCopy;
+ const char* cString = env->GetStringUTFChars(databaseDirectoryJString, &isCopy);
+ std::string databaseDirectory(cString);
+ if (isCopy == JNI_TRUE)
+ env->ReleaseStringUTFChars(databaseDirectoryJString, cString);
+ cString = env->GetStringUTFChars(cacheDirectoryJString, &isCopy);
+ std::string cacheDirectory(cString);
+ if (isCopy == JNI_TRUE)
+ env->ReleaseStringUTFChars(cacheDirectoryJString, cString);
+ return WebRequestContext::CleanupPrivateBrowsingFiles(databaseDirectory, cacheDirectory);
+#else
+ return JNI_FALSE;
+#endif
+}
+
static void nativeResetSelection(JNIEnv *env, jobject obj)
{
return GET_NATIVE_VIEW(env, obj)->resetSelection();
@@ -1979,26 +2151,13 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
SkDumpCanvas canvas(&dumper);
// this will playback the picture into the canvas, which will
// spew its contents to the dumper
- view->getWebViewCore()->drawContent(&canvas, 0);
-#if USE(ACCELERATED_COMPOSITING)
- if (true) {
- LayerAndroid* rootLayer = view->rootLayer();
- if (rootLayer) {
- // We have to set the canvas' matrix on the root layer
- // (to have fixed layers work as intended)
- SkAutoCanvasRestore restore(&canvas, true);
- rootLayer->setMatrix(canvas.getTotalMatrix());
- canvas.resetMatrix();
- rootLayer->draw(&canvas);
- }
- }
-#endif
+ view->draw(&canvas, 0, 0, false);
// we're done with the file now
fwrite("\n", 1, 1, file);
fclose(file);
}
#if USE(ACCELERATED_COMPOSITING)
- const LayerAndroid* rootLayer = view->rootLayer();
+ const LayerAndroid* rootLayer = view->compositeRoot();
if (rootLayer) {
FILE* file = fopen(LAYERS_TREE_LOG_FILE,"w");
if (file) {
@@ -2011,6 +2170,40 @@ static void nativeDumpDisplayTree(JNIEnv* env, jobject jwebview, jstring jurl)
#endif
}
+static int nativeScrollableLayer(JNIEnv* env, jobject jwebview, jint x, jint y)
+{
+ WebView* view = GET_NATIVE_VIEW(env, jwebview);
+ LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
+ return (int) view->scrollableLayer(x, y);
+}
+
+static bool validLayer(const LayerAndroid* root, const LayerAndroid* layer) {
+ if (root == layer)
+ return true;
+ for (int i = 0; i < root->countChildren(); i++) {
+ const LayerAndroid* l = root->getChild(i);
+ if (validLayer(l, layer))
+ return true;
+ }
+ return false;
+}
+
+static bool nativeScrollLayer(JNIEnv* env, jobject obj, jint pLayer, jint dx,
+ jint dy)
+{
+#if ENABLE(ANDROID_OVERFLOW_SCROLL)
+ WebView* view = GET_NATIVE_VIEW(env, obj);
+ const LayerAndroid* root = view->compositeRoot();
+ LayerAndroid* layer = (LayerAndroid*) pLayer;
+ if (!validLayer(root, layer)) {
+ return false;
+ }
+ LOG_ASSERT(layer, "layer not set in %s", __FUNCTION__);
+ return layer->scrollBy(dx, dy);
+#endif
+ return false;
+}
+
/*
* JNI registration
*/
@@ -2027,6 +2220,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeCreate },
{ "nativeCursorFramePointer", "()I",
(void*) nativeCursorFramePointer },
+ { "nativePageShouldHandleShiftAndArrows", "()Z",
+ (void*) nativePageShouldHandleShiftAndArrows },
{ "nativeCursorMatchesFocus", "()Z",
(void*) nativeCursorMatchesFocus },
{ "nativeCursorNodeBounds", "()Landroid/graphics/Rect;",
@@ -2049,8 +2244,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeDebugDump },
{ "nativeDestroy", "()V",
(void*) nativeDestroy },
- { "nativeDrawExtras", "(Landroid/graphics/Canvas;I)V",
- (void*) nativeDrawExtras },
+ { "nativeDraw", "(Landroid/graphics/Canvas;IIZ)I",
+ (void*) nativeDraw },
+ { "nativeDrawGL", "(Landroid/graphics/Rect;FI)Z",
+ (void*) nativeDrawGL },
{ "nativeDumpDisplayTree", "(Ljava/lang/String;)V",
(void*) nativeDumpDisplayTree },
{ "nativeEvaluateLayersAnimations", "()Z",
@@ -2121,6 +2318,8 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeMoveGeneration },
{ "nativeMoveSelection", "(II)V",
(void*) nativeMoveSelection },
+ { "nativeCleanupPrivateBrowsingFiles", "(Ljava/lang/String;Ljava/lang/String;)Z",
+ (void*) nativeCleanupPrivateBrowsingFiles },
{ "nativePointInNavCache", "(III)Z",
(void*) nativePointInNavCache },
{ "nativeRecordButtons", "(ZZZ)V",
@@ -2141,14 +2340,20 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeSetFindIsEmpty },
{ "nativeSetFindIsUp", "(Z)V",
(void*) nativeSetFindIsUp },
- { "nativeSetFollowedLink", "(Z)V",
- (void*) nativeSetFollowedLink },
{ "nativeSetHeightCanMeasure", "(Z)V",
(void*) nativeSetHeightCanMeasure },
- { "nativeSetRootLayer", "(I)V",
- (void*) nativeSetRootLayer },
+ { "nativeSetBaseLayer", "(ILandroid/graphics/Rect;)V",
+ (void*) nativeSetBaseLayer },
+ { "nativeReplaceBaseContent", "(I)V",
+ (void*) nativeReplaceBaseContent },
+ { "nativeCopyBaseContentToPicture", "(Landroid/graphics/Picture;)V",
+ (void*) nativeCopyBaseContentToPicture },
+ { "nativeHasContent", "()Z",
+ (void*) nativeHasContent },
{ "nativeSetSelectionPointer", "(ZFII)V",
(void*) nativeSetSelectionPointer },
+ { "nativeShowCursorTimed", "()V",
+ (void*) nativeShowCursorTimed },
{ "nativeStartSelection", "(II)Z",
(void*) nativeStartSelection },
{ "nativeSubtractLayers", "(Landroid/graphics/Rect;)Landroid/graphics/Rect;",
@@ -2161,6 +2366,10 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeWordSelection },
{ "nativeGetBlockLeftEdge", "(IIF)I",
(void*) nativeGetBlockLeftEdge },
+ { "nativeScrollableLayer", "(II)I",
+ (void*) nativeScrollableLayer },
+ { "nativeScrollLayer", "(III)Z",
+ (void*) nativeScrollLayer },
};
int register_webview(JNIEnv* env)