summaryrefslogtreecommitdiffstats
path: root/WebKit
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp77
-rw-r--r--WebKit/android/jni/WebViewCore.h5
-rw-r--r--WebKit/android/nav/CachedFrame.cpp21
-rw-r--r--WebKit/android/nav/CachedFrame.h2
-rw-r--r--WebKit/android/nav/CachedLayer.cpp32
-rw-r--r--WebKit/android/nav/CachedLayer.h4
-rw-r--r--WebKit/android/nav/CachedRoot.cpp4
-rw-r--r--WebKit/android/nav/WebView.cpp6
8 files changed, 38 insertions, 113 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 66c78b5..00e4be7 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -3113,51 +3113,6 @@ void WebViewCore::touchUp(int touchGeneration,
handleMouseClick(frame, node, false);
}
-// Return the RenderLayer for the given RenderObject only if the layer is
-// composited and it contains a scrollable content layer.
-static WebCore::RenderLayer* getScrollingLayerFromRenderer(
- WebCore::RenderObject* renderer)
-{
-#if ENABLE(ANDROID_OVERFLOW_SCROLL)
- if (!renderer)
- return 0;
- WebCore::RenderLayer* layer = renderer->enclosingSelfPaintingLayer();
- if (!layer)
- return 0;
- // Find the layer that actually has overflow scroll in case this renderer is
- // inside a child layer.
- while (layer && !layer->hasOverflowScroll())
- layer = layer->parent();
- return layer;
-#endif
- return 0;
-}
-
-// Scroll the RenderLayer associated with a scrollable div element. This is
-// done so that the node is visible when it is clicked.
-static void scrollLayer(WebCore::RenderObject* renderer, WebCore::IntPoint* pos)
-{
- WebCore::RenderLayer* layer = getScrollingLayerFromRenderer(renderer);
- if (!layer)
- return;
- // The cache uses absolute coordinates when clicking on nodes and it assumes
- // the layer is not scrolled.
- layer->scrollToOffset(0, 0, true, false);
-
- WebCore::IntRect absBounds = renderer->absoluteBoundingBoxRect();
- // Do not include the outline when moving the node's bounds.
- WebCore::IntRect layerBounds = layer->renderer()->absoluteBoundingBoxRect();
-
- // Move the node's bounds into the layer's coordinates.
- absBounds.move(-layerBounds.x(), -layerBounds.y());
-
- // Scroll the layer to the node's position.
- layer->scrollToOffset(absBounds.x(), absBounds.y(), true, true);
-
- // Update the mouse position to the layer offset.
- pos->move(-layer->scrollXOffset(), -layer->scrollYOffset());
-}
-
// Common code for both clicking with the trackball and touchUp
// Also used when typing into a non-focused textfield to give the textfield focus,
// in which case, 'fake' is set to true
@@ -3176,8 +3131,6 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node
DBG_NAV_LOG("area");
return true;
}
-
- scrollLayer(nodePtr->renderer(), &m_mousePos);
}
if (!valid || !framePtr)
framePtr = m_mainFrame;
@@ -3689,6 +3642,27 @@ WebRequestContext* WebViewCore::webRequestContext()
}
#endif
+void WebViewCore::scrollRenderLayer(int layer, const SkRect& rect)
+{
+#if USE(ACCELERATED_COMPOSITING)
+ GraphicsLayerAndroid* root = graphicsRootLayer();
+ if (!root)
+ return;
+
+ LayerAndroid* layerAndroid = root->platformLayer();
+ if (!layerAndroid)
+ return;
+
+ LayerAndroid* target = layerAndroid->findById(layer);
+ if (!target)
+ return;
+
+ RenderLayer* owner = target->owningLayer();
+ if (owner)
+ owner->scrollToOffset(rect.fLeft, rect.fTop, true, false);
+#endif
+}
+
//----------------------------------------------------------------------
// Native JNI methods
//----------------------------------------------------------------------
@@ -4370,6 +4344,13 @@ static void AutoFillForm(JNIEnv* env, jobject obj, jint queryId)
#endif
}
+static void ScrollRenderLayer(JNIEnv* env, jobject obj, jint layer, jobject jRect)
+{
+ SkRect rect;
+ GraphicsJNI::jrect_to_rect(env, jRect, &rect);
+ GET_NATIVE_VIEW(env, obj)->scrollRenderLayer(layer, rect);
+}
+
// ----------------------------------------------------------------------------
/*
@@ -4477,6 +4458,8 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = {
(void*) GetTouchHighlightRects },
{ "nativeAutoFillForm", "(I)V",
(void*) AutoFillForm },
+ { "nativeScrollLayer", "(ILandroid/graphics/Rect;)V",
+ (void*) ScrollRenderLayer },
};
int registerWebViewCore(JNIEnv* env)
diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h
index 411be1c..4ebe848 100644
--- a/WebKit/android/jni/WebViewCore.h
+++ b/WebKit/android/jni/WebViewCore.h
@@ -579,6 +579,11 @@ namespace android {
void setWebRequestContextCacheMode(int mode);
WebRequestContext* webRequestContext();
#endif
+
+ // Attempts to scroll the layer to the x,y coordinates of rect. The
+ // layer is the id of the LayerAndroid.
+ void scrollRenderLayer(int layer, const SkRect& rect);
+
// end of shared members
// internal functions
diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp
index 419be14..b26e24b 100644
--- a/WebKit/android/nav/CachedFrame.cpp
+++ b/WebKit/android/nav/CachedFrame.cpp
@@ -65,24 +65,6 @@ WebCore::IntRect CachedFrame::adjustBounds(const CachedNode* node,
return rect;
}
-// This is for nodes inside a layer. It takes an IntRect that has been
-// adjusted by the layer's position and removes the adjustment made by the
-// layer.
-WebCore::IntRect CachedFrame::unadjustBounds(const CachedNode* node,
- const WebCore::IntRect& rect) const
-{
-#if USE(ACCELERATED_COMPOSITING)
- if (node->isInLayer()) {
- const CachedLayer* cachedLayer = layer(node);
- const WebCore::LayerAndroid* rootLayer = mRoot->rootLayer();
- const LayerAndroid* aLayer = cachedLayer->layer(rootLayer);
- if (aLayer)
- return cachedLayer->unadjustBounds(rootLayer, rect);
- }
-#endif
- return rect;
-}
-
bool CachedFrame::CheckBetween(Direction direction, const WebCore::IntRect& bestRect,
const WebCore::IntRect& prior, WebCore::IntRect* result)
{
@@ -435,7 +417,6 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect,
*directHit = test;
*directHitFramePtr = this;
IntRect r(center, IntSize(0, 0));
- r = unadjustBounds(test, r);
*x = r.x();
*y = r.y();
} else {
@@ -480,7 +461,6 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect,
*inside = testInside;
result = test;
*framePtr = this;
- both = unadjustBounds(test, both);
*x = both.x() + (both.width() >> 1);
*y = both.y() + (both.height() >> 1);
}
@@ -552,7 +532,6 @@ const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect,
if (cursorRect.intersects(rect)) {
WebCore::IntRect intersection(cursorRect);
intersection.intersect(rect);
- intersection = unadjustBounds(test, intersection);
*x = intersection.x() + (intersection.width() >> 1);
*y = intersection.y() + (intersection.height() >> 1);
*framePtr = this;
diff --git a/WebKit/android/nav/CachedFrame.h b/WebKit/android/nav/CachedFrame.h
index 470f522..039a0ee 100644
--- a/WebKit/android/nav/CachedFrame.h
+++ b/WebKit/android/nav/CachedFrame.h
@@ -80,8 +80,6 @@ public:
void addFrame(CachedFrame& child) { mCachedFrames.append(child); }
WebCore::IntRect adjustBounds(const CachedNode* ,
const WebCore::IntRect& ) const;
- WebCore::IntRect unadjustBounds(const CachedNode*,
- const WebCore::IntRect& ) const;
bool checkRings(const CachedNode* node,
const WebCore::IntRect& testBounds) const;
bool checkVisited(const CachedNode* , CachedFrame::Direction ) const;
diff --git a/WebKit/android/nav/CachedLayer.cpp b/WebKit/android/nav/CachedLayer.cpp
index 3321797..299f2d1 100644
--- a/WebKit/android/nav/CachedLayer.cpp
+++ b/WebKit/android/nav/CachedLayer.cpp
@@ -99,38 +99,6 @@ IntRect CachedLayer::adjustBounds(const LayerAndroid* root,
return result;
}
-IntRect CachedLayer::unadjustBounds(const LayerAndroid* root,
- const IntRect& bounds) const
-{
- const LayerAndroid* aLayer = layer(root);
- if (!aLayer)
- return bounds;
-
- IntRect temp = bounds;
- // Remove the new position (i.e. fixed position elements).
- FloatPoint position = getGlobalPosition(aLayer);
-
- temp.move(-position.x(), -position.y());
-
- // Remove any layer translation.
- const FloatPoint& translation = aLayer->translation();
- temp.move(-translation.x(), -translation.y());
-
- // Move it back to the original offset.
- temp.move(mOffset.x(), mOffset.y());
-
- DBG_NAV_LOGD("root=%p aLayer=%p [%d]"
- " bounds=(%d,%d,w=%d,h=%d) trans=(%g,%g) pos=(%f,%f)"
- " offset=(%d,%d)"
- " result=(%d,%d,w=%d,h=%d)",
- root, aLayer, aLayer->uniqueId(),
- bounds.x(), bounds.y(), bounds.width(), bounds.height(),
- translation.x(), translation.y(), position.x(), position.y(),
- mOffset.x(), mOffset.y(),
- temp.x(), temp.y(), temp.width(), temp.height());
- return temp;
-}
-
FloatPoint CachedLayer::getGlobalPosition(const LayerAndroid* aLayer) const
{
SkPoint result = aLayer->getPosition();
diff --git a/WebKit/android/nav/CachedLayer.h b/WebKit/android/nav/CachedLayer.h
index 0a382fd..3d963e0 100644
--- a/WebKit/android/nav/CachedLayer.h
+++ b/WebKit/android/nav/CachedLayer.h
@@ -48,10 +48,6 @@ public:
}
// FIXME: adjustBounds should be renamed globalBounds or toGlobal
IntRect adjustBounds(const LayerAndroid* root, const IntRect& bounds) const;
- // Moves the bounds by the layer's position. Assumes the incoming
- // bounds have been adjusted by adjustBounds.
- IntRect unadjustBounds(const LayerAndroid* root,
- const IntRect& bounds) const;
int cachedNodeIndex() const { return mCachedNodeIndex; }
FloatPoint getGlobalPosition(const LayerAndroid* ) const;
const LayerAndroid* layer(const LayerAndroid* root) const;
diff --git a/WebKit/android/nav/CachedRoot.cpp b/WebKit/android/nav/CachedRoot.cpp
index 2662071..03dd398 100644
--- a/WebKit/android/nav/CachedRoot.cpp
+++ b/WebKit/android/nav/CachedRoot.cpp
@@ -1379,9 +1379,7 @@ void CachedRoot::innerMove(const CachedNode* node, BestData* bestData,
if (bestData->mNode != NULL) {
mHistory->addToVisited(bestData->mNode, direction);
mHistory->mNavBounds = bestData->bounds();
- mHistory->mMouseBounds =
- bestData->mFrame->unadjustBounds(bestData->mNode,
- bestData->mouseBounds());
+ mHistory->mMouseBounds = bestData->mouseBounds();
} else if (scroll->x() != 0 || scroll->y() != 0) {
WebCore::IntRect newBounds = mHistory->mNavBounds;
int offsetX = scroll->x();
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index edd362c..96ded71 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -936,7 +936,7 @@ void selectBestAt(const WebCore::IntRect& rect)
} else {
DBG_NAV_LOGD("CachedNode:%p (%d)", node, node->index());
WebCore::IntRect bounds = node->bounds(frame);
- root->rootHistory()->setMouseBounds(frame->unadjustBounds(node, bounds));
+ root->rootHistory()->setMouseBounds(bounds);
m_viewImpl->updateCursorBounds(root, frame, node);
showCursorTimed();
root->setCursor(const_cast<CachedFrame*>(frame),
@@ -988,8 +988,6 @@ bool motionUp(int x, int y, int slop)
}
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);
history->setNavBounds(navBounds);
history->setMouseBounds(navBounds);
@@ -2240,7 +2238,7 @@ static bool nativeMoveCursorToNextTextInput(JNIEnv *env, jobject obj)
if (!next)
return false;
const WebCore::IntRect& bounds = next->bounds(frame);
- root->rootHistory()->setMouseBounds(frame->unadjustBounds(next, bounds));
+ root->rootHistory()->setMouseBounds(bounds);
view->getWebViewCore()->updateCursorBounds(root, frame, next);
view->showCursorUntimed();
root->setCursor(const_cast<CachedFrame*>(frame),