| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | |
| 3 * | |
| 4 * Redistribution and use in source and binary forms, with or without | |
| 5 * modification, are permitted provided that the following conditions | |
| 6 * are met: | |
| 7 * | |
| 8 * 1. Redistributions of source code must retain the above | |
| 9 * copyright notice, this list of conditions and the following | |
| 10 * disclaimer. | |
| 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. | |
| 15 * | |
| 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 | |
| 27 * SUCH DAMAGE. | |
| 28 */ | |
| 29 | |
| 30 #include "config.h" | |
| 31 #include "core/rendering/RenderNamedFlowFragment.h" | |
| 32 | |
| 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" | |
| 38 | |
| 39 using namespace std; | |
| 40 | |
| 41 namespace WebCore { | |
| 42 | |
| 43 RenderNamedFlowFragment::RenderNamedFlowFragment() | |
| 44 : RenderRegion(0, 0) | |
| 45 { | |
| 46 } | |
| 47 | |
| 48 RenderNamedFlowFragment::~RenderNamedFlowFragment() | |
| 49 { | |
| 50 } | |
| 51 | |
| 52 RenderNamedFlowFragment* RenderNamedFlowFragment::createAnonymous(Document* docu
ment) | |
| 53 { | |
| 54 RenderNamedFlowFragment* region = new RenderNamedFlowFragment(); | |
| 55 region->setDocumentForAnonymous(document); | |
| 56 return region; | |
| 57 } | |
| 58 | |
| 59 void RenderNamedFlowFragment::setStyleForNamedFlowFragment(const RenderStyle* pa
rentStyle) | |
| 60 { | |
| 61 RefPtr<RenderStyle> newStyle = RenderStyle::createAnonymousStyleWithDisplay(
parentStyle, BLOCK); | |
| 62 | |
| 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()); | |
| 69 | |
| 70 setStyle(newStyle.release()); | |
| 71 } | |
| 72 | |
| 73 void RenderNamedFlowFragment::styleDidChange(StyleDifference diff, const RenderS
tyle* oldStyle) | |
| 74 { | |
| 75 RenderRegion::styleDidChange(diff, oldStyle); | |
| 76 | |
| 77 if (parent() && parent()->needsLayout()) | |
| 78 setNeedsLayout(); | |
| 79 } | |
| 80 | |
| 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 | |
| 84 { | |
| 85 ASSERT(parent()); | |
| 86 | |
| 87 RenderStyle* styleToUse = parent()->style(); | |
| 88 bool hasSpecifiedEndpointsForHeight = styleToUse->logicalTop().isSpecified()
&& styleToUse->logicalBottom().isSpecified(); | |
| 89 bool hasAnchoredEndpointsForHeight = isOutOfFlowPositioned() && hasSpecified
EndpointsForHeight; | |
| 90 bool hasAutoHeightStyle = styleToUse->logicalHeight().isAuto() | |
| 91 || styleToUse->logicalHeight().isFitContent() | |
| 92 || styleToUse->logicalHeight().isMaxContent() | |
| 93 || styleToUse->logicalHeight().isMinContent(); | |
| 94 return hasAutoHeightStyle && !hasAnchoredEndpointsForHeight; | |
| 95 } | |
| 96 | |
| 97 LayoutUnit RenderNamedFlowFragment::maxPageLogicalHeight() const | |
| 98 { | |
| 99 ASSERT(m_flowThread); | |
| 100 ASSERT(hasAutoLogicalHeight() && !m_flowThread->inConstrainedLayoutPhase()); | |
| 101 ASSERT(isAnonymous()); | |
| 102 ASSERT(parent()); | |
| 103 | |
| 104 RenderStyle* styleToUse = parent()->style(); | |
| 105 return styleToUse->logicalMaxHeight().isUndefined() ? RenderFlowThread::maxL
ogicalHeight() : toRenderBlock(parent())->computeReplacedLogicalHeightUsing(styl
eToUse->logicalMaxHeight()); | |
| 106 } | |
| 107 | |
| 108 } | |
| OLD | NEW |