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, 2013 Intel Corporation. All rights reserved. | 8 * Copyright (C) 2012, 2013 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 1875 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1886 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y) | 1886 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y) |
1887 { | 1887 { |
1888 drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType)
; | 1888 drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType)
; |
1889 } | 1889 } |
1890 | 1890 |
1891 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y,
float maxWidth) | 1891 void CanvasRenderingContext2D::strokeText(const String& text, float x, float y,
float maxWidth) |
1892 { | 1892 { |
1893 drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType,
&maxWidth); | 1893 drawTextInternal(text, x, y, CanvasRenderingContext2DState::StrokePaintType,
&maxWidth); |
1894 } | 1894 } |
1895 | 1895 |
1896 PassRefPtrWillBeRawPtr<TextMetrics> CanvasRenderingContext2D::measureText(const
String& text) | 1896 TextMetrics* CanvasRenderingContext2D::measureText(const String& text) |
1897 { | 1897 { |
1898 RefPtrWillBeRawPtr<TextMetrics> metrics = TextMetrics::create(); | 1898 TextMetrics* metrics = TextMetrics::create(); |
1899 | 1899 |
1900 // The style resolution required for rendering text is not available in fram
e-less documents. | 1900 // The style resolution required for rendering text is not available in fram
e-less documents. |
1901 if (!canvas()->document().frame()) | 1901 if (!canvas()->document().frame()) |
1902 return metrics.release(); | 1902 return metrics; |
1903 | 1903 |
1904 canvas()->document().updateLayoutTreeForNodeIfNeeded(canvas()); | 1904 canvas()->document().updateLayoutTreeForNodeIfNeeded(canvas()); |
1905 const Font& font = accessFont(); | 1905 const Font& font = accessFont(); |
1906 | 1906 |
1907 TextDirection direction; | 1907 TextDirection direction; |
1908 if (state().direction() == CanvasRenderingContext2DState::DirectionInherit) | 1908 if (state().direction() == CanvasRenderingContext2DState::DirectionInherit) |
1909 direction = determineDirectionality(text); | 1909 direction = determineDirectionality(text); |
1910 else | 1910 else |
1911 direction = toTextDirection(state().direction(), canvas()); | 1911 direction = toTextDirection(state().direction(), canvas()); |
1912 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion | TextRun::Forbi
dLeadingExpansion, direction, false); | 1912 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion | TextRun::Forbi
dLeadingExpansion, direction, false); |
(...skipping 17 matching lines...) Expand all Loading... |
1930 metrics->setActualBoundingBoxDescent(textBounds.maxY() + baselineY); | 1930 metrics->setActualBoundingBoxDescent(textBounds.maxY() + baselineY); |
1931 | 1931 |
1932 // Note : top/bottom and ascend/descend are currently the same, so there's n
o difference | 1932 // Note : top/bottom and ascend/descend are currently the same, so there's n
o difference |
1933 // between the EM box's top and bottom and the font's ascend and desc
end | 1933 // between the EM box's top and bottom and the font's ascend and desc
end |
1934 metrics->setEmHeightAscent(0); | 1934 metrics->setEmHeightAscent(0); |
1935 metrics->setEmHeightDescent(0); | 1935 metrics->setEmHeightDescent(0); |
1936 | 1936 |
1937 metrics->setHangingBaseline(-0.8f * ascent + baselineY); | 1937 metrics->setHangingBaseline(-0.8f * ascent + baselineY); |
1938 metrics->setAlphabeticBaseline(baselineY); | 1938 metrics->setAlphabeticBaseline(baselineY); |
1939 metrics->setIdeographicBaseline(descent + baselineY); | 1939 metrics->setIdeographicBaseline(descent + baselineY); |
1940 return metrics.release(); | 1940 return metrics; |
1941 } | 1941 } |
1942 | 1942 |
1943 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
at y, CanvasRenderingContext2DState::PaintType paintType, float* maxWidth) | 1943 void CanvasRenderingContext2D::drawTextInternal(const String& text, float x, flo
at y, CanvasRenderingContext2DState::PaintType paintType, float* maxWidth) |
1944 { | 1944 { |
1945 // The style resolution required for rendering text is not available in fram
e-less documents. | 1945 // The style resolution required for rendering text is not available in fram
e-less documents. |
1946 if (!canvas()->document().frame()) | 1946 if (!canvas()->document().frame()) |
1947 return; | 1947 return; |
1948 | 1948 |
1949 // accessFont needs the style to be up to date, but updating style can cause
script to run, | 1949 // accessFont needs the style to be up to date, but updating style can cause
script to run, |
1950 // (e.g. due to autofocus) which can free the canvas (set size to 0, for exa
mple), so update | 1950 // (e.g. due to autofocus) which can free the canvas (set size to 0, for exa
mple), so update |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2320 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) | 2320 if (imageType == CanvasRenderingContext2DState::NonOpaqueImage) |
2321 return; | 2321 return; |
2322 if (alpha < 0xFF) | 2322 if (alpha < 0xFF) |
2323 return; | 2323 return; |
2324 } | 2324 } |
2325 | 2325 |
2326 canvas()->buffer()->willOverwriteCanvas(); | 2326 canvas()->buffer()->willOverwriteCanvas(); |
2327 } | 2327 } |
2328 | 2328 |
2329 } // namespace blink | 2329 } // namespace blink |
OLD | NEW |