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 15:36:04 -0800
commit5fd03af0d9f4f978332fa17a40cc9f782db2432c (patch)
treec9c5606be5afabdc43ddce1c93b9cfb4e536e4ef /Source
parentc97291b2e7a966abf8dbad5cf2e0e8b033c3cd90 (diff)
downloadexternal_webkit-5fd03af0d9f4f978332fa17a40cc9f782db2432c.zip
external_webkit-5fd03af0d9f4f978332fa17a40cc9f782db2432c.tar.gz
external_webkit-5fd03af0d9f4f978332fa17a40cc9f782db2432c.tar.bz2
DO NOT MERGE 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. Cherry-picked from master CL: I6a91b97f 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 bb28d28..d53ddb6 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 0708d5c..7692de1 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