Changeset 162462 in webkit
- Timestamp:
- Jan 21, 2014 12:25:48 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r162459 r162462 1 2014-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 1 24 2014-01-21 Tamas Gergely <tgergely.u-szeged@partner.samsung.com> 2 25 -
trunk/Source/WebCore/rendering/RenderBox.cpp
r162158 r162462 2953 2953 } 2954 2954 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 #endif2981 2982 2955 LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogicalHeightType heightType) const 2983 2956 { … … 2992 2965 2993 2966 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 #else3005 2967 // FIXME: This is wrong if the containingBlock has a perpendicular writing mode. 3006 2968 LayoutUnit availableHeight = containingBlockLogicalHeightForPositioned(containingBlock()); 3007 2969 return adjustContentBoxLogicalHeightForBoxSizing(valueForLength(h, availableHeight)); 3008 #endif3009 2970 } 3010 2971 … … 3061 3022 LayoutUnit RenderBox::containingBlockLogicalWidthForPositioned(const RenderBoxModelObject* containingBlock, RenderRegion* region, bool checkForPerpendicularWritingMode) const 3062 3023 { 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 3068 3024 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode()) 3069 3025 return containingBlockLogicalHeightForPositioned(containingBlock, false); 3070 3026 3071 3027 if (containingBlock->isBox()) { 3028 bool isFixedPosition = style().position() == FixedPosition; 3029 3072 3030 RenderFlowThread* flowThread = flowThreadContainingBlock(); 3073 3031 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 3080 3035 return toRenderBox(containingBlock)->clientLogicalWidth(); 3081 3036 } 3082 3037 3083 if ( containingBlock->isRenderNamedFlowThread() && style().position() == FixedPosition)3038 if (isFixedPosition && containingBlock->isRenderNamedFlowThread()) 3084 3039 return containingBlock->view().clientLogicalWidth(); 3085 3040 … … 3127 3082 LayoutUnit RenderBox::containingBlockLogicalHeightForPositioned(const RenderBoxModelObject* containingBlock, bool checkForPerpendicularWritingMode) const 3128 3083 { 3129 const FrameView& frameView = view().frameView();3130 if (fixedElementLaysOutRelativeToFrame(frameView))3131 return (view().isHorizontalWritingMode() ? frameView.visibleHeight() : frameView.visibleWidth()) / frameView.frame().frameScaleFactor();3132 3133 3084 if (checkForPerpendicularWritingMode && containingBlock->isHorizontalWritingMode() != isHorizontalWritingMode()) 3134 3085 return containingBlockLogicalWidthForPositioned(containingBlock, 0, false); 3135 3086 3136 3087 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 3141 3093 const RenderBlock* cb = toRenderBlock(containingBlock); 3142 3094 LayoutUnit result = cb->clientLogicalHeight(); 3143 3095 RenderFlowThread* flowThread = flowThreadContainingBlock(); 3144 3096 if (flowThread && containingBlock->isRenderFlowThread() && flowThread->isHorizontalWritingMode() == containingBlock->isHorizontalWritingMode()) { 3145 if (containingBlock->isRenderNamedFlowThread() && style().position() ==FixedPosition)3097 if (containingBlock->isRenderNamedFlowThread() && isFixedPosition) 3146 3098 return containingBlock->view().clientLogicalHeight(); 3147 3099 return toRenderFlowThread(containingBlock)->contentLogicalHeightOfFirstRegion(); -
trunk/Source/WebCore/rendering/RenderView.cpp
r162098 r162462 367 367 } 368 368 369 LayoutUnit 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 383 LayoutUnit 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 369 397 #if PLATFORM(IOS) 370 398 static inline LayoutSize fixedPositionOffset(const FrameView& frameView) -
trunk/Source/WebCore/rendering/RenderView.h
r162158 r162462 69 69 int viewLogicalHeight() const; 70 70 71 LayoutUnit clientLogicalWidthForFixedPosition() const; 72 LayoutUnit clientLogicalHeightForFixedPosition() const; 73 71 74 float zoomFactor() const; 72 75
Note: See TracChangeset
for help on using the changeset viewer.