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

Unified Diff: Source/core/rendering/svg/SVGInlineTextBox.cpp

Issue 184023003: Make InlineBox::renderer() and related subclass methods return reference. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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
Index: Source/core/rendering/svg/SVGInlineTextBox.cpp
diff --git a/Source/core/rendering/svg/SVGInlineTextBox.cpp b/Source/core/rendering/svg/SVGInlineTextBox.cpp
index 64f6fc7b7df9b86bfa5f00d713d52673780efb26..dd2254a83e4cbc9624198cebc56e7dc3cd28500c 100644
--- a/Source/core/rendering/svg/SVGInlineTextBox.cpp
+++ b/Source/core/rendering/svg/SVGInlineTextBox.cpp
@@ -55,7 +55,7 @@ struct ExpectedSVGInlineTextBoxSize : public InlineTextBox {
COMPILE_ASSERT(sizeof(SVGInlineTextBox) == sizeof(ExpectedSVGInlineTextBoxSize), SVGInlineTextBox_is_not_of_expected_size);
-SVGInlineTextBox::SVGInlineTextBox(RenderObject* object)
+SVGInlineTextBox::SVGInlineTextBox(RenderObject& object)
: InlineTextBox(object)
, m_logicalHeight(0)
, m_paintingResourceMode(ApplyToDefaultMode)
@@ -88,8 +88,7 @@ int SVGInlineTextBox::offsetForPosition(float, bool) const
int SVGInlineTextBox::offsetForPositionInFragment(const SVGTextFragment& fragment, float position, bool includePartialGlyphs) const
{
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
Inactive 2014/02/28 02:28:19 RenderSVGInlineText& textRenderer = toRenderSVGInl
ostap 2014/02/28 08:29:14 Done.
float scalingFactor = textRenderer->scalingFactor();
ASSERT(scalingFactor);
@@ -123,8 +122,7 @@ FloatRect SVGInlineTextBox::selectionRectForTextFragment(const SVGTextFragment&
FontCachePurgePreventer fontCachePurgePreventer;
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
Inactive 2014/02/28 02:28:19 RenderSVGInlineText& textRenderer = toRenderSVGInl
ostap 2014/02/28 08:29:14 Done.
float scalingFactor = textRenderer->scalingFactor();
ASSERT(scalingFactor);
@@ -153,10 +151,7 @@ LayoutRect SVGInlineTextBox::localSelectionRect(int startPosition, int endPositi
if (startPosition >= endPosition)
return LayoutRect();
- RenderText* text = textRenderer();
- ASSERT(text);
-
- RenderStyle* style = text->style();
+ RenderStyle* style = textRenderer().style();
ASSERT(style);
AffineTransform fragmentTransform;
@@ -192,16 +187,15 @@ static inline bool textShouldBePainted(RenderSVGInlineText* textRenderer)
void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
{
- ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
+ ASSERT(paintInfo.shouldPaintWithinRoot(&renderer()));
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
ASSERT(truncation() == cNoTruncation);
- if (renderer()->style()->visibility() != VISIBLE)
+ if (renderer().style()->visibility() != VISIBLE)
return;
- RenderObject* parentRenderer = parent()->renderer();
- ASSERT(parentRenderer);
- ASSERT(!parentRenderer->document().printing());
+ RenderObject& parentRenderer = parent()->renderer();
+ ASSERT(!parentRenderer.document().printing());
// Determine whether or not we're selected.
bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
@@ -209,16 +203,15 @@ void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
if (!hasSelection || paintSelectedTextOnly)
return;
- Color backgroundColor = renderer()->selectionBackgroundColor();
+ Color backgroundColor = renderer().selectionBackgroundColor();
if (!backgroundColor.alpha())
return;
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
if (!textShouldBePainted(textRenderer))
return;
- RenderStyle* style = parentRenderer->style();
+ RenderStyle* style = parentRenderer.style();
ASSERT(style);
int startPosition, endPosition;
@@ -253,30 +246,28 @@ void SVGInlineTextBox::paintSelectionBackground(PaintInfo& paintInfo)
void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffset, LayoutUnit, LayoutUnit)
{
- ASSERT(paintInfo.shouldPaintWithinRoot(renderer()));
+ ASSERT(paintInfo.shouldPaintWithinRoot(&renderer()));
ASSERT(paintInfo.phase == PaintPhaseForeground || paintInfo.phase == PaintPhaseSelection);
ASSERT(truncation() == cNoTruncation);
- if (renderer()->style()->visibility() != VISIBLE)
+ if (renderer().style()->visibility() != VISIBLE)
return;
// Note: We're explicitely 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.
- RenderObject* parentRenderer = parent()->renderer();
- ASSERT(parentRenderer);
+ RenderObject& parentRenderer = parent()->renderer();
bool paintSelectedTextOnly = paintInfo.phase == PaintPhaseSelection;
- bool hasSelection = !parentRenderer->document().printing() && selectionState() != RenderObject::SelectionNone;
+ bool hasSelection = !parentRenderer.document().printing() && selectionState() != RenderObject::SelectionNone;
if (!hasSelection && paintSelectedTextOnly)
return;
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
Inactive 2014/02/28 02:28:19 RenderSVGInlineText& textRenderer = toRenderSVGInl
ostap 2014/02/28 08:29:14 Done.
if (!textShouldBePainted(textRenderer))
return;
- RenderStyle* style = parentRenderer->style();
+ RenderStyle* style = parentRenderer.style();
ASSERT(style);
paintDocumentMarkers(paintInfo.context, paintOffset, style, textRenderer->scaledFont(), true);
@@ -289,7 +280,7 @@ void SVGInlineTextBox::paint(PaintInfo& paintInfo, const LayoutPoint& paintOffse
RenderStyle* selectionStyle = style;
if (hasSelection) {
- selectionStyle = parentRenderer->getCachedPseudoStyle(SELECTION);
+ selectionStyle = parentRenderer.getCachedPseudoStyle(SELECTION);
if (selectionStyle) {
const SVGRenderStyle* svgSelectionStyle = selectionStyle->svgStyle();
ASSERT(svgSelectionStyle);
@@ -400,16 +391,13 @@ void SVGInlineTextBox::releasePaintingResource(GraphicsContext*& context, const
{
ASSERT(m_paintingResource);
- RenderObject* parentRenderer = parent()->renderer();
- ASSERT(parentRenderer);
-
- m_paintingResource->postApplyResource(parentRenderer, context, m_paintingResourceMode, path, /*RenderSVGShape*/ 0);
+ m_paintingResource->postApplyResource(&parent()->renderer(), context, m_paintingResourceMode, path, /*RenderSVGShape*/ 0);
m_paintingResource = 0;
}
bool SVGInlineTextBox::prepareGraphicsContextForTextPainting(GraphicsContext*& context, float scalingFactor, TextRun& textRun, RenderStyle* style)
{
- bool acquiredResource = acquirePaintingResource(context, scalingFactor, parent()->renderer(), style);
+ bool acquiredResource = acquirePaintingResource(context, scalingFactor, &parent()->renderer(), style);
if (!acquiredResource)
return false;
@@ -437,10 +425,8 @@ void SVGInlineTextBox::restoreGraphicsContextAfterTextPainting(GraphicsContext*&
TextRun SVGInlineTextBox::constructTextRun(RenderStyle* style, const SVGTextFragment& fragment) const
{
ASSERT(style);
- ASSERT(textRenderer());
- RenderText* text = textRenderer();
- ASSERT(text);
+ RenderText* text = &textRenderer();
Inactive 2014/02/28 02:28:19 RenderText& text = textRenderer();
ostap 2014/02/28 08:29:14 Done.
// FIXME(crbug.com/264211): This should not be necessary but can occur if we
// layout during layout. Remove this when 264211 is fixed.
@@ -529,7 +515,7 @@ static inline RenderObject* findRenderObjectDefininingTextDecoration(InlineFlowB
// Lookup first render object in parent hierarchy which has text-decoration set.
RenderObject* renderer = 0;
while (parentBox) {
- renderer = parentBox->renderer();
+ renderer = &parentBox->renderer();
if (renderer->style() && renderer->style()->textDecoration() != TextDecorationNone)
break;
@@ -543,7 +529,7 @@ static inline RenderObject* findRenderObjectDefininingTextDecoration(InlineFlowB
void SVGInlineTextBox::paintDecoration(GraphicsContext* context, TextDecoration decoration, const SVGTextFragment& fragment)
{
- if (textRenderer()->style()->textDecorationsInEffect() == TextDecorationNone)
+ if (textRenderer().style()->textDecorationsInEffect() == TextDecorationNone)
return;
// Find out which render style defined the text-decoration, as its fill/stroke properties have to be used for drawing instead of ours.
@@ -615,8 +601,7 @@ void SVGInlineTextBox::paintDecorationWithStyle(GraphicsContext* context, TextDe
void SVGInlineTextBox::paintTextWithShadows(GraphicsContext* context, RenderStyle* style, TextRun& textRun, const SVGTextFragment& fragment, int startPosition, int endPosition)
{
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
Inactive 2014/02/28 02:28:19 RenderSVGInlineText& textRenderer = toRenderSVGInl
ostap 2014/02/28 08:29:14 Done.
float scalingFactor = textRenderer->scalingFactor();
ASSERT(scalingFactor);
@@ -689,13 +674,13 @@ void SVGInlineTextBox::paintText(GraphicsContext* context, RenderStyle* style, R
// Draw text using selection style from the start to the end position of the selection
if (style != selectionStyle)
- SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, selectionStyle);
+ SVGResourcesCache::clientStyleChanged(&parent()->renderer(), StyleDifferenceRepaint, selectionStyle);
TextRun selectionTextRun = constructTextRun(selectionStyle, fragment);
paintTextWithShadows(context, selectionStyle, textRun, fragment, startPosition, endPosition);
if (style != selectionStyle)
- SVGResourcesCache::clientStyleChanged(parent()->renderer(), StyleDifferenceRepaint, style);
+ SVGResourcesCache::clientStyleChanged(&parent()->renderer(), StyleDifferenceRepaint, style);
// Eventually draw text using regular style from the end position of the selection to the end of the current chunk part
if (endPosition < static_cast<int>(fragment.length) && !paintSelectedTextOnly)
@@ -713,8 +698,7 @@ void SVGInlineTextBox::paintTextMatchMarker(GraphicsContext* context, const Floa
if (marker->type() != DocumentMarker::TextMatch)
return;
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
Inactive 2014/02/28 02:28:19 RenderSVGInlineText& textRenderer = toRenderSVGInl
ostap 2014/02/28 08:29:14 Done.
FloatRect markerRect;
AffineTransform fragmentTransform;
@@ -744,7 +728,7 @@ void SVGInlineTextBox::paintTextMatchMarker(GraphicsContext* context, const Floa
fragment.buildFragmentTransform(fragmentTransform);
// Draw the marker highlight.
- if (renderer()->frame()->editor().markedTextMatchesAreHighlighted()) {
+ if (renderer().frame()->editor().markedTextMatchesAreHighlighted()) {
Color color = marker->activeMatch() ?
RenderTheme::theme().platformActiveTextSearchHighlightColor() :
RenderTheme::theme().platformInactiveTextSearchHighlightColor();
@@ -767,8 +751,7 @@ FloatRect SVGInlineTextBox::calculateBoundaries() const
{
FloatRect textRect;
- RenderSVGInlineText* textRenderer = toRenderSVGInlineText(this->textRenderer());
- ASSERT(textRenderer);
+ RenderSVGInlineText* textRenderer = &toRenderSVGInlineText(this->textRenderer());
Inactive 2014/02/28 02:28:19 RenderSVGInlineText& textRenderer = toRenderSVGInl
ostap 2014/02/28 08:29:14 Done.
float scalingFactor = textRenderer->scalingFactor();
ASSERT(scalingFactor);
@@ -794,18 +777,18 @@ bool SVGInlineTextBox::nodeAtPoint(const HitTestRequest& request, HitTestResult&
// FIXME: integrate with InlineTextBox::nodeAtPoint better.
ASSERT(!isLineBreak());
- PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, request, renderer()->style()->pointerEvents());
- bool isVisible = renderer()->style()->visibility() == VISIBLE;
+ PointerEventsHitRules hitRules(PointerEventsHitRules::SVG_TEXT_HITTESTING, request, renderer().style()->pointerEvents());
+ bool isVisible = renderer().style()->visibility() == VISIBLE;
if (isVisible || !hitRules.requireVisible) {
if (hitRules.canHitBoundingBox
- || (hitRules.canHitStroke && (renderer()->style()->svgStyle()->hasStroke() || !hitRules.requireStroke))
- || (hitRules.canHitFill && (renderer()->style()->svgStyle()->hasFill() || !hitRules.requireFill))) {
+ || (hitRules.canHitStroke && (renderer().style()->svgStyle()->hasStroke() || !hitRules.requireStroke))
+ || (hitRules.canHitFill && (renderer().style()->svgStyle()->hasFill() || !hitRules.requireFill))) {
FloatPoint boxOrigin(x(), y());
boxOrigin.moveBy(accumulatedOffset);
FloatRect rect(boxOrigin, size());
if (locationInContainer.intersects(rect)) {
- renderer()->updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
- if (!result.addNodeToRectBasedTestResult(renderer()->node(), request, locationInContainer, rect))
+ renderer().updateHitTestResult(result, locationInContainer.point() - toLayoutSize(accumulatedOffset));
+ if (!result.addNodeToRectBasedTestResult(renderer().node(), request, locationInContainer, rect))
return true;
}
}

Powered by Google App Engine
This is Rietveld 408576698