Modified: trunk/Source/WebCore/ChangeLog (252639 => 252640)
--- trunk/Source/WebCore/ChangeLog 2019-11-19 19:04:38 UTC (rev 252639)
+++ trunk/Source/WebCore/ChangeLog 2019-11-19 20:00:28 UTC (rev 252640)
@@ -1,3 +1,22 @@
+2019-11-19 Zalan Bujtas <[email protected]>
+
+ [LFC][IFC] Display::Run:TextContext should use StringView
+ https://bugs.webkit.org/show_bug.cgi?id=204356
+ <rdar://problem/57323695>
+
+ Reviewed by Antti Koivisto.
+
+ We could just use StringView instead of String here (though this is all temporary until We figure out the relationship
+ between the layout and the display trees e.g. how to reference content from the display tree).
+
+ * layout/displaytree/DisplayRun.h:
+ (WebCore::Display::Run::TextContext::TextContext):
+ (WebCore::Display::Run::TextContext::content const):
+ (WebCore::Display::Run::TextContext::expand):
+ * layout/inlineformatting/InlineLine.cpp:
+ (WebCore::Layout::Line::Run::expand):
+ (WebCore::Layout::Line::appendTextContent):
+
2019-11-19 Antti Koivisto <[email protected]>
Rename CSSDefaultStyleSheets to UserAgentStyle
Modified: trunk/Source/WebCore/layout/displaytree/DisplayRun.h (252639 => 252640)
--- trunk/Source/WebCore/layout/displaytree/DisplayRun.h 2019-11-19 19:04:38 UTC (rev 252639)
+++ trunk/Source/WebCore/layout/displaytree/DisplayRun.h 2019-11-19 20:00:28 UTC (rev 252640)
@@ -44,12 +44,12 @@
WTF_MAKE_STRUCT_FAST_ALLOCATED;
public:
struct ExpansionContext;
- TextContext(unsigned position, unsigned length, String content, Optional<ExpansionContext> = { });
+ TextContext(unsigned position, unsigned length, StringView content, Optional<ExpansionContext> = { });
unsigned start() const { return m_start; }
unsigned end() const { return start() + length(); }
unsigned length() const { return m_length; }
- String content() const { return m_content; }
+ StringView content() const { return m_content; }
struct ExpansionContext {
ExpansionBehavior behavior;
@@ -58,7 +58,7 @@
void setExpansion(ExpansionContext expansionContext) { m_expansionContext = expansionContext; }
Optional<ExpansionContext> expansion() const { return m_expansionContext; }
- void expand(const TextContext& other);
+ void expand(StringView, unsigned expandedLength);
private:
unsigned m_start { 0 };
@@ -65,7 +65,7 @@
unsigned m_length { 0 };
Optional<ExpansionContext> m_expansionContext;
// FIXME: This is temporary. We should have some mapping setup to identify associated text content instead.
- String m_content;
+ StringView m_content;
};
Run(const RenderStyle&, const Rect& logicalRect, Optional<TextContext> = WTF::nullopt);
@@ -114,7 +114,7 @@
{
}
-inline Run::TextContext::TextContext(unsigned start, unsigned length, String content, Optional<ExpansionContext> expansionContext)
+inline Run::TextContext::TextContext(unsigned start, unsigned length, StringView content, Optional<ExpansionContext> expansionContext)
: m_start(start)
, m_length(length)
, m_expansionContext(expansionContext)
@@ -122,10 +122,10 @@
{
}
-inline void Run::TextContext::expand(const TextContext& other)
+inline void Run::TextContext::expand(StringView text, unsigned expandedLength)
{
- m_content.append(other.content());
- m_length += other.length();
+ m_length = expandedLength;
+ m_content = text;
}
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (252639 => 252640)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-11-19 19:04:38 UTC (rev 252639)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp 2019-11-19 20:00:28 UTC (rev 252640)
@@ -130,7 +130,8 @@
ASSERT(!isCollapsedToVisuallyEmpty());
m_logicalRect.expandHorizontally(nextRun.logicalRect().width());
- m_textContext->expand(*nextRun.textContext());
+ auto expandedLength = m_textContext->length() + nextRun.textContext()->length();
+ m_textContext->expand(StringView(layoutBox().textContent()).substring(m_textContext->start(), expandedLength), expandedLength);
// FIXME: This is a very simple expansion merge. We should eventually switch over to FontCascade::expansionOpportunityCount.
if (hasExpansionOpportunity() && nextRun.hasExpansionOpportunity()) {
@@ -548,8 +549,7 @@
auto collapsedRun = inlineItem.isCollapsible() && inlineItem.length() > 1;
auto contentStart = inlineItem.start();
auto contentLength = collapsedRun ? 1 : inlineItem.length();
- auto textContent = inlineItem.layoutBox().textContent().substring(contentStart, contentLength);
- auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, textContent });
+ auto lineRun = makeUnique<InlineItemRun>(inlineItem, logicalRect, Display::Run::TextContext { contentStart, contentLength, StringView(inlineItem.layoutBox().textContent()).substring(contentStart, contentLength) });
auto collapsesToZeroAdvanceWidth = willCollapseCompletely();
if (collapsesToZeroAdvanceWidth)