Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (224459 => 224460)
--- trunk/Source/WebCore/rendering/LayoutState.cpp 2017-11-04 21:19:11 UTC (rev 224459)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp 2017-11-04 21:41:10 UTC (rev 224460)
@@ -20,7 +20,7 @@
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
@@ -34,6 +34,31 @@
namespace WebCore {
+LayoutState::LayoutState(RenderElement& renderer)
+ : m_clipped(false)
+ , m_isPaginated(false)
+ , m_pageLogicalHeightChanged(false)
+#if !ASSERT_DISABLED
+ , m_layoutDeltaXSaturated(false)
+ , m_layoutDeltaYSaturated(false)
+#endif
+#ifndef NDEBUG
+ , m_renderer(&renderer)
+#endif
+{
+ if (RenderElement* container = renderer.container()) {
+ FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTransforms);
+ m_paintOffset = LayoutSize(absContentPoint.x(), absContentPoint.y());
+
+ if (container->hasOverflowClip()) {
+ m_clipped = true;
+ auto& containerBox = downcast<RenderBox>(*container);
+ m_clipRect = LayoutRect(toLayoutPoint(m_paintOffset), containerBox.cachedSizeForOverflowClip());
+ m_paintOffset -= toLayoutSize(containerBox.scrollPosition());
+ }
+ }
+}
+
LayoutState::LayoutState(std::unique_ptr<LayoutState> ancestor, RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
: m_ancestor(WTFMove(ancestor))
#ifndef NDEBUG
@@ -40,11 +65,17 @@
, m_renderer(&renderer)
#endif
{
+ computeOffsets(renderer, offset);
+ computeClipRect(renderer);
+ computePaginationInformation(renderer, pageLogicalHeight, pageLogicalHeightChanged);
+}
+
+void LayoutState::computeOffsets(RenderBox& renderer, LayoutSize offset)
+{
ASSERT(m_ancestor);
bool fixed = renderer.isFixedPositioned();
if (fixed) {
- // FIXME: This doesn't work correctly with transforms.
FloatPoint fixedOffset = renderer.view().localToAbsolute(FloatPoint(), IsFixed);
m_paintOffset = LayoutSize(fixedOffset.x(), fixedOffset.y()) + offset;
} else
@@ -51,7 +82,7 @@
m_paintOffset = m_ancestor->m_paintOffset + offset;
if (renderer.isOutOfFlowPositioned() && !fixed) {
- if (RenderElement* container = renderer.container()) {
+ if (auto* container = renderer.container()) {
if (container->isInFlowPositioned() && is<RenderInline>(*container))
m_paintOffset += downcast<RenderInline>(*container).offsetForInFlowPositionedInline(&renderer);
}
@@ -62,22 +93,37 @@
if (renderer.isInFlowPositioned() && renderer.hasLayer())
m_paintOffset += renderer.layer()->offsetForInFlowPosition();
- m_clipped = !fixed && m_ancestor->m_clipped;
+ if (renderer.hasOverflowClip())
+ m_paintOffset -= toLayoutSize(renderer.scrollPosition());
+
+ m_layoutDelta = m_ancestor->m_layoutDelta;
+#if !ASSERT_DISABLED
+ m_layoutDeltaXSaturated = m_ancestor->m_layoutDeltaXSaturated;
+ m_layoutDeltaYSaturated = m_ancestor->m_layoutDeltaYSaturated;
+#endif
+}
+
+void LayoutState::computeClipRect(RenderBox& renderer)
+{
+ ASSERT(m_ancestor);
+
+ m_clipped = !renderer.isFixedPositioned() && m_ancestor->m_clipped;
if (m_clipped)
m_clipRect = m_ancestor->m_clipRect;
+ if (!renderer.hasOverflowClip())
+ return;
- if (renderer.hasOverflowClip()) {
- LayoutRect clipRect(toLayoutPoint(m_paintOffset) + renderer.view().layoutDelta(), renderer.cachedSizeForOverflowClip());
- if (m_clipped)
- m_clipRect.intersect(clipRect);
- else {
- m_clipRect = clipRect;
- m_clipped = true;
- }
+ LayoutRect clipRect(toLayoutPoint(m_paintOffset) + renderer.view().layoutDelta(), renderer.cachedSizeForOverflowClip());
+ if (m_clipped)
+ m_clipRect.intersect(clipRect);
+ else
+ m_clipRect = clipRect;
+ m_clipped = true;
+ // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
+}
- m_paintOffset -= toLayoutSize(renderer.scrollPosition());
- }
-
+void LayoutState::computePaginationInformation(RenderBox& renderer, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
+{
// If we establish a new page height, then cache the offset to the top of the first page.
// We can compare this later on to figure out what part of the page we're actually on,
if (pageLogicalHeight || renderer.isRenderFragmentedFlow()) {
@@ -86,14 +132,13 @@
m_pageOffset = LayoutSize(m_layoutOffset.width() + (!isFlipped ? renderer.borderLeft() + renderer.paddingLeft() : renderer.borderRight() + renderer.paddingRight()), m_layoutOffset.height() + (!isFlipped ? renderer.borderTop() + renderer.paddingTop() : renderer.borderBottom() + renderer.paddingBottom()));
m_pageLogicalHeightChanged = pageLogicalHeightChanged;
m_isPaginated = true;
- } else {
+ } else if (m_ancestor) {
// If we don't establish a new page height, then propagate the old page height and offset down.
m_pageLogicalHeight = m_ancestor->m_pageLogicalHeight;
m_pageLogicalHeightChanged = m_ancestor->m_pageLogicalHeightChanged;
m_pageOffset = m_ancestor->m_pageOffset;
-
- // Disable pagination for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and
- // writing mode roots.
+
+ // Disable pagination for objects we don't support. For now this includes overflow:scroll/auto, inline blocks and writing mode roots.
if (renderer.isUnsplittableForPagination()) {
m_pageLogicalHeight = 0;
m_isPaginated = false;
@@ -100,16 +145,10 @@
} else
m_isPaginated = m_pageLogicalHeight || renderer.enclosingFragmentedFlow();
}
-
+
// Propagate line grid information.
propagateLineGridInfo(renderer);
- m_layoutDelta = m_ancestor->m_layoutDelta;
-#if !ASSERT_DISABLED
- m_layoutDeltaXSaturated = m_ancestor->m_layoutDeltaXSaturated;
- m_layoutDeltaYSaturated = m_ancestor->m_layoutDeltaYSaturated;
-#endif
-
if (lineGrid() && (lineGrid()->style().writingMode() == renderer.style().writingMode()) && is<RenderMultiColumnFlow>(renderer))
downcast<RenderMultiColumnFlow>(renderer).computeLineGridPaginationOrigin(*this);
@@ -116,35 +155,8 @@
// If we have a new grid to track, then add it to our set.
if (renderer.style().lineGrid() != RenderStyle::initialLineGrid() && is<RenderBlockFlow>(renderer))
establishLineGrid(downcast<RenderBlockFlow>(renderer));
-
- // FIXME: <http://bugs.webkit.org/show_bug.cgi?id=13443> Apply control clip if present.
}
-LayoutState::LayoutState(RenderElement& renderer)
- : m_clipped(false)
- , m_isPaginated(false)
- , m_pageLogicalHeightChanged(false)
-#if !ASSERT_DISABLED
- , m_layoutDeltaXSaturated(false)
- , m_layoutDeltaYSaturated(false)
-#endif
-#ifndef NDEBUG
- , m_renderer(&renderer)
-#endif
-{
- if (RenderElement* container = renderer.container()) {
- FloatPoint absContentPoint = container->localToAbsolute(FloatPoint(), UseTransforms);
- m_paintOffset = LayoutSize(absContentPoint.x(), absContentPoint.y());
-
- if (container->hasOverflowClip()) {
- m_clipped = true;
- auto& containerBox = downcast<RenderBox>(*container);
- m_clipRect = LayoutRect(toLayoutPoint(m_paintOffset), containerBox.cachedSizeForOverflowClip());
- m_paintOffset -= toLayoutSize(containerBox.scrollPosition());
- }
- }
-}
-
void LayoutState::clearPaginationInformation()
{
m_pageLogicalHeight = m_ancestor->m_pageLogicalHeight;
@@ -193,7 +205,8 @@
// We didn't find an already-established grid with this identifier. Our render object establishes the grid.
m_lineGrid = &renderer;
- m_lineGridOffset = m_layoutOffset;
+ m_lineGridOffset = m_layoutOffset;
}
} // namespace WebCore
+
Modified: trunk/Source/WebCore/rendering/LayoutState.h (224459 => 224460)
--- trunk/Source/WebCore/rendering/LayoutState.h 2017-11-04 21:19:11 UTC (rev 224459)
+++ trunk/Source/WebCore/rendering/LayoutState.h 2017-11-04 21:41:10 UTC (rev 224460)
@@ -81,6 +81,9 @@
void setCurrentRenderFragmentedFlow(RenderFragmentedFlow* fragmentedFlow) { m_currentRenderFragmentedFlow = fragmentedFlow; }
private:
+ void computeOffsets(RenderBox&, LayoutSize offset);
+ void computeClipRect(RenderBox&);
+ void computePaginationInformation(RenderBox&, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged);
void propagateLineGridInfo(RenderBox&);
void establishLineGrid(RenderBlockFlow&);