Title: [237321] trunk/Source/WebCore
Revision
237321
Author
[email protected]
Date
2018-10-22 08:42:44 -0700 (Mon, 22 Oct 2018)

Log Message

[LFC][IFC] Implement Replaced helper class.
https://bugs.webkit.org/show_bug.cgi?id=190719

Reviewed by Antti Koivisto.

* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::Box):
* layout/layouttree/LayoutBox.h:
(WebCore::Layout::Box::replaced const):
* layout/layouttree/LayoutReplaced.cpp:
(WebCore::Layout::Replaced::Replaced):
(WebCore::Layout::Replaced::hasIntrinsicWidth const):
(WebCore::Layout::Replaced::hasIntrinsicHeight const):
(WebCore::Layout::Replaced::hasIntrinsicRatio const):
(WebCore::Layout::Replaced::intrinsicWidth const):
(WebCore::Layout::Replaced::intrinsicHeight const):
(WebCore::Layout::Replaced::intrinsicRatio const):
* layout/layouttree/LayoutReplaced.h:
(WebCore::Layout::Replaced::hasIntrinsicWidth const): Deleted.
(WebCore::Layout::Replaced::hasIntrinsicHeight const): Deleted.
(WebCore::Layout::Replaced::hasIntrinsicRatio const): Deleted.
(WebCore::Layout::Replaced::intrinsicWidth const): Deleted.
(WebCore::Layout::Replaced::intrinsicHeight const): Deleted.
(WebCore::Layout::Replaced::intrinsicRatio const): Deleted.
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::TreeBuilder::createSubTree):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (237320 => 237321)


--- trunk/Source/WebCore/ChangeLog	2018-10-22 15:21:59 UTC (rev 237320)
+++ trunk/Source/WebCore/ChangeLog	2018-10-22 15:42:44 UTC (rev 237321)
@@ -1,5 +1,34 @@
 2018-10-22  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Implement Replaced helper class.
+        https://bugs.webkit.org/show_bug.cgi?id=190719
+
+        Reviewed by Antti Koivisto.
+
+        * layout/layouttree/LayoutBox.cpp:
+        (WebCore::Layout::Box::Box):
+        * layout/layouttree/LayoutBox.h:
+        (WebCore::Layout::Box::replaced const):
+        * layout/layouttree/LayoutReplaced.cpp:
+        (WebCore::Layout::Replaced::Replaced):
+        (WebCore::Layout::Replaced::hasIntrinsicWidth const):
+        (WebCore::Layout::Replaced::hasIntrinsicHeight const):
+        (WebCore::Layout::Replaced::hasIntrinsicRatio const):
+        (WebCore::Layout::Replaced::intrinsicWidth const):
+        (WebCore::Layout::Replaced::intrinsicHeight const):
+        (WebCore::Layout::Replaced::intrinsicRatio const):
+        * layout/layouttree/LayoutReplaced.h:
+        (WebCore::Layout::Replaced::hasIntrinsicWidth const): Deleted.
+        (WebCore::Layout::Replaced::hasIntrinsicHeight const): Deleted.
+        (WebCore::Layout::Replaced::hasIntrinsicRatio const): Deleted.
+        (WebCore::Layout::Replaced::intrinsicWidth const): Deleted.
+        (WebCore::Layout::Replaced::intrinsicHeight const): Deleted.
+        (WebCore::Layout::Replaced::intrinsicRatio const): Deleted.
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::TreeBuilder::createSubTree):
+
+2018-10-22  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Block formatting context roots avoid floats.
         https://bugs.webkit.org/show_bug.cgi?id=190723
 

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp (237320 => 237321)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2018-10-22 15:21:59 UTC (rev 237320)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.cpp	2018-10-22 15:42:44 UTC (rev 237321)
@@ -42,6 +42,8 @@
     , m_elementAttributes(attributes)
     , m_baseTypeFlags(baseTypeFlags)
 {
+    if (m_elementAttributes && m_elementAttributes.value().elementType == ElementType::Replaced)
+        m_replaced = std::make_unique<Replaced>(*this);
 }
 
 Box::~Box()

Modified: trunk/Source/WebCore/layout/layouttree/LayoutBox.h (237320 => 237321)


--- trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2018-10-22 15:21:59 UTC (rev 237320)
+++ trunk/Source/WebCore/layout/layouttree/LayoutBox.h	2018-10-22 15:42:44 UTC (rev 237321)
@@ -51,6 +51,7 @@
         TableRowGroup,
         TableHeaderGroup,
         TableFooterGroup,
+        Replaced,
         GenericElement
     };
 
@@ -126,7 +127,7 @@
 
     const RenderStyle& style() const { return m_style; }
 
