diff options
-rw-r--r-- | Source/WebCore/platform/android/ScrollViewAndroid.cpp | 7 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/FontAndroid.cpp | 61 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/GLWebViewState.cpp | 4 | ||||
-rw-r--r-- | Source/WebCore/platform/graphics/android/TiledPage.cpp | 4 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebCoreFrameBridge.cpp | 21 | ||||
-rw-r--r-- | Source/WebKit/android/jni/WebViewCore.cpp | 22 | ||||
-rw-r--r-- | Source/WebKit/android/nav/CacheBuilder.cpp | 2 | ||||
-rw-r--r-- | Source/WebKit/android/nav/WebView.cpp | 12 |
8 files changed, 91 insertions, 42 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/WebCore/platform/graphics/android/FontAndroid.cpp b/Source/WebCore/platform/graphics/android/FontAndroid.cpp index 3528d47..81dbdae 100644 --- a/Source/WebCore/platform/graphics/android/FontAndroid.cpp +++ b/Source/WebCore/platform/graphics/android/FontAndroid.cpp @@ -59,6 +59,9 @@ using namespace android; namespace WebCore { +typedef std::pair<int, float> FallbackFontKey; +typedef HashMap<FallbackFontKey, FontPlatformData*> FallbackHash; + static void updateForFont(SkPaint* paint, const SimpleFontData* font) { font->platformData().setupPaint(paint); paint->setTextEncoding(SkPaint::kGlyphID_TextEncoding); @@ -445,16 +448,17 @@ public: private: enum CustomScript { - Hindi, - Thai, - Naskh, + Bengali, + Devanagari, Hebrew, HebrewBold, + Naskh, + Tamil, + Thai, NUM_SCRIPTS }; static const char* paths[NUM_SCRIPTS]; - static const FontPlatformData* s_fallbackPlatformData[NUM_SCRIPTS]; void setupFontForScriptRun(); const FontPlatformData* setupComplexFont(CustomScript script, @@ -502,16 +506,15 @@ private: // Indexed using enum CustomScript const char* TextRunWalker::paths[] = { + "/system/fonts/Lohit-Bengali.ttf", "/system/fonts/Lohit-Devanagari.ttf", - "/system/fonts/DroidSansThai.ttf", - "/system/fonts/DroidNaskh-Regular.ttf", "/system/fonts/DroidSansHebrew-Regular.ttf", - "/system/fonts/DroidSansHebrew-Bold.ttf" + "/system/fonts/DroidSansHebrew-Bold.ttf", + "/system/fonts/DroidNaskh-Regular.ttf", + "/system/fonts/Lohit-Tamil.ttf", + "/system/fonts/DroidSansThai.ttf" }; -// Indexed using enum CustomScript -const FontPlatformData* TextRunWalker::s_fallbackPlatformData[] = {}; - TextRunWalker::TextRunWalker(const TextRun& run, unsigned startingX, const Font* font) : m_font(font) , m_startingX(startingX) @@ -668,17 +671,23 @@ const FontPlatformData* TextRunWalker::setupComplexFont( CustomScript script, const FontPlatformData& platformData) { - if (!s_fallbackPlatformData[script]) { + static FallbackHash fallbackPlatformData; + + FallbackFontKey key(script, platformData.size()); + FontPlatformData* newPlatformData = 0; + + if (!fallbackPlatformData.contains(key)) { SkTypeface* typeface = SkTypeface::CreateFromFile(paths[script]); - s_fallbackPlatformData[script] = new FontPlatformData(platformData, typeface); + newPlatformData = new FontPlatformData(platformData, typeface); SkSafeUnref(typeface); + fallbackPlatformData.set(key, newPlatformData); } - // If we couldn't allocate a new FontPlatformData, revert to the one passed - if (!s_fallbackPlatformData[script]) - return &platformData; + if (!newPlatformData) + newPlatformData = fallbackPlatformData.get(key); - return s_fallbackPlatformData[script]; + // If we couldn't allocate a new FontPlatformData, revert to the one passed + return newPlatformData ? newPlatformData : &platformData; } void TextRunWalker::setupFontForScriptRun() @@ -689,14 +698,11 @@ void TextRunWalker::setupFontForScriptRun() const FontPlatformData* complexPlatformData = &platformData; switch (m_item.item.script) { + case HB_Script_Bengali: + complexPlatformData = setupComplexFont(Bengali, platformData); + break; case HB_Script_Devanagari: - complexPlatformData = setupComplexFont(Hindi, platformData); - break; - case HB_Script_Thai: - complexPlatformData = setupComplexFont(Thai, platformData); - break; - case HB_Script_Arabic: - complexPlatformData = setupComplexFont(Naskh, platformData); + complexPlatformData = setupComplexFont(Devanagari, platformData); break; case HB_Script_Hebrew: switch (platformData.typeface()->style()) { @@ -711,6 +717,15 @@ void TextRunWalker::setupFontForScriptRun() break; } break; + case HB_Script_Arabic: + complexPlatformData = setupComplexFont(Naskh, platformData); + break; + case HB_Script_Tamil: + complexPlatformData = setupComplexFont(Tamil, platformData); + break; + case HB_Script_Thai: + complexPlatformData = setupComplexFont(Thai, platformData); + break; default: // HB_Script_Common; includes Ethiopic complexPlatformData = &platformData; diff --git a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp index e997b57..fa22593 100644 --- a/Source/WebCore/platform/graphics/android/GLWebViewState.cpp +++ b/Source/WebCore/platform/graphics/android/GLWebViewState.cpp @@ -549,10 +549,8 @@ bool GLWebViewState::drawGL(IntRect& rect, SkRect& viewport, IntRect* invalRect, // TODO: upload as many textures as possible within a certain time limit bool ret = ImagesManager::instance()->uploadTextures(); - if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) { + if (scale < MIN_SCALE_WARNING || scale > MAX_SCALE_WARNING) XLOGC("WARNING, scale seems corrupted after update: %e", scale); - CRASH(); - } // gather the textures we can use TilesManager::instance()->gatherLayerTextures(); diff --git a/Source/WebCore/platform/graphics/android/TiledPage.cpp b/Source/WebCore/platform/graphics/android/TiledPage.cpp index c097c58..3c262d4 100644 --- a/Source/WebCore/platform/graphics/android/TiledPage.cpp +++ b/Source/WebCore/platform/graphics/android/TiledPage.cpp @@ -374,8 +374,8 @@ void TiledPage::draw(float transparency, const SkIRect& tileBounds) bool TiledPage::paint(BaseTile* tile, SkCanvas* canvas, unsigned int* pictureUsed) { - // TODO: consider other flags so the pre-rendered tiles aren't so ugly - static SkPaintFlagsDrawFilter prefetchFilter(SkPaint::kAllFlags, 0); + static SkPaintFlagsDrawFilter prefetchFilter(SkPaint::kAllFlags, + SkPaint::kAntiAlias_Flag); if (!m_glWebViewState) return false; 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 diff --git a/Source/WebKit/android/nav/CacheBuilder.cpp b/Source/WebKit/android/nav/CacheBuilder.cpp index 623d2cb..0c9e85c 100644 --- a/Source/WebKit/android/nav/CacheBuilder.cpp +++ b/Source/WebKit/android/nav/CacheBuilder.cpp @@ -2882,8 +2882,6 @@ bool CacheBuilder::setData(CachedFrame* cachedFrame) RenderLayer* layer = renderer->enclosingLayer(); if (layer == NULL) return false; - if (layer->width() == 0 || layer->height() == 0) - return false; if (!frame->view()) return false; int x, y; diff --git a/Source/WebKit/android/nav/WebView.cpp b/Source/WebKit/android/nav/WebView.cpp index 60bdd3e..d852790 100644 --- a/Source/WebKit/android/nav/WebView.cpp +++ b/Source/WebKit/android/nav/WebView.cpp @@ -204,6 +204,7 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl, WTF::String drawableDir) m_ringAnimationEnd = 0; m_baseLayer = 0; m_glDrawFunctor = 0; + m_isDrawingPaused = false; m_buttonSkin = drawableDir.isEmpty() ? 0 : new RenderSkinButton(drawableDir); #if USE(ACCELERATED_COMPOSITING) m_glWebViewState = 0; @@ -542,7 +543,7 @@ bool drawGL(WebCore::IntRect& viewRect, WebCore::IntRect* invalRect, WebCore::In } } if (ret || m_glWebViewState->currentPictureCounter() != pic) - return true; + return !m_isDrawingPaused; #endif return false; } @@ -1544,6 +1545,7 @@ BaseLayerAndroid* getBaseLayer() { return m_baseLayer; } + bool m_isDrawingPaused; private: // local state for WebView // private to getFrameCache(); other functions operate in a different thread CachedRoot* m_frameCacheUI; // navigation data ready for use @@ -2703,6 +2705,12 @@ static int nativeGetBackgroundColor(JNIEnv* env, jobject obj) return SK_ColorWHITE; } +static void nativeSetPauseDrawing(JNIEnv *env, jobject obj, jint nativeView, + jboolean pause) +{ + ((WebView*)nativeView)->m_isDrawingPaused = pause; +} + /* * JNI registration */ @@ -2915,6 +2923,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeGetProperty }, { "nativeOnTrimMemory", "(I)V", (void*) nativeOnTrimMemory }, + { "nativeSetPauseDrawing", "(IZ)V", + (void*) nativeSetPauseDrawing }, }; int registerWebView(JNIEnv* env) |