| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Copyright (C) 2011 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/layout/LayoutRegion.h" | |
| 32 | |
| 33 #include "core/layout/LayoutFlowThread.h" | |
| 34 | |
| 35 namespace blink { | |
| 36 | |
| 37 LayoutRegion::LayoutRegion(Element* element, LayoutFlowThread* flowThread) | |
| 38 : LayoutBlockFlow(element) | |
| 39 , m_flowThread(flowThread) | |
| 40 , m_isValid(false) | |
| 41 { | |
| 42 } | |
| 43 | |
| 44 LayoutUnit LayoutRegion::pageLogicalWidth() const | |
| 45 { | |
| 46 ASSERT(m_flowThread); | |
| 47 return m_flowThread->isHorizontalWritingMode() ? contentWidth() : contentHei
ght(); | |
| 48 } | |
| 49 | |
| 50 LayoutUnit LayoutRegion::pageLogicalHeight() const | |
| 51 { | |
| 52 ASSERT(m_flowThread); | |
| 53 return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWi
dth(); | |
| 54 } | |
| 55 | |
| 56 LayoutRect LayoutRegion::flowThreadPortionOverflowRect() const | |
| 57 { | |
| 58 return overflowRectForFlowThreadPortion(flowThreadPortionRect(), isFirstRegi
on(), isLastRegion()); | |
| 59 } | |
| 60 | |
| 61 LayoutRect LayoutRegion::overflowRectForFlowThreadPortion(const LayoutRect& flow
ThreadPortionRect, bool isFirstPortion, bool isLastPortion) const | |
| 62 { | |
| 63 ASSERT(isValid()); | |
| 64 | |
| 65 if (hasOverflowClip()) | |
| 66 return flowThreadPortionRect; | |
| 67 | |
| 68 LayoutRect flowThreadOverflow = m_flowThread->visualOverflowRect(); | |
| 69 | |
| 70 // Only clip along the flow thread axis. | |
| 71 LayoutRect clipRect; | |
| 72 if (m_flowThread->isHorizontalWritingMode()) { | |
| 73 LayoutUnit minY = isFirstPortion ? flowThreadOverflow.y() : flowThreadPo
rtionRect.y(); | |
| 74 LayoutUnit maxY = isLastPortion ? std::max(flowThreadPortionRect.maxY(),
flowThreadOverflow.maxY()) : flowThreadPortionRect.maxY(); | |
| 75 LayoutUnit minX = std::min(flowThreadPortionRect.x(), flowThreadOverflow
.x()); | |
| 76 LayoutUnit maxX = std::max(flowThreadPortionRect.maxX(), flowThreadOverf
low.maxX()); | |
| 77 clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY); | |
| 78 } else { | |
| 79 LayoutUnit minX = isFirstPortion ? flowThreadOverflow.x() : flowThreadPo
rtionRect.x(); | |
| 80 LayoutUnit maxX = isLastPortion ? std::max(flowThreadPortionRect.maxX(),
flowThreadOverflow.maxX()) : flowThreadPortionRect.maxX(); | |
| 81 LayoutUnit minY = std::min(flowThreadPortionRect.y(), (flowThreadOverflo
w.y())); | |
| 82 LayoutUnit maxY = std::max(flowThreadPortionRect.y(), (flowThreadOverflo
w.maxY())); | |
| 83 clipRect = LayoutRect(minX, minY, maxX - minX, maxY - minY); | |
| 84 } | |
| 85 | |
| 86 return clipRect; | |
| 87 } | |
| 88 | |
| 89 bool LayoutRegion::isFirstRegion() const | |
| 90 { | |
| 91 ASSERT(isValid()); | |
| 92 | |
| 93 return m_flowThread->firstRegion() == this; | |
| 94 } | |
| 95 | |
| 96 bool LayoutRegion::isLastRegion() const | |
| 97 { | |
| 98 ASSERT(isValid()); | |
| 99 | |
| 100 return m_flowThread->lastRegion() == this; | |
| 101 } | |
| 102 | |
| 103 void LayoutRegion::layoutBlock(bool relayoutChildren) | |
| 104 { | |
| 105 LayoutBlockFlow::layoutBlock(relayoutChildren); | |
| 106 | |
| 107 // FIXME: We need to find a way to set up overflow properly. Our flow thread
hasn't gotten a layout | |
| 108 // yet, so we can't look to it for correct information. It's possible we cou
ld wait until after the LayoutFlowThread | |
| 109 // gets a layout, and then try to propagate overflow information back to the
region, and then mark for a second layout. | |
| 110 // That second layout would then be able to use the information from the Lay
outFlowThread to set up overflow. | |
| 111 // | |
| 112 // The big problem though is that overflow needs to be region-specific. We c
an't simply use the LayoutFlowThread's global | |
| 113 // overflow values, since then we'd always think any narrow region had huge
overflow (all the way to the width of the | |
| 114 // LayoutFlowThread itself). | |
| 115 } | |
| 116 | |
| 117 void LayoutRegion::computeIntrinsicLogicalWidths(LayoutUnit& minLogicalWidth, La
youtUnit& maxLogicalWidth) const | |
| 118 { | |
| 119 if (!isValid()) { | |
| 120 LayoutBlockFlow::computeIntrinsicLogicalWidths(minLogicalWidth, maxLogic
alWidth); | |
| 121 return; | |
| 122 } | |
| 123 | |
| 124 minLogicalWidth = m_flowThread->minPreferredLogicalWidth(); | |
| 125 maxLogicalWidth = m_flowThread->maxPreferredLogicalWidth(); | |
| 126 } | |
| 127 | |
| 128 } // namespace blink | |
| OLD | NEW |