[LFC] Implement Display::Box functions
https://bugs.webkit.org/show_bug.cgi?id=185116
Reviewed by Antti Koivisto.
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
(WebCore::Display::Box::~Box):
(WebCore::Display::Box::marginBox const):
(WebCore::Display::Box::borderBox const):
(WebCore::Display::Box::paddingBox const):
(WebCore::Display::Box::contentBox const):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::rect const):
(WebCore::Display::Box::top const):
(WebCore::Display::Box::left const):
(WebCore::Display::Box::bottom const):
(WebCore::Display::Box::right const):
(WebCore::Display::Box::topLeft const):
(WebCore::Display::Box::bottomRight const):
(WebCore::Display::Box::size const):
(WebCore::Display::Box::width const):
(WebCore::Display::Box::height const):
(WebCore::Display::Box::marginTop const):
(WebCore::Display::Box::marginLeft const):
(WebCore::Display::Box::marginBottom const):
(WebCore::Display::Box::marginRight const):
(WebCore::Display::Box::parent const):
(WebCore::Display::Box::nextSibling const):
(WebCore::Display::Box::previousSibling const):
(WebCore::Display::Box::firstChild const):
(WebCore::Display::Box::lastChild const):
(WebCore::Display::Box::setRect):
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setSize):
(WebCore::Display::Box::setWidth):
(WebCore::Display::Box::setHeight):
(WebCore::Display::Box::setMarginTop):
(WebCore::Display::Box::setMarginLeft):
(WebCore::Display::Box::setMarginBottom):
(WebCore::Display::Box::setMarginRight):
(WebCore::Display::Box::setBorderTop):
(WebCore::Display::Box::setBorderLeft):
(WebCore::Display::Box::setBorderBottom):
(WebCore::Display::Box::setBorderRight):
(WebCore::Display::Box::setPaddingTop):
(WebCore::Display::Box::setPaddingLeft):
(WebCore::Display::Box::setPaddingBottom):
(WebCore::Display::Box::setPaddingRight):
(WebCore::Display::Box::setParent):
(WebCore::Display::Box::setNextSibling):
(WebCore::Display::Box::setPreviousSibling):
(WebCore::Display::Box::setFirstChild):
(WebCore::Display::Box::setLastChild):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@231150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 43ff2b4..62a0340 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,62 @@
+2018-04-29 Zalan Bujtas <zalan@apple.com>
+
+ [LFC] Implement Display::Box functions
+ https://bugs.webkit.org/show_bug.cgi?id=185116
+
+ Reviewed by Antti Koivisto.
+
+ * layout/displaytree/DisplayBox.cpp:
+ (WebCore::Display::Box::Box):
+ (WebCore::Display::Box::~Box):
+ (WebCore::Display::Box::marginBox const):
+ (WebCore::Display::Box::borderBox const):
+ (WebCore::Display::Box::paddingBox const):
+ (WebCore::Display::Box::contentBox const):
+ * layout/displaytree/DisplayBox.h:
+ (WebCore::Display::Box::rect const):
+ (WebCore::Display::Box::top const):
+ (WebCore::Display::Box::left const):
+ (WebCore::Display::Box::bottom const):
+ (WebCore::Display::Box::right const):
+ (WebCore::Display::Box::topLeft const):
+ (WebCore::Display::Box::bottomRight const):
+ (WebCore::Display::Box::size const):
+ (WebCore::Display::Box::width const):
+ (WebCore::Display::Box::height const):
+ (WebCore::Display::Box::marginTop const):
+ (WebCore::Display::Box::marginLeft const):
+ (WebCore::Display::Box::marginBottom const):
+ (WebCore::Display::Box::marginRight const):
+ (WebCore::Display::Box::parent const):
+ (WebCore::Display::Box::nextSibling const):
+ (WebCore::Display::Box::previousSibling const):
+ (WebCore::Display::Box::firstChild const):
+ (WebCore::Display::Box::lastChild const):
+ (WebCore::Display::Box::setRect):
+ (WebCore::Display::Box::setTopLeft):
+ (WebCore::Display::Box::setTop):
+ (WebCore::Display::Box::setLeft):
+ (WebCore::Display::Box::setSize):
+ (WebCore::Display::Box::setWidth):
+ (WebCore::Display::Box::setHeight):
+ (WebCore::Display::Box::setMarginTop):
+ (WebCore::Display::Box::setMarginLeft):
+ (WebCore::Display::Box::setMarginBottom):
+ (WebCore::Display::Box::setMarginRight):
+ (WebCore::Display::Box::setBorderTop):
+ (WebCore::Display::Box::setBorderLeft):
+ (WebCore::Display::Box::setBorderBottom):
+ (WebCore::Display::Box::setBorderRight):
+ (WebCore::Display::Box::setPaddingTop):
+ (WebCore::Display::Box::setPaddingLeft):
+ (WebCore::Display::Box::setPaddingBottom):
+ (WebCore::Display::Box::setPaddingRight):
+ (WebCore::Display::Box::setParent):
+ (WebCore::Display::Box::setNextSibling):
+ (WebCore::Display::Box::setPreviousSibling):
+ (WebCore::Display::Box::setFirstChild):
+ (WebCore::Display::Box::setLastChild):
+
2018-04-29 Youenn Fablet <youenn@apple.com>
Make RestrictedHTTPResponseAccess flag true by default
diff --git a/Source/WebCore/layout/displaytree/DisplayBox.cpp b/Source/WebCore/layout/displaytree/DisplayBox.cpp
index c4e1c16..eac3baf 100644
--- a/Source/WebCore/layout/displaytree/DisplayBox.cpp
+++ b/Source/WebCore/layout/displaytree/DisplayBox.cpp
@@ -25,3 +25,63 @@
#include "config.h"
#include "DisplayBox.h"
+
+#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+
+#include <wtf/IsoMallocInlines.h>
+
+namespace WebCore {
+namespace Display {
+
+WTF_MAKE_ISO_ALLOCATED_IMPL(Box);
+
+Box::Box()
+{
+}
+
+Box::~Box()
+{
+}
+
+LayoutRect Box::marginBox() const
+{
+ auto marginBox = rect();
+ auto topLeftMargin = LayoutSize(m_marginLeft, m_marginTop);
+ marginBox.inflate(topLeftMargin);
+
+ auto bottomRightMargin = LayoutSize(m_marginRight, m_marginBottom);
+ marginBox.expand(bottomRightMargin);
+ return marginBox;
+}
+
+LayoutRect Box::borderBox() const
+{
+ return LayoutRect(LayoutPoint(0, 0), size());
+}
+
+LayoutRect Box::paddingBox() const
+{
+ auto paddingBox = borderBox();
+ auto topLeftBorder = LayoutSize(m_borderLeft, m_borderTop);
+ paddingBox.inflate(-topLeftBorder);
+
+ auto bottomRightBorder = LayoutSize(m_borderRight, m_borderBottom);
+ paddingBox.expand(-bottomRightBorder);
+ return paddingBox;
+}
+
+LayoutRect Box::contentBox() const
+{
+ auto contentBox = paddingBox();
+ auto topLeftPadding = LayoutSize(m_paddingLeft, m_paddingTop);
+ contentBox.inflate(-topLeftPadding);
+
+ auto bottomRightPadding = LayoutSize(m_paddingRight, m_paddingBottom);
+ contentBox.expand(-bottomRightPadding);
+ return contentBox;
+}
+
+}
+}
+
+#endif
diff --git a/Source/WebCore/layout/displaytree/DisplayBox.h b/Source/WebCore/layout/displaytree/DisplayBox.h
index 39df2f1..e9d429f 100644
--- a/Source/WebCore/layout/displaytree/DisplayBox.h
+++ b/Source/WebCore/layout/displaytree/DisplayBox.h
@@ -33,60 +33,99 @@
#include <wtf/IsoMalloc.h>
namespace WebCore {
-
namespace Display {
class Box {
WTF_MAKE_ISO_ALLOCATED(Box);
public:
- void setRect(const LayoutRect&);
- void setTopLeft(const LayoutPoint&);
- void setTop(LayoutUnit);
- void setLeft(LayoutUnit);
- void setSize(const LayoutSize&);
- void setWidth(LayoutUnit);
- void setHeight(LayoutUnit);
+ friend class FormattingContext;
- LayoutRect rect() const;
+ ~Box();
- LayoutUnit top() const;
- LayoutUnit left() const;
- LayoutUnit bottom() const;
- LayoutUnit right() const;
+ LayoutRect rect() const { return m_rect; }
- LayoutPoint topLeft() const;
- LayoutPoint bottomRight() const;
+ LayoutUnit top() const { return m_rect.y(); }
+ LayoutUnit left() const { return m_rect.x(); }
+ LayoutUnit bottom() const { return m_rect.maxY(); }
+ LayoutUnit right() const { return m_rect.maxX(); }
- LayoutSize size() const;
- LayoutUnit width() const;
- LayoutUnit height() const;
+ LayoutPoint topLeft() const { return m_rect.location(); }
+ LayoutPoint bottomRight() const { return m_rect.location(); }
- void setMarginTop(LayoutUnit);
- void setMarginLeft(LayoutUnit);
- void setMarginBottom(LayoutUnit);
- void setMarginRight(LayoutUnit);
+ LayoutSize size() const { return m_rect.size(); }
+ LayoutUnit width() const { return m_rect.width(); }
+ LayoutUnit height() const { return m_rect.height(); }
- LayoutUnit marginTop() const;
- LayoutUnit marginLeft() const;
- LayoutUnit marginBottom() const;
- LayoutUnit marginRight() const;
+ LayoutUnit marginTop() const { return m_marginTop; }
+ LayoutUnit marginLeft() const { return m_marginLeft; }
+ LayoutUnit marginBottom() const { return m_marginBottom; }
+ LayoutUnit marginRight() const { return m_marginRight; }
LayoutRect marginBox() const;
LayoutRect borderBox() const;
LayoutRect paddingBox() const;
LayoutRect contentBox() const;
- void setParent(Box&);
- void setNextSibling(Box&);
- void setPreviousSibling(Box&);
- void setFirstChild(Box&);
- void setLastChild(Box&);
+ const Box* parent() const { return m_parent; }
+ const Box* nextSibling() const { return m_parent; }
+ const Box* previousSibling() const { return m_parent; }
+ const Box* firstChild() const { return m_firstChild; }
+ const Box* lastChild() const { return m_lastChild; }
+
+private:
+ Box();
- Box* parent() const;
- Box* nextSibling() const;
- Box* previousSibling() const;
- Box* firstChild() const;
- Box* lastChild() const;
+ void setRect(const LayoutRect& rect) { m_rect = rect; }
+ void setTopLeft(const LayoutPoint& topLeft) { m_rect.setLocation(topLeft); }
+ void setTop(LayoutUnit top) { m_rect.setY(top); }
+ void setLeft(LayoutUnit left) { m_rect.setX(left); }
+ void setSize(const LayoutSize& size) { m_rect.setSize(size); }
+ void setWidth(LayoutUnit width) { m_rect.setWidth(width); }
+ void setHeight(LayoutUnit height) { m_rect.setHeight(height); }
+
+ void setMarginTop(LayoutUnit marginTop) { m_marginTop = marginTop; }
+ void setMarginLeft(LayoutUnit marginLeft) { m_marginLeft = marginLeft; }
+ void setMarginBottom(LayoutUnit marginBottom) { m_marginBottom = marginBottom; }
+ void setMarginRight(LayoutUnit marginRight) { m_marginRight = marginRight; }
+
+ void setBorderTop(LayoutUnit borderTop) { m_borderTop = borderTop; }
+ void setBorderLeft(LayoutUnit borderLeft) { m_borderLeft = borderLeft; }
+ void setBorderBottom(LayoutUnit borderBottom) { m_borderBottom = borderBottom; }
+ void setBorderRight(LayoutUnit borderRight) { m_borderRight = borderRight; }
+
+ void setPaddingTop(LayoutUnit paddingTop) { m_paddingTop = paddingTop; }
+ void setPaddingLeft(LayoutUnit paddingLeft) { m_paddingLeft = paddingLeft; }
+ void setPaddingBottom(LayoutUnit paddingBottom) { m_paddingBottom = paddingBottom; }
+ void setPaddingRight(LayoutUnit paddingRight) { m_paddingRight = paddingRight; }
+
+ void setParent(Box& parent) { m_parent = &parent; }
+ void setNextSibling(Box& nextSibling) { m_nextSibling = &nextSibling; }
+ void setPreviousSibling(Box& previousSibling) { m_previousSibling = &previousSibling; }
+ void setFirstChild(Box& firstChild) { m_firstChild = &firstChild; }
+ void setLastChild(Box& lastChild) { m_lastChild = &lastChild; }
+
+ LayoutRect m_rect;
+ LayoutUnit m_marginTop;
+ LayoutUnit m_marginLeft;
+ LayoutUnit m_marginBottom;
+ LayoutUnit m_marginRight;
+
+ LayoutUnit m_borderTop;
+ LayoutUnit m_borderLeft;
+ LayoutUnit m_borderBottom;
+ LayoutUnit m_borderRight;
+
+ LayoutUnit m_paddingTop;
+ LayoutUnit m_paddingLeft;
+ LayoutUnit m_paddingBottom;
+ LayoutUnit m_paddingRight;
+
+ const Box* m_parent { nullptr };
+ const Box* m_nextSibling { nullptr };
+ const Box* m_previousSibling { nullptr };
+ const Box* m_firstChild { nullptr };
+ const Box* m_lastChild { nullptr };
+
};
}