2 * Copyright (C) 2018 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE.
28 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
30 #include "LayoutPoint.h"
31 #include "LayoutRect.h"
32 #include "LayoutUnit.h"
33 #include <wtf/IsoMalloc.h>
44 WTF_MAKE_ISO_ALLOCATED(Box);
46 friend class Layout::LayoutContext;
50 LayoutRect rect() const { return m_rect; }
52 LayoutUnit top() const { return m_rect.y(); }
53 LayoutUnit left() const { return m_rect.x(); }
54 LayoutUnit bottom() const { return m_rect.maxY(); }
55 LayoutUnit right() const { return m_rect.maxX(); }
57 LayoutPoint topLeft() const { return m_rect.location(); }
58 LayoutPoint bottomRight() const { return m_rect.location(); }
60 LayoutSize size() const { return m_rect.size(); }
61 LayoutUnit width() const { return m_rect.width(); }
62 LayoutUnit height() const { return m_rect.height(); }
64 LayoutUnit marginTop() const { return m_marginTop; }
65 LayoutUnit marginLeft() const { return m_marginLeft; }
66 LayoutUnit marginBottom() const { return m_marginBottom; }
67 LayoutUnit marginRight() const { return m_marginRight; }
69 LayoutRect marginBox() const;
70 LayoutRect borderBox() const;
71 LayoutRect paddingBox() const;
72 LayoutRect contentBox() const;
77 void setRect(const LayoutRect& rect) { m_rect = rect; }
78 void setTopLeft(const LayoutPoint& topLeft) { m_rect.setLocation(topLeft); }
79 void setTop(LayoutUnit top) { m_rect.setY(top); }
80 void setLeft(LayoutUnit left) { m_rect.setX(left); }
81 void setSize(const LayoutSize& size) { m_rect.setSize(size); }
82 void setWidth(LayoutUnit width) { m_rect.setWidth(width); }
83 void setHeight(LayoutUnit height) { m_rect.setHeight(height); }
85 void setMarginTop(LayoutUnit marginTop) { m_marginTop = marginTop; }
86 void setMarginLeft(LayoutUnit marginLeft) { m_marginLeft = marginLeft; }
87 void setMarginBottom(LayoutUnit marginBottom) { m_marginBottom = marginBottom; }
88 void setMarginRight(LayoutUnit marginRight) { m_marginRight = marginRight; }
90 void setBorderTop(LayoutUnit borderTop) { m_borderTop = borderTop; }
91 void setBorderLeft(LayoutUnit borderLeft) { m_borderLeft = borderLeft; }
92 void setBorderBottom(LayoutUnit borderBottom) { m_borderBottom = borderBottom; }
93 void setBorderRight(LayoutUnit borderRight) { m_borderRight = borderRight; }
95 void setPaddingTop(LayoutUnit paddingTop) { m_paddingTop = paddingTop; }
96 void setPaddingLeft(LayoutUnit paddingLeft) { m_paddingLeft = paddingLeft; }
97 void setPaddingBottom(LayoutUnit paddingBottom) { m_paddingBottom = paddingBottom; }
98 void setPaddingRight(LayoutUnit paddingRight) { m_paddingRight = paddingRight; }
101 LayoutUnit m_marginTop;
102 LayoutUnit m_marginLeft;
103 LayoutUnit m_marginBottom;
104 LayoutUnit m_marginRight;
106 LayoutUnit m_borderTop;
107 LayoutUnit m_borderLeft;
108 LayoutUnit m_borderBottom;
109 LayoutUnit m_borderRight;
111 LayoutUnit m_paddingTop;
112 LayoutUnit m_paddingLeft;
113 LayoutUnit m_paddingBottom;
114 LayoutUnit m_paddingRight;