[LFC][IFC] Add style and text content to Display::Run
https://bugs.webkit.org/show_bug.cgi?id=203045
<rdar://problem/56340105>
Reviewed by Antti Koivisto.
Painting Display::Runs requires style and text content. Currently there's no mapping structure to connect Display::Runs to Display::Boxes to access style and content.
* layout/displaytree/DisplayRun.h:
(WebCore::Display::Run::TextContext::content const):
(WebCore::Display::Run::style const):
(WebCore::Display::Run::Run):
(WebCore::Display::Run::TextContext::TextContext):
(WebCore::Display::Run::TextContext::expand):
* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::appendNonBreakableSpace):
(WebCore::Layout::Line::appendTextContent):
(WebCore::Layout::Line::appendNonReplacedInlineBox):
(WebCore::Layout::Line::appendHardLineBreak):
* layout/inlineformatting/InlineLine.h:
(WebCore::Layout::Line::Run::expand):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@251211 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b7ab961..2f24c2a 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,27 @@
+2019-10-16 Zalan Bujtas <zalan@apple.com>
+
+ [LFC][IFC] Add style and text content to Display::Run
+ https://bugs.webkit.org/show_bug.cgi?id=203045
+ <rdar://problem/56340105>
+
+ Reviewed by Antti Koivisto.
+
+ Painting Display::Runs requires style and text content. Currently there's no mapping structure to connect Display::Runs to Display::Boxes to access style and content.
+
+ * layout/displaytree/DisplayRun.h:
+ (WebCore::Display::Run::TextContext::content const):
+ (WebCore::Display::Run::style const):
+ (WebCore::Display::Run::Run):
+ (WebCore::Display::Run::TextContext::TextContext):
+ (WebCore::Display::Run::TextContext::expand):
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::appendNonBreakableSpace):
+ (WebCore::Layout::Line::appendTextContent):
+ (WebCore::Layout::Line::appendNonReplacedInlineBox):
+ (WebCore::Layout::Line::appendHardLineBreak):
+ * layout/inlineformatting/InlineLine.h:
+ (WebCore::Layout::Line::Run::expand):
+
2019-10-16 Simon Fraser <simon.fraser@apple.com>
Add dumping for BorderData and StyleBackgroundData
@@ -68,7 +92,8 @@
(WebCore::Layout::LineBox::setAscentIfGreater):
(WebCore::Layout::LineBox::setDescentIfGreater):
(WebCore::Layout::LineBox::resetBaseline):
- (WebCore::Layout::LineBox::setBaseline): Deleted.
+ (WebCore::
+ Layout::LineBox::setBaseline): Deleted.
(WebCore::Layout::LineBox::baseline): Deleted.
(WebCore::Layout::LineBox::setBaselineOffset): Deleted.
(WebCore::Layout::LineBox::Baseline::setAscentIfGreater): Deleted.
diff --git a/Source/WebCore/layout/displaytree/DisplayRun.h b/Source/WebCore/layout/displaytree/DisplayRun.h
index c746c87..58a46af 100644
--- a/Source/WebCore/layout/displaytree/DisplayRun.h
+++ b/Source/WebCore/layout/displaytree/DisplayRun.h
@@ -29,6 +29,7 @@
#include "DisplayRect.h"
#include "LayoutUnit.h"
+#include "RenderStyle.h"
namespace WebCore {
namespace Display {
@@ -38,22 +39,23 @@
struct TextContext {
WTF_MAKE_STRUCT_FAST_ALLOCATED;
public:
- TextContext(unsigned position, unsigned length);
+ TextContext(unsigned position, unsigned length, String content);
unsigned start() const { return m_start; }
unsigned end() const { return start() + length(); }
unsigned length() const { return m_length; }
+ String content() const { return m_content; }
- void expand(unsigned length) { m_length += length; }
+ void expand(const TextContext& other);
private:
unsigned m_start;
unsigned m_length;
+ // FIXME: This is temporary. We should have some mapping setup to identify associated text content instead.
+ String m_content;
};
- Run(Rect logicalRect);
- Run(Rect logicalRect, TextContext);
- Run(const Run&);
+ Run(const RenderStyle&, Rect logicalRect, Optional<TextContext> = WTF::nullopt);
const Rect& logicalRect() const { return m_logicalRect; }
@@ -79,32 +81,33 @@
Optional<TextContext>& textContext() { return m_textContext; }
Optional<TextContext> textContext() const { return m_textContext; }
+ const RenderStyle& style() const { return m_style; }
+
private:
+ // FIXME: Find out the Display::Run <-> paint style setup.
+ const RenderStyle& m_style;
Rect m_logicalRect;
Optional<TextContext> m_textContext;
};
-inline Run::Run(Rect logicalRect)
- : m_logicalRect(logicalRect)
-{
-}
-
-inline Run::Run(Rect logicalRect, TextContext textContext)
- : m_logicalRect(logicalRect)
+inline Run::Run(const RenderStyle& style, Rect logicalRect, Optional<TextContext> textContext)
+ : m_style(style)
+ , m_logicalRect(logicalRect)
, m_textContext(textContext)
{
}
-inline Run::TextContext::TextContext(unsigned start, unsigned length)
+inline Run::TextContext::TextContext(unsigned start, unsigned length, String content)
: m_start(start)
, m_length(length)
+ , m_content(content)
{
}
-inline Run::Run(const Run& other)
+inline void Run::TextContext::expand(const TextContext& other)
{
- m_logicalRect = other.m_logicalRect;
- m_textContext = other.m_textContext;
+ m_content.append(other.content());
+ m_length += other.length();
}
}
diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.cpp b/Source/WebCore/layout/inlineformatting/InlineLine.cpp
index b819ff7..c1f7150 100644
--- a/Source/WebCore/layout/inlineformatting/InlineLine.cpp
+++ b/Source/WebCore/layout/inlineformatting/InlineLine.cpp
@@ -299,7 +299,7 @@
void Line::appendNonBreakableSpace(const InlineItem& inlineItem, const Display::Rect& logicalRect)
{
- m_runList.append(makeUnique<Run>(inlineItem, Display::Run { logicalRect }));
+ m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect }));
m_lineBox.expandHorizontally(logicalRect.width());
}
@@ -359,7 +359,10 @@
logicalRect.setHeight(inlineItemContentHeight(inlineItem));
}
- auto lineItem = makeUnique<Run>(inlineItem, Display::Run { logicalRect, Display::Run::TextContext { inlineItem.start(), inlineItem.isCollapsed() ? 1 : inlineItem.length() } });
+ auto contentStart = inlineItem.start();
+ auto contentLength = inlineItem.isCollapsed() ? 1 : inlineItem.length();
+ auto textContent = inlineItem.layoutBox().textContent().substring(contentStart, contentLength);
+ auto lineItem = makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect, Display::Run::TextContext { contentStart, contentLength, textContent } });
auto isVisuallyEmpty = willCollapseCompletely();
if (isVisuallyEmpty)
lineItem->setVisuallyIsEmpty();
@@ -386,7 +389,7 @@
logicalRect.setHeight(runHeight);
}
- m_runList.append(makeUnique<Run>(inlineItem, Display::Run { logicalRect }));
+ m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect }));
m_lineBox.expandHorizontally(logicalWidth + horizontalMargin.start + horizontalMargin.end);
m_trimmableContent.clear();
}
@@ -406,7 +409,7 @@
adjustBaselineAndLineHeight(inlineItem);
logicalRect.setHeight(logicalHeight());
}
- m_runList.append(makeUnique<Run>(inlineItem, Display::Run { logicalRect }));
+ m_runList.append(makeUnique<Run>(inlineItem, Display::Run { inlineItem.style(), logicalRect }));
}
void Line::adjustBaselineAndLineHeight(const InlineItem& inlineItem)
diff --git a/Source/WebCore/layout/inlineformatting/InlineLine.h b/Source/WebCore/layout/inlineformatting/InlineLine.h
index 03b88a3..090532c 100644
--- a/Source/WebCore/layout/inlineformatting/InlineLine.h
+++ b/Source/WebCore/layout/inlineformatting/InlineLine.h
@@ -154,7 +154,7 @@
auto& otherDisplayRun = other.displayRun();
m_displayRun.expandHorizontally(otherDisplayRun.logicalWidth());
- m_displayRun.textContext()->expand(otherDisplayRun.textContext()->length());
+ m_displayRun.textContext()->expand(*otherDisplayRun.textContext());
}
}