Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[LFC] Block/InlinFormattingContext should take Block/InlineFormatting…
…State

https://bugs.webkit.org/show_bug.cgi?id=193383

Reviewed by Antti Koivisto.

This is just a downcast really.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::FormattingContext):
(WebCore::Layout::FormattingContext::formattingState const): Deleted.
* layout/FormattingContext.h:
* layout/LayoutState.cpp:
(WebCore::Layout::LayoutState::createFormattingContext):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
* layout/blockformatting/BlockFormattingContext.h:
(WebCore::Layout::BlockFormattingContext::formattingState const):
(WebCore::Layout::BlockFormattingContext::blockFormattingState const): Deleted.
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
(WebCore::Layout::InlineFormattingContext::splitInlineRunIfNeeded const):
(WebCore::Layout::InlineFormattingContext::createFinalRuns const):
(WebCore::Layout::InlineFormattingContext::postProcessInlineRuns const):
(WebCore::Layout::InlineFormattingContext::layoutInlineContent const):
(WebCore::Layout::InlineFormattingContext::placeInFlowPositionedChildren const):
(WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
(WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const):
* layout/inlineformatting/InlineFormattingContext.h:
(WebCore::Layout::InlineFormattingContext::formattingState const):
(WebCore::Layout::InlineFormattingContext::inlineFormattingState const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::layoutUsingFormattingContext):

Canonical link: https://commits.webkit.org/207884@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@239903 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbaradlay committed Jan 12, 2019
1 parent 30edab7 commit 3723068
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 23 deletions.
35 changes: 35 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,38 @@
2019-01-12 Zalan Bujtas <zalan@apple.com>

[LFC] Block/InlinFormattingContext should take Block/InlineFormattingState
https://bugs.webkit.org/show_bug.cgi?id=193383

Reviewed by Antti Koivisto.

This is just a downcast really.

* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::FormattingContext):
(WebCore::Layout::FormattingContext::formattingState const): Deleted.
* layout/FormattingContext.h:
* layout/LayoutState.cpp:
(WebCore::Layout::LayoutState::createFormattingContext):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::BlockFormattingContext):
* layout/blockformatting/BlockFormattingContext.h:
(WebCore::Layout::BlockFormattingContext::formattingState const):
(WebCore::Layout::BlockFormattingContext::blockFormattingState const): Deleted.
* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::InlineFormattingContext):
(WebCore::Layout::InlineFormattingContext::splitInlineRunIfNeeded const):
(WebCore::Layout::InlineFormattingContext::createFinalRuns const):
(WebCore::Layout::InlineFormattingContext::postProcessInlineRuns const):
(WebCore::Layout::InlineFormattingContext::layoutInlineContent const):
(WebCore::Layout::InlineFormattingContext::placeInFlowPositionedChildren const):
(WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
(WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const):
* layout/inlineformatting/InlineFormattingContext.h:
(WebCore::Layout::InlineFormattingContext::formattingState const):
(WebCore::Layout::InlineFormattingContext::inlineFormattingState const): Deleted.
* page/FrameViewLayoutContext.cpp:
(WebCore::layoutUsingFormattingContext):

2019-01-12 Myles C. Maxfield <mmaxfield@apple.com>

[WHLSL] Add native function synthesis passes
Expand Down
5 changes: 0 additions & 5 deletions Source/WebCore/layout/FormattingContext.cpp
Expand Up @@ -59,11 +59,6 @@ FormattingContext::~FormattingContext()
#endif
}

FormattingState& FormattingContext::formattingState() const
{
return m_formattingState;
}

