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

Unified Diff: Source/core/rendering/RenderImage.cpp

Issue 14160005: Track the region where text is painted. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase with TOT Created 7 years, 8 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/RenderImage.cpp
diff --git a/Source/core/rendering/RenderImage.cpp b/Source/core/rendering/RenderImage.cpp
index 60ead09bd296a5ef2f7db0ec1266ab95fc38963c..6d86bd57a0727bad28c77ff19b772da2dc634577 100644
--- a/Source/core/rendering/RenderImage.cpp
+++ b/Source/core/rendering/RenderImage.cpp
@@ -341,18 +341,20 @@ void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf
const Font& font = style()->font();
const FontMetrics& fontMetrics = font.fontMetrics();
LayoutUnit ascent = fontMetrics.ascent();
- LayoutPoint altTextOffset = paintOffset;
- altTextOffset.move(leftBorder + leftPad + (paddingWidth / 2) - borderWidth, topBorder + topPad + ascent + (paddingHeight / 2) - borderWidth);
+ LayoutPoint textRectOrigin = paintOffset;
+ textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) - borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth);
+ LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() + ascent);
// Only draw the alt text if it'll fit within the content box,
// and only if it fits above the error image.
TextRun textRun = RenderBlock::constructTextRun(this, font, text, style());
LayoutUnit textWidth = font.width(textRun);
+ FloatRect textRect(textRectOrigin, FloatSize(textWidth, fontMetrics.height()));
if (errorPictureDrawn) {
if (usableWidth >= textWidth && fontMetrics.height() <= imageOffset.height())
- context->drawText(font, textRun, altTextOffset);
+ context->drawText(font, textRun, textOrigin, textRect);
} else if (usableWidth >= textWidth && usableHeight >= fontMetrics.height())
- context->drawText(font, textRun, altTextOffset);
+ context->drawText(font, textRun, textOrigin, textRect);
}
}
} else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) {

Powered by Google App Engine
This is Rietveld 408576698