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

Side by Side Diff: Source/core/html/canvas/CanvasRenderingContext2D.cpp

Issue 5216392399814656: Clear StyleResolverState after each resolve. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: You people refactor too quickly. (Sync ;) Created 7 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
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 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 1972 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 defaultFontDescription.setFamily(fontFamily); 1983 defaultFontDescription.setFamily(fontFamily);
1984 defaultFontDescription.setSpecifiedSize(defaultFontSize); 1984 defaultFontDescription.setSpecifiedSize(defaultFontSize);
1985 defaultFontDescription.setComputedSize(defaultFontSize); 1985 defaultFontDescription.setComputedSize(defaultFontSize);
1986 1986
1987 newStyle->setFontDescription(defaultFontDescription); 1987 newStyle->setFontDescription(defaultFontDescription);
1988 } 1988 }
1989 1989
1990 newStyle->font().update(newStyle->font().fontSelector()); 1990 newStyle->font().update(newStyle->font().fontSelector());
1991 1991
1992 // Now map the font property longhands into the style. 1992 // Now map the font property longhands into the style.
1993 StyleResolver::PropertyValue properties[] = {
1994 StyleResolver::PropertyValue(CSSPropertyFontFamily, *parsedStyle),
1995 StyleResolver::PropertyValue(CSSPropertyFontStyle, *parsedStyle),
1996 StyleResolver::PropertyValue(CSSPropertyFontVariant, *parsedStyle),
1997 StyleResolver::PropertyValue(CSSPropertyFontWeight, *parsedStyle),
1998 StyleResolver::PropertyValue(CSSPropertyFontSize, *parsedStyle),
1999 StyleResolver::PropertyValue(CSSPropertyLineHeight, *parsedStyle),
2000 };
2001
1993 StyleResolver* styleResolver = canvas()->styleResolver(); 2002 StyleResolver* styleResolver = canvas()->styleResolver();
1994 styleResolver->applyPropertyToStyle(CSSPropertyFontFamily, parsedStyle->getP ropertyCSSValue(CSSPropertyFontFamily).get(), newStyle.get()); 2003 styleResolver->applyPropertiesToStyle(properties, arraysize(properties), new Style.get());
1995 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontStyle, parsedStyle ->getPropertyCSSValue(CSSPropertyFontStyle).get());
1996 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontVariant, parsedSty le->getPropertyCSSValue(CSSPropertyFontVariant).get());
1997 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontWeight, parsedStyl e->getPropertyCSSValue(CSSPropertyFontWeight).get());
1998
1999 // As described in BUG66291, setting font-size and line-height on a font may entail a CSSPrimitiveValue::computeLengthDouble call,
2000 // which assumes the fontMetrics are available for the affected font, otherw ise a crash occurs (see http://trac.webkit.org/changeset/96122).
2001 // The updateFont() calls below update the fontMetrics and ensure the proper setting of font-size and line-height.
2002 styleResolver->updateFont();
2003 styleResolver->applyPropertyToCurrentStyle(CSSPropertyFontSize, parsedStyle- >getPropertyCSSValue(CSSPropertyFontSize).get());
2004 styleResolver->updateFont();
2005 styleResolver->applyPropertyToCurrentStyle(CSSPropertyLineHeight, parsedStyl e->getPropertyCSSValue(CSSPropertyLineHeight).get());
2006 2004
2007 modifiableState().m_font = newStyle->font(); 2005 modifiableState().m_font = newStyle->font();
2008 modifiableState().m_font.update(styleResolver->fontSelector()); 2006 modifiableState().m_font.update(styleResolver->fontSelector());
2009 modifiableState().m_realizedFont = true; 2007 modifiableState().m_realizedFont = true;
2010 styleResolver->fontSelector()->registerForInvalidationCallbacks(&modifiableS tate()); 2008 styleResolver->fontSelector()->registerForInvalidationCallbacks(&modifiableS tate());
2011 } 2009 }
2012 2010
2013 String CanvasRenderingContext2D::textAlign() const 2011 String CanvasRenderingContext2D::textAlign() const
2014 { 2012 {
2015 return textAlignName(state().m_textAlign); 2013 return textAlignName(state().m_textAlign);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2228 } 2226 }
2229 2227
2230 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const 2228 PassRefPtr<Canvas2DContextAttributes> CanvasRenderingContext2D::getContextAttrib utes() const
2231 { 2229 {
2232 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate(); 2230 RefPtr<Canvas2DContextAttributes> attributes = Canvas2DContextAttributes::cr eate();
2233 attributes->setAlpha(m_hasAlpha); 2231 attributes->setAlpha(m_hasAlpha);
2234 return attributes.release(); 2232 return attributes.release();
2235 } 2233 }
2236 2234
2237 } // namespace WebCore 2235 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698