Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1183)

Unified Diff: Source/core/paint/InlineTextBoxPainter.cpp

Issue 672713002: [TextBlob] Permit drawing selected text from cache, if possible. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/paint/InlineTextBoxPainter.cpp
diff --git a/Source/core/paint/InlineTextBoxPainter.cpp b/Source/core/paint/InlineTextBoxPainter.cpp
index 47e6345165fb86b6725d3c2e5cf4f02931a02426..483b6e879e5f6b242c62b84663dec6a11b5da00c 100644
--- a/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/Source/core/paint/InlineTextBoxPainter.cpp
@@ -33,6 +33,13 @@ void InlineTextBoxPainter::removeFromTextBlobCache(InlineTextBox& inlineTextBox)
gTextBlobCache->remove(&inlineTextBox);
}
+static TextBlobPtr* addToTextBlobCache(InlineTextBox& inlineTextBox)
+{
+ if (!gTextBlobCache)
+ gTextBlobCache = new InlineTextBoxBlobCacheMap;
+ return &gTextBlobCache->add(&inlineTextBox, nullptr).storedValue->value;
+}
+
void InlineTextBoxPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
if (m_inlineTextBox.isLineBreak() || !paintInfo.shouldPaintWithinRoot(&m_inlineTextBox.renderer()) || m_inlineTextBox.renderer().style()->visibility() != VISIBLE
@@ -187,17 +194,18 @@ void InlineTextBoxPainter::paint(PaintInfo& paintInfo, const LayoutPoint& paintO
// RuntimeEnabledFeature is off.
bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && startOffset == 0 && endOffset == length;
TextBlobPtr* cachedTextBlob = 0;
- if (textBlobIsCacheable) {
- if (!gTextBlobCache)
- gTextBlobCache = new InlineTextBoxBlobCacheMap;
- cachedTextBlob = &gTextBlobCache->add(&m_inlineTextBox, nullptr).storedValue->value;
- }
+ if (textBlobIsCacheable)
+ cachedTextBlob = addToTextBlobCache(m_inlineTextBox);
textPainter.paint(startOffset, endOffset, length, textStyle, cachedTextBlob);
}
if ((paintSelectedTextOnly || paintSelectedTextSeparately) && selectionStart < selectionEnd) {
// paint only the text that is selected
- textPainter.paint(selectionStart, selectionEnd, length, selectionStyle);
+ bool textBlobIsCacheable = RuntimeEnabledFeatures::textBlobEnabled() && selectionStart == 0 && selectionEnd == length;
+ TextBlobPtr* cachedTextBlob = 0;
+ if (textBlobIsCacheable)
+ cachedTextBlob = addToTextBlobCache(m_inlineTextBox);
+ textPainter.paint(selectionStart, selectionEnd, length, selectionStyle, cachedTextBlob);
}
// Paint decorations
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698