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

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

Issue 2261663002: Disallow cast/implicit conversion from LayoutUnit to int/unsigned (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: - Created 4 years, 3 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 reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved. 4 * Copyright (C) 2011 Adobe Systems Incorporated. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 1475 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 int ComputedStyle::computedLineHeight() const 1486 int ComputedStyle::computedLineHeight() const
1487 { 1487 {
1488 const Length& lh = lineHeight(); 1488 const Length& lh = lineHeight();
1489 1489
1490 // Negative value means the line height is not set. Use the font's built-in 1490 // Negative value means the line height is not set. Use the font's built-in
1491 // spacing, if avalible. 1491 // spacing, if avalible.
1492 if (lh.isNegative() && font().primaryFont()) 1492 if (lh.isNegative() && font().primaryFont())
1493 return getFontMetrics().lineSpacing(); 1493 return getFontMetrics().lineSpacing();
1494 1494
1495 if (lh.hasPercent()) 1495 if (lh.hasPercent())
1496 return minimumValueForLength(lh, LayoutUnit(computedFontSize())); 1496 return minimumValueForLength(lh, LayoutUnit(computedFontSize())).toInt() ;
1497 1497
1498 return std::min(lh.value(), LayoutUnit::max().toFloat()); 1498 return std::min(lh.value(), LayoutUnit::max().toFloat());
1499 } 1499 }
1500 1500
1501 void ComputedStyle::setWordSpacing(float wordSpacing) 1501 void ComputedStyle::setWordSpacing(float wordSpacing)
1502 { 1502 {
1503 FontSelector* currentFontSelector = font().getFontSelector(); 1503 FontSelector* currentFontSelector = font().getFontSelector();
1504 FontDescription desc(getFontDescription()); 1504 FontDescription desc(getFontDescription());
1505 desc.setWordSpacing(wordSpacing); 1505 desc.setWordSpacing(wordSpacing);
1506 setFontDescription(desc); 1506 setFontDescription(desc);
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1949 return false; 1949 return false;
1950 } 1950 }
1951 1951
1952 return true; 1952 return true;
1953 } 1953 }
1954 1954
1955 void ComputedStyle::getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLef tEdge, bool includeLogicalRightEdge) const 1955 void ComputedStyle::getBorderEdgeInfo(BorderEdge edges[], bool includeLogicalLef tEdge, bool includeLogicalRightEdge) const
1956 { 1956 {
1957 bool horizontal = isHorizontalWritingMode(); 1957 bool horizontal = isHorizontalWritingMode();
1958 1958
1959 edges[BSTop] = BorderEdge(LayoutUnit(borderTopWidth()), 1959 edges[BSTop] = BorderEdge(borderTopWidth(),
1960 visitedDependentColor(CSSPropertyBorderTopColor), 1960 visitedDependentColor(CSSPropertyBorderTopColor),
1961 borderTopStyle(), 1961 borderTopStyle(),
1962 horizontal || includeLogicalLeftEdge); 1962 horizontal || includeLogicalLeftEdge);
1963 1963
1964 edges[BSRight] = BorderEdge(LayoutUnit(borderRightWidth()), 1964 edges[BSRight] = BorderEdge(borderRightWidth(),
1965 visitedDependentColor(CSSPropertyBorderRightColor), 1965 visitedDependentColor(CSSPropertyBorderRightColor),
1966 borderRightStyle(), 1966 borderRightStyle(),
1967 !horizontal || includeLogicalRightEdge); 1967 !horizontal || includeLogicalRightEdge);
1968 1968
1969 edges[BSBottom] = BorderEdge(LayoutUnit(borderBottomWidth()), 1969 edges[BSBottom] = BorderEdge(borderBottomWidth(),
1970 visitedDependentColor(CSSPropertyBorderBottomColor), 1970 visitedDependentColor(CSSPropertyBorderBottomColor),
1971 borderBottomStyle(), 1971 borderBottomStyle(),
1972 horizontal || includeLogicalRightEdge); 1972 horizontal || includeLogicalRightEdge);
1973 1973
1974 edges[BSLeft] = BorderEdge(LayoutUnit(borderLeftWidth()), 1974 edges[BSLeft] = BorderEdge(borderLeftWidth(),
1975 visitedDependentColor(CSSPropertyBorderLeftColor), 1975 visitedDependentColor(CSSPropertyBorderLeftColor),
1976 borderLeftStyle(), 1976 borderLeftStyle(),
1977 !horizontal || includeLogicalLeftEdge); 1977 !horizontal || includeLogicalLeftEdge);
1978 } 1978 }
1979 1979
1980 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other) 1980 void ComputedStyle::copyChildDependentFlagsFrom(const ComputedStyle& other)
1981 { 1981 {
1982 setEmptyState(other.emptyState()); 1982 setEmptyState(other.emptyState());
1983 if (other.hasExplicitlyInheritedProperties()) 1983 if (other.hasExplicitlyInheritedProperties())
1984 setHasExplicitlyInheritedProperties(); 1984 setHasExplicitlyInheritedProperties();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
2022 if (value < 0) 2022 if (value < 0)
2023 fvalue -= 0.5f; 2023 fvalue -= 0.5f;
2024 else 2024 else
2025 fvalue += 0.5f; 2025 fvalue += 0.5f;
2026 } 2026 }
2027 2027
2028 return roundForImpreciseConversion<int>(fvalue / zoomFactor); 2028 return roundForImpreciseConversion<int>(fvalue / zoomFactor);
2029 } 2029 }
2030 2030
2031 } // namespace blink 2031 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/paint/ViewPainter.cpp ('k') | third_party/WebKit/Source/core/testing/Internals.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698