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.
27 #include "FormattingContext.h"
29 #if ENABLE(LAYOUT_FORMATTING_CONTEXT)
31 #include "LayoutBox.h"
32 #include <wtf/IsoMallocInlines.h>
37 WTF_MAKE_ISO_ALLOCATED_IMPL(FormattingContext);
39 FormattingContext::FormattingContext(const Box& formattingContextRoot, LayoutContext& layoutContext)
40 : m_root(makeWeakPtr(const_cast<Box&>(formattingContextRoot)))
41 , m_layoutContext(layoutContext)
45 FormattingContext::~FormattingContext()
49 void FormattingContext::computeStaticPosition(const Box&, Display::Box&) const
53 void FormattingContext::computeInFlowPositionedPosition(const Box&, Display::Box&) const
57 void FormattingContext::computeOutOfFlowPosition(const Box&, Display::Box&) const
61 void FormattingContext::computeWidth(const Box& layoutBox, Display::Box& displayBox) const
63 if (layoutBox.isOutOfFlowPositioned())
64 return computeOutOfFlowWidth(layoutBox, displayBox);
65 if (layoutBox.isFloatingPositioned())
66 return computeFloatingWidth(layoutBox, displayBox);
67 return computeInFlowWidth(layoutBox, displayBox);
70 void FormattingContext::computeHeight(const Box& layoutBox, Display::Box& displayBox) const
72 if (layoutBox.isOutOfFlowPositioned())
73 return computeOutOfFlowHeight(layoutBox, displayBox);
74 if (layoutBox.isFloatingPositioned())
75 return computeFloatingHeight(layoutBox, displayBox);
76 return computeInFlowHeight(layoutBox, displayBox);
79 void FormattingContext::computeOutOfFlowWidth(const Box&, Display::Box&) const
83 void FormattingContext::computeFloatingWidth(const Box&, Display::Box&) const
87 void FormattingContext::computeOutOfFlowHeight(const Box&, Display::Box&) const
91 void FormattingContext::computeFloatingHeight(const Box&, Display::Box&) const
95 LayoutUnit FormattingContext::marginTop(const Box&) const
100 LayoutUnit FormattingContext::marginLeft(const Box&) const
105 LayoutUnit FormattingContext::marginBottom(const Box&) const
110 LayoutUnit FormattingContext::marginRight(const Box&) const
115 void FormattingContext::placeInFlowPositionedChildren(const Container&) const
119 void FormattingContext::layoutOutOfFlowDescendants() const