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

Side by Side Diff: Source/core/rendering/RenderImage.cpp

Issue 397723006: Move RenderBlockFlow::constructTextRun out. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2000 Dirk Mueller (mueller@kde.org) 4 * (C) 2000 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com) 5 * (C) 2006 Allan Sandfeld Jensen (kde@carewolf.com)
6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 6 * (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 7 * Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
8 * Copyright (C) 2010 Google Inc. All rights reserved. 8 * Copyright (C) 2010 Google Inc. All rights reserved.
9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved. 9 * Copyright (C) Research In Motion Limited 2011-2012. All rights reserved.
10 * 10 *
(...skipping 25 matching lines...) Expand all
36 #include "core/frame/LocalFrame.h" 36 #include "core/frame/LocalFrame.h"
37 #include "core/html/HTMLAreaElement.h" 37 #include "core/html/HTMLAreaElement.h"
38 #include "core/html/HTMLImageElement.h" 38 #include "core/html/HTMLImageElement.h"
39 #include "core/html/HTMLInputElement.h" 39 #include "core/html/HTMLInputElement.h"
40 #include "core/html/HTMLMapElement.h" 40 #include "core/html/HTMLMapElement.h"
41 #include "core/inspector/InspectorInstrumentation.h" 41 #include "core/inspector/InspectorInstrumentation.h"
42 #include "core/inspector/InspectorTraceEvents.h" 42 #include "core/inspector/InspectorTraceEvents.h"
43 #include "core/rendering/HitTestResult.h" 43 #include "core/rendering/HitTestResult.h"
44 #include "core/rendering/PaintInfo.h" 44 #include "core/rendering/PaintInfo.h"
45 #include "core/rendering/RenderView.h" 45 #include "core/rendering/RenderView.h"
46 #include "core/rendering/TextRunConstructor.h"
46 #include "core/svg/graphics/SVGImage.h" 47 #include "core/svg/graphics/SVGImage.h"
47 #include "platform/fonts/Font.h" 48 #include "platform/fonts/Font.h"
48 #include "platform/fonts/FontCache.h" 49 #include "platform/fonts/FontCache.h"
49 #include "platform/graphics/GraphicsContext.h" 50 #include "platform/graphics/GraphicsContext.h"
50 #include "platform/graphics/GraphicsContextStateSaver.h" 51 #include "platform/graphics/GraphicsContextStateSaver.h"
51 52
52 namespace WebCore { 53 namespace WebCore {
53 54
54 float deviceScaleFactor(LocalFrame*); 55 float deviceScaleFactor(LocalFrame*);
55 56
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 else if (!m_altText.isEmpty() || newImage) { 124 else if (!m_altText.isEmpty() || newImage) {
124 // If we'll be displaying either text or an image, add a little padding. 125 // If we'll be displaying either text or an image, add a little padding.
125 imageSize = IntSize(paddingWidth, paddingHeight); 126 imageSize = IntSize(paddingWidth, paddingHeight);
126 } 127 }
127 128
128 // we have an alt and the user meant it (its not a text we invented) 129 // we have an alt and the user meant it (its not a text we invented)
129 if (!m_altText.isEmpty()) { 130 if (!m_altText.isEmpty()) {
130 FontCachePurgePreventer fontCachePurgePreventer; 131 FontCachePurgePreventer fontCachePurgePreventer;
131 132
132 const Font& font = style()->font(); 133 const Font& font = style()->font();
133 IntSize paddedTextSize(paddingWidth + std::min(ceilf(font.width(RenderBl ockFlow::constructTextRun(this, font, m_altText, style()))), maxAltTextWidth), p addingHeight + std::min(font.fontMetrics().height(), maxAltTextHeight)); 134 IntSize paddedTextSize(paddingWidth + std::min(ceilf(font.width(construc tTextRun(this, font, m_altText, style()))), maxAltTextWidth), paddingHeight + st d::min(font.fontMetrics().height(), maxAltTextHeight));
134 imageSize = imageSize.expandedTo(paddedTextSize); 135 imageSize = imageSize.expandedTo(paddedTextSize);
135 } 136 }
136 137
137 if (imageSize == intrinsicSize()) 138 if (imageSize == intrinsicSize())
138 return false; 139 return false;
139 140
140 setIntrinsicSize(imageSize); 141 setIntrinsicSize(imageSize);
141 return true; 142 return true;
142 } 143 }
143 144
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 if (!m_altText.isEmpty()) { 325 if (!m_altText.isEmpty()) {
325 const Font& font = style()->font(); 326 const Font& font = style()->font();
326 const FontMetrics& fontMetrics = font.fontMetrics(); 327 const FontMetrics& fontMetrics = font.fontMetrics();
327 LayoutUnit ascent = fontMetrics.ascent(); 328 LayoutUnit ascent = fontMetrics.ascent();
328 LayoutPoint textRectOrigin = paintOffset; 329 LayoutPoint textRectOrigin = paintOffset;
329 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) - borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth); 330 textRectOrigin.move(leftBorder + leftPad + (paddingWidth / 2) - borderWidth, topBorder + topPad + (paddingHeight / 2) - borderWidth);
330 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() + ascent); 331 LayoutPoint textOrigin(textRectOrigin.x(), textRectOrigin.y() + ascent);
331 332
332 // Only draw the alt text if it'll fit within the content box, 333 // Only draw the alt text if it'll fit within the content box,
333 // and only if it fits above the error image. 334 // and only if it fits above the error image.
334 TextRun textRun = RenderBlockFlow::constructTextRun(this, font, m_altText, style(), TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpa nsion, DefaultTextRunFlags | RespectDirection); 335 TextRun textRun = constructTextRun(this, font, m_altText, style( ), TextRun::AllowTrailingExpansion | TextRun::ForbidLeadingExpansion, DefaultTex tRunFlags | RespectDirection);
335 float textWidth = font.width(textRun); 336 float textWidth = font.width(textRun);
336 TextRunPaintInfo textRunPaintInfo(textRun); 337 TextRunPaintInfo textRunPaintInfo(textRun);
337 textRunPaintInfo.bounds = FloatRect(textRectOrigin, FloatSize(te xtWidth, fontMetrics.height())); 338 textRunPaintInfo.bounds = FloatRect(textRectOrigin, FloatSize(te xtWidth, fontMetrics.height()));
338 context->setFillColor(resolveColor(CSSPropertyColor)); 339 context->setFillColor(resolveColor(CSSPropertyColor));
339 if (textRun.direction() == RTL) { 340 if (textRun.direction() == RTL) {
340 int availableWidth = cWidth - static_cast<int>(paddingWidth) ; 341 int availableWidth = cWidth - static_cast<int>(paddingWidth) ;
341 textOrigin.move(availableWidth - ceilf(textWidth), 0); 342 textOrigin.move(availableWidth - ceilf(textWidth), 0);
342 } 343 }
343 if (errorPictureDrawn) { 344 if (errorPictureDrawn) {
344 if (usableWidth >= textWidth && fontMetrics.height() <= imag eOffset.height()) 345 if (usableWidth >= textWidth && fontMetrics.height() <= imag eOffset.height())
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 return 0; 622 return 0;
622 623
623 ImageResource* cachedImage = m_imageResource->cachedImage(); 624 ImageResource* cachedImage = m_imageResource->cachedImage();
624 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( )) 625 if (cachedImage && cachedImage->image() && cachedImage->image()->isSVGImage( ))
625 return toSVGImage(cachedImage->image())->embeddedContentBox(); 626 return toSVGImage(cachedImage->image())->embeddedContentBox();
626 627
627 return 0; 628 return 0;
628 } 629 }
629 630
630 } // namespace WebCore 631 } // namespace WebCore
OLDNEW
« 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