Diff
Modified: trunk/Source/WebCore/ChangeLog (231894 => 231895)
--- trunk/Source/WebCore/ChangeLog 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/ChangeLog 2018-05-17 14:11:08 UTC (rev 231895)
@@ -1,5 +1,33 @@
2018-05-17 Zalan Bujtas <[email protected]>
+ [LFC] Move replaced logic from Layout::Box to Layout::Replaced class
+ https://bugs.webkit.org/show_bug.cgi?id=185711
+
+ Reviewed by Antti Koivisto.
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::computeOutOfFlowWidth const):
+ (WebCore::Layout::FormattingContext::computeFloatingWidth const):
+ (WebCore::Layout::FormattingContext::computeOutOfFlowHeight const):
+ (WebCore::Layout::FormattingContext::computeInFlowReplacedWidth const):
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::computeInFlowWidth const):
+ (WebCore::Layout::BlockFormattingContext::computeInFlowHeight const):
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::isReplaced const): Deleted.
+ (WebCore::Layout::Box::hasIntrinsicWidth const): Deleted.
+ (WebCore::Layout::Box::hasIntrinsicHeight const): Deleted.
+ (WebCore::Layout::Box::hasIntrinsicRatio const): Deleted.
+ (WebCore::Layout::Box::intrinsicWidth const): Deleted.
+ (WebCore::Layout::Box::intrinsicHeight const): Deleted.
+ (WebCore::Layout::Box::intrinsicRatio const): Deleted.
+ * layout/layouttree/LayoutBox.h:
+ (WebCore::Layout::Box::replaced const):
+
+2018-05-17 Zalan Bujtas <[email protected]>
+
[LFC] Implement width computation for replaced out if flow elements.
https://bugs.webkit.org/show_bug.cgi?id=185701
Modified: trunk/Source/WebCore/Sources.txt (231894 => 231895)
--- trunk/Source/WebCore/Sources.txt 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/Sources.txt 2018-05-17 14:11:08 UTC (rev 231895)
@@ -1231,6 +1231,7 @@
layout/layouttree/LayoutContainer.cpp
layout/layouttree/LayoutInlineBox.cpp
layout/layouttree/LayoutInlineContainer.cpp
+layout/layouttree/LayoutReplaced.cpp
layout/layouttree/LayoutTreeBuilder.cpp
loader/ContentFilter.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (231894 => 231895)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2018-05-17 14:11:08 UTC (rev 231895)
@@ -5727,6 +5727,8 @@
11100FCA2092868D0081AA6C /* LayoutAncestorIterator.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutAncestorIterator.h; sourceTree = "<group>"; };
11100FD5209514DE0081AA6C /* LayoutTreeBuilder.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutTreeBuilder.cpp; sourceTree = "<group>"; };
11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutTreeBuilder.h; sourceTree = "<group>"; };
+ 111C615620AD1AE1005B82FA /* LayoutReplaced.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LayoutReplaced.h; sourceTree = "<group>"; };
+ 111C615720AD1AE1005B82FA /* LayoutReplaced.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = LayoutReplaced.cpp; sourceTree = "<group>"; };
1123AFD9209ABB2000736ACC /* BlockInvalidation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BlockInvalidation.h; sourceTree = "<group>"; };
1123AFDA209ABB2000736ACC /* BlockInvalidation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = BlockInvalidation.cpp; sourceTree = "<group>"; };
1123AFDC209ABBBA00736ACC /* InlineInvalidation.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = InlineInvalidation.h; sourceTree = "<group>"; };
@@ -15700,6 +15702,8 @@
1199FA4E208E3899002358CC /* LayoutInlineContainer.cpp */,
1199FA4D208E3899002358CC /* LayoutInlineContainer.h */,
11100FC72092764C0081AA6C /* LayoutIterator.h */,
+ 111C615720AD1AE1005B82FA /* LayoutReplaced.cpp */,
+ 111C615620AD1AE1005B82FA /* LayoutReplaced.h */,
11100FD5209514DE0081AA6C /* LayoutTreeBuilder.cpp */,
11100FD7209514DF0081AA6C /* LayoutTreeBuilder.h */,
);
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (231894 => 231895)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2018-05-17 14:11:08 UTC (rev 231895)
@@ -80,7 +80,7 @@
void FormattingContext::computeOutOfFlowWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- if (!layoutBox.isReplaced()) {
+ if (!layoutBox.replaced()) {
computeOutOfFlowNonReplacedWidth(layoutContext, layoutBox, displayBox);
return;
}
@@ -89,7 +89,7 @@
void FormattingContext::computeFloatingWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- if (!layoutBox.isReplaced()) {
+ if (!layoutBox.replaced()) {
ASSERT_NOT_REACHED();
return;
}
@@ -98,7 +98,7 @@
void FormattingContext::computeOutOfFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- if (!layoutBox.isReplaced()) {
+ if (!layoutBox.replaced()) {
computeOutOfFlowNonReplacedHeight(layoutContext, layoutBox, displayBox);
return;
}
@@ -241,21 +241,23 @@
auto height = style.logicalHeight();
LayoutUnit computedWidthValue;
+ auto replaced = layoutBox.replaced();
+ ASSERT(replaced);
- if (width.isAuto() && height.isAuto() && layoutBox.hasIntrinsicWidth()) {
+ if (width.isAuto() && height.isAuto() && replaced->hasIntrinsicWidth()) {
// #1
- computedWidthValue = layoutBox.intrinsicWidth();
- } else if (width.isAuto() && (height.isCalculated() || layoutBox.hasIntrinsicHeight()) && layoutBox.hasIntrinsicRatio()) {
+ computedWidthValue = replaced->intrinsicWidth();
+ } else if (width.isAuto() && (height.isCalculated() || replaced->hasIntrinsicHeight()) && replaced->hasIntrinsicRatio()) {
// #2
- auto usedHeight = height.isCalculated() ? LayoutUnit(height.value()) : layoutBox.intrinsicHeight();
- computedWidthValue = usedHeight * layoutBox.intrinsicRatio();
- } else if (width.isAuto() && height.isAuto() && layoutBox.hasIntrinsicRatio()) {
+ auto usedHeight = height.isCalculated() ? LayoutUnit(height.value()) : replaced->intrinsicHeight();
+ computedWidthValue = usedHeight * replaced->intrinsicRatio();
+ } else if (width.isAuto() && height.isAuto() && replaced->hasIntrinsicRatio()) {
// #3
// FIXME: undefined but surely doable.
ASSERT_NOT_REACHED();
- } else if (width.isAuto() && layoutBox.hasIntrinsicWidth()) {
+ } else if (width.isAuto() && replaced->hasIntrinsicWidth()) {
// #4
- computedWidthValue = layoutBox.intrinsicWidth();
+ computedWidthValue = replaced->intrinsicWidth();
} else {
// #5
computedWidthValue = 300;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (231894 => 231895)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2018-05-17 14:11:08 UTC (rev 231895)
@@ -145,7 +145,7 @@
void BlockFormattingContext::computeInFlowWidth(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- if (!layoutBox.isReplaced()) {
+ if (!layoutBox.replaced()) {
computeInFlowNonReplacedWidth(layoutContext, layoutBox, displayBox);
return;
}
@@ -185,7 +185,7 @@
void BlockFormattingContext::computeInFlowHeight(LayoutContext& layoutContext, const Box& layoutBox, Display::Box& displayBox) const
{
- if (!layoutBox.isReplaced()) {
+ if (!layoutBox.replaced()) {
computeInFlowNonReplacedHeight(layoutContext, layoutBox, displayBox);
return;
}
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (231894 => 231895)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp 2018-05-17 14:11:08 UTC (rev 231895)
@@ -179,12 +179,6 @@
return !parent();
}
-bool Box::isReplaced() const
-{
- // HTMLAudioElement || HTMLCanvasElement || HTMLEmbedElement || HTMLIFrameElement || HTMLImageElement || HTMLInputElement || HTMLObjectElement || HTMLVideoElement
- return false;
-}
-
const Box* Box::nextInFlowSibling() const
{
if (auto* nextSibling = this->nextSibling()) {
@@ -230,40 +224,7 @@
return m_style.overflowX() == OVISIBLE || m_style.overflowY() == OVISIBLE;
}
-bool Box::hasIntrinsicWidth() const
-{
- return false;
}
-
-bool Box::hasIntrinsicHeight() const
-{
- return false;
}
-bool Box::hasIntrinsicRatio() const
-{
- return false;
-}
-
-LayoutUnit Box::intrinsicWidth() const
-{
- ASSERT(hasIntrinsicWidth());
- return { };
-}
-
-LayoutUnit Box::intrinsicHeight() const
-{
- ASSERT(hasIntrinsicHeight());
- return { };
-}
-
-LayoutUnit Box::intrinsicRatio() const
-{
- ASSERT(hasIntrinsicRatio());
- return { };
-}
-
-}
-}
-
#endif
Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (231894 => 231895)
--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2018-05-17 14:07:49 UTC (rev 231894)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h 2018-05-17 14:11:08 UTC (rev 231895)
@@ -27,6 +27,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "LayoutReplaced.h"
#include "RenderStyle.h"
#include <wtf/IsoMalloc.h>
#include <wtf/WeakPtr.h>
@@ -90,14 +91,7 @@
const RenderStyle& style() const { return m_style; }
auto& weakPtrFactory() const { return m_weakFactory; }
- bool isReplaced() const;
- // FIXME: find out how to not pollute the Box interface
- bool hasIntrinsicWidth() const;
- bool hasIntrinsicHeight() const;
- bool hasIntrinsicRatio() const;
- LayoutUnit intrinsicWidth() const;
- LayoutUnit intrinsicHeight() const;
- LayoutUnit intrinsicRatio() const;
+ std::optional<const Replaced> replaced() const { return m_replaced; }
protected:
enum BaseTypeFlag {
@@ -123,6 +117,8 @@
Box* m_previousSibling { nullptr };
Box* m_nextSibling { nullptr };
+ std::optional<const Replaced> m_replaced;
+
unsigned m_baseTypeFlags : 4;
unsigned m_isAnonymous : 1;
Added: trunk/Source/WebCore/layout/layouttree/LayoutReplaced.cpp (0 => 231895)
--- trunk/Source/WebCore/layout/layouttree/LayoutReplaced.cpp (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplaced.cpp 2018-05-17 14:11:08 UTC (rev 231895)
@@ -0,0 +1,44 @@
+/*
+ * 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 "LayoutReplaced.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include "LayoutBox.h"
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Layout {
+
+Replaced::Replaced(const LayoutBox&)
+{
+}
+
+}
+}
+
+#endif
Added: trunk/Source/WebCore/layout/layouttree/LayoutReplaced.h (0 => 231895)
--- trunk/Source/WebCore/layout/layouttree/LayoutReplaced.h (rev 0)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplaced.h 2018-05-17 14:11:08 UTC (rev 231895)
@@ -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 "LayoutUnit.h"
+#include <wtf/IsoMalloc.h>
+
+namespace WebCore {
+
+namespace Layout {
+class LayoutBox;
+
+// HTMLAudioElement, HTMLCanvasElement. HTMLEmbedElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLObjectElement, HTMLVideoElement.
+class Replaced {
+ WTF_MAKE_ISO_ALLOCATED(Replaced);
+public:
+ friend class LayoutBox;
+
+ bool hasIntrinsicWidth() const { return m_intrinsicWidth.has_value(); }
+ bool hasIntrinsicHeight() const { return m_intrinsicHeight.has_value(); }
+ bool hasIntrinsicRatio() const { return m_intrinsicRatio.has_value(); }
+ LayoutUnit intrinsicWidth() const;
+ LayoutUnit intrinsicHeight() const;
+ LayoutUnit intrinsicRatio() const;
+
+private:
+ Replaced(const LayoutBox&);
+
+ std::optional<LayoutUnit> m_intrinsicWidth;
+ std::optional<LayoutUnit> m_intrinsicHeight;
+ std::optional<LayoutUnit> m_intrinsicRatio;
+};
+
+inline LayoutUnit Replaced::intrinsicWidth() const
+{
+ ASSERT(hasIntrinsicWidth());
+ return m_intrinsicWidth.value_or(LayoutUnit::max());
+}
+
+inline LayoutUnit Replaced::intrinsicHeight() const
+{
+ ASSERT(hasIntrinsicHeight());
+ return m_intrinsicHeight.value_or(LayoutUnit::max());
+}
+
+inline LayoutUnit Replaced::intrinsicRatio() const
+{
+ ASSERT(hasIntrinsicRatio());
+ return m_intrinsicRatio.value_or(LayoutUnit::max());
+}
+
+}
+}
+
+#endif