-    std::optional<const Replaced> replaced() const { return m_replaced; }
+    const Replaced* replaced() const { return m_replaced.get(); }
 
     void setParent(Container& parent) { m_parent = &parent; }
     void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }
@@ -140,7 +141,7 @@
     Box* m_previousSibling { nullptr };
     Box* m_nextSibling { nullptr };
 
-    std::optional<const Replaced> m_replaced;
+    std::unique_ptr<const Replaced> m_replaced;
 
     unsigned m_baseTypeFlags : 4;
 };

Modified: trunk/Source/WebCore/layout/layouttree/LayoutReplaced.cpp (237320 => 237321)


--- trunk/Source/WebCore/layout/layouttree/LayoutReplaced.cpp	2018-10-22 15:21:59 UTC (rev 237320)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplaced.cpp	2018-10-22 15:42:44 UTC (rev 237321)
@@ -29,16 +29,53 @@
 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
 
 #include "LayoutBox.h"
+#include "RenderStyle.h"
 #include <wtf/IsoMallocInlines.h>
 
 namespace WebCore {
 namespace Layout {
 
-Replaced::Replaced(const LayoutBox&)
+WTF_MAKE_ISO_ALLOCATED_IMPL(Replaced);
+
+Replaced::Replaced(const Box& layoutBox)
+    : m_layoutBox(makeWeakPtr(layoutBox))
 {
 }
 
+bool Replaced::hasIntrinsicWidth() const
+{
+    return m_layoutBox->style().logicalWidth().isIntrinsic();
 }
+
+bool Replaced::hasIntrinsicHeight() const
+{
+    return m_layoutBox->style().logicalHeight().isIntrinsic();
 }
 
+bool Replaced::hasIntrinsicRatio() const
+{
+    return m_layoutBox->style().aspectRatioType() == AspectRatioType::FromIntrinsic;
+}
+
+LayoutUnit Replaced::intrinsicWidth() const
+{
+    ASSERT(hasIntrinsicWidth());
+    return m_layoutBox->style().logicalWidth().value();
+}
+
+LayoutUnit Replaced::intrinsicHeight() const
+{
+    ASSERT(hasIntrinsicHeight());
+    return m_layoutBox->style().logicalHeight().value();
+}
+
+LayoutUnit Replaced::intrinsicRatio() const
+{
+    ASSERT(hasIntrinsicRatio());
+    ASSERT_NOT_IMPLEMENTED_YET();
+    return 1;
+}
+
+}
+}
 #endif

Modified: trunk/Source/WebCore/layout/layouttree/LayoutReplaced.h (237320 => 237321)


--- trunk/Source/WebCore/layout/layouttree/LayoutReplaced.h	2018-10-22 15:21:59 UTC (rev 237320)
+++ trunk/Source/WebCore/layout/layouttree/LayoutReplaced.h	2018-10-22 15:42:44 UTC (rev 237321)
@@ -29,52 +29,31 @@
 
 #include "LayoutUnit.h"
 #include <wtf/IsoMalloc.h>
+#include <wtf/WeakPtr.h>
 
 namespace WebCore {
-
 namespace Layout {
-class LayoutBox;
 
+class Box;
+
 // HTMLAudioElement, HTMLCanvasElement. HTMLEmbedElement, HTMLIFrameElement, HTMLImageElement, HTMLInputElement, HTMLObjectElement, HTMLVideoElement.
 class Replaced {
     WTF_MAKE_ISO_ALLOCATED(Replaced);
 public:
-    friend class LayoutBox;
+    Replaced(const Box&);
+    ~Replaced() = default;
 
-    bool hasIntrinsicWidth() const { return m_intrinsicWidth.has_value(); }
-    bool hasIntrinsicHeight() const { return m_intrinsicHeight.has_value(); }
-    bool hasIntrinsicRatio() const { return m_intrinsicRatio.has_value(); }
+    bool hasIntrinsicWidth() const;
+    bool hasIntrinsicHeight() const;
+    bool hasIntrinsicRatio() const;
     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;
+    WeakPtr<const Box> m_layoutBox;
 };
 
-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

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (237320 => 237321)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-10-22 15:21:59 UTC (rev 237320)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2018-10-22 15:42:44 UTC (rev 237321)
@@ -77,6 +77,8 @@
                 return Box::ElementAttributes { Box::ElementType::TableFooterGroup };
             if (element->hasTagName(HTMLNames::tfootTag))
                 return Box::ElementAttributes { Box::ElementType::TableFooterGroup };
+            if (element->hasTagName(HTMLNames::imgTag))
+                return Box::ElementAttributes { Box::ElementType::Replaced };
             return Box::ElementAttributes { Box::ElementType::GenericElement };
         }
         return std::nullopt;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to