diff options
-rw-r--r-- | WebCore/history/android/AndroidWebHistoryBridge.h | 8 | ||||
-rw-r--r-- | WebCore/platform/Widget.h | 2 | ||||
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 2 | ||||
-rw-r--r-- | WebCore/platform/android/WidgetAndroid.cpp | 4 | ||||
-rw-r--r-- | WebCore/rendering/RenderBlockLineLayout.cpp | 8 | ||||
-rw-r--r-- | WebCore/rendering/RenderBox.cpp | 2 | ||||
-rw-r--r-- | WebCore/rendering/RenderTable.cpp | 2 | ||||
-rw-r--r-- | WebCore/rendering/RenderTableCell.cpp | 2 | ||||
-rw-r--r-- | WebCore/rendering/RenderTableSection.cpp | 2 | ||||
-rw-r--r-- | WebCore/rendering/RenderView.cpp | 2 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp | 8 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/PlatformBridge.cpp | 12 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.cpp | 10 | ||||
-rw-r--r-- | WebKit/android/jni/WebHistory.h | 6 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 61 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 17 |
16 files changed, 53 insertions, 95 deletions
diff --git a/WebCore/history/android/AndroidWebHistoryBridge.h b/WebCore/history/android/AndroidWebHistoryBridge.h index 893d137..b320c4a 100644 --- a/WebCore/history/android/AndroidWebHistoryBridge.h +++ b/WebCore/history/android/AndroidWebHistoryBridge.h @@ -36,23 +36,23 @@ class AndroidWebHistoryBridge : public RefCounted<AndroidWebHistoryBridge> { public: AndroidWebHistoryBridge(HistoryItem* item) : m_scale(0) - , m_screenWidthScale(0) + , m_textWrapScale(0) , m_active(false) , m_historyItem(item) { } virtual ~AndroidWebHistoryBridge() { } virtual void updateHistoryItem(HistoryItem* item) = 0; void setScale(int s) { m_scale = s; } - void setScreenWidthScale(int s) { m_screenWidthScale = s; } + void setTextWrapScale(int s) { m_textWrapScale = s; } int scale() const { return m_scale; } - int screenWidthScale() const { return m_screenWidthScale; } + int textWrapScale() const { return m_textWrapScale; } void detachHistoryItem() { m_historyItem = 0; } HistoryItem* historyItem() const { return m_historyItem; } void setActive() { m_active = true; } protected: int m_scale; - int m_screenWidthScale; + int m_textWrapScale; bool m_active; HistoryItem* m_historyItem; }; diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h index 23d228e..795dac3 100644 --- a/WebCore/platform/Widget.h +++ b/WebCore/platform/Widget.h @@ -276,7 +276,7 @@ private: #endif #if PLATFORM(ANDROID) public: - int screenWidth() const; + int textWrapWidth() const; #endif }; diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index 33f8697..64984db 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -129,8 +129,6 @@ public: static void setUIRootLayer(const FrameView* view, const LayerAndroid* layer); static void immediateRepaint(const FrameView* view); #endif // USE(ACCELERATED_COMPOSITING) - static int screenWidth(const FrameView* view); - static int screenHeight(const FrameView* view); // Whether the WebView is paused. // ANDROID diff --git a/WebCore/platform/android/WidgetAndroid.cpp b/WebCore/platform/android/WidgetAndroid.cpp index 14da0ca..10326f9 100644 --- a/WebCore/platform/android/WidgetAndroid.cpp +++ b/WebCore/platform/android/WidgetAndroid.cpp @@ -107,7 +107,7 @@ void Widget::setIsSelected(bool isSelected) notImplemented(); } -int Widget::screenWidth() const +int Widget::textWrapWidth() const { const Widget* widget = this; while (!widget->isFrameView()) { @@ -121,7 +121,7 @@ int Widget::screenWidth() const static_cast<const ScrollView*>(widget)); if (!core) return 0; - return core->screenWidth(); + return core->textWrapWidth(); } } // WebCore namepsace diff --git a/WebCore/rendering/RenderBlockLineLayout.cpp b/WebCore/rendering/RenderBlockLineLayout.cpp index ec138b9..96b4c6e 100644 --- a/WebCore/rendering/RenderBlockLineLayout.cpp +++ b/WebCore/rendering/RenderBlockLineLayout.cpp @@ -677,12 +677,12 @@ void RenderBlock::layoutInlineChildren(bool relayoutChildren, int& repaintTop, i obj = obj->container(); } if (!isConstrained) { - int screenWidth = view()->frameView()->screenWidth(); + int textWrapWidth = view()->frameView()->textWrapWidth(); int padding = paddingLeft() + paddingRight(); - if (screenWidth > 0 && width() > (screenWidth + padding)) { + if (textWrapWidth > 0 && width() > (textWrapWidth + padding)) { // limit the content width (width excluding padding) to be - // (screenWidth - 2 * ANDROID_FCTS_MARGIN_PADDING) - int maxWidth = screenWidth - 2 * ANDROID_FCTS_MARGIN_PADDING + padding; + // (textWrapWidth - 2 * ANDROID_FCTS_MARGIN_PADDING) + int maxWidth = textWrapWidth - 2 * ANDROID_FCTS_MARGIN_PADDING + padding; setWidth(min(width(), maxWidth)); m_minPrefWidth = min(m_minPrefWidth, maxWidth); m_maxPrefWidth = min(m_maxPrefWidth, maxWidth); diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp index 12bfced..caadbf0 100644 --- a/WebCore/rendering/RenderBox.cpp +++ b/WebCore/rendering/RenderBox.cpp @@ -1293,7 +1293,7 @@ void RenderBox::calcWidth() const Settings* settings = document()->settings(); ASSERT(settings); if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) { - m_visibleWidth = view()->frameView()->screenWidth(); + m_visibleWidth = view()->frameView()->textWrapWidth(); } } #endif diff --git a/WebCore/rendering/RenderTable.cpp b/WebCore/rendering/RenderTable.cpp index 6541ccd..00c6ac0 100644 --- a/WebCore/rendering/RenderTable.cpp +++ b/WebCore/rendering/RenderTable.cpp @@ -207,7 +207,7 @@ void RenderTable::calcWidth() const Settings* settings = document()->settings(); ASSERT(settings); if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) { - m_visibleWidth = view()->frameView()->screenWidth(); + m_visibleWidth = view()->frameView()->textWrapWidth(); } } #endif diff --git a/WebCore/rendering/RenderTableCell.cpp b/WebCore/rendering/RenderTableCell.cpp index bce659a..de93107 100644 --- a/WebCore/rendering/RenderTableCell.cpp +++ b/WebCore/rendering/RenderTableCell.cpp @@ -156,7 +156,7 @@ void RenderTableCell::calcWidth() const Settings* settings = document()->settings(); ASSERT(settings); if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) { - m_visibleWidth = view()->frameView()->screenWidth(); + m_visibleWidth = view()->frameView()->textWrapWidth(); } } #endif diff --git a/WebCore/rendering/RenderTableSection.cpp b/WebCore/rendering/RenderTableSection.cpp index e8f9cc4..5f6c1eb 100644 --- a/WebCore/rendering/RenderTableSection.cpp +++ b/WebCore/rendering/RenderTableSection.cpp @@ -271,7 +271,7 @@ void RenderTableSection::setCellWidths() const Settings* settings = document()->settings(); ASSERT(settings); if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) - visibleWidth = view()->frameView()->screenWidth(); + visibleWidth = view()->frameView()->textWrapWidth(); } #endif diff --git a/WebCore/rendering/RenderView.cpp b/WebCore/rendering/RenderView.cpp index 7a38e41..1eef860 100644 --- a/WebCore/rendering/RenderView.cpp +++ b/WebCore/rendering/RenderView.cpp @@ -93,7 +93,7 @@ void RenderView::calcWidth() const Settings * settings = document()->settings(); ASSERT(settings); if (settings->layoutAlgorithm() == Settings::kLayoutFitColumnToScreen) - m_visibleWidth = m_frameView->screenWidth(); + m_visibleWidth = m_frameView->textWrapWidth(); if (settings->useWideViewport() && settings->viewportWidth() == -1 && width() < minPrefWidth()) setWidth(m_minPrefWidth); #endif diff --git a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp index 3daa162..9278bf8 100644 --- a/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp +++ b/WebKit/android/WebCoreSupport/FrameLoaderClientAndroid.cpp @@ -810,7 +810,7 @@ void FrameLoaderClientAndroid::saveViewStateToItem(HistoryItem* item) { if (!m_frame->tree()->parent()) { WebViewCore* webViewCore = WebViewCore::getWebViewCore(m_frame->view()); bridge->setScale((int)(webViewCore->scale() * 100)); - bridge->setScreenWidthScale((int)(webViewCore->screenWidthScale() * 100)); + bridge->setTextWrapScale((int)(webViewCore->textWrapScale() * 100)); } WebCore::notifyHistoryItemChanged(item); @@ -822,11 +822,7 @@ void FrameLoaderClientAndroid::restoreViewState() { AndroidWebHistoryBridge* bridge = item->bridge(); // restore the scale (only) for the top frame if (!m_frame->tree()->parent()) { - int scale = bridge->scale(); - webViewCore->restoreScale(scale); - int screenWidthScale = bridge->screenWidthScale(); - if (screenWidthScale != scale) - webViewCore->restoreScreenWidthScale(screenWidthScale); + webViewCore->restoreScale(bridge->scale(), bridge->textWrapScale()); } } diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index c64bb9d..006f529 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -62,18 +62,6 @@ void PlatformBridge::immediateRepaint(const WebCore::FrameView* view) #endif // USE(ACCELERATED_COMPOSITING) -int PlatformBridge::screenWidth(const WebCore::FrameView* view) -{ - android::WebViewCore* core = android::WebViewCore::getWebViewCore(view); - return static_cast<int>((core->screenWidthScale() * core->screenWidth()) / core->scale()); -} - -int PlatformBridge::screenHeight(const WebCore::FrameView* view) -{ - android::WebViewCore* core = android::WebViewCore::getWebViewCore(view); - return core->screenHeight(); -} - WTF::Vector<String> PlatformBridge::getSupportedKeyStrengthList() { KeyGeneratorClient* client = JavaSharedClient::GetKeyGeneratorClient(); diff --git a/WebKit/android/jni/WebHistory.cpp b/WebKit/android/jni/WebHistory.cpp index b2af67a..37a4d1d 100644 --- a/WebKit/android/jni/WebHistory.cpp +++ b/WebKit/android/jni/WebHistory.cpp @@ -419,9 +419,9 @@ static void write_item(WTF::Vector<char>& v, WebCore::HistoryItem* item) const int scale = bridge->scale(); LOGV("Writing scale %d", scale); v.append((char*)&scale, sizeof(int)); - const int screenWidthScale = bridge->screenWidthScale(); - LOGV("Writing screen width scale %d", screenWidthScale); - v.append((char*)&screenWidthScale, sizeof(int)); + const int textWrapScale = bridge->textWrapScale(); + LOGV("Writing text wrap scale %d", textWrapScale); + v.append((char*)&textWrapScale, sizeof(int)); // Document state const WTF::Vector<WebCore::String>& docState = item->documentState(); @@ -603,8 +603,8 @@ static bool read_item_recursive(WebCore::HistoryItem* newItem, bridge->setScale(l); data += sizeofUnsigned; memcpy(&l, data, sizeofUnsigned); - LOGV("Screen width scale %d", l); - bridge->setScreenWidthScale(l); + LOGV("Text wrap scale %d", l); + bridge->setTextWrapScale(l); data += sizeofUnsigned; if (end - data < sizeofUnsigned) diff --git a/WebKit/android/jni/WebHistory.h b/WebKit/android/jni/WebHistory.h index 12bf00a..2d86aa4 100644 --- a/WebKit/android/jni/WebHistory.h +++ b/WebKit/android/jni/WebHistory.h @@ -44,9 +44,9 @@ public: static void UpdateHistoryIndex(const AutoJObject&, int); }; -// there are two scale factors saved with each history item. mScale reflects the -// viewport scale factor, default to 100 means 100%. mScreenWidthScale records -// the scale factor for the screen width used to wrap the text paragraph. +// there are two scale factors saved with each history item. m_scale reflects the +// viewport scale factor, default to 100 means 100%. m_textWrapScale records +// the scale factor for wrapping the text paragraph. class WebHistoryItem : public WebCore::AndroidWebHistoryBridge { public: WebHistoryItem(WebHistoryItem* parent) diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 78b6b05..f95672a 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -236,7 +236,6 @@ struct WebViewCore::JavaGlue { jmethodID m_updateTextSelection; jmethodID m_clearTextEntry; jmethodID m_restoreScale; - jmethodID m_restoreScreenWidthScale; jmethodID m_needTouchEvents; jmethodID m_requestKeyboard; jmethodID m_requestKeyboardWithSelection; @@ -293,8 +292,8 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_maxYScroll = 240/4; m_textGeneration = 0; m_screenWidth = 320; + m_textWrapWidth = 320; m_scale = 1; - m_screenWidthScale = 1; #if ENABLE(TOUCH_EVENTS) m_forwardingTouchEvents = false; #endif @@ -326,8 +325,7 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V"); m_javaGlue->m_updateTextSelection = GetJMethod(env, clazz, "updateTextSelection", "(IIII)V"); m_javaGlue->m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); - m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(I)V"); - m_javaGlue->m_restoreScreenWidthScale = GetJMethod(env, clazz, "restoreScreenWidthScale", "(I)V"); + m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(II)V"); m_javaGlue->m_needTouchEvents = GetJMethod(env, clazz, "needTouchEvents", "(Z)V"); m_javaGlue->m_requestKeyboard = GetJMethod(env, clazz, "requestKeyboard", "(Z)V"); m_javaGlue->m_requestKeyboardWithSelection = GetJMethod(env, clazz, "requestKeyboardWithSelection", "(IIII)V"); @@ -1048,24 +1046,13 @@ void WebViewCore::updateViewport() checkException(env); } -void WebViewCore::restoreScale(int scale) +void WebViewCore::restoreScale(int scale, int textWrapScale) { DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_restoreScale, scale); - checkException(env); -} - -void WebViewCore::restoreScreenWidthScale(int scale) -{ - DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); - LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); - - JNIEnv* env = JSC::Bindings::getJNIEnv(); - env->CallVoidMethod(m_javaGlue->object(env).get(), - m_javaGlue->m_restoreScreenWidthScale, scale); + env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_restoreScale, scale, textWrapScale); checkException(env); } @@ -1176,49 +1163,45 @@ void WebViewCore::setGlobalBounds(int x, int y, int h, int v) } void WebViewCore::setSizeScreenWidthAndScale(int width, int height, - int screenWidth, float scale, int realScreenWidth, int screenHeight, + int textWrapWidth, float scale, int screenWidth, int screenHeight, int anchorX, int anchorY, bool ignoreHeight) { WebCoreViewBridge* window = m_mainFrame->view()->platformWidget(); int ow = window->width(); int oh = window->height(); window->setSize(width, height); - window->setVisibleSize(realScreenWidth, screenHeight); - if (width > 0) { + window->setVisibleSize(screenWidth, screenHeight); + if (width != screenWidth) { m_mainFrame->view()->setUseFixedLayout(true); m_mainFrame->view()->setFixedLayoutSize(IntSize(width, height)); } else { m_mainFrame->view()->setUseFixedLayout(false); } int osw = m_screenWidth; - int orsw = m_screenWidth * m_screenWidthScale / m_scale; int osh = m_screenHeight; + int otw = m_textWrapWidth; DBG_NAV_LOGD("old:(w=%d,h=%d,sw=%d,scale=%g) new:(w=%d,h=%d,sw=%d,scale=%g)", ow, oh, osw, m_scale, width, height, screenWidth, scale); m_screenWidth = screenWidth; m_screenHeight = screenHeight; - if (scale >= 0) { // negative means ignore + m_textWrapWidth = textWrapWidth; + if (scale >= 0) // negative means keep the current scale m_scale = scale; - if (screenWidth != realScreenWidth) - m_screenWidthScale = realScreenWidth * scale / screenWidth; - else - m_screenWidthScale = m_scale; - } m_maxXScroll = screenWidth >> 2; - m_maxYScroll = (screenWidth * height / width) >> 2; - if (ow != width || (!ignoreHeight && oh != height) || osw != screenWidth) { + m_maxYScroll = m_maxXScroll * height / width; + if (ow != width || (!ignoreHeight && oh != height) || otw != textWrapWidth) { WebCore::RenderObject *r = m_mainFrame->contentRenderer(); DBG_NAV_LOGD("renderer=%p view=(w=%d,h=%d)", r, - realScreenWidth, screenHeight); + screenWidth, screenHeight); if (r) { WebCore::IntPoint anchorPoint = WebCore::IntPoint(anchorX, anchorY); DBG_NAV_LOGD("anchorX=%d anchorY=%d", anchorX, anchorY); - WebCore::Node* node = 0; + RefPtr<WebCore::Node> node; WebCore::IntRect bounds; WebCore::IntPoint offset; - // If the screen width changed, it is probably zoom change or + // If the text wrap changed, it is probably zoom change or // orientation change. Try to keep the anchor at the same place. - if (osw && screenWidth && osw != screenWidth) { + if (otw && textWrapWidth && otw != textWrapWidth) { WebCore::HitTestResult hitTestResult = m_mainFrame->eventHandler()-> hitTestResultAtPoint( anchorPoint, false); @@ -1248,19 +1231,19 @@ void WebViewCore::setSizeScreenWidthAndScale(int width, int height, 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()) + if ((osw && 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) + const bool leftAlign = (otw != textWrapWidth) && (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; + leftAlign ? 0.0 : (float) (anchorX - m_scrollOffsetX) / osw; const float yPercentInDoc = (float) (anchorY - bounds.y()) / bounds.height(); const float yPercentInView = (float) (anchorY - m_scrollOffsetY) / osh; showRect(newBounds.x(), newBounds.y(), newBounds.width(), @@ -2908,7 +2891,7 @@ static void UpdateFrameCacheIfLoading(JNIEnv *env, jobject obj) } static void SetSize(JNIEnv *env, jobject obj, jint width, jint height, - jint screenWidth, jfloat scale, jint realScreenWidth, jint screenHeight, + jint textWrapWidth, jfloat scale, jint screenWidth, jint screenHeight, jint anchorX, jint anchorY, jboolean ignoreHeight) { #ifdef ANDROID_INSTRUMENT @@ -2917,8 +2900,8 @@ static void SetSize(JNIEnv *env, jobject obj, jint width, jint height, WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOGV("webviewcore::nativeSetSize(%u %u)\n viewImpl: %p", (unsigned)width, (unsigned)height, viewImpl); LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetSize"); - viewImpl->setSizeScreenWidthAndScale(width, height, screenWidth, scale, - realScreenWidth, screenHeight, anchorX, anchorY, ignoreHeight); + viewImpl->setSizeScreenWidthAndScale(width, height, textWrapWidth, scale, + screenWidth, screenHeight, anchorX, anchorY, ignoreHeight); } static void SetScrollOffset(JNIEnv *env, jobject obj, jint gen, jint x, jint y) diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index c5461f7..44d7bcc 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -170,15 +170,9 @@ namespace android { /** * Notify the view to restore the screen width, which in turn restores - * the scale. + * the scale. Also restore the scale for the text wrap. */ - void restoreScale(int); - - /** - * Notify the view to restore the scale used to calculate the screen - * width for wrapping the text - */ - void restoreScreenWidthScale(int); + void restoreScale(int scale, int textWrapScale); /** * Tell the java side to update the focused textfield @@ -465,10 +459,9 @@ namespace android { // record the inval area, and the picture size bool recordContent(SkRegion* , SkIPoint* ); - int screenWidth() const { return m_screenWidth; } - int screenHeight() const { return m_screenHeight; } + int textWrapWidth() const { return m_textWrapWidth; } float scale() const { return m_scale; } - float screenWidthScale() const { return m_screenWidthScale; } + float textWrapScale() const { return m_screenWidth * m_scale / m_textWrapWidth; } WebCore::Frame* mainFrame() const { return m_mainFrame; } void updateCursorBounds(const CachedRoot* root, const CachedFrame* cachedFrame, const CachedNode* cachedNode); @@ -551,8 +544,8 @@ namespace android { CachedHistory m_history; int m_screenWidth; // width of the visible rect in document coordinates int m_screenHeight;// height of the visible rect in document coordinates + int m_textWrapWidth; float m_scale; - float m_screenWidthScale; unsigned m_domtree_version; bool m_check_domtree_version; PageGroup* m_groupForVisitedLinks; |