| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Apple Inc.
All rights reserved. |
| 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) | 3 * Copyright (C) 2008, 2010 Nokia Corporation and/or its subsidiary(-ies) |
| 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> | 4 * Copyright (C) 2007 Alp Toker <alp@atoker.com> |
| 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> | 5 * Copyright (C) 2008 Eric Seidel <eric@webkit.org> |
| 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> | 6 * Copyright (C) 2008 Dirk Schulze <krit@webkit.org> |
| 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. | 7 * Copyright (C) 2010 Torch Mobile (Beijing) Co. Ltd. All rights reserved. |
| 8 * Copyright (C) 2012 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012 Intel Corporation. All rights reserved. |
| 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 9 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
| 10 * | 10 * |
| (...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2184 location.setX(location.x() - width / 2); | 2184 location.setX(location.x() - width / 2); |
| 2185 break; | 2185 break; |
| 2186 case RightTextAlign: | 2186 case RightTextAlign: |
| 2187 location.setX(location.x() - width); | 2187 location.setX(location.x() - width); |
| 2188 break; | 2188 break; |
| 2189 default: | 2189 default: |
| 2190 break; | 2190 break; |
| 2191 } | 2191 } |
| 2192 | 2192 |
| 2193 // The slop built in to this mask rect matches the heuristic used in FontCGW
in.cpp for GDI text. | 2193 // The slop built in to this mask rect matches the heuristic used in FontCGW
in.cpp for GDI text. |
| 2194 FloatRect textRect = FloatRect(location.x() - fontMetrics.height() / 2, loca
tion.y() - fontMetrics.ascent() - fontMetrics.lineGap(), | 2194 TextRunPaintInfo textRunPaintInfo(textRun); |
| 2195 width + fontMetrics.height(), fontMetrics.lin
eSpacing()); | 2195 textRunPaintInfo.bounds = FloatRect(location.x() - fontMetrics.height() / 2, |
| 2196 location.y() - fontMetrics.ascent() - fo
ntMetrics.lineGap(), |
| 2197 width + fontMetrics.height(), |
| 2198 fontMetrics.lineSpacing()); |
| 2196 if (!fill) | 2199 if (!fill) |
| 2197 inflateStrokeRect(textRect); | 2200 inflateStrokeRect(textRunPaintInfo.bounds); |
| 2198 | 2201 |
| 2199 c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke); | 2202 c->setTextDrawingMode(fill ? TextModeFill : TextModeStroke); |
| 2200 if (useMaxWidth) { | 2203 if (useMaxWidth) { |
| 2201 GraphicsContextStateSaver stateSaver(*c); | 2204 GraphicsContextStateSaver stateSaver(*c); |
| 2202 c->translate(location.x(), location.y()); | 2205 c->translate(location.x(), location.y()); |
| 2203 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o
p) still work. | 2206 // We draw when fontWidth is 0 so compositing operations (eg, a "copy" o
p) still work. |
| 2204 c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); | 2207 c->scale(FloatSize((fontWidth > 0 ? (width / fontWidth) : 0), 1)); |
| 2205 c->drawBidiText(font, textRun, FloatPoint(0, 0), Font::UseFallbackIfFont
NotReady); | 2208 c->drawBidiText(font, textRunPaintInfo, FloatPoint(0, 0), Font::UseFallb
ackIfFontNotReady); |
| 2206 } else | 2209 } else |
| 2207 c->drawBidiText(font, textRun, location, Font::UseFallbackIfFontNotReady
); | 2210 c->drawBidiText(font, textRunPaintInfo, location, Font::UseFallbackIfFon
tNotReady); |
| 2208 | 2211 |
| 2209 didDraw(textRect); | 2212 didDraw(textRunPaintInfo.bounds); |
| 2210 } | 2213 } |
| 2211 | 2214 |
| 2212 void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const | 2215 void CanvasRenderingContext2D::inflateStrokeRect(FloatRect& rect) const |
| 2213 { | 2216 { |
| 2214 // Fast approximation of the stroke's bounding rect. | 2217 // Fast approximation of the stroke's bounding rect. |
| 2215 // This yields a slightly oversized rect but is very fast | 2218 // This yields a slightly oversized rect but is very fast |
| 2216 // compared to Path::strokeBoundingRect(). | 2219 // compared to Path::strokeBoundingRect(). |
| 2217 static const float root2 = sqrtf(2); | 2220 static const float root2 = sqrtf(2); |
| 2218 float delta = state().m_lineWidth / 2; | 2221 float delta = state().m_lineWidth / 2; |
| 2219 if (state().m_lineJoin == MiterJoin) | 2222 if (state().m_lineJoin == MiterJoin) |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 } | 2259 } |
| 2257 | 2260 |
| 2258 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib
utes() const | 2261 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib
utes() const |
| 2259 { | 2262 { |
| 2260 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr
eate(); | 2263 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr
eate(); |
| 2261 attributes->setAlpha(m_hasAlpha); | 2264 attributes->setAlpha(m_hasAlpha); |
| 2262 return attributes.release(); | 2265 return attributes.release(); |
| 2263 } | 2266 } |
| 2264 | 2267 |
| 2265 } // namespace WebCore | 2268 } // namespace WebCore |
| OLD | NEW |