summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorGeorge Mount <mount@google.com>2011-10-24 15:45:31 -0700
committerGeorge Mount <mount@google.com>2011-11-09 14:43:00 -0800
commit44bed85f240ccdf65de028e6fe2832b390676d47 (patch)
tree52594a8bbb50a98c79b1816b743782a6cb575efd /Source
parentdd14b5fc24b7b5dc7542e8af7249d239efb87516 (diff)
downloadexternal_webkit-44bed85f240ccdf65de028e6fe2832b390676d47.zip
external_webkit-44bed85f240ccdf65de028e6fe2832b390676d47.tar.gz
external_webkit-44bed85f240ccdf65de028e6fe2832b390676d47.tar.bz2
Offset scroll area by the scroll origin on Android
Bug 5268793 The scrolled area for WebView is 0,0 - maxX,maxY while ScrollView can have any origin. On RTL pages, the origin is negative when it can scroll. This scrolls the page to the right when it detects an RTL page. Framework CL: I2537b84a Change-Id: I6a91b97f90f5ba4c323c56dda9d125108d9502c4
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/platform/android/ScrollViewAndroid.cpp7
-rw-r--r--Source/WebKit/android/jni/WebCoreFrameBridge.cpp21
-rw-r--r--Source/WebKit/android/jni/WebViewCore.cpp22
3 files changed, 39 insertions, 11 deletions
diff --git a/Source/WebCore/platform/android/ScrollViewAndroid.cpp b/Source/WebCore/platform/android/ScrollViewAndroid.cpp
index f54e5ea..f29e998 100644
--- a/Source/WebCore/platform/android/ScrollViewAndroid.cpp
+++ b/Source/WebCore/platform/android/ScrollViewAndroid.cpp
@@ -100,7 +100,8 @@ void ScrollView::platformSetScrollPosition(const WebCore::IntPoint& pt)
{
if (parent()) // don't attempt to scroll subframes; they're fully visible
return;
- PlatformBridge::setScrollPosition(this, pt.x(), pt.y());
+ PlatformBridge::setScrollPosition(this, m_scrollOrigin.x() + pt.x(),
+ m_scrollOrigin.y() + pt.y());
}
void ScrollView::platformSetScrollbarModes()
@@ -119,7 +120,9 @@ void ScrollView::platformScrollbarModes(ScrollbarMode& h, ScrollbarMode& v) cons
void ScrollView::platformRepaintContentRectangle(const IntRect &rect, bool now)
{
- android::WebViewCore::getWebViewCore(this)->contentInvalidate(rect);
+ IntRect offsetRect = rect;
+ offsetRect.move(m_scrollOrigin.x(), m_scrollOrigin.y());
+ android::WebViewCore::getWebViewCore(this)->contentInvalidate(offsetRect);
}
#ifdef ANDROID_CAPTURE_OFFSCREEN_PAINTS
diff --git a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
index a01cca2..d4d2cc7 100644
--- a/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
+++ b/Source/WebKit/android/jni/WebCoreFrameBridge.cpp
@@ -2117,6 +2117,25 @@ static void OrientationChanged(JNIEnv *env, jobject obj, int orientation)
pFrame->sendOrientationChangeEvent(orientation);
}
+static jboolean GetShouldStartScrolledRight(JNIEnv *env, jobject obj,
+ jint browserFrame)
+{
+ jboolean startScrolledRight = false; // default is start scrolled left
+ WebCore::Frame* frame = reinterpret_cast<WebCore::Frame*>(browserFrame);
+ WebCore::Document* document = frame->document();
+ if (document) {
+ RenderStyle* style = document->renderer()->style();
+ WritingMode writingMode = style->writingMode();
+ LOG_ASSERT(writingMode != WebCore::BottomToTopWritingMode,
+ "BottomToTopWritingMode isn't supported");
+ if (writingMode == WebCore::RightToLeftWritingMode)
+ startScrolledRight = true; // vertical-rl pages start scrolled right
+ else if (writingMode == WebCore::TopToBottomWritingMode)
+ startScrolledRight = !style->isLeftToRightDirection(); // RTL starts right
+ }
+ return startScrolledRight;
+}
+
#if USE(CHROME_NETWORK_STACK)
static void AuthenticationProceed(JNIEnv *env, jobject obj, int handle, jstring jUsername, jstring jPassword)
@@ -2315,6 +2334,8 @@ static JNINativeMethod gBrowserFrameNativeMethods[] = {
(void*) SslCertErrorCancel },
{ "nativeSslClientCert", "(I[B[[B)V",
(void*) SslClientCert },
+ { "nativeGetShouldStartScrolledRight", "(I)Z",
+ (void*) GetShouldStartScrolledRight },
};
int registerWebFrame(JNIEnv* env)
diff --git a/Source/WebKit/android/jni/WebViewCore.cpp b/Source/WebKit/android/jni/WebViewCore.cpp
index 491a58c..eb2e3cc 100644
--- a/Source/WebKit/android/jni/WebViewCore.cpp
+++ b/Source/WebKit/android/jni/WebViewCore.cpp
@@ -832,10 +832,12 @@ SkPicture* WebViewCore::rebuildPicture(const SkIRect& inval)
WebCore::PlatformGraphicsContext pgc(recordingCanvas);
WebCore::GraphicsContext gc(&pgc);
- recordingCanvas->translate(-inval.fLeft, -inval.fTop);
+ IntPoint origin = view->minimumScrollPosition();
+ WebCore::IntRect drawArea(inval.fLeft + origin.x(), inval.fTop + origin.y(),
+ inval.width(), inval.height());
+ recordingCanvas->translate(-drawArea.x(), -drawArea.y());
recordingCanvas->save();
- view->platformWidget()->draw(&gc, WebCore::IntRect(inval.fLeft,
- inval.fTop, inval.width(), inval.height()));
+ view->platformWidget()->draw(&gc, drawArea);
m_rebuildInval.op(inval, SkRegion::kUnion_Op);
DBG_SET_LOGD("m_rebuildInval={%d,%d,r=%d,b=%d}",
m_rebuildInval.getBounds().fLeft, m_rebuildInval.getBounds().fTop,
@@ -1094,7 +1096,10 @@ void WebViewCore::didFirstLayout()
// When redirect with locked history, we would like to reset the
// scale factor. This is important for www.yahoo.com as it is
// redirected to www.yahoo.com/?rs=1 on load.
- || loadType == WebCore::FrameLoadTypeRedirectWithLockedBackForwardList);
+ || loadType == WebCore::FrameLoadTypeRedirectWithLockedBackForwardList
+ // When "request desktop page" is used, we want to treat it as
+ // a newly-loaded page.
+ || loadType == WebCore::FrameLoadTypeSame);
checkException(env);
DBG_NAV_LOG("call updateFrameCache");
@@ -1340,11 +1345,11 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
if (width != screenWidth) {
m_mainFrame->view()->setUseFixedLayout(true);
m_mainFrame->view()->setFixedLayoutSize(IntSize(width, height));
- } else {
+ } else
m_mainFrame->view()->setUseFixedLayout(false);
- }
r->setNeedsLayoutAndPrefWidthsRecalc();
- m_mainFrame->view()->forceLayout();
+ if (m_mainFrame->view()->didFirstLayout())
+ m_mainFrame->view()->forceLayout();
// scroll to restore current screen center
if (node) {
@@ -1382,9 +1387,8 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height,
if (width != screenWidth) {
m_mainFrame->view()->setUseFixedLayout(true);
m_mainFrame->view()->setFixedLayoutSize(IntSize(width, height));
- } else {
+ } else
m_mainFrame->view()->setUseFixedLayout(false);
- }
}
// update the currently visible screen as perceived by the plugin