Commit 037f67dc authored by simon.fraser@apple.com's avatar simon.fraser@apple.com
Browse files

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:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162462 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 215375d8
2014-01-21 Simon Fraser <simon.fraser@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-szeged@partner.samsung.com>
 
ASSERT(time.isFinite()) in SVGSMILElement::createInstanceTimesFromSyncbase
......@@ -2952,33 +2952,6 @@ LayoutUnit RenderBox::availableLogicalHeight(AvailableLogicalHeightType heightTy
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 @@ LayoutUnit RenderBox::availableLogicalHeightUsing(const Length& h, AvailableLogi
}
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 @@ void RenderBox::computeAndSetBlockDirectionMargins(const RenderBlock* containing
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::containingBlockLogicalWidthForPositioned(const RenderBoxMo
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();
}
......
......@@ -366,6 +366,34 @@ LayoutUnit RenderView::pageOrViewLogicalHeight() const
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)
{
......
......@@ -68,6 +68,9 @@ public:
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; }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment