diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2011-01-28 14:00:43 -0800 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2011-01-30 09:40:54 -0800 |
commit | 0026842c0dc9cc472966e6ef44b707683ca5317b (patch) | |
tree | 62d6fbadc39b8c0b033dbc1bb9491966a5f338fd | |
parent | 5e3e997a109b7e20ddd7e04c6ec14b01dac2f32a (diff) | |
download | external_webkit-0026842c0dc9cc472966e6ef44b707683ca5317b.zip external_webkit-0026842c0dc9cc472966e6ef44b707683ca5317b.tar.gz external_webkit-0026842c0dc9cc472966e6ef44b707683ca5317b.tar.bz2 |
Fixed element positioning fix
This is for fixed bottom/ right, in the zooming case.
The width and height in webkit should be calculated as the visibleRect
we use for drawing. And that is document coordinate for visible size.
Basically it is send the Rect info from webView to webViewCore.
Then at RenderBox, it will go through the PlatformBridge to pick the
info up.
Notice that the touch is not 100% working yet, the layout call in webkit
can have a early return such that fixed element layer didn't get update.
And a touch/click is not really causing the whole layout update yet.
That will be addressed in seperate change though.
bug:3404129
Change-Id: I225d41815143a05d540ed32bfc76f823603ca89c
-rw-r--r-- | WebCore/platform/android/PlatformBridge.h | 3 | ||||
-rw-r--r-- | WebCore/rendering/RenderBox.cpp | 14 | ||||
-rw-r--r-- | WebKit/android/WebCoreSupport/PlatformBridge.cpp | 13 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 2 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 9 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 4 |
6 files changed, 45 insertions, 0 deletions
diff --git a/WebCore/platform/android/PlatformBridge.h b/WebCore/platform/android/PlatformBridge.h index 7d54ae5..3f559d5 100644 --- a/WebCore/platform/android/PlatformBridge.h +++ b/WebCore/platform/android/PlatformBridge.h @@ -148,6 +148,9 @@ public: static int highUsageDeltaMB(); static int memoryUsageMB(); static int actualMemoryUsageMB(); + + static int visibleScreenWidth(const FrameView*); + static int visibleScreenHeight(const FrameView*); }; } diff --git a/WebCore/rendering/RenderBox.cpp b/WebCore/rendering/RenderBox.cpp index 772879c..54bcf11 100644 --- a/WebCore/rendering/RenderBox.cpp +++ b/WebCore/rendering/RenderBox.cpp @@ -2077,6 +2077,13 @@ void RenderBox::computeBlockDirectionMargins(RenderBlock* containingBlock) int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* containingBlock) const { + // Fixed element's position should be decided by the visible screen size. + // That is in the doc coordindate. + if (style()->position() == FixedPosition && containingBlock->isRenderView()) { + const RenderView* view = toRenderView(containingBlock); + return PlatformBridge::visibleScreenWidth(view->frameView()); + } + if (containingBlock->isBox()) { const RenderBox* containingBlockBox = toRenderBox(containingBlock); return containingBlockBox->width() - containingBlockBox->borderLeft() - containingBlockBox->borderRight() - containingBlockBox->verticalScrollbarWidth(); @@ -2107,6 +2114,13 @@ int RenderBox::containingBlockWidthForPositioned(const RenderBoxModelObject* con int RenderBox::containingBlockHeightForPositioned(const RenderBoxModelObject* containingBlock) const { + // Fixed element's position should be decided by the visible screen size. + // That is in the doc coordindate. + if (style()->position() == FixedPosition && containingBlock->isRenderView()) { + const RenderView* view = toRenderView(containingBlock); + return PlatformBridge::visibleScreenHeight(view->frameView()); + } + int heightResult = 0; if (containingBlock->isBox()) heightResult = toRenderBox(containingBlock)->height(); diff --git a/WebKit/android/WebCoreSupport/PlatformBridge.cpp b/WebKit/android/WebCoreSupport/PlatformBridge.cpp index 0bc2e3c..b34ff8c 100644 --- a/WebKit/android/WebCoreSupport/PlatformBridge.cpp +++ b/WebKit/android/WebCoreSupport/PlatformBridge.cpp @@ -159,6 +159,19 @@ FloatRect PlatformBridge::screenRect() return FloatRect(0.0, 0.0, info.w, info.h); } +// The visible size on screen in document coordinate +int PlatformBridge::visibleScreenWidth(const WebCore::FrameView* frameView) +{ + android::WebViewCore* webViewCore = android::WebViewCore::getWebViewCore(frameView); + return webViewCore->visibleScreenWidth(); +} + +int PlatformBridge::visibleScreenHeight(const WebCore::FrameView* frameView) +{ + android::WebViewCore* webViewCore = android::WebViewCore::getWebViewCore(frameView); + return webViewCore->visibleScreenHeight(); +} + String PlatformBridge::computeDefaultLanguage() { #if USE(CHROME_NETWORK_STACK) diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 6ba8276..ef4cf66 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -486,6 +486,8 @@ void WebViewCore::reset(bool fromConstructor) m_scrollOffsetY = 0; m_screenWidth = 0; m_screenHeight = 0; + m_visibleScreenWidth = 0; + m_visibleScreenHeight = 0; m_groupForVisitedLinks = NULL; m_currentNodeDomNavigationAxis = 0; } diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 4357165..a32ce49 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -581,6 +581,10 @@ namespace android { bool isPaused() const { return m_isPaused; } void setIsPaused(bool isPaused) { m_isPaused = isPaused; } bool drawIsPaused() const; + int visibleScreenWidth() const { return m_visibleScreenWidth; } + int visibleScreenHeight() const { return m_visibleScreenHeight; } + void setVisibleScreenWidth(int w) { m_visibleScreenWidth = w; } + void setVisibleScreenHeight(int h) { m_visibleScreenHeight = h; } #if USE(CHROME_NETWORK_STACK) void setWebRequestContextUserAgent(); void setWebRequestContextCacheMode(int mode); @@ -633,6 +637,11 @@ 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 + // The m_screenHeight is not equal to the visibleRect from WebView, + // using m_visibleScreenHeight to store that info. + // After we can fix the m_screenHeight in java side, we can merge them. + int m_visibleScreenWidth; + int m_visibleScreenHeight; int m_textWrapWidth; float m_scale; unsigned m_domtree_version; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 16ec826..573718b 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -474,6 +474,8 @@ bool drawGL(WebCore::IntRect& viewRect, float scale, int extras) m_glWebViewState->setExtra(m_baseLayer, picture, rect); SkRect visibleRect; calcOurContentVisibleRect(&visibleRect); + m_viewImpl->setVisibleScreenWidth(visibleRect.width()); + m_viewImpl->setVisibleScreenHeight(visibleRect.height()); bool ret = m_baseLayer->drawGL(viewRect, visibleRect, scale); if (ret || m_glWebViewState->currentPictureCounter() != pic) return true; @@ -536,6 +538,8 @@ PictureSet* draw(SkCanvas* canvas, SkColor bgColor, int extras, bool split) compositeLayer->setExtra(extra); SkRect visible; calcOurContentVisibleRect(&visible); + m_viewImpl->setVisibleScreenWidth(visible.width()); + m_viewImpl->setVisibleScreenHeight(visible.height()); // call this to be sure we've adjusted for any scrolling or animations // before we actually draw compositeLayer->updateFixedLayersPositions(visible); |