LayoutState& FormattingContext::layoutState() const
{
return m_formattingState.layoutState();
Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/layout/FormattingContext.h
Expand Up @@ -65,8 +65,8 @@ class FormattingContext {
protected:
using LayoutQueue = Vector<const Box*>;

FormattingState& formattingState() const;
LayoutState& layoutState() const;
FormattingState& formattingState() const { return m_formattingState; }
const Box& root() const { return *m_root; }

void computeBorderAndPadding(const Box&) const;
Expand Down
9 changes: 6 additions & 3 deletions Source/WebCore/layout/LayoutState.cpp
Expand Up @@ -153,12 +153,15 @@ FormattingState& LayoutState::createFormattingStateForFormattingRootIfNeeded(con
std::unique_ptr<FormattingContext> LayoutState::createFormattingContext(const Box& formattingContextRoot)
{
ASSERT(formattingContextRoot.establishesFormattingContext());
if (formattingContextRoot.establishesInlineFormattingContext())
return std::make_unique<InlineFormattingContext>(formattingContextRoot, createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
if (formattingContextRoot.establishesInlineFormattingContext()) {
auto& inlineFormattingState = downcast<InlineFormattingState>(createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
return std::make_unique<InlineFormattingContext>(formattingContextRoot, inlineFormattingState);
}

if (formattingContextRoot.establishesBlockFormattingContext()) {
ASSERT(formattingContextRoot.establishesBlockFormattingContextOnly());
return std::make_unique<BlockFormattingContext>(formattingContextRoot, createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
auto& blockFormattingState = downcast<BlockFormattingState>(createFormattingStateForFormattingRootIfNeeded(formattingContextRoot));
return std::make_unique<BlockFormattingContext>(formattingContextRoot, blockFormattingState);
}

CRASH();
Expand Down
Expand Up @@ -44,7 +44,7 @@ namespace Layout {

WTF_MAKE_ISO_ALLOCATED_IMPL(BlockFormattingContext);

BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
BlockFormattingContext::BlockFormattingContext(const Box& formattingContextRoot, BlockFormattingState& formattingState)
: FormattingContext(formattingContextRoot, formattingState)
{
}
Expand Down
Expand Up @@ -47,13 +47,11 @@ class FloatingContext;
class BlockFormattingContext : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(BlockFormattingContext);
public:
BlockFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState);
BlockFormattingContext(const Box& formattingContextRoot, BlockFormattingState&);

void layout() const override;

private:
BlockFormattingState& blockFormattingState() const { return downcast<BlockFormattingState>(formattingState()); }

void layoutFormattingContextRoot(FloatingContext&, const Box&) const;
void placeInFlowPositionedChildren(const Container&) const;

Expand Down Expand Up @@ -137,6 +135,8 @@ class BlockFormattingContext : public FormattingContext {
bool hasPrecomputedMarginBefore(const Box&) const;
#endif

BlockFormattingState& formattingState() const { return downcast<BlockFormattingState>(FormattingContext::formattingState()); }

private:
mutable HashMap<const Box*, EstimatedMarginBefore> m_estimatedMarginBeforeList;
};
Expand Down
Expand Up @@ -48,7 +48,7 @@ namespace Layout {

WTF_MAKE_ISO_ALLOCATED_IMPL(InlineFormattingContext);

InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot, FormattingState& formattingState)
InlineFormattingContext::InlineFormattingContext(const Box& formattingContextRoot, InlineFormattingState& formattingState)
: FormattingContext(formattingContextRoot, formattingState)
{
}
Expand Down Expand Up @@ -133,7 +133,7 @@ void InlineFormattingContext::splitInlineRunIfNeeded(const InlineRun& inlineRun,
// 1. Start with the first inline item (element) and travers the list until
// 2. either find an inline item that needs a dedicated run or we reach the end of the run
// 3. Create dedicate inline runs.
auto& inlineContent = inlineFormattingState().inlineContent();
auto& inlineContent = formattingState().inlineContent();
auto contentStart = inlineRun.logicalLeft();
auto startPosition = inlineRun.textContext()->start();
auto remaningLength = inlineRun.textContext()->length();
Expand Down Expand Up @@ -215,7 +215,7 @@ void InlineFormattingContext::splitInlineRunIfNeeded(const InlineRun& inlineRun,

void InlineFormattingContext::createFinalRuns(Line& line) const
{
auto& inlineFormattingState = this->inlineFormattingState();
auto& inlineFormattingState = formattingState();
for (auto& inlineRun : line.runs()) {
if (inlineRun.overlapsMultipleInlineItems()) {
InlineRuns splitRuns;
Expand Down Expand Up @@ -246,7 +246,7 @@ void InlineFormattingContext::createFinalRuns(Line& line) const
void InlineFormattingContext::postProcessInlineRuns(Line& line, IsLastLine isLastLine) const
{
Geometry::alignRuns(root().style().textAlign(), line, isLastLine);
auto firstRunIndex = inlineFormattingState().inlineRuns().size();
auto firstRunIndex = formattingState().inlineRuns().size();
createFinalRuns(line);

placeInFlowPositionedChildren(firstRunIndex);
Expand All @@ -273,7 +273,7 @@ void InlineFormattingContext::appendContentToLine(Line& line, const InlineRunPro
void InlineFormattingContext::layoutInlineContent(const InlineRunProvider& inlineRunProvider) const
{
auto& layoutState = this->layoutState();
auto& inlineFormattingState = this->inlineFormattingState();
auto& inlineFormattingState = formattingState();
auto floatingContext = FloatingContext { inlineFormattingState.floatingState() };

Line line;
Expand Down Expand Up @@ -408,7 +408,7 @@ void InlineFormattingContext::computeFloatPosition(const FloatingContext& floati

void InlineFormattingContext::placeInFlowPositionedChildren(unsigned fistRunIndex) const
{
auto& inlineRuns = inlineFormattingState().inlineRuns();
auto& inlineRuns = formattingState().inlineRuns();
for (auto runIndex = fistRunIndex; runIndex < inlineRuns.size(); ++runIndex) {
auto& inlineRun = inlineRuns[runIndex];

Expand All @@ -433,7 +433,7 @@ void InlineFormattingContext::placeInFlowPositionedChildren(unsigned fistRunInde
void InlineFormattingContext::collectInlineContentForSubtree(const Box& root, InlineRunProvider& inlineRunProvider) const
{
// Collect inline content recursively and set breaking rules for the inline elements (for paddings, margins, positioned element etc).
auto& inlineFormattingState = this->inlineFormattingState();
auto& inlineFormattingState = formattingState();

auto createAndAppendInlineItem = [&] {
auto inlineItem = std::make_unique<InlineItem>(root);
Expand Down Expand Up @@ -528,7 +528,7 @@ FormattingContext::InstrinsicWidthConstraints InlineFormattingContext::instrinsi
if (auto instrinsicWidthConstraints = formattingStateForRoot.instrinsicWidthConstraints(root()))
return *instrinsicWidthConstraints;

auto& inlineFormattingState = this->inlineFormattingState();
auto& inlineFormattingState = formattingState();
InlineRunProvider inlineRunProvider;
collectInlineContent(inlineRunProvider);

Expand Down
Expand Up @@ -43,7 +43,7 @@ class InlineRunProvider;
class InlineFormattingContext : public FormattingContext {
WTF_MAKE_ISO_ALLOCATED(InlineFormattingContext);
public:
InlineFormattingContext(const Box& formattingContextRoot, FormattingState&);
InlineFormattingContext(const Box& formattingContextRoot, InlineFormattingState&);

void layout() const override;

Expand Down Expand Up @@ -121,7 +121,7 @@ class InlineFormattingContext : public FormattingContext {
void collectInlineContentForSubtree(const Box& root, InlineRunProvider&) const;
InstrinsicWidthConstraints instrinsicWidthConstraints() const override;

InlineFormattingState& inlineFormattingState() const { return downcast<InlineFormattingState>(formattingState()); }
InlineFormattingState& formattingState() const { return downcast<InlineFormattingState>(FormattingContext::formattingState()); }
};

}
Expand Down

0 comments on commit 3723068

Please sign in to comment.