Diff
Modified: trunk/Source/WebCore/ChangeLog (235351 => 235352)
--- trunk/Source/WebCore/ChangeLog 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/ChangeLog 2018-08-27 05:01:28 UTC (rev 235352)
@@ -1,3 +1,38 @@
+2018-08-26 Zalan Bujtas <[email protected]>
+
+ [LFC][Floating] FloatBox -> FloatAvoider
+ https://bugs.webkit.org/show_bug.cgi?id=188941
+
+ Reviewed by Antti Koivisto.
+
+ This is in preparation for the float avoidance feature where formatting context root boxes avoid existing floats.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/displaytree/DisplayBox.h:
+ * layout/floats/FloatAvoider.cpp: Renamed from Source/WebCore/layout/floats/FloatBox.cpp.
+ (WebCore::Layout::FloatAvoider::FloatAvoider):
+ (WebCore::Layout::FloatAvoider::initializePosition):
+ (WebCore::Layout::FloatAvoider::isLeftAligned const):
+ (WebCore::Layout::FloatAvoider::setLeft):
+ (WebCore::Layout::FloatAvoider::setTopLeft):
+ (WebCore::Layout::FloatAvoider::resetVertically):
+ (WebCore::Layout::FloatAvoider::resetHorizontally):
+ (WebCore::Layout::FloatAvoider::topLeftInContainingBlock const):
+ * layout/floats/FloatAvoider.h: Renamed from Source/WebCore/layout/floats/FloatBox.h.
+ (WebCore::Layout::FloatAvoider::top const):
+ (WebCore::Layout::FloatAvoider::left const):
+ (WebCore::Layout::FloatAvoider::marginTop const):
+ (WebCore::Layout::FloatAvoider::marginLeft const):
+ (WebCore::Layout::FloatAvoider::marginBottom const):
+ (WebCore::Layout::FloatAvoider::marginRight const):
+ (WebCore::Layout::FloatAvoider::rectWithMargin const):
+ (WebCore::Layout::FloatAvoider::setTop):
+ * layout/floats/FloatingContext.cpp:
+ (WebCore::Layout::FloatingContext::positionForFloat const):
+ (WebCore::Layout::FloatingContext::floatingPosition const):
+ * layout/floats/FloatingContext.h:
+
2018-08-26 Christopher Reid <[email protected]>
[Curl] Implement deleteCookie()
Modified: trunk/Source/WebCore/Sources.txt (235351 => 235352)
--- trunk/Source/WebCore/Sources.txt 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/Sources.txt 2018-08-27 05:01:28 UTC (rev 235352)
@@ -1229,7 +1229,7 @@
layout/blockformatting/BlockMarginCollapse.cpp
layout/blockformatting/BlockInvalidation.cpp
layout/displaytree/DisplayBox.cpp
-layout/floats/FloatBox.cpp
+layout/floats/FloatAvoider.cpp
layout/floats/FloatingContext.cpp
layout/floats/FloatingState.cpp
layout/inlineformatting/InlineFormattingContext.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (235351 => 235352)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-08-27 05:01:28 UTC (rev 235352)
@@ -1990,7 +1990,7 @@
6F995A381A70833700A735F4 /* JSWebGLTransformFeedback.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A2E1A70833700A735F4 /* JSWebGLTransformFeedback.h */; };
6F995A3A1A70833700A735F4 /* JSWebGLVertexArrayObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 6F995A301A70833700A735F4 /* JSWebGLVertexArrayObject.h */; };
6FA4454E898F2FC168BC38C1 /* JSBeforeUnloadEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */; };
- 6FFDC442212EFF1700A9CA91 /* FloatBox.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FFDC440212EFF1600A9CA91 /* FloatBox.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 6FFDC442212EFF1700A9CA91 /* FloatAvoider.h in Headers */ = {isa = PBXBuildFile; fileRef = 6FFDC440212EFF1600A9CA91 /* FloatAvoider.h */; settings = {ATTRIBUTES = (Private, ); }; };
709A01FE1E3D0BDD006B0D4C /* ModuleFetchFailureKind.h in Headers */ = {isa = PBXBuildFile; fileRef = 709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */; settings = {ATTRIBUTES = (Private, ); }; };
71025ECD1F99F0CE004A250C /* AnimationTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 71025EC71F99F096004A250C /* AnimationTimeline.h */; settings = {ATTRIBUTES = (Private, ); }; };
71025ED01F99F0CE004A250C /* DocumentTimeline.h in Headers */ = {isa = PBXBuildFile; fileRef = 71025EC51F99F096004A250C /* DocumentTimeline.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8969,8 +8969,8 @@
6FCD19C120F9727A00FD4529 /* TextContentProvider.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextContentProvider.h; sourceTree = "<group>"; };
6FCD19C720F9727D00FD4529 /* TextContentProvider.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TextContentProvider.cpp; sourceTree = "<group>"; };
6FCF975220F02B3500214960 /* Runs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Runs.h; sourceTree = "<group>"; };
- 6FFDC43E212EFF1600A9CA91 /* FloatBox.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatBox.cpp; sourceTree = "<group>"; };
- 6FFDC440212EFF1600A9CA91 /* FloatBox.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatBox.h; sourceTree = "<group>"; };
+ 6FFDC43E212EFF1600A9CA91 /* FloatAvoider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FloatAvoider.cpp; sourceTree = "<group>"; };
+ 6FFDC440212EFF1600A9CA91 /* FloatAvoider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FloatAvoider.h; sourceTree = "<group>"; };
709A01FD1E3D0BCC006B0D4C /* ModuleFetchFailureKind.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModuleFetchFailureKind.h; sourceTree = "<group>"; };
71004B9D1DC1398800A52A38 /* playback-support.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode._javascript_; path = "playback-support.js"; sourceTree = "<group>"; };
71025EC21F99F096004A250C /* WebAnimation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebAnimation.h; sourceTree = "<group>"; };
@@ -19480,8 +19480,8 @@
6FCFC055212DACC2007695D2 /* floats */ = {
isa = PBXGroup;
children = (
- 6FFDC43E212EFF1600A9CA91 /* FloatBox.cpp */,
- 6FFDC440212EFF1600A9CA91 /* FloatBox.h */,
+ 6FFDC43E212EFF1600A9CA91 /* FloatAvoider.cpp */,
+ 6FFDC440212EFF1600A9CA91 /* FloatAvoider.h */,
115CFA85208B9066001E6991 /* FloatingContext.cpp */,
115CFA84208B9066001E6991 /* FloatingContext.h */,
115CFA81208B8EDA001E6991 /* FloatingState.cpp */,
@@ -27870,7 +27870,7 @@
49ECEB701499790D00CDD3A4 /* FilterOperations.h in Headers */,
372C00D9129619F8005C9575 /* FindOptions.h in Headers */,
A8CFF04F0A154F09000A4234 /* FixedTableLayout.h in Headers */,
- 6FFDC442212EFF1700A9CA91 /* FloatBox.h in Headers */,
+ 6FFDC442212EFF1700A9CA91 /* FloatAvoider.h in Headers */,
BC073BAA0C399B1F000F5979 /* FloatConversion.h in Headers */,
115CFA86208B9066001E6991 /* FloatingContext.h in Headers */,
9A528E8417D7F52F00AA9518 /* FloatingObjects.h in Headers */,
Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (235351 => 235352)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2018-08-27 05:01:28 UTC (rev 235352)
@@ -36,7 +36,7 @@
class RenderStyle;
namespace Layout {
-class FloatBox;
+class FloatAvoider;
class BlockFormattingContext;
class FormattingContext;
class FloatingContext;
@@ -48,7 +48,7 @@
class Box {
WTF_MAKE_ISO_ALLOCATED(Box);
public:
- friend class Layout::FloatBox;
+ friend class Layout::FloatAvoider;
friend class Layout::BlockFormattingContext;
friend class Layout::FormattingContext;
friend class Layout::FloatingContext;
Copied: trunk/Source/WebCore/layout/floats/FloatAvoider.cpp (from rev 235351, trunk/Source/WebCore/layout/floats/FloatBox.cpp) (0 => 235352)
--- trunk/Source/WebCore/layout/floats/FloatAvoider.cpp (rev 0)
+++ trunk/Source/WebCore/layout/floats/FloatAvoider.cpp 2018-08-27 05:01:28 UTC (rev 235352)
@@ -0,0 +1,118 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 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.
+ */
+
+#include "config.h"
+#include "FloatAvoider.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "LayoutBox.h"
+#include "LayoutContainer.h"
+#include "LayoutContext.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(FloatAvoider);
+
+FloatAvoider::FloatAvoider(const Box& layoutBox, const FloatingState& floatingState, const LayoutContext& layoutContext)
+ : m_layoutBox(makeWeakPtr(const_cast<Box&>(layoutBox)))
+ , m_floatingState(floatingState)
+ , m_absoluteDisplayBox(FormattingContext::mapBoxToAncestor(layoutContext, layoutBox, downcast<Container>(floatingState.root())))
+ , m_containingBlockAbsoluteDisplayBox(FormattingContext::mapBoxToAncestor(layoutContext, *layoutBox.containingBlock(), downcast<Container>(floatingState.root())))
+{
+ initializePosition();
+}
+
+void FloatAvoider::initializePosition()
+{
+ resetVertically();
+ resetHorizontally();
+}
+
+bool FloatAvoider::isLeftAligned() const
+{
+ return m_layoutBox->isLeftFloatingPositioned();
+}
+
+void FloatAvoider::setLeft(PositionInContextRoot left)
+{
+ // Horizontal position is constrained by the containing block's content box.
+ // Compute the horizontal position for the new floating by taking both the contining block and the current left/right floats into account.
+ auto containingBlockContentBoxLeft = m_containingBlockAbsoluteDisplayBox.left() + m_containingBlockAbsoluteDisplayBox.contentBoxLeft();
+ auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth();
+
+ // Align it with the containing block's left edge first.
+ left = std::max(containingBlockContentBoxLeft + marginLeft(), left);
+ // Make sure it does not overflow the containing block on the right.
+ auto marginBoxSize = m_absoluteDisplayBox.marginBox().width();
+ left = std::min(left, containingBlockContentBoxRight - marginBoxSize + marginLeft());
+
+ m_absoluteDisplayBox.setLeft(left);
+}
+
+void FloatAvoider::setTopLeft(PointInContextRoot topLeft)
+{
+ setTop(topLeft.y);
+ setLeft(topLeft.x);
+}
+
+void FloatAvoider::resetVertically()
+{
+ // Incoming float cannot be placed higher than existing floats (margin box of the last float).
+ // Take the static position (where the box would go if it wasn't floating) and adjust it with the last float.
+ auto top = m_absoluteDisplayBox.rectWithMargin().top();
+ if (auto lastFloat = m_floatingState.last())
+ top = std::max(top, lastFloat->rectWithMargin().top());
+ top += m_absoluteDisplayBox.marginTop();
+
+ m_absoluteDisplayBox.setTop(top);
+}
+
+void FloatAvoider::resetHorizontally()
+{
+ // Align the box with the containing block's content box.
+ auto containingBlockContentBoxLeft = m_containingBlockAbsoluteDisplayBox.left() + m_containingBlockAbsoluteDisplayBox.contentBoxLeft();
+ auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth();
+
+ auto left = isLeftAligned() ? containingBlockContentBoxLeft : containingBlockContentBoxRight - m_absoluteDisplayBox.marginBox().width();
+ left += m_absoluteDisplayBox.marginLeft();
+
+ m_absoluteDisplayBox.setLeft(left);
+}
+
+PointInContainingBlock FloatAvoider::topLeftInContainingBlock() const
+{
+ // From formatting root coordinate system back to containing block's.
+ if (m_layoutBox->containingBlock() == &m_floatingState.root())
+ return m_absoluteDisplayBox.topLeft();
+
+ return { m_absoluteDisplayBox.left() - m_containingBlockAbsoluteDisplayBox.left(), m_absoluteDisplayBox.top() - m_containingBlockAbsoluteDisplayBox.top() };
+}
+
+}
+}
+#endif
Copied: trunk/Source/WebCore/layout/floats/FloatAvoider.h (from rev 235351, trunk/Source/WebCore/layout/floats/FloatBox.h) (0 => 235352)
--- trunk/Source/WebCore/layout/floats/FloatAvoider.h (rev 0)
+++ trunk/Source/WebCore/layout/floats/FloatAvoider.h 2018-08-27 05:01:28 UTC (rev 235352)
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2018 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 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.
+ */
+
+#pragma once
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "DisplayBox.h"
+#include "LayoutUnit.h"
+#include <wtf/IsoMalloc.h>
+#include <wtf/WeakPtr.h>
+
+namespace WebCore {
+
+namespace Layout {
+
+class Box;
+class FloatingState;
+class LayoutContext;
+
+class FloatAvoider {
+ WTF_MAKE_ISO_ALLOCATED(FloatAvoider);
+public:
+ FloatAvoider(const Box&, const FloatingState&, const LayoutContext&);
+
+ PositionInContextRoot top() const { return m_absoluteDisplayBox.top(); }
+ PositionInContextRoot left() const { return m_absoluteDisplayBox.left(); }
+ PointInContainingBlock topLeftInContainingBlock() const;
+
+ LayoutUnit marginTop() const { return m_absoluteDisplayBox.marginTop(); }
+ LayoutUnit marginLeft() const { return m_absoluteDisplayBox.marginLeft(); }
+ LayoutUnit marginBottom() const { return m_absoluteDisplayBox.marginBottom(); }
+ LayoutUnit marginRight() const { return m_absoluteDisplayBox.marginRight(); }
+
+ Display::Box::Rect rectWithMargin() const { return m_absoluteDisplayBox.rectWithMargin(); }
+
+ void setTop(PositionInContextRoot top) { m_absoluteDisplayBox.setTop(top); }
+ void setLeft(PositionInContextRoot);
+ void setTopLeft(PointInContextRoot);
+
+ void resetHorizontally();
+ void resetVertically();
+
+ bool isLeftAligned() const;
+
+private:
+ void initializePosition();
+
+ WeakPtr<Box> m_layoutBox;
+ const FloatingState& m_floatingState;
+
+ Display::Box m_absoluteDisplayBox;
+ Display::Box m_containingBlockAbsoluteDisplayBox;
+};
+
+}
+}
+#endif
Deleted: trunk/Source/WebCore/layout/floats/FloatBox.cpp (235351 => 235352)
--- trunk/Source/WebCore/layout/floats/FloatBox.cpp 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/layout/floats/FloatBox.cpp 2018-08-27 05:01:28 UTC (rev 235352)
@@ -1,118 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 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.
- */
-
-#include "config.h"
-#include "FloatBox.h"
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include "LayoutBox.h"
-#include "LayoutContainer.h"
-#include "LayoutContext.h"
-#include <wtf/IsoMallocInlines.h>
-
-namespace WebCore {
-namespace Layout {
-
-WTF_MAKE_ISO_ALLOCATED_IMPL(FloatBox);
-
-FloatBox::FloatBox(const Box& layoutBox, const FloatingState& floatingState, const LayoutContext& layoutContext)
- : m_layoutBox(makeWeakPtr(const_cast<Box&>(layoutBox)))
- , m_floatingState(floatingState)
- , m_absoluteDisplayBox(FormattingContext::mapBoxToAncestor(layoutContext, layoutBox, downcast<Container>(floatingState.root())))
- , m_containingBlockAbsoluteDisplayBox(FormattingContext::mapBoxToAncestor(layoutContext, *layoutBox.containingBlock(), downcast<Container>(floatingState.root())))
-{
- initializePosition();
-}
-
-void FloatBox::initializePosition()
-{
- resetVertically();
- resetHorizontally();
-}
-
-bool FloatBox::isLeftAligned() const
-{
- return m_layoutBox->isLeftFloatingPositioned();
-}
-
-void FloatBox::setLeft(PositionInContextRoot left)
-{
- // Horizontal position is constrained by the containing block's content box.
- // Compute the horizontal position for the new floating by taking both the contining block and the current left/right floats into account.
- auto containingBlockContentBoxLeft = m_containingBlockAbsoluteDisplayBox.left() + m_containingBlockAbsoluteDisplayBox.contentBoxLeft();
- auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth();
-
- // Align it with the containing block's left edge first.
- left = std::max(containingBlockContentBoxLeft + marginLeft(), left);
- // Make sure it does not overflow the containing block on the right.
- auto marginBoxSize = m_absoluteDisplayBox.marginBox().width();
- left = std::min(left, containingBlockContentBoxRight - marginBoxSize + marginLeft());
-
- m_absoluteDisplayBox.setLeft(left);
-}
-
-void FloatBox::setTopLeft(PointInContextRoot topLeft)
-{
- setTop(topLeft.y);
- setLeft(topLeft.x);
-}
-
-void FloatBox::resetVertically()
-{
- // Incoming float cannot be placed higher than existing floats (margin box of the last float).
- // Take the static position (where the box would go if it wasn't floating) and adjust it with the last float.
- auto top = m_absoluteDisplayBox.rectWithMargin().top();
- if (auto lastFloat = m_floatingState.last())
- top = std::max(top, lastFloat->rectWithMargin().top());
- top += m_absoluteDisplayBox.marginTop();
-
- m_absoluteDisplayBox.setTop(top);
-}
-
-void FloatBox::resetHorizontally()
-{
- // Align the box with the containing block's content box.
- auto containingBlockContentBoxLeft = m_containingBlockAbsoluteDisplayBox.left() + m_containingBlockAbsoluteDisplayBox.contentBoxLeft();
- auto containingBlockContentBoxRight = containingBlockContentBoxLeft + m_containingBlockAbsoluteDisplayBox.contentBoxWidth();
-
- auto left = isLeftAligned() ? containingBlockContentBoxLeft : containingBlockContentBoxRight - m_absoluteDisplayBox.marginBox().width();
- left += m_absoluteDisplayBox.marginLeft();
-
- m_absoluteDisplayBox.setLeft(left);
-}
-
-PointInContainingBlock FloatBox::topLeftInContainingBlock() const
-{
- // From formatting root coordinate system back to containing block's.
- if (m_layoutBox->containingBlock() == &m_floatingState.root())
- return m_absoluteDisplayBox.topLeft();
-
- return { m_absoluteDisplayBox.left() - m_containingBlockAbsoluteDisplayBox.left(), m_absoluteDisplayBox.top() - m_containingBlockAbsoluteDisplayBox.top() };
-}
-
-}
-}
-#endif
Deleted: trunk/Source/WebCore/layout/floats/FloatBox.h (235351 => 235352)
--- trunk/Source/WebCore/layout/floats/FloatBox.h 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/layout/floats/FloatBox.h 2018-08-27 05:01:28 UTC (rev 235352)
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 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.
- */
-
-#pragma once
-
-#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
-
-#include "DisplayBox.h"
-#include "LayoutUnit.h"
-#include <wtf/IsoMalloc.h>
-#include <wtf/WeakPtr.h>
-
-namespace WebCore {
-
-namespace Layout {
-
-class Box;
-class FloatingState;
-class LayoutContext;
-
-class FloatBox {
- WTF_MAKE_ISO_ALLOCATED(FloatBox);
-public:
- FloatBox(const Box&, const FloatingState&, const LayoutContext&);
-
- PositionInContextRoot top() const { return m_absoluteDisplayBox.top(); }
- PositionInContextRoot left() const { return m_absoluteDisplayBox.left(); }
- PointInContainingBlock topLeftInContainingBlock() const;
-
- LayoutUnit marginTop() const { return m_absoluteDisplayBox.marginTop(); }
- LayoutUnit marginLeft() const { return m_absoluteDisplayBox.marginLeft(); }
- LayoutUnit marginBottom() const { return m_absoluteDisplayBox.marginBottom(); }
- LayoutUnit marginRight() const { return m_absoluteDisplayBox.marginRight(); }
-
- Display::Box::Rect rectWithMargin() const { return m_absoluteDisplayBox.rectWithMargin(); }
-
- void setTop(PositionInContextRoot top) { m_absoluteDisplayBox.setTop(top); }
- void setLeft(PositionInContextRoot);
- void setTopLeft(PointInContextRoot);
-
- void resetHorizontally();
- void resetVertically();
-
- bool isLeftAligned() const;
-
-private:
- void initializePosition();
-
- WeakPtr<Box> m_layoutBox;
- const FloatingState& m_floatingState;
-
- Display::Box m_absoluteDisplayBox;
- Display::Box m_containingBlockAbsoluteDisplayBox;
-};
-
-}
-}
-#endif
Modified: trunk/Source/WebCore/layout/floats/FloatingContext.cpp (235351 => 235352)
--- trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.cpp 2018-08-27 05:01:28 UTC (rev 235352)
@@ -29,7 +29,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
#include "DisplayBox.h"
-#include "FloatBox.h"
+#include "FloatAvoider.h"
#include "LayoutBox.h"
#include "LayoutContainer.h"
#include "LayoutContext.h"
@@ -137,7 +137,7 @@
}
// Find the top most position where the float box fits.
- FloatBox alignedBox = { layoutBox, m_floatingState, layoutContext() };
+ FloatAvoider alignedBox = { layoutBox, m_floatingState, layoutContext() };
floatingPosition(alignedBox);
return alignedBox.topLeftInContainingBlock();
}
@@ -213,28 +213,28 @@
return { };
}
-void FloatingContext::floatingPosition(FloatBox& floatBox) const
+void FloatingContext::floatingPosition(FloatAvoider& floatAvoider) const
{
std::optional<PositionInContextRoot> bottomMost;
- auto initialLeft = floatBox.left();
+ auto initialLeft = floatAvoider.left();
auto end = Layout::end(m_floatingState);
- for (auto iterator = begin(m_floatingState, floatBox.rectWithMargin().top()); iterator != end; ++iterator) {
+ for (auto iterator = begin(m_floatingState, floatAvoider.rectWithMargin().top()); iterator != end; ++iterator) {
ASSERT(!(*iterator).isEmpty());
auto floats = *iterator;
- floatBox.setTop(floats.verticalPosition() + floatBox.marginTop());
+ floatAvoider.setTop(floats.verticalPosition() + floatAvoider.marginTop());
// Move the box horizontally so that it either
// 1. aligns with the current floating pair
// 2. or with the containing block's content box if there's no float to align with at this vertical position.
- if (auto horiztonalPosition = floats.horiztonalPosition(floatBox.isLeftAligned() ? Float::Left : Float::Right)) {
- if (!floatBox.isLeftAligned())
- horiztonalPosition = *horiztonalPosition - floatBox.rectWithMargin().width();
- floatBox.setLeft(*horiztonalPosition + floatBox.marginLeft());
+ if (auto horiztonalPosition = floats.horiztonalPosition(floatAvoider.isLeftAligned() ? Float::Left : Float::Right)) {
+ if (!floatAvoider.isLeftAligned())
+ horiztonalPosition = *horiztonalPosition - floatAvoider.rectWithMargin().width();
+ floatAvoider.setLeft(*horiztonalPosition + floatAvoider.marginLeft());
} else
- floatBox.resetHorizontally();
+ floatAvoider.resetHorizontally();
// Check if the box fits at this position.
- if (!floats.intersects(floatBox.rectWithMargin()))
+ if (!floats.intersects(floatAvoider.rectWithMargin()))
return;
bottomMost = floats.bottom();
@@ -246,7 +246,7 @@
return;
// Passed all the floats and still does not fit? Push it below the last float.
- floatBox.setTopLeft({ initialLeft, *bottomMost + floatBox.marginTop() });
+ floatAvoider.setTopLeft({ initialLeft, *bottomMost + floatAvoider.marginTop() });
}
FloatingPair::FloatingPair(const FloatingState::FloatList& floats)
Modified: trunk/Source/WebCore/layout/floats/FloatingContext.h (235351 => 235352)
--- trunk/Source/WebCore/layout/floats/FloatingContext.h 2018-08-27 04:55:10 UTC (rev 235351)
+++ trunk/Source/WebCore/layout/floats/FloatingContext.h 2018-08-27 05:01:28 UTC (rev 235352)
@@ -35,7 +35,7 @@
namespace Layout {
-class FloatBox;
+class FloatAvoider;
class Box;
class Container;
class FloatingPair;
@@ -56,7 +56,7 @@
private:
LayoutContext& layoutContext() const { return m_floatingState.layoutContext(); }
- void floatingPosition(FloatBox&) const;
+ void floatingPosition(FloatAvoider&) const;
FloatingState& m_floatingState;
};