Title: [162462] trunk/Source/WebCore
Revision
162462
Author
simon.fra...@apple.com
Date
2014-01-21 12:25:48 -0800 (Tue, 21 Jan 2014)

Log Message

Clean up PLATFORM(IOS) code related to the custom fixed position layout rect
https://bugs.webkit.org/show_bug.cgi?id=127362

Reviewed by Dave Hyatt.

Various platforms customize the rect used to layout position:fixed elements,
and each modified RenderBox::availableLogicalHeight/WidthUsing() in different
ways.

Clean this up by adding RenderView::clientLogicalWidth/HeightForFixedPosition(),
and moving the platform hacks into it.

* rendering/RenderBox.cpp:
(WebCore::RenderBox::availableLogicalHeightUsing):
(WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
(WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
* rendering/RenderView.cpp:
(WebCore::RenderView::clientLogicalWidthForFixedPosition):
(WebCore::RenderView::clientLogicalHeightForFixedPosition):
* rendering/RenderView.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (162461 => 162462)


--- trunk/Source/WebCore/ChangeLog	2014-01-21 20:25:46 UTC (rev 162461)
+++ trunk/Source/WebCore/ChangeLog	2014-01-21 20:25:48 UTC (rev 162462)
@@ -1,3 +1,26 @@
+2014-01-21  Simon Fraser  <simon.fra...@apple.com>
+
+        Clean up PLATFORM(IOS) code related to the custom fixed position layout rect
+        https://bugs.webkit.org/show_bug.cgi?id=127362
+
+        Reviewed by Dave Hyatt.
+
+        Various platforms customize the rect used to layout position:fixed elements,
+        and each modified RenderBox::availableLogicalHeight/WidthUsing() in different
+        ways.
+        
+        Clean this up by adding RenderView::clientLogicalWidth/HeightForFixedPosition(),
+        and moving the platform hacks into it.
+
+        * rendering/RenderBox.cpp:
+        (WebCore::RenderBox::availableLogicalHeightUsing):
+        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
+        (WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
+        * rendering/RenderView.cpp:
+        (WebCore::RenderView::clientLogicalWidthForFixedPosition):
+        (WebCore::RenderView::clientLogicalHeightForFixedPosition):
+        * rendering/RenderView.h:
+
 2014-01-21  Tamas Gergely  <tgergely.u-sze...@partner.samsung.com>
 
         ASSERT(time.isFinite()) in SVGSMILElement::createInstanceTimesFromSyncbase

Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (162461 => 162462)


--- trunk/Source/WebCore/rendering/RenderBox.cpp	2014-01-21 20:25:46 UTC (rev 162461)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp	2014-01-21 20:25:48 UTC (rev 162462)
@@ -2952,33 +2952,6 @@
     return constrainLogicalHeightByMinMax(availableLogicalHeightUsing(style().logicalHeight(), heightType));
 }
 
-#if PLATFORM(IOS)
-static inline int customContainingBlockWidth(const RenderView& view, const RenderBox& containingBlockBox)
-{
-    return view.frameView().customFixedPositionLayoutRect().width() - containingBlockBox.borderLeft() - containingBlockBox.borderRight() - containingBlockBox.verticalScrollbarWidth();
-}
-
-static inline int customContainingBlockHeight(const RenderView& view, const RenderBox& containingBlockBox)
-{
-    return view.frameView().customFixedPositionLayoutRect().height() - containingBlockBox.borderTop() - containingBlockBox.borderBottom() - containingBlockBox.horizontalScrollbarHeight();
-}
-
-static int customContainingBlockLogicalWidth(const RenderStyle& style, const RenderView& view, const RenderBox& containingBlockBox)
-{
-    return style.isHorizontalWritingMode() ? customContainingBlockWidth(view, containingBlockBox) : customContainingBlockHeight(view, containingBlockBox);
-}
-
-static int customContainingBlockLogicalHeight(const RenderStyle& style, const RenderView& view, const RenderBox& containingBlockBox)
-{
-    return style.isHorizontalWritingMode() ? customContainingBlockHeight(view, containingBlockBox) : customContainingBlockWidth(view, containingBlockBox);
-}
-
-static inline int customContainingBlockAvailableLogicalHeight(const RenderStyle& style, const RenderView& view)
-{
-    return style.isHorizontalWritingMode() ? view.frameView().customFixedPositionLayoutRect().height() : view.frameView().customFixedPositionLayoutRect().width();
-}
-#endif
-
 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogicalHeightType heightType) const
 {
     // We need to stop here, since we don't want to increase the height of the table
@@ -2991,21 +2964,9 @@
     }
 
     if (h.isPercent() && isOutOfFlowPositioned() && !isRenderFlowThread()) {
-#if PLATFORM(IOS)
-        RenderBlock* containingBlock = this->containingBlock();
-        // If we're fixed, and our container is the RenderView, use the custom fixed position rect for sizing.
-        if (containingBlock->isRenderView()) {
-            RenderView& view = toRenderView(*containingBlock);
-            if (view.hasCustomFixedPosition(*this))
-                return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, customContainingBlockAvailableLogicalHeight(containingBlock->style(), view)));
-        }
-
-        return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, containingBlock->availableLogicalHeight(heightType)));
-#else
         // FIXME: This is wrong if the containingBlock has a perpendicular writing mode.
         LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(containingBlock());
         return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, availableHeight));
-#endif
     }
 
     LayoutUnit heightIncludingScrollbar = computeContentAndScrollbarLogicalHeightUsing(h);
@@ -3060,27 +3021,21 @@
 
 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region, bool checkForPerpendicularWritingMode) const
 {
-    // Container for position:fixed is the frame.
-    const FrameView& frameView = view().frameView();
-    if (fixedElementLaysOutRelativeToFrame(frameView))
-        return (view().isHorizontalWritingMode() ? frameView.visibleWidth() : frameView.visibleHeight()) / frameView.frame().frameScaleFactor();
-
     if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
         return containingBlockLogicalHeightForPositioned(containingBlock, false);
 
     if (containingBlock->isBox()) {
+        bool isFixedPosition = style().position() == FixedPosition;
+
         RenderFlowThread* flowThread = flowThreadContainingBlock();
         if (!flowThread) {
-#if PLATFORM(IOS)
-            if (view().hasCustomFixedPosition(*this)) {
-                const RenderBox& containingBlockBox = toRenderBox(*containingBlock);
-                return customContainingBlockLogicalWidth(containingBlockBox.style(), view(), containingBlockBox);
-            }
-#endif
+            if (isFixedPosition && containingBlock->isRenderView())
+                return toRenderView(containingBlock)->clientLogicalWidthForFixedPosition();
+
             return toRenderBox(containingBlock)->clientLogicalWidth();
         }
 
-        if (containingBlock->isRenderNamedFlowThread() && style().position() == FixedPosition)
+        if (isFixedPosition && containingBlock->isRenderNamedFlowThread())
             return containingBlock->view().clientLogicalWidth();
 
         const RenderBlock* cb = toRenderBlock(containingBlock);
@@ -3126,23 +3081,20 @@
 
 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const
 {
-    const FrameView& frameView = view().frameView();
-    if (fixedElementLaysOutRelativeToFrame(frameView))
-        return (view().isHorizontalWritingMode() ? frameView.visibleHeight() : frameView.visibleWidth()) / frameView.frame().frameScaleFactor();
-
     if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
         return containingBlockLogicalWidthForPositioned(containingBlock, 0, false);
 
     if (containingBlock->isBox()) {
-#if PLATFORM(IOS)
-        if (view().hasCustomFixedPosition(*this))
-            return customContainingBlockLogicalHeight(style(), view(), toRenderBox(*containingBlock));
-#endif
+        bool isFixedPosition = style().position() == FixedPosition;
+
+        if (isFixedPosition && containingBlock->isRenderView())
+            return toRenderView(containingBlock)->clientLogicalHeightForFixedPosition();
+
         const RenderBlock* cb = toRenderBlock(containingBlock);
         LayoutUnit result = cb->clientLogicalHeight();
         RenderFlowThread* flowThread = flowThreadContainingBlock();
         if (flowThread && containingBlock->isRenderFlowThread() && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
-            if (containingBlock->isRenderNamedFlowThread() && style().position() == FixedPosition)
+            if (containingBlock->isRenderNamedFlowThread() && isFixedPosition)
                 return containingBlock->view().clientLogicalHeight();
             return toRenderFlowThread(containingBlock)->contentLogicalHeightOfFirstRegion();
         }

Modified: trunk/Source/WebCore/rendering/RenderView.cpp (162461 => 162462)


--- trunk/Source/WebCore/rendering/RenderView.cpp	2014-01-21 20:25:46 UTC (rev 162461)
+++ trunk/Source/WebCore/rendering/RenderView.cpp	2014-01-21 20:25:48 UTC (rev 162462)
@@ -366,7 +366,35 @@
     return viewLogicalHeight();
 }
 
+LayoutUnit RenderView::clientLogicalWidthForFixedPosition() const
+{
+    // FIXME: If the FrameView's fixedVisibleContentRect() is not empty, perhaps it should be consulted here too?
+    if (frameView().fixedElementsLayoutRelativeToFrame())
+        return (isHorizontalWritingMode() ? frameView().visibleWidth() : frameView().visibleHeight()) / frameView().frame().frameScaleFactor();
+
 #if PLATFORM(IOS)
+    if (frameView().useCustomFixedPositionLayoutRect())
+        return isHorizontalWritingMode() ? frameView().customFixedPositionLayoutRect().width() : frameView().customFixedPositionLayoutRect().height();
+#endif
+
+    return clientLogicalWidth();
+}
+
+LayoutUnit RenderView::clientLogicalHeightForFixedPosition() const
+{
+    // FIXME: If the FrameView's fixedVisibleContentRect() is not empty, perhaps it should be consulted here too?
+    if (frameView().fixedElementsLayoutRelativeToFrame())
+        return (isHorizontalWritingMode() ? frameView().visibleHeight() : frameView().visibleWidth()) / frameView().frame().frameScaleFactor();
+
+#if PLATFORM(IOS)
+    if (frameView().useCustomFixedPositionLayoutRect())
+        return isHorizontalWritingMode() ? frameView().customFixedPositionLayoutRect().height() : frameView().customFixedPositionLayoutRect().width();
+#endif
+
+    return clientLogicalHeight();
+}
+
+#if PLATFORM(IOS)
 static inline LayoutSize fixedPositionOffset(const FrameView& frameView)
 {
     return frameView.useCustomFixedPositionLayoutRect() ? (frameView.customFixedPositionLayoutRect().location() - LayoutPoint()) : frameView.scrollOffset();

Modified: trunk/Source/WebCore/rendering/RenderView.h (162461 => 162462)


--- trunk/Source/WebCore/rendering/RenderView.h	2014-01-21 20:25:46 UTC (rev 162461)
+++ trunk/Source/WebCore/rendering/RenderView.h	2014-01-21 20:25:48 UTC (rev 162462)
@@ -68,6 +68,9 @@
     int viewLogicalWidth() const { return style().isHorizontalWritingMode() ? viewWidth() : viewHeight(); }
     int viewLogicalHeight() const;
 
+    LayoutUnit clientLogicalWidthForFixedPosition() const;
+    LayoutUnit clientLogicalHeightForFixedPosition() const;
+
     float zoomFactor() const;
 
     FrameView& frameView() const { return m_frameView; }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to