From: yael.aharon@nokia.com Date: Mon, 16 Apr 2012 14:05:42 +0000 (+0000) Subject: [Qt][WK2] Fixed elements position is wrong after zooming. X-Git-Tag: 070512121124~6931 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a848c9d3596a88dcce58c927dbee8ddd3460c9b4;p=profile%2Fivi%2Fwebkit-efl.git [Qt][WK2] Fixed elements position is wrong after zooming. https://bugs.webkit.org/show_bug.cgi?id=83981 Reviewed by Kenneth Rohde Christiansen. .: * ManualTests/remove-add-fixed-position.html: Added. Source/WebCore: When setFixedVisibleContentRect is called we mark all fixed elements in the frame for layout. In order to find these elements, RenderView maintains a list of fixed elements. They are added and removed at the same time that they are added and removed from their parent RenderBlock. The idea is taken from the iOS5.1 branch, at opensource.apple.com. Added a manual test that allows removing and adding fixed elements at will. * page/FrameView.cpp: (WebCore::FrameView::setFixedVisibleContentRect): * rendering/RenderBlock.cpp: (WebCore::RenderBlock::insertPositionedObject): (WebCore::RenderBlock::removePositionedObject): * rendering/RenderView.cpp: (WebCore::RenderView::setFixedPositionedObjectsNeedLayout): (WebCore): (WebCore::RenderView::insertFixedPositionedObject): (WebCore::RenderView::removeFixedPositionedObject): * rendering/RenderView.h: (RenderView): Source/WebKit2: Turn on the flag setFixedElementsLayoutRelativeToFrame. This causes fixed elements position to be calculated based on visibleWidth and visibleHeight. When zoom level grows, the visibleWidth and visibleHeight become smaller. * WebProcess/WebPage/WebPage.cpp: (WebKit::WebPage::setResizesToContentsUsingLayoutSize): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@114249 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- diff --git a/ChangeLog b/ChangeLog index 1d02f3c..4db92b7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-04-16 Yael Aharon + + [Qt][WK2] Fixed elements position is wrong after zooming. + https://bugs.webkit.org/show_bug.cgi?id=83981 + + Reviewed by Kenneth Rohde Christiansen. + + * ManualTests/remove-add-fixed-position.html: Added. + 2012-04-13 Jason Liu [BlackBerry] Sign in cookie for ESPN.com does not retain login account (for fantasy sports). diff --git a/ManualTests/remove-add-fixed-position.html b/ManualTests/remove-add-fixed-position.html new file mode 100644 index 0000000..983f13d --- /dev/null +++ b/ManualTests/remove-add-fixed-position.html @@ -0,0 +1,93 @@ + + + + + + +
This is a test
+
+000 +
+
+200
+ +
+
+400
+ +
+
+600
+
+
+800 +
+
+1000 +
+
+1200 +
+
+1400 +
+
+1600 +
+
+1800 +
+
+2000 +
+
+2200 +
+
+2400 +
+
+2600 +
+
+2800 +
+
+3000 +
+
+3200 +
+
+3400 +
+
+3600 +
+
+3800 +
+
+4000 +
+ diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 3b32c0c..7d97b98 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,29 @@ +2012-04-16 Yael Aharon + + [Qt][WK2] Fixed elements position is wrong after zooming. + https://bugs.webkit.org/show_bug.cgi?id=83981 + + Reviewed by Kenneth Rohde Christiansen. + + When setFixedVisibleContentRect is called we mark all fixed elements in the frame for layout. + In order to find these elements, RenderView maintains a list of fixed elements. + They are added and removed at the same time that they are added and removed from their parent RenderBlock. + The idea is taken from the iOS5.1 branch, at opensource.apple.com. + Added a manual test that allows removing and adding fixed elements at will. + + * page/FrameView.cpp: + (WebCore::FrameView::setFixedVisibleContentRect): + * rendering/RenderBlock.cpp: + (WebCore::RenderBlock::insertPositionedObject): + (WebCore::RenderBlock::removePositionedObject): + * rendering/RenderView.cpp: + (WebCore::RenderView::setFixedPositionedObjectsNeedLayout): + (WebCore): + (WebCore::RenderView::insertFixedPositionedObject): + (WebCore::RenderView::removeFixedPositionedObject): + * rendering/RenderView.h: + (RenderView): + 2012-04-13 Pavel Feldman Web Inspector: extract ContentProvider into its own file, make NetworkRequest, Resoruce and others implement it. diff --git a/Source/WebCore/page/FrameView.cpp b/Source/WebCore/page/FrameView.cpp index 149c536..844de28 100644 --- a/Source/WebCore/page/FrameView.cpp +++ b/Source/WebCore/page/FrameView.cpp @@ -1705,6 +1705,13 @@ void FrameView::delegatesScrollingDidChange() void FrameView::setFixedVisibleContentRect(const IntRect& visibleContentRect) { + if (visibleContentRect.size() != this->fixedVisibleContentRect().size()) { + // When the viewport size changes or the content is scaled, we need to + // reposition the fixed positioned elements. + if (RenderView* root = rootRenderer(this)) + root->setFixedPositionedObjectsNeedLayout(); + } + IntSize offset = scrollOffset(); ScrollView::setFixedVisibleContentRect(visibleContentRect); if (offset != scrollOffset()) { diff --git a/Source/WebCore/rendering/RenderBlock.cpp b/Source/WebCore/rendering/RenderBlock.cpp index b30ba3d..ef9ad33 100755 --- a/Source/WebCore/rendering/RenderBlock.cpp +++ b/Source/WebCore/rendering/RenderBlock.cpp @@ -3418,12 +3418,18 @@ void RenderBlock::insertPositionedObject(RenderBox* o) m_positionedObjects = adoptPtr(new PositionedObjectsListHashSet); m_positionedObjects->add(o); + + if (o->style()->position() == FixedPosition && view()) + view()->insertFixedPositionedObject(o); } void RenderBlock::removePositionedObject(RenderBox* o) { if (m_positionedObjects) m_positionedObjects->remove(o); + + if (view()) + view()->removeFixedPositionedObject(o); } void RenderBlock::removePositionedObjects(RenderBlock* o) diff --git a/Source/WebCore/rendering/RenderView.cpp b/Source/WebCore/rendering/RenderView.cpp index 7cf2ead..8f76afb 100644 --- a/Source/WebCore/rendering/RenderView.cpp +++ b/Source/WebCore/rendering/RenderView.cpp @@ -920,4 +920,35 @@ RenderBlock::IntervalArena* RenderView::intervalArena() return m_intervalArena.get(); } +void RenderView::setFixedPositionedObjectsNeedLayout() +{ + ASSERT(m_frameView); + + PositionedObjectsListHashSet* positionedObjects = this->positionedObjects(); + if (!positionedObjects) + return; + + PositionedObjectsListHashSet::const_iterator end = positionedObjects->end(); + for (PositionedObjectsListHashSet::const_iterator it = positionedObjects->begin(); it != end; ++it) { + RenderBox* currBox = *it; + currBox->setNeedsLayout(true); + } +} + +void RenderView::insertFixedPositionedObject(RenderBox* object) +{ + if (!m_positionedObjects) + m_positionedObjects = adoptPtr(new PositionedObjectsListHashSet); + + m_positionedObjects->add(object); +} + +void RenderView::removeFixedPositionedObject(RenderBox* object) +{ + if (!m_positionedObjects) + return; + + m_positionedObjects->remove(object); +} + } // namespace WebCore diff --git a/Source/WebCore/rendering/RenderView.h b/Source/WebCore/rendering/RenderView.h index a0a3e55..e6baa09 100644 --- a/Source/WebCore/rendering/RenderView.h +++ b/Source/WebCore/rendering/RenderView.h @@ -179,6 +179,11 @@ public: IntervalArena* intervalArena(); IntSize viewportSize() const { return document()->viewportSize(); } + + void setFixedPositionedObjectsNeedLayout(); + void insertFixedPositionedObject(RenderBox*); + void removeFixedPositionedObject(RenderBox*); + protected: virtual void mapLocalToContainer(RenderBoxModelObject* repaintContainer, bool useTransforms, bool fixed, TransformState&, bool* wasFixed = 0) const; virtual void mapAbsoluteToLocalPoint(bool fixed, bool useTransforms, TransformState&) const; @@ -254,7 +259,10 @@ protected: typedef HashSet RenderWidgetSet; RenderWidgetSet m_widgets; - + + typedef HashSet RenderBoxSet; + OwnPtr m_fixedPositionedElements; + private: unsigned m_pageLogicalHeight; bool m_pageLogicalHeightChanged; diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog index 1db8237..0131e84 100644 --- a/Source/WebKit2/ChangeLog +++ b/Source/WebKit2/ChangeLog @@ -1,3 +1,16 @@ +2012-04-16 Yael Aharon + + [Qt][WK2] Fixed elements position is wrong after zooming. + https://bugs.webkit.org/show_bug.cgi?id=83981 + + Reviewed by Kenneth Rohde Christiansen. + + Turn on the flag setFixedElementsLayoutRelativeToFrame. This causes fixed elements position to be calculated based on + visibleWidth and visibleHeight. When zoom level grows, the visibleWidth and visibleHeight become smaller. + + * WebProcess/WebPage/WebPage.cpp: + (WebKit::WebPage::setResizesToContentsUsingLayoutSize): + 2012-04-16 Kenneth Rohde Christiansen [Qt] Clean up how the interaction engine is making use of ViewportAttributes diff --git a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp index 1ea91c7..6eaecc7 100644 --- a/Source/WebKit2/WebProcess/WebPage/WebPage.cpp +++ b/Source/WebKit2/WebProcess/WebPage/WebPage.cpp @@ -836,6 +836,7 @@ void WebPage::setResizesToContentsUsingLayoutSize(const IntSize& targetLayoutSiz view->setFixedLayoutSize(targetLayoutSize); m_page->settings()->setAcceleratedCompositingForFixedPositionEnabled(true); + m_page->settings()->setFixedElementsLayoutRelativeToFrame(true); // Schedule a layout to use the new target size. if (!view->layoutPending()) {