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

Side by Side Diff: third_party/WebKit/Source/core/style/ComputedStyle.cpp

Issue 2416033003: Remove unsafe getFontMetrics methods (Closed)
Patch Set: Address wkroman suggestions Created 4 years, 2 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) 1999 Antti Koivisto (koivisto@kde.org) 2 * Copyright (C) 1999 Antti Koivisto (koivisto@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 5 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1641 CSSTransitionData& ComputedStyle::accessTransitions() { 1641 CSSTransitionData& ComputedStyle::accessTransitions() {
1642 if (!m_rareNonInheritedData.access()->m_transitions) 1642 if (!m_rareNonInheritedData.access()->m_transitions)
1643 m_rareNonInheritedData.access()->m_transitions = 1643 m_rareNonInheritedData.access()->m_transitions =
1644 CSSTransitionData::create(); 1644 CSSTransitionData::create();
1645 return *m_rareNonInheritedData->m_transitions; 1645 return *m_rareNonInheritedData->m_transitions;
1646 } 1646 }
1647 1647
1648 const Font& ComputedStyle::font() const { 1648 const Font& ComputedStyle::font() const {
1649 return m_styleInheritedData->font; 1649 return m_styleInheritedData->font;
1650 } 1650 }
1651 const FontMetrics& ComputedStyle::getFontMetrics() const {
1652 return m_styleInheritedData->font.getFontMetrics();
1653 }
1654 const FontDescription& ComputedStyle::getFontDescription() const { 1651 const FontDescription& ComputedStyle::getFontDescription() const {
1655 return m_styleInheritedData->font.getFontDescription(); 1652 return m_styleInheritedData->font.getFontDescription();
1656 } 1653 }
1657 float ComputedStyle::specifiedFontSize() const { 1654 float ComputedStyle::specifiedFontSize() const {
1658 return getFontDescription().specifiedSize(); 1655 return getFontDescription().specifiedSize();
1659 } 1656 }
1660 float ComputedStyle::computedFontSize() const { 1657 float ComputedStyle::computedFontSize() const {
1661 return getFontDescription().computedSize(); 1658 return getFontDescription().computedSize();
1662 } 1659 }
1663 int ComputedStyle::fontSize() const { 1660 int ComputedStyle::fontSize() const {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1831 void ComputedStyle::setLineHeight(const Length& specifiedLineHeight) { 1828 void ComputedStyle::setLineHeight(const Length& specifiedLineHeight) {
1832 SET_VAR(m_styleInheritedData, line_height, specifiedLineHeight); 1829 SET_VAR(m_styleInheritedData, line_height, specifiedLineHeight);
1833 } 1830 }
1834 1831
1835 int ComputedStyle::computedLineHeight() const { 1832 int ComputedStyle::computedLineHeight() const {
1836 const Length& lh = lineHeight(); 1833 const Length& lh = lineHeight();
1837 1834
1838 // Negative value means the line height is not set. Use the font's built-in 1835 // Negative value means the line height is not set. Use the font's built-in
1839 // spacing, if avalible. 1836 // spacing, if avalible.
1840 if (lh.isNegative() && font().primaryFont()) 1837 if (lh.isNegative() && font().primaryFont())
1841 return getFontMetrics().lineSpacing(); 1838 return font().primaryFont()->getFontMetrics().lineSpacing();
1842 1839
1843 if (lh.isPercentOrCalc()) 1840 if (lh.isPercentOrCalc())
1844 return minimumValueForLength(lh, LayoutUnit(computedFontSize())).toInt(); 1841 return minimumValueForLength(lh, LayoutUnit(computedFontSize())).toInt();
1845 1842
1846 return std::min(lh.value(), LayoutUnit::max().toFloat()); 1843 return std::min(lh.value(), LayoutUnit::max().toFloat());
1847 } 1844 }
1848 1845
1849 void ComputedStyle::setWordSpacing(float wordSpacing) { 1846 void ComputedStyle::setWordSpacing(float wordSpacing) {
1850 FontSelector* currentFontSelector = font().getFontSelector(); 1847 FontSelector* currentFontSelector = font().getFontSelector();
1851 FontDescription desc(getFontDescription()); 1848 FontDescription desc(getFontDescription());
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
2370 if (value < 0) 2367 if (value < 0)
2371 fvalue -= 0.5f; 2368 fvalue -= 0.5f;
2372 else 2369 else
2373 fvalue += 0.5f; 2370 fvalue += 0.5f;
2374 } 2371 }
2375 2372
2376 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2373 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2377 } 2374 }
2378 2375
2379 } // namespace blink 2376 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/style/ComputedStyle.h ('k') | third_party/WebKit/Source/core/svg/SVGLengthContext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698