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

Unified Diff: third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp

Issue 2124553002: Refine cull rect for SVGInlineTextBox painting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add boundsForDrawingRecorder; expose helper from InlineTextBoxPainter Created 4 years, 5 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 | « third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp
index 93f106836dfb6959eb96f3cbe10e6f858e91f1eb..71497f19b4e7d726b137fc59243de4674977f0d5 100644
--- a/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.cpp
@@ -38,6 +38,23 @@ bool SVGInlineTextBoxPainter::shouldPaintSelection(const PaintInfo& paintInfo) c
return !paintInfo.isPrinting() && m_svgInlineTextBox.getSelectionState() != SelectionNone;
}
+FloatRect SVGInlineTextBoxPainter::boundsForDrawingRecorder(
+ const LayoutPoint& paintOffset, bool includeSelectionRect) const
+{
+ // We compute the paint rect with what looks like the logical values, to match the
+ // computation in SVGInlineTextBox::calculateBoundaries, and the fact that vertical (etc)
+ // layouts are handled by SVGTextLayoutEngine.
+ LayoutRect bounds(
+ m_svgInlineTextBox.topLeft(),
+ LayoutSize(m_svgInlineTextBox.logicalWidth(), m_svgInlineTextBox.logicalHeight()));
+ if (includeSelectionRect) {
+ bounds.unite(m_svgInlineTextBox.localSelectionRect(
+ m_svgInlineTextBox.start(), m_svgInlineTextBox.start() + m_svgInlineTextBox.len()));
+ }
+ bounds.moveBy(paintOffset);
+ return FloatRect(bounds);
+}
+
void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint& paintOffset)
{
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
@@ -49,7 +66,8 @@ void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
// We're explicitly not supporting composition & custom underlines and custom highlighters -- unlike InlineTextBox.
// If we ever need that for SVG, it's very easy to refactor and reuse the code.
- if (paintInfo.phase == PaintPhaseSelection && !shouldPaintSelection(paintInfo))
+ bool haveSelection = shouldPaintSelection(paintInfo);
+ if (!haveSelection && paintInfo.phase == PaintPhaseSelection)
return;
LayoutSVGInlineText& textLayoutObject = toLayoutSVGInlineText(*LineLayoutAPIShim::layoutObjectFrom(m_svgInlineTextBox.getLineLayoutItem()));
@@ -61,8 +79,10 @@ void SVGInlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoin
LayoutObject& parentLayoutObject = *LineLayoutAPIShim::layoutObjectFrom(m_svgInlineTextBox.parent()->getLineLayoutItem());
const ComputedStyle& style = parentLayoutObject.styleRef();
- // TODO(chrishtr): passing the cull rect is incorrect.
- DrawingRecorder recorder(paintInfo.context, m_svgInlineTextBox, displayItemType, FloatRect(paintInfo.cullRect().m_rect));
+ bool includeSelectionRect = paintInfo.phase != PaintPhaseSelection
+ && (haveSelection || InlineTextBoxPainter::paintsMarkerHighlights(textLayoutObject));
+ DrawingRecorder recorder(paintInfo.context, m_svgInlineTextBox, displayItemType,
+ boundsForDrawingRecorder(paintOffset, includeSelectionRect));
InlineTextBoxPainter(m_svgInlineTextBox).paintDocumentMarkers(
paintInfo, paintOffset, style,
textLayoutObject.scaledFont(), DocumentMarkerPaintPhase::Background);
« no previous file with comments | « third_party/WebKit/Source/core/paint/SVGInlineTextBoxPainter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698