2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above
9 * copyright notice, this list of conditions and the following
11 * 2. Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following
13 * disclaimer in the documentation and/or other materials
14 * provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER "AS IS" AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21 * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
22 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
23 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
25 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
26 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 #include "core/rendering/RenderNamedFlowFragment.h"
33 #include "core/rendering/FlowThreadController.h"
34 #include "core/rendering/RenderBoxRegionInfo.h"
35 #include "core/rendering/RenderFlowThread.h"
36 #include "core/rendering/RenderNamedFlowThread.h"
37 #include "core/rendering/RenderView.h"
43 RenderNamedFlowFragment::RenderNamedFlowFragment()
48 RenderNamedFlowFragment::~RenderNamedFlowFragment()
52 RenderNamedFlowFragment* RenderNamedFlowFragment::createAnonymous(Document* document)
54 RenderNamedFlowFragment* region = new RenderNamedFlowFragment();
55 region->setDocumentForAnonymous(document);
59 void RenderNamedFlowFragment::setStyleForNamedFlowFragment(const RenderStyle* parentStyle)
61 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(parentStyle, BLOCK);
63 newStyle->setFlowThread(parentStyle->flowThread());
64 newStyle->setRegionThread(parentStyle->regionThread());
65 newStyle->setRegionFragment(parentStyle->regionFragment());
66 newStyle->setShapeInside(parentStyle->shapeInside());
67 newStyle->setOverflowX(parentStyle->overflowX());
68 newStyle->setOverflowY(parentStyle->overflowY());
70 setStyle(newStyle.release());
73 void RenderNamedFlowFragment::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
75 RenderRegion::styleDidChange(diff, oldStyle);
77 if (parent() && parent()->needsLayout())
81 // FIXME: flex items as regions with flex-basis: 0 inside a flex container
82 // with flex-direction: column should not be treated as auto-height regions
83 bool RenderNamedFlowFragment::shouldHaveAutoLogicalHeight() const
87 RenderStyle* styleToUse = parent()->style();
88 bool hasSpecifiedEndpointsForHeight = styleToUse->logicalTop().isSpecified() && styleToUse->logicalBottom().isSpecified();
89 bool hasAnchoredEndpointsForHeight = isOutOfFlowPositioned() && hasSpecifiedEndpointsForHeight;
90 bool hasAutoHeightStyle = styleToUse->logicalHeight().isAuto()
91 || styleToUse->logicalHeight().isFitContent()
92 || styleToUse->logicalHeight().isMaxContent()
93 || styleToUse->logicalHeight().isMinContent();
94 return hasAutoHeightStyle && !hasAnchoredEndpointsForHeight;
97 LayoutUnit RenderNamedFlowFragment::maxPageLogicalHeight() const
100 ASSERT(hasAutoLogicalHeight() && !m_flowThread->inConstrainedLayoutPhase());
101 ASSERT(isAnonymous());
104 RenderStyle* styleToUse = parent()->style();
105 return styleToUse->logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : toRenderBlock(parent())->computeReplacedLogicalHeightUsing(styleToUse->logicalMaxHeight());