Changeset 162462 in webkit


Ignore:
Timestamp:
Jan 21, 2014 12:25:48 PM (10 years ago)
Author:
Simon Fraser
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:
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r162459 r162462  
     12014-01-21  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Clean up PLATFORM(IOS) code related to the custom fixed position layout rect
     4        https://bugs.webkit.org/show_bug.cgi?id=127362
     5
     6        Reviewed by Dave Hyatt.
     7
     8        Various platforms customize the rect used to layout position:fixed elements,
     9        and each modified RenderBox::availableLogicalHeight/WidthUsing() in different
     10        ways.
     11       
     12        Clean this up by adding RenderView::clientLogicalWidth/HeightForFixedPosition(),
     13        and moving the platform hacks into it.
     14
     15        * rendering/RenderBox.cpp:
     16        (WebCore::RenderBox::availableLogicalHeightUsing):
     17        (WebCore::RenderBox::containingBlockLogicalWidthForPositioned):
     18        (WebCore::RenderBox::containingBlockLogicalHeightForPositioned):
     19        * rendering/RenderView.cpp:
     20        (WebCore::RenderView::clientLogicalWidthForFixedPosition):
     21        (WebCore::RenderView::clientLogicalHeightForFixedPosition):
     22        * rendering/RenderView.h:
     23
    1242014-01-21  Tamas Gergely  <tgergely.u-szeged@partner.samsung.com>
    225
  • trunk/Source/WebCore/rendering/RenderBox.cpp

    r162158 r162462  
    29532953}
    29542954
    2955 #if PLATFORM(IOS)
    2956 static inline int customContainingBlockWidth(const RenderView& view, const RenderBox& containingBlockBox)
    2957 {
    2958     return view.frameView().customFixedPositionLayoutRect().width() - containingBlockBox.borderLeft() - containingBlockBox.borderRight() - containingBlockBox.verticalScrollbarWidth();
    2959 }
    2960 
    2961 static inline int customContainingBlockHeight(const RenderView& view, const RenderBox& containingBlockBox)
    2962 {
    2963     return view.frameView().customFixedPositionLayoutRect().height() - containingBlockBox.borderTop() - containingBlockBox.borderBottom() - containingBlockBox.horizontalScrollbarHeight();
    2964 }
    2965 
    2966 static int customContainingBlockLogicalWidth(const RenderStyle& style, const RenderView& view, const RenderBox& containingBlockBox)
    2967 {
    2968     return style.isHorizontalWritingMode() ? customContainingBlockWidth(view, containingBlockBox) : customContainingBlockHeight(view, containingBlockBox);
    2969 }
    2970 
    2971 static int customContainingBlockLogicalHeight(const RenderStyle& style, const RenderView& view, const RenderBox& containingBlockBox)
    2972 {
    2973     return style.isHorizontalWritingMode() ? customContainingBlockHeight(view, containingBlockBox) : customContainingBlockWidth(view, containingBlockBox);
    2974 }
    2975 
    2976 static inline int customContainingBlockAvailableLogicalHeight(const RenderStyle& style, const RenderView& view)
    2977 {
    2978     return style.isHorizontalWritingMode() ? view.frameView().customFixedPositionLayoutRect().height() : view.frameView().customFixedPositionLayoutRect().width();
    2979 }
    2980 #endif
    2981 
    29822955LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogicalHeightType heightType) const
    29832956{
     
    29922965
    29932966    if (h.isPercent() && isOutOfFlowPositioned() && !isRenderFlowThread()) {
    2994 #if PLATFORM(IOS)
    2995         RenderBlock* containingBlock = this->containingBlock();
    2996         // If we're fixed, and our container is the RenderView, use the custom fixed position rect for sizing.
    2997         if (containingBlock->isRenderView()) {
    2998             RenderView& view = toRenderView(*containingBlock);
    2999             if (view.hasCustomFixedPosition(*this))
    3000                 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, customContainingBlockAvailableLogicalHeight(containingBlock->style(), view)));
    3001         }
    3002 
    3003         return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, containingBlock->availableLogicalHeight(heightType)));
    3004 #else
    30052967        // FIXME: This is wrong if the containingBlock has a perpendicular writing mode.
    30062968        LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(containingBlock());
    30072969        return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, availableHeight));
    3008 #endif
    30092970    }
    30102971
     
    30613022LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region, bool checkForPerpendicularWritingMode) const
    30623023{
    3063     // Container for position:fixed is the frame.
    3064     const FrameView& frameView = view().frameView();
    3065     if (fixedElementLaysOutRelativeToFrame(frameView))
    3066         return (view().isHorizontalWritingMode() ? frameView.visibleWidth() : frameView.visibleHeight()) / frameView.frame().frameScaleFactor();
    3067 
    30683024    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
    30693025        return containingBlockLogicalHeightForPositioned(containingBlock, false);
    30703026
    30713027    if (containingBlock->isBox()) {
     3028        bool isFixedPosition = style().position() == FixedPosition;
     3029
    30723030        RenderFlowThread* flowThread = flowThreadContainingBlock();
    30733031        if (!flowThread) {
    3074 #if PLATFORM(IOS)
    3075             if (view().hasCustomFixedPosition(*this)) {
    3076                 const RenderBox& containingBlockBox = toRenderBox(*containingBlock);
    3077                 return customContainingBlockLogicalWidth(containingBlockBox.style(), view(), containingBlockBox);
    3078             }
    3079 #endif
     3032            if (isFixedPosition && containingBlock->isRenderView())
     3033                return toRenderView(containingBlock)->clientLogicalWidthForFixedPosition();
     3034
    30803035            return toRenderBox(containingBlock)->clientLogicalWidth();
    30813036        }
    30823037
    3083         if (containingBlock->isRenderNamedFlowThread() && style().position() == FixedPosition)
     3038        if (isFixedPosition && containingBlock->isRenderNamedFlowThread())
    30843039            return containingBlock->view().clientLogicalWidth();
    30853040
     
    31273082LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const
    31283083{
    3129     const FrameView& frameView = view().frameView();
    3130     if (fixedElementLaysOutRelativeToFrame(frameView))
    3131         return (view().isHorizontalWritingMode() ? frameView.visibleHeight() : frameView.visibleWidth()) / frameView.frame().frameScaleFactor();
    3132 
    31333084    if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode())
    31343085        return containingBlockLogicalWidthForPositioned(containingBlock, 0, false);
    31353086
    31363087    if (containingBlock->isBox()) {
    3137 #if PLATFORM(IOS)
    3138         if (view().hasCustomFixedPosition(*this))
    3139             return customContainingBlockLogicalHeight(style(), view(), toRenderBox(*containingBlock));
    3140 #endif
     3088        bool isFixedPosition = style().position() == FixedPosition;
     3089
     3090        if (isFixedPosition && containingBlock->isRenderView())
     3091            return toRenderView(containingBlock)->clientLogicalHeightForFixedPosition();
     3092
    31413093        const RenderBlock* cb = toRenderBlock(containingBlock);
    31423094        LayoutUnit result = cb->clientLogicalHeight();
    31433095        RenderFlowThread* flowThread = flowThreadContainingBlock();
    31443096        if (flowThread && containingBlock->isRenderFlowThread() && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) {
    3145             if (containingBlock->isRenderNamedFlowThread() && style().position() == FixedPosition)
     3097            if (containingBlock->isRenderNamedFlowThread() && isFixedPosition)
    31463098                return containingBlock->view().clientLogicalHeight();
    31473099            return toRenderFlowThread(containingBlock)->contentLogicalHeightOfFirstRegion();
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r162098 r162462  
    367367}
    368368
     369LayoutUnit RenderView::clientLogicalWidthForFixedPosition() const
     370{
     371    // FIXME: If the FrameView's fixedVisibleContentRect() is not empty, perhaps it should be consulted here too?
     372    if (frameView().fixedElementsLayoutRelativeToFrame())
     373        return (isHorizontalWritingMode() ? frameView().visibleWidth() : frameView().visibleHeight()) / frameView().frame().frameScaleFactor();
     374
     375#if PLATFORM(IOS)
     376    if (frameView().useCustomFixedPositionLayoutRect())
     377        return isHorizontalWritingMode() ? frameView().customFixedPositionLayoutRect().width() : frameView().customFixedPositionLayoutRect().height();
     378#endif
     379
     380    return clientLogicalWidth();
     381}
     382
     383LayoutUnit RenderView::clientLogicalHeightForFixedPosition() const
     384{
     385    // FIXME: If the FrameView's fixedVisibleContentRect() is not empty, perhaps it should be consulted here too?
     386    if (frameView().fixedElementsLayoutRelativeToFrame())
     387        return (isHorizontalWritingMode() ? frameView().visibleHeight() : frameView().visibleWidth()) / frameView().frame().frameScaleFactor();
     388
     389#if PLATFORM(IOS)
     390    if (frameView().useCustomFixedPositionLayoutRect())
     391        return isHorizontalWritingMode() ? frameView().customFixedPositionLayoutRect().height() : frameView().customFixedPositionLayoutRect().width();
     392#endif
     393
     394    return clientLogicalHeight();
     395}
     396
    369397#if PLATFORM(IOS)
    370398static inline LayoutSize fixedPositionOffset(const FrameView& frameView)
  • trunk/Source/WebCore/rendering/RenderView.h

    r162158 r162462  
    6969    int viewLogicalHeight() const;
    7070
     71    LayoutUnit clientLogicalWidthForFixedPosition() const;
     72    LayoutUnit clientLogicalHeightForFixedPosition() const;
     73
    7174    float zoomFactor() const;
    7275
Note: See TracChangeset for help on using the changeset viewer.