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

Side by Side Diff: Source/modules/canvas2d/CanvasRenderingContext2D.cpp

Issue 1297383003: Keep TextMetrics on the Oilpan heap always. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 4 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
« no previous file with comments | « Source/modules/canvas2d/CanvasRenderingContext2D.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
OLDNEW
« no previous file with comments | « Source/modules/canvas2d/CanvasRenderingContext2D.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698