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

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: fixed build on win and mac Created 7 years, 7 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 | « Source/core/rendering/RenderFileUploadControl.cpp ('k') | Source/core/rendering/RenderListBox.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderImage.cpp
diff --git a/Source/core/rendering/RenderImage.cpp b/Source/core/rendering/RenderImage.cpp
index df2aa0a6b800ff5575825b117a7121d2a6549f30..f056ce0b73a9417a3e0689bea9fa42886a1916f4 100644
--- a/Source/core/rendering/RenderImage.cpp
+++ b/Source/core/rendering/RenderImage.cpp
@@ -334,22 +334,25 @@ void RenderImage::paintReplaced(PaintInfo& paintInfo, const LayoutPoint& paintOf
if (!m_altText.isEmpty()) {
String text = document()->displayStringModifiedByEncoding(m_altText);
- context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
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);
+ TextRunPaintInfo textRunPaintInfo(textRun);
+ textRunPaintInfo.bounds = FloatRect(textRectOrigin, FloatSize(textWidth, fontMetrics.height()));
+ context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
if (errorPictureDrawn) {
if (usableWidth >= textWidth && fontMetrics.height() <= imageOffset.height())
- context->drawText(font, textRun, altTextOffset);
+ context->drawText(font, textRunPaintInfo, textOrigin);
} else if (usableWidth >= textWidth && usableHeight >= fontMetrics.height())
- context->drawText(font, textRun, altTextOffset);
+ context->drawText(font, textRunPaintInfo, textOrigin);
}
}
} else if (m_imageResource->hasImage() && cWidth > 0 && cHeight > 0) {
« no previous file with comments | « Source/core/rendering/RenderFileUploadControl.cpp ('k') | Source/core/rendering/RenderListBox.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698