summaryrefslogtreecommitdiffstats
path: root/WebKit/android/jni/WebViewCore.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebKit/android/jni/WebViewCore.cpp')
-rw-r--r--WebKit/android/jni/WebViewCore.cpp74
1 files changed, 42 insertions, 32 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 8dc58d2..14fd44e 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -252,6 +252,7 @@ struct WebViewCore::JavaGlue {
jmethodID m_sendFindAgain;
jmethodID m_showRect;
jmethodID m_centerFitRect;
+ jmethodID m_setScrollbarModes;
AutoJObject object(JNIEnv* env) {
return getRealObject(env, m_obj);
}
@@ -342,6 +343,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_sendFindAgain = GetJMethod(env, clazz, "sendFindAgain", "()V");
m_javaGlue->m_showRect = GetJMethod(env, clazz, "showRect", "(IIIIIIFFFF)V");
m_javaGlue->m_centerFitRect = GetJMethod(env, clazz, "centerFitRect", "(IIII)V");
+ m_javaGlue->m_setScrollbarModes = GetJMethod(env, clazz, "setScrollbarModes", "(II)V");
env->SetIntField(javaWebViewCore, gWebViewCoreFields.m_nativeClass, (jint)this);
@@ -1220,37 +1222,37 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
r->setNeedsLayoutAndPrefWidthsRecalc();
m_mainFrame->view()->forceLayout();
// scroll to restore current screen center
- if (!node)
- return;
- const WebCore::IntRect& newBounds = node->getRect();
- DBG_NAV_LOGD("nb:(x=%d,y=%d,w=%d,"
- "h=%d)", newBounds.x(), newBounds.y(),
- newBounds.width(), newBounds.height());
- if ((orsw && osh && bounds.width() && bounds.height())
- && (bounds != newBounds)) {
- WebCore::FrameView* view = m_mainFrame->view();
- // force left align if width is not changed while height changed.
- // the anchorPoint is probably at some white space in the node
- // which is affected by text wrap around the screen width.
- const bool leftAlign = (osw != m_screenWidth)
- && (bounds.width() == newBounds.width())
- && (bounds.height() != newBounds.height());
- const float xPercentInDoc =
- leftAlign ? 0.0 : (float) (anchorX - bounds.x()) / bounds.width();
- const float xPercentInView =
- leftAlign ? 0.0 : (float) (anchorX - m_scrollOffsetX) / orsw;
- const float yPercentInDoc = (float) (anchorY - bounds.y()) / bounds.height();
- const float yPercentInView = (float) (anchorY - m_scrollOffsetY) / osh;
- showRect(newBounds.x(), newBounds.y(), newBounds.width(),
- newBounds.height(), view->contentsWidth(),
- view->contentsHeight(),
- xPercentInDoc, xPercentInView,
- yPercentInDoc, yPercentInView);
+ if (node) {
+ const WebCore::IntRect& newBounds = node->getRect();
+ DBG_NAV_LOGD("nb:(x=%d,y=%d,w=%d,"
+ "h=%d)", newBounds.x(), newBounds.y(),
+ newBounds.width(), newBounds.height());
+ if ((orsw && osh && bounds.width() && bounds.height())
+ && (bounds != newBounds)) {
+ WebCore::FrameView* view = m_mainFrame->view();
+ // force left align if width is not changed while height changed.
+ // the anchorPoint is probably at some white space in the node
+ // which is affected by text wrap around the screen width.
+ const bool leftAlign = (osw != m_screenWidth)
+ && (bounds.width() == newBounds.width())
+ && (bounds.height() != newBounds.height());
+ const float xPercentInDoc =
+ leftAlign ? 0.0 : (float) (anchorX - bounds.x()) / bounds.width();
+ const float xPercentInView =
+ leftAlign ? 0.0 : (float) (anchorX - m_scrollOffsetX) / orsw;
+ const float yPercentInDoc = (float) (anchorY - bounds.y()) / bounds.height();
+ const float yPercentInView = (float) (anchorY - m_scrollOffsetY) / osh;
+ showRect(newBounds.x(), newBounds.y(), newBounds.width(),
+ newBounds.height(), view->contentsWidth(),
+ view->contentsHeight(),
+ xPercentInDoc, xPercentInView,
+ yPercentInDoc, yPercentInView);
+ }
}
}
}
- // update the currently visible screen
+ // update the currently visible screen as perceived by the plugin
sendPluginVisibleScreen();
}
@@ -1528,6 +1530,10 @@ void WebViewCore::notifyPluginsOnFrameLoad(const Frame* frame) {
void WebViewCore::sendPluginVisibleScreen()
{
+ /* We may want to cache the previous values and only send the notification
+ to the plugin in the event that one of the values has changed.
+ */
+
ANPRectI visibleRect;
visibleRect.left = m_scrollOffsetX;
visibleRect.top = m_scrollOffsetY;
@@ -2069,11 +2075,6 @@ bool WebViewCore::handleTouchEvent(int action, int x, int y, int metaState)
// Track previous touch and if stationary set the state.
WebCore::IntPoint pt(x - m_scrollOffsetX, y - m_scrollOffsetY);
- if (type == WebCore::TouchMove && pt == m_lastTouchPoint)
- touchState = WebCore::PlatformTouchPoint::TouchStationary;
-
- m_lastTouchPoint = pt;
-
WebCore::PlatformTouchEvent te(pt, type, touchState, metaState);
preventDefault = m_mainFrame->eventHandler()->handleTouchEvent(te);
#endif
@@ -2524,6 +2525,15 @@ void WebViewCore::centerFitRect(int x, int y, int width, int height)
checkException(env);
}
+
+void WebViewCore::setScrollbarModes(ScrollbarMode horizontalMode, ScrollbarMode verticalMode)
+{
+ JNIEnv* env = JSC::Bindings::getJNIEnv();
+ env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_setScrollbarModes,
+ horizontalMode, verticalMode);
+ checkException(env);
+}
+
//----------------------------------------------------------------------
// Native JNI methods
//----------------------------------------------------------------------