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 1829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1840 if (fontValue == "inherit" || fontValue == "initial") | 1840 if (fontValue == "inherit" || fontValue == "initial") |
1841 return; | 1841 return; |
1842 | 1842 |
1843 // The parse succeeded. | 1843 // The parse succeeded. |
1844 String newFontSafeCopy(newFont); // Create a string copy since newFont can b
e deleted inside realizeSaves. | 1844 String newFontSafeCopy(newFont); // Create a string copy since newFont can b
e deleted inside realizeSaves. |
1845 realizeSaves(nullptr); | 1845 realizeSaves(nullptr); |
1846 modifiableState().setUnparsedFont(newFontSafeCopy); | 1846 modifiableState().setUnparsedFont(newFontSafeCopy); |
1847 | 1847 |
1848 // Map the <canvas> font into the text style. If the font uses keywords like
larger/smaller, these will work | 1848 // Map the <canvas> font into the text style. If the font uses keywords like
larger/smaller, these will work |
1849 // relative to the canvas. | 1849 // relative to the canvas. |
1850 RefPtr<LayoutStyle> newStyle = LayoutStyle::create(); | 1850 RefPtr<ComputedStyle> newStyle = ComputedStyle::create(); |
1851 canvas()->document().updateRenderTreeIfNeeded(); | 1851 canvas()->document().updateRenderTreeIfNeeded(); |
1852 if (const LayoutStyle* computedStyle = canvas()->computedStyle()) { | 1852 if (const ComputedStyle* computedStyle = canvas()->ensureComputedStyle()) { |
1853 FontDescription elementFontDescription(computedStyle->fontDescription())
; | 1853 FontDescription elementFontDescription(computedStyle->fontDescription())
; |
1854 // Reset the computed size to avoid inheriting the zoom factor from the
<canvas> element. | 1854 // Reset the computed size to avoid inheriting the zoom factor from the
<canvas> element. |
1855 elementFontDescription.setComputedSize(elementFontDescription.specifiedS
ize()); | 1855 elementFontDescription.setComputedSize(elementFontDescription.specifiedS
ize()); |
1856 newStyle->setFontDescription(elementFontDescription); | 1856 newStyle->setFontDescription(elementFontDescription); |
1857 } else { | 1857 } else { |
1858 FontFamily fontFamily; | 1858 FontFamily fontFamily; |
1859 fontFamily.setFamily(defaultFontFamily); | 1859 fontFamily.setFamily(defaultFontFamily); |
1860 | 1860 |
1861 FontDescription defaultFontDescription; | 1861 FontDescription defaultFontDescription; |
1862 defaultFontDescription.setFamily(fontFamily); | 1862 defaultFontDescription.setFamily(fontFamily); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1909 { | 1909 { |
1910 TextBaseline baseline; | 1910 TextBaseline baseline; |
1911 if (!parseTextBaseline(s, baseline)) | 1911 if (!parseTextBaseline(s, baseline)) |
1912 return; | 1912 return; |
1913 if (state().textBaseline() == baseline) | 1913 if (state().textBaseline() == baseline) |
1914 return; | 1914 return; |
1915 realizeSaves(nullptr); | 1915 realizeSaves(nullptr); |
1916 modifiableState().setTextBaseline(baseline); | 1916 modifiableState().setTextBaseline(baseline); |
1917 } | 1917 } |
1918 | 1918 |
1919 static inline TextDirection toTextDirection(CanvasRenderingContext2DState::Direc
tion direction, HTMLCanvasElement* canvas, const LayoutStyle** computedStyle = 0
) | 1919 static inline TextDirection toTextDirection(CanvasRenderingContext2DState::Direc
tion direction, HTMLCanvasElement* canvas, const ComputedStyle** computedStyle =
0) |
1920 { | 1920 { |
1921 const LayoutStyle* style = (computedStyle || direction == CanvasRenderingCon
text2DState::DirectionInherit) ? canvas->computedStyle() : nullptr; | 1921 const ComputedStyle* style = (computedStyle || direction == CanvasRenderingC
ontext2DState::DirectionInherit) ? canvas->ensureComputedStyle() : nullptr; |
1922 if (computedStyle) | 1922 if (computedStyle) |
1923 *computedStyle = style; | 1923 *computedStyle = style; |
1924 switch (direction) { | 1924 switch (direction) { |
1925 case CanvasRenderingContext2DState::DirectionInherit: | 1925 case CanvasRenderingContext2DState::DirectionInherit: |
1926 return style ? style->direction() : LTR; | 1926 return style ? style->direction() : LTR; |
1927 case CanvasRenderingContext2DState::DirectionRTL: | 1927 case CanvasRenderingContext2DState::DirectionRTL: |
1928 return RTL; | 1928 return RTL; |
1929 case CanvasRenderingContext2DState::DirectionLTR: | 1929 case CanvasRenderingContext2DState::DirectionLTR: |
1930 return LTR; | 1930 return LTR; |
1931 } | 1931 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2057 if (gradient && gradient->gradient()->isZeroSize()) | 2057 if (gradient && gradient->gradient()->isZeroSize()) |
2058 return; | 2058 return; |
2059 | 2059 |
2060 FontCachePurgePreventer fontCachePurgePreventer; | 2060 FontCachePurgePreventer fontCachePurgePreventer; |
2061 | 2061 |
2062 const Font& font = accessFont(); | 2062 const Font& font = accessFont(); |
2063 const FontMetrics& fontMetrics = font.fontMetrics(); | 2063 const FontMetrics& fontMetrics = font.fontMetrics(); |
2064 | 2064 |
2065 // FIXME: Need to turn off font smoothing. | 2065 // FIXME: Need to turn off font smoothing. |
2066 | 2066 |
2067 const LayoutStyle* computedStyle = 0; | 2067 const ComputedStyle* computedStyle = 0; |
2068 TextDirection direction = toTextDirection(state().direction(), canvas(), &co
mputedStyle); | 2068 TextDirection direction = toTextDirection(state().direction(), canvas(), &co
mputedStyle); |
2069 bool isRTL = direction == RTL; | 2069 bool isRTL = direction == RTL; |
2070 bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : f
alse; | 2070 bool override = computedStyle ? isOverride(computedStyle->unicodeBidi()) : f
alse; |
2071 | 2071 |
2072 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, over
ride, true); | 2072 TextRun textRun(text, 0, 0, TextRun::AllowTrailingExpansion, direction, over
ride, true); |
2073 // Draw the item text at the correct point. | 2073 // Draw the item text at the correct point. |
2074 FloatPoint location(x, y + getFontBaseline(fontMetrics)); | 2074 FloatPoint location(x, y + getFontBaseline(fontMetrics)); |
2075 float fontWidth = font.width(textRun); | 2075 float fontWidth = font.width(textRun); |
2076 | 2076 |
2077 bool useMaxWidth = (maxWidth && *maxWidth < fontWidth); | 2077 bool useMaxWidth = (maxWidth && *maxWidth < fontWidth); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2437 if (imageType == NonOpaqueImage) | 2437 if (imageType == NonOpaqueImage) |
2438 return; | 2438 return; |
2439 if (alpha < 0xFF) | 2439 if (alpha < 0xFF) |
2440 return; | 2440 return; |
2441 } | 2441 } |
2442 | 2442 |
2443 canvas()->buffer()->willOverwriteCanvas(); | 2443 canvas()->buffer()->willOverwriteCanvas(); |
2444 } | 2444 } |
2445 | 2445 |
2446 } // namespace blink | 2446 } // namespace blink |
OLD | NEW |