Title: [237452] trunk/Source/WebCore
- Revision
- 237452
- Author
- [email protected]
- Date
- 2018-10-26 07:29:22 -0700 (Fri, 26 Oct 2018)
Log Message
[LFC][IFC] Find floating constraints for a given vertical position
https://bugs.webkit.org/show_bug.cgi?id=190928
Reviewed by Antti Koivisto.
https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
"In general, the left edge of a line box touches the left edge of its containing block and the right edge touches the right edge of its containing block.
However, floating boxes may come between the containing block edge and the line box edge.
Thus, although line boxes in the same inline formatting context generally have the same width
(that of the containing block), they may vary in width if available horizontal space is reduced due to floats."
This patch adds support for retrieving left/right constraints for a given line (vertical position).
* layout/floats/FloatingState.cpp:
(WebCore::Layout::FloatingState::constraints const):
* layout/floats/FloatingState.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (237451 => 237452)
--- trunk/Source/WebCore/ChangeLog 2018-10-26 14:25:14 UTC (rev 237451)
+++ trunk/Source/WebCore/ChangeLog 2018-10-26 14:29:22 UTC (rev 237452)
@@ -1,5 +1,25 @@
2018-10-26 Zalan Bujtas <[email protected]>
+ [LFC][IFC] Find floating constraints for a given vertical position
+ https://bugs.webkit.org/show_bug.cgi?id=190928
+
+ Reviewed by Antti Koivisto.
+
+ https://www.w3.org/TR/CSS22/visuren.html#inline-formatting
+
+ "In general, the left edge of a line box touches the left edge of its containing block and the right edge touches the right edge of its containing block.
+ However, floating boxes may come between the containing block edge and the line box edge.
+ Thus, although line boxes in the same inline formatting context generally have the same width
+ (that of the containing block), they may vary in width if available horizontal space is reduced due to floats."
+
+ This patch adds support for retrieving left/right constraints for a given line (vertical position).
+
+ * layout/floats/FloatingState.cpp:
+ (WebCore::Layout::FloatingState::constraints const):
+ * layout/floats/FloatingState.h:
+
+2018-10-26 Zalan Bujtas <[email protected]>
+
[LFC] Inline formatting context has higher priority than block
https://bugs.webkit.org/show_bug.cgi?id=190924
Modified: trunk/Source/WebCore/layout/floats/FloatingState.cpp (237451 => 237452)
--- trunk/Source/WebCore/layout/floats/FloatingState.cpp 2018-10-26 14:25:14 UTC (rev 237451)
+++ trunk/Source/WebCore/layout/floats/FloatingState.cpp 2018-10-26 14:29:22 UTC (rev 237452)
@@ -86,6 +86,54 @@
m_floats.append({ layoutBox, *this });
}
+FloatingState::Constraints FloatingState::constraints(LayoutUnit verticalPosition, const Box& formattingContextRoot) const
+{
+ if (isEmpty())
+ return { };
+
+ // 1. Convert vertical position if this floating context is inherited.
+ // 2. Find the inner left/right floats at verticalPosition.
+ // 3. Convert left/right positions back to formattingContextRoot's cooridnate system.
+ auto coordinateMappingIsRequired = &root() != &formattingContextRoot;
+ auto adjustedPosition = Position { 0, verticalPosition };
+
+ if (coordinateMappingIsRequired)
+ adjustedPosition = FormattingContext::mapCoordinateToAncestor(m_layoutContext, adjustedPosition, downcast<Container>(formattingContextRoot), downcast<Container>(root()));
+
+ Constraints constraints;
+ for (int index = m_floats.size() - 1; index >= 0; --index) {
+ auto& floatItem = m_floats[index];
+
+ if (constraints.left && floatItem.isLeftPositioned())
+ continue;
+
+ if (constraints.right && !floatItem.isLeftPositioned())
+ continue;
+
+ auto rect = floatItem.rectWithMargin();
+ if (!(rect.top() <= verticalPosition && verticalPosition < rect.bottom()))
+ continue;
+
+ if (floatItem.isLeftPositioned())
+ constraints.left = rect.right();
+ else
+ constraints.right = rect.left();
+
+ if (constraints.left && constraints.right)
+ break;
+ }
+
+ if (coordinateMappingIsRequired) {
+ if (constraints.left)
+ constraints.left = *constraints.left - adjustedPosition.x;
+
+ if (constraints.right)
+ constraints.right = *constraints.right - adjustedPosition.x;
+ }
+
+ return constraints;
+}
+
std::optional<LayoutUnit> FloatingState::bottom(const Box& formattingContextRoot, Clear type) const
{
if (m_floats.isEmpty())
Modified: trunk/Source/WebCore/layout/floats/FloatingState.h (237451 => 237452)
--- trunk/Source/WebCore/layout/floats/FloatingState.h 2018-10-26 14:25:14 UTC (rev 237451)
+++ trunk/Source/WebCore/layout/floats/FloatingState.h 2018-10-26 14:29:22 UTC (rev 237452)
@@ -58,6 +58,12 @@
std::optional<LayoutUnit> rightBottom(const Box& formattingContextRoot) const;
std::optional<LayoutUnit> bottom(const Box& formattingContextRoot) const;
+ struct Constraints {
+ std::optional<LayoutUnit> left;
+ std::optional<LayoutUnit> right;
+ };
+ Constraints constraints(LayoutUnit verticalPosition, const Box& formattingContextRoot) const;
+
class FloatItem {
public:
FloatItem(const Box&, const FloatingState&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes