Skip to content
Permalink
Browse files
[LFC][IFC] InlineRunProvider::append() should just take const InlineI…
…tem&.

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

Reviewed by Antti Koivisto.

This allows us to remove the InlineFormattingState dependency as well.

* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
(WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const):
* layout/inlineformatting/InlineRunProvider.cpp:
(WebCore::Layout::InlineRunProvider::InlineRunProvider):
(WebCore::Layout::InlineRunProvider::append):
* layout/inlineformatting/InlineRunProvider.h:

Canonical link: https://commits.webkit.org/206575@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@238399 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed Nov 20, 2018
1 parent b1db337 commit 13a1bb10c670fd756c109c7a87a5adc1cc126928
@@ -1,3 +1,20 @@
2018-11-20 Zalan Bujjtas <zalan@apple.com>

[LFC][IFC] InlineRunProvider::append() should just take const InlineItem&.
https://bugs.webkit.org/show_bug.cgi?id=191837

Reviewed by Antti Koivisto.

This allows us to remove the InlineFormattingState dependency as well.

* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::collectInlineContentForSubtree const):
(WebCore::Layout::InlineFormattingContext::instrinsicWidthConstraints const):
* layout/inlineformatting/InlineRunProvider.cpp:
(WebCore::Layout::InlineRunProvider::InlineRunProvider):
(WebCore::Layout::InlineRunProvider::append):
* layout/inlineformatting/InlineRunProvider.h:

2018-11-20 Thibault Saunier <tsaunier@igalia.com>

[GStreamer] Enhance debugging by making sure to print the pipeline in MediaPlayerPrivateGStreamer
@@ -58,7 +58,7 @@ void InlineFormattingContext::layout() const

LOG_WITH_STREAM(FormattingContextLayout, stream << "[Start] -> inline formatting context -> formatting root(" << &root() << ")");

InlineRunProvider inlineRunProvider(inlineFormattingState());
InlineRunProvider inlineRunProvider;
collectInlineContent(inlineRunProvider);
// Compute width/height for non-text content.
for (auto& inlineRun : inlineRunProvider.runs()) {
@@ -452,15 +452,21 @@ void InlineFormattingContext::collectInlineContentForSubtree(const Box& root, In
// Collect inline content recursively and set breaking rules for the inline elements (for paddings, margins, positioned element etc).
auto& inlineFormattingState = this->inlineFormattingState();

auto createAndAppendInlineItem = [&] {
auto inlineItem = std::make_unique<InlineItem>(root);
inlineRunProvider.append(*inlineItem);
inlineFormattingState.inlineContent().add(WTFMove(inlineItem));
};

if (root.establishesFormattingContext() && &root != &(this->root())) {
createAndAppendInlineItem();
// Skip formatting root subtree. They are not part of this inline formatting context.
inlineRunProvider.append(root);
inlineFormattingState.setDetachingRules(root, { InlineFormattingState::DetachingRule::BreakAtStart, InlineFormattingState::DetachingRule::BreakAtEnd });
return;
}

if (!is<Container>(root)) {
inlineRunProvider.append(root);
createAndAppendInlineItem();
return;
}

@@ -517,7 +523,7 @@ FormattingContext::InstrinsicWidthConstraints InlineFormattingContext::instrinsi
return *instrinsicWidthConstraints;

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

// Compute width for non-text content.
@@ -37,34 +37,29 @@ namespace Layout {

WTF_MAKE_ISO_ALLOCATED_IMPL(InlineRunProvider);

InlineRunProvider::InlineRunProvider(InlineFormattingState& inlineFormattingState)
: m_inlineFormattingState(inlineFormattingState)
InlineRunProvider::InlineRunProvider()
{
}

void InlineRunProvider::append(const Box& layoutBox)
void InlineRunProvider::append(const InlineItem& inlineItem)
{
auto inlineItem = std::make_unique<InlineItem>(layoutBox);

// Special case text item. Texts can overlap multiple items. <span>foo</span><span>bar</span>
switch (inlineItem->type()) {
switch (inlineItem.type()) {
case InlineItem::Type::Text:
processInlineTextItem(*inlineItem);
// Special case text content. They can overlap multiple items. <span>foo</span><span>bar</span>
processInlineTextItem(inlineItem);
break;
case InlineItem::Type::HardLineBreak:
m_inlineRuns.append(InlineRunProvider::Run::createHardLineBreakRun(*inlineItem));
m_inlineRuns.append(InlineRunProvider::Run::createHardLineBreakRun(inlineItem));
break;
case InlineItem::Type::InlineBox:
m_inlineRuns.append(InlineRunProvider::Run::createBoxRun(*inlineItem));
m_inlineRuns.append(InlineRunProvider::Run::createBoxRun(inlineItem));
break;
case InlineItem::Type::Float:
m_inlineRuns.append(InlineRunProvider::Run::createFloatRun(*inlineItem));
m_inlineRuns.append(InlineRunProvider::Run::createFloatRun(inlineItem));
break;
default:
ASSERT_NOT_IMPLEMENTED_YET();
}

m_inlineFormattingState.inlineContent().add(WTFMove(inlineItem));
}

void InlineRunProvider::insertBefore(const Box&, const Box&)
@@ -34,16 +34,14 @@
namespace WebCore {
namespace Layout {

class InlineFormattingState;

using ItemPosition = unsigned;

class InlineRunProvider {
WTF_MAKE_ISO_ALLOCATED(InlineRunProvider);
public:
InlineRunProvider(InlineFormattingState&);
InlineRunProvider();

void append(const Box&);
void append(const InlineItem&);
void insertBefore(const Box&, const Box& before);
void remove(const Box&);

@@ -117,7 +115,6 @@ class InlineRunProvider {

LazyLineBreakIterator m_lineBreakIterator;

InlineFormattingState& m_inlineFormattingState;
Vector<InlineRunProvider::Run> m_inlineRuns;
};

0 comments on commit 13a1bb1

Please sign in to comment.