- Revision
- 256107
- Author
- [email protected]
- Date
- 2020-02-09 17:51:43 -0800 (Sun, 09 Feb 2020)
Log Message
[LFC][Integration] Support intruding floats
https://bugs.webkit.org/show_bug.cgi?id=207099
Reviewed by Zalan Bujtas.
Add support for for floats placed by the legacy render tree layout intruding to IFC flow.
This was the last frequently used feature supported by the simple line layout but not
the integrated LFC (pagination is the final missing piece).
* layout/floats/FloatingContext.cpp:
(WebCore::Layout::FloatingContext::remove): Deleted.
* layout/floats/FloatingContext.h:
* layout/floats/FloatingState.cpp:
(WebCore::Layout::FloatingState::FloatItem::FloatItem):
(WebCore::Layout::FloatingState::FloatingState):
(WebCore::Layout::FloatingState::remove): Deleted.
Delete some unused functions.
* layout/floats/FloatingState.h:
(WebCore::Layout::FloatingState::FloatItem::isLeftPositioned const):
(WebCore::Layout::FloatingState::clear):
(WebCore::Layout::FloatingState::FloatItem::operator== const): Deleted.
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::canUseFor):
Allow floats.
(WebCore::LayoutIntegration::LineLayout::layout):
(WebCore::LayoutIntegration::LineLayout::prepareLayoutState):
(WebCore::LayoutIntegration::LineLayout::prepareFloatingState):
Translate floats from render tree to IFC float structures.
* layout/integration/LayoutIntegrationLineLayout.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (256106 => 256107)
--- trunk/Source/WebCore/ChangeLog 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/ChangeLog 2020-02-10 01:51:43 UTC (rev 256107)
@@ -1,3 +1,42 @@
+2020-02-09 Antti Koivisto <[email protected]>
+
+ [LFC][Integration] Support intruding floats
+ https://bugs.webkit.org/show_bug.cgi?id=207099
+
+ Reviewed by Zalan Bujtas.
+
+ Add support for for floats placed by the legacy render tree layout intruding to IFC flow.
+
+ This was the last frequently used feature supported by the simple line layout but not
+ the integrated LFC (pagination is the final missing piece).
+
+ * layout/floats/FloatingContext.cpp:
+ (WebCore::Layout::FloatingContext::remove): Deleted.
+ * layout/floats/FloatingContext.h:
+ * layout/floats/FloatingState.cpp:
+ (WebCore::Layout::FloatingState::FloatItem::FloatItem):
+ (WebCore::Layout::FloatingState::FloatingState):
+ (WebCore::Layout::FloatingState::remove): Deleted.
+
+ Delete some unused functions.
+
+ * layout/floats/FloatingState.h:
+ (WebCore::Layout::FloatingState::FloatItem::isLeftPositioned const):
+ (WebCore::Layout::FloatingState::clear):
+ (WebCore::Layout::FloatingState::FloatItem::operator== const): Deleted.
+ * layout/integration/LayoutIntegrationLineLayout.cpp:
+ (WebCore::LayoutIntegration::LineLayout::canUseFor):
+
+ Allow floats.
+
+ (WebCore::LayoutIntegration::LineLayout::layout):
+ (WebCore::LayoutIntegration::LineLayout::prepareLayoutState):
+ (WebCore::LayoutIntegration::LineLayout::prepareFloatingState):
+
+ Translate floats from render tree to IFC float structures.
+
+ * layout/integration/LayoutIntegrationLineLayout.h:
+
2020-02-09 Zalan Bujtas <[email protected]>
[LFC][BFC] Move updatePositiveNegativeMarginValues out of MarginCollapse class
Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (256106 => 256107)
--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2020-02-10 01:51:43 UTC (rev 256107)
@@ -333,11 +333,6 @@
floatingState().append(FloatingState::FloatItem { floatBox, mapToFloatingStateRoot(floatBox) });
}
-void FloatingContext::remove(const Box& floatBox)
-{
- floatingState().remove(floatBox);
-}
-
static FloatPair::LeftRightIndex findAvailablePosition(FloatAvoider& floatAvoider, const FloatingState::FloatList& floats)
{
Optional<PositionInContextRoot> bottomMost;
Modified: trunk/Source/WebCore/layout/floats/FloatingContext.h (256106 => 256107)
--- trunk/Source/WebCore/layout/floats/FloatingContext.h 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.h 2020-02-10 01:51:43 UTC (rev 256107)
@@ -66,7 +66,6 @@
};
Constraints constraints(LayoutUnit logicalTop, LayoutUnit logicalBottom) const;
void append(const Box&);
- void remove(const Box&);
private:
LayoutState& layoutState() const { return m_floatingState.layoutState(); }
Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (256106 => 256107)
--- trunk/Source/WebCore/layout/floats/FloatingState.cpp 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp 2020-02-10 01:51:43 UTC (rev 256107)
@@ -41,10 +41,17 @@
FloatingState::FloatItem::FloatItem(const Box& layoutBox, Display::Box absoluteDisplayBox)
: m_layoutBox(makeWeakPtr(layoutBox))
+ , m_position(layoutBox.isLeftFloatingPositioned() ? Position::Left : Position::Right)
, m_absoluteDisplayBox(absoluteDisplayBox)
{
}
+FloatingState::FloatItem::FloatItem(Position position, Display::Box absoluteDisplayBox)
+ : m_position(position)
+ , m_absoluteDisplayBox(absoluteDisplayBox)
+{
+}
+
FloatingState::FloatingState(LayoutState& layoutState, const Container& formattingContextRoot)
: m_layoutState(layoutState)
, m_formattingContextRoot(makeWeakPtr(formattingContextRoot))
@@ -51,17 +58,6 @@
{
}
-void FloatingState::remove(const Box& layoutBox)
-{
- for (size_t index = 0; index < m_floats.size(); ++index) {
- if (m_floats[index] == layoutBox) {
- m_floats.remove(index);
- return;
- }
- }
- ASSERT_NOT_REACHED();
-}
-
void FloatingState::append(FloatItem floatItem)
{
ASSERT(is<Container>(*m_formattingContextRoot));
Modified: trunk/Source/WebCore/layout/floats/FloatingState.h (256106 => 256107)
--- trunk/Source/WebCore/layout/floats/FloatingState.h 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/layout/floats/FloatingState.h 2020-02-10 01:51:43 UTC (rev 256107)
@@ -62,9 +62,10 @@
public:
FloatItem(const Box&, Display::Box absoluteDisplayBox);
- bool operator==(const Box& layoutBox) const { return m_layoutBox.get() == &layoutBox; }
+ enum class Position { Left, Right };
+ FloatItem(Position, Display::Box absoluteDisplayBox);
- bool isLeftPositioned() const { return m_layoutBox->isLeftFloatingPositioned(); }
+ bool isLeftPositioned() const { return m_position == Position::Left; }
bool isDescendantOfFormattingRoot(const Container&) const;
Display::Rect rectWithMargin() const { return m_absoluteDisplayBox.rectWithMargin(); }
@@ -73,6 +74,7 @@
private:
WeakPtr<const Box> m_layoutBox;
+ Position m_position;
Display::Box m_absoluteDisplayBox;
};
using FloatList = Vector<FloatItem>;
@@ -79,13 +81,13 @@
const FloatList& floats() const { return m_floats; }
const FloatItem* last() const { return floats().isEmpty() ? nullptr : &m_floats.last(); }
+ void append(FloatItem);
+ void clear() { m_floats.clear(); }
+
private:
friend class FloatingContext;
FloatingState(LayoutState&, const Container& formattingContextRoot);
- void append(FloatItem);
- void remove(const Box& layoutBox);
-
LayoutState& layoutState() const { return m_layoutState; }
Optional<PositionInContextRoot> bottom(const Container& formattingContextRoot, Clear) const;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (256106 => 256107)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp 2020-02-10 01:51:43 UTC (rev 256107)
@@ -77,9 +77,6 @@
if (!passesSimpleLineLayoutTest)
return false;
- if (flow.containsFloats())
- return false;
-
if (flow.fragmentedFlowState() != RenderObject::NotInsideFragmentedFlow)
return false;
@@ -101,10 +98,11 @@
void LineLayout::layout()
{
+ prepareLayoutState();
+ prepareFloatingState();
+
auto inlineFormattingContext = Layout::InlineFormattingContext { rootLayoutBox(), m_inlineFormattingState };
- m_layoutState.setViewportSize(m_flow.frame().view()->size());
-
auto invalidationState = Layout::InvalidationState { };
auto horizontalConstraints = Layout::HorizontalConstraints { m_flow.borderAndPaddingStart(), m_flow.contentSize().width() };
auto verticalConstraints = Layout::VerticalConstraints { m_flow.borderAndPaddingBefore(), { } };
@@ -112,6 +110,40 @@
inlineFormattingContext.layoutInFlowContent(invalidationState, horizontalConstraints, verticalConstraints);
}
+void LineLayout::prepareLayoutState()
+{
+ m_layoutState.setViewportSize(m_flow.frame().view()->size());
+}
+
+void LineLayout::prepareFloatingState()
+{
+ auto& floatingState = m_inlineFormattingState.floatingState();
+ floatingState.clear();
+
+ if (!m_flow.containsFloats())
+ return;
+
+ for (auto& floatingObject : *m_flow.floatingObjectSet()) {
+ auto& rect = floatingObject->frameRect();
+ auto position = floatingObject->type() == FloatingObject::FloatRight
+ ? Layout::FloatingState::FloatItem::Position::Right
+ : Layout::FloatingState::FloatItem::Position::Left;
+ auto box = Display::Box { };
+ // FIXME: We are flooring here for legacy compatibility.
+ // See FloatingObjects::intervalForFloatingObject.
+ auto y = rect.y().floor();
+ auto maxY = rect.maxY().floor();
+ box.setTopLeft({ rect.x(), y });
+ box.setContentBoxWidth(rect.width());
+ box.setContentBoxHeight(maxY - y);
+ box.setBorder({ });
+ box.setPadding({ });
+ box.setHorizontalMargin({ });
+ box.setVerticalMargin({ });
+ floatingState.append({ position, box });
+ }
+}
+
LayoutUnit LineLayout::contentLogicalHeight() const
{
auto& lineBoxes = displayInlineContent()->lineBoxes;
Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h (256106 => 256107)
--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-02-10 01:34:09 UTC (rev 256106)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.h 2020-02-10 01:51:43 UTC (rev 256107)
@@ -83,6 +83,9 @@
static void releaseCaches(RenderView&);
private:
+ void prepareLayoutState();
+ void prepareFloatingState();
+
const Layout::Container& rootLayoutBox() const;
Layout::Container& rootLayoutBox();
ShadowData* debugTextShadow();