| OLD | NEW |
| 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 17 matching lines...) Expand all Loading... |
| 28 #include "core/css/resolver/StyleResolver.h" | 28 #include "core/css/resolver/StyleResolver.h" |
| 29 #include "core/platform/graphics/Font.h" | 29 #include "core/platform/graphics/Font.h" |
| 30 #include "core/rendering/RenderTheme.h" | 30 #include "core/rendering/RenderTheme.h" |
| 31 #include "core/rendering/TextAutosizer.h" | 31 #include "core/rendering/TextAutosizer.h" |
| 32 #include "core/rendering/style/ContentData.h" | 32 #include "core/rendering/style/ContentData.h" |
| 33 #include "core/rendering/style/CursorList.h" | 33 #include "core/rendering/style/CursorList.h" |
| 34 #include "core/rendering/style/QuotesData.h" | 34 #include "core/rendering/style/QuotesData.h" |
| 35 #include "core/rendering/style/ShadowList.h" | 35 #include "core/rendering/style/ShadowList.h" |
| 36 #include "core/rendering/style/StyleImage.h" | 36 #include "core/rendering/style/StyleImage.h" |
| 37 #include "core/rendering/style/StyleInheritedData.h" | 37 #include "core/rendering/style/StyleInheritedData.h" |
| 38 #include "platform/LengthFunctions.h" |
| 38 #include "platform/fonts/FontSelector.h" | 39 #include "platform/fonts/FontSelector.h" |
| 39 #include "wtf/MathExtras.h" | 40 #include "wtf/MathExtras.h" |
| 40 | 41 |
| 41 using namespace std; | 42 using namespace std; |
| 42 | 43 |
| 43 namespace WebCore { | 44 namespace WebCore { |
| 44 | 45 |
| 45 struct SameSizeAsBorderValue { | 46 struct SameSizeAsBorderValue { |
| 46 RGBA32 m_color; | 47 RGBA32 m_color; |
| 47 unsigned m_width; | 48 unsigned m_width; |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 noninherited_flags._clear = other->noninherited_flags._clear; | 227 noninherited_flags._clear = other->noninherited_flags._clear; |
| 227 noninherited_flags._position = other->noninherited_flags._position; | 228 noninherited_flags._position = other->noninherited_flags._position; |
| 228 noninherited_flags._floating = other->noninherited_flags._floating; | 229 noninherited_flags._floating = other->noninherited_flags._floating; |
| 229 noninherited_flags._table_layout = other->noninherited_flags._table_layout; | 230 noninherited_flags._table_layout = other->noninherited_flags._table_layout; |
| 230 noninherited_flags._unicodeBidi = other->noninherited_flags._unicodeBidi; | 231 noninherited_flags._unicodeBidi = other->noninherited_flags._unicodeBidi; |
| 231 noninherited_flags._page_break_before = other->noninherited_flags._page_brea
k_before; | 232 noninherited_flags._page_break_before = other->noninherited_flags._page_brea
k_before; |
| 232 noninherited_flags._page_break_after = other->noninherited_flags._page_break
_after; | 233 noninherited_flags._page_break_after = other->noninherited_flags._page_break
_after; |
| 233 noninherited_flags._page_break_inside = other->noninherited_flags._page_brea
k_inside; | 234 noninherited_flags._page_break_inside = other->noninherited_flags._page_brea
k_inside; |
| 234 noninherited_flags.explicitInheritance = other->noninherited_flags.explicitI
nheritance; | 235 noninherited_flags.explicitInheritance = other->noninherited_flags.explicitI
nheritance; |
| 235 noninherited_flags.currentColor = other->noninherited_flags.currentColor; | 236 noninherited_flags.currentColor = other->noninherited_flags.currentColor; |
| 237 noninherited_flags.hasViewportUnits = other->noninherited_flags.hasViewportU
nits; |
| 236 if (m_svgStyle != other->m_svgStyle) | 238 if (m_svgStyle != other->m_svgStyle) |
| 237 m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get()); | 239 m_svgStyle.access()->copyNonInheritedFrom(other->m_svgStyle.get()); |
| 238 ASSERT(zoom() == initialZoom()); | 240 ASSERT(zoom() == initialZoom()); |
| 239 } | 241 } |
| 240 | 242 |
| 241 bool RenderStyle::operator==(const RenderStyle& o) const | 243 bool RenderStyle::operator==(const RenderStyle& o) const |
| 242 { | 244 { |
| 243 // compare everything except the pseudoStyle pointer | 245 // compare everything except the pseudoStyle pointer |
| 244 return inherited_flags == o.inherited_flags | 246 return inherited_flags == o.inherited_flags |
| 245 && noninherited_flags == o.noninherited_flags | 247 && noninherited_flags == o.noninherited_flags |
| (...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 | 871 |
| 870 void RenderStyle::applyTransform(TransformationMatrix& transform, const FloatRec
t& boundingBox, ApplyTransformOrigin applyOrigin) const | 872 void RenderStyle::applyTransform(TransformationMatrix& transform, const FloatRec
t& boundingBox, ApplyTransformOrigin applyOrigin) const |
| 871 { | 873 { |
| 872 const Vector<RefPtr<TransformOperation> >& transformOperations = rareNonInhe
ritedData->m_transform->m_operations.operations(); | 874 const Vector<RefPtr<TransformOperation> >& transformOperations = rareNonInhe
ritedData->m_transform->m_operations.operations(); |
| 873 bool applyTransformOrigin = requireTransformOrigin(transformOperations, appl
yOrigin); | 875 bool applyTransformOrigin = requireTransformOrigin(transformOperations, appl
yOrigin); |
| 874 | 876 |
| 875 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; | 877 float offsetX = transformOriginX().type() == Percent ? boundingBox.x() : 0; |
| 876 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; | 878 float offsetY = transformOriginY().type() == Percent ? boundingBox.y() : 0; |
| 877 | 879 |
| 878 if (applyTransformOrigin) { | 880 if (applyTransformOrigin) { |
| 879 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo
x.width(), 0) + offsetX, | 881 transform.translate3d(floatValueForLength(transformOriginX(), boundingBo
x.width()) + offsetX, |
| 880 floatValueForLength(transformOriginY(), boundingBox.height(), 0) + o
ffsetY, | 882 floatValueForLength(transformOriginY(), boundingBox.height()) + offs
etY, |
| 881 transformOriginZ()); | 883 transformOriginZ()); |
| 882 } | 884 } |
| 883 | 885 |
| 884 unsigned size = transformOperations.size(); | 886 unsigned size = transformOperations.size(); |
| 885 for (unsigned i = 0; i < size; ++i) | 887 for (unsigned i = 0; i < size; ++i) |
| 886 transformOperations[i]->apply(transform, boundingBox.size()); | 888 transformOperations[i]->apply(transform, boundingBox.size()); |
| 887 | 889 |
| 888 if (applyTransformOrigin) { | 890 if (applyTransformOrigin) { |
| 889 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB
ox.width(), 0) - offsetX, | 891 transform.translate3d(-floatValueForLength(transformOriginX(), boundingB
ox.width()) - offsetX, |
| 890 -floatValueForLength(transformOriginY(), boundingBox.height(), 0) -
offsetY, | 892 -floatValueForLength(transformOriginY(), boundingBox.height()) - off
setY, |
| 891 -transformOriginZ()); | 893 -transformOriginZ()); |
| 892 } | 894 } |
| 893 } | 895 } |
| 894 | 896 |
| 895 void RenderStyle::setTextShadow(PassRefPtr<ShadowList> s) | 897 void RenderStyle::setTextShadow(PassRefPtr<ShadowList> s) |
| 896 { | 898 { |
| 897 rareInheritedData.access()->textShadow = s; | 899 rareInheritedData.access()->textShadow = s; |
| 898 } | 900 } |
| 899 | 901 |
| 900 void RenderStyle::setBoxShadow(PassRefPtr<ShadowList> s) | 902 void RenderStyle::setBoxShadow(PassRefPtr<ShadowList> s) |
| 901 { | 903 { |
| 902 rareNonInheritedData.access()->m_boxShadow = s; | 904 rareNonInheritedData.access()->m_boxShadow = s; |
| 903 } | 905 } |
| 904 | 906 |
| 905 static RoundedRect::Radii calcRadiiFor(const BorderData& border, IntSize size, R
enderView* renderView) | 907 static RoundedRect::Radii calcRadiiFor(const BorderData& border, IntSize size) |
| 906 { | 908 { |
| 907 return RoundedRect::Radii( | 909 return RoundedRect::Radii( |
| 908 IntSize(valueForLength(border.topLeft().width(), size.width(), renderVie
w), | 910 IntSize(valueForLength(border.topLeft().width(), size.width()), |
| 909 valueForLength(border.topLeft().height(), size.height(), renderV
iew)), | 911 valueForLength(border.topLeft().height(), size.height())), |
| 910 IntSize(valueForLength(border.topRight().width(), size.width(), renderVi
ew), | 912 IntSize(valueForLength(border.topRight().width(), size.width()), |
| 911 valueForLength(border.topRight().height(), size.height(), render
View)), | 913 valueForLength(border.topRight().height(), size.height())), |
| 912 IntSize(valueForLength(border.bottomLeft().width(), size.width(), render
View), | 914 IntSize(valueForLength(border.bottomLeft().width(), size.width()), |
| 913 valueForLength(border.bottomLeft().height(), size.height(), rend
erView)), | 915 valueForLength(border.bottomLeft().height(), size.height())), |
| 914 IntSize(valueForLength(border.bottomRight().width(), size.width(), rende
rView), | 916 IntSize(valueForLength(border.bottomRight().width(), size.width()), |
| 915 valueForLength(border.bottomRight().height(), size.height(), ren
derView))); | 917 valueForLength(border.bottomRight().height(), size.height()))); |
| 916 } | 918 } |
| 917 | 919 |
| 918 static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radi
i& radii) | 920 static float calcConstraintScaleFor(const IntRect& rect, const RoundedRect::Radi
i& radii) |
| 919 { | 921 { |
| 920 // Constrain corner radii using CSS3 rules: | 922 // Constrain corner radii using CSS3 rules: |
| 921 // http://www.w3.org/TR/css3-background/#the-border-radius | 923 // http://www.w3.org/TR/css3-background/#the-border-radius |
| 922 | 924 |
| 923 float factor = 1; | 925 float factor = 1; |
| 924 unsigned radiiSum; | 926 unsigned radiiSum; |
| 925 | 927 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 957 Color RenderStyle::color() const { return inherited->color; } | 959 Color RenderStyle::color() const { return inherited->color; } |
| 958 Color RenderStyle::visitedLinkColor() const { return inherited->visitedLinkColor
; } | 960 Color RenderStyle::visitedLinkColor() const { return inherited->visitedLinkColor
; } |
| 959 void RenderStyle::setColor(const Color& v) { SET_VAR(inherited, color, v); } | 961 void RenderStyle::setColor(const Color& v) { SET_VAR(inherited, color, v); } |
| 960 void RenderStyle::setVisitedLinkColor(const Color& v) { SET_VAR(inherited, visit
edLinkColor, v); } | 962 void RenderStyle::setVisitedLinkColor(const Color& v) { SET_VAR(inherited, visit
edLinkColor, v); } |
| 961 | 963 |
| 962 short RenderStyle::horizontalBorderSpacing() const { return inherited->horizonta
l_border_spacing; } | 964 short RenderStyle::horizontalBorderSpacing() const { return inherited->horizonta
l_border_spacing; } |
| 963 short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_bo
rder_spacing; } | 965 short RenderStyle::verticalBorderSpacing() const { return inherited->vertical_bo
rder_spacing; } |
| 964 void RenderStyle::setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horiz
ontal_border_spacing, v); } | 966 void RenderStyle::setHorizontalBorderSpacing(short v) { SET_VAR(inherited, horiz
ontal_border_spacing, v); } |
| 965 void RenderStyle::setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertica
l_border_spacing, v); } | 967 void RenderStyle::setVerticalBorderSpacing(short v) { SET_VAR(inherited, vertica
l_border_spacing, v); } |
| 966 | 968 |
| 967 RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, Rende
rView* renderView, bool includeLogicalLeftEdge, bool includeLogicalRightEdge) co
nst | 969 RoundedRect RenderStyle::getRoundedBorderFor(const LayoutRect& borderRect, bool
includeLogicalLeftEdge, bool includeLogicalRightEdge) const |
| 968 { | 970 { |
| 969 IntRect snappedBorderRect(pixelSnappedIntRect(borderRect)); | 971 IntRect snappedBorderRect(pixelSnappedIntRect(borderRect)); |
| 970 RoundedRect roundedRect(snappedBorderRect); | 972 RoundedRect roundedRect(snappedBorderRect); |
| 971 if (hasBorderRadius()) { | 973 if (hasBorderRadius()) { |
| 972 RoundedRect::Radii radii = calcRadiiFor(surround->border, snappedBorderR
ect.size(), renderView); | 974 RoundedRect::Radii radii = calcRadiiFor(surround->border, snappedBorderR
ect.size()); |
| 973 radii.scale(calcConstraintScaleFor(snappedBorderRect, radii)); | 975 radii.scale(calcConstraintScaleFor(snappedBorderRect, radii)); |
| 974 roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includ
eLogicalLeftEdge, includeLogicalRightEdge); | 976 roundedRect.includeLogicalEdges(radii, isHorizontalWritingMode(), includ
eLogicalLeftEdge, includeLogicalRightEdge); |
| 975 } | 977 } |
| 976 return roundedRect; | 978 return roundedRect; |
| 977 } | 979 } |
| 978 | 980 |
| 979 RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const | 981 RoundedRect RenderStyle::getRoundedInnerBorderFor(const LayoutRect& borderRect,
bool includeLogicalLeftEdge, bool includeLogicalRightEdge) const |
| 980 { | 982 { |
| 981 bool horizontal = isHorizontalWritingMode(); | 983 bool horizontal = isHorizontalWritingMode(); |
| 982 | 984 |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1207 // FIXME: Should consider scaling the fixed part of any calc expressions | 1209 // FIXME: Should consider scaling the fixed part of any calc expressions |
| 1208 // too, though this involves messily poking into CalcExpressionLength. | 1210 // too, though this involves messily poking into CalcExpressionLength. |
| 1209 float multiplier = textAutosizingMultiplier(); | 1211 float multiplier = textAutosizingMultiplier(); |
| 1210 if (multiplier > 1 && lh.isFixed()) | 1212 if (multiplier > 1 && lh.isFixed()) |
| 1211 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multip
lier), Fixed); | 1213 return Length(TextAutosizer::computeAutosizedFontSize(lh.value(), multip
lier), Fixed); |
| 1212 | 1214 |
| 1213 return lh; | 1215 return lh; |
| 1214 } | 1216 } |
| 1215 void RenderStyle::setLineHeight(Length specifiedLineHeight) { SET_VAR(inherited,
line_height, specifiedLineHeight); } | 1217 void RenderStyle::setLineHeight(Length specifiedLineHeight) { SET_VAR(inherited,
line_height, specifiedLineHeight); } |
| 1216 | 1218 |
| 1217 int RenderStyle::computedLineHeight(RenderView* renderView) const | 1219 int RenderStyle::computedLineHeight() const |
| 1218 { | 1220 { |
| 1219 const Length& lh = lineHeight(); | 1221 const Length& lh = lineHeight(); |
| 1220 | 1222 |
| 1221 // Negative value means the line height is not set. Use the font's built-in
spacing. | 1223 // Negative value means the line height is not set. Use the font's built-in
spacing. |
| 1222 if (lh.isNegative()) | 1224 if (lh.isNegative()) |
| 1223 return fontMetrics().lineSpacing(); | 1225 return fontMetrics().lineSpacing(); |
| 1224 | 1226 |
| 1225 if (lh.isPercent()) | 1227 if (lh.isPercent()) |
| 1226 return minimumValueForLength(lh, fontSize()); | 1228 return minimumValueForLength(lh, fontSize()); |
| 1227 | 1229 |
| 1228 if (lh.isViewportPercentage()) | |
| 1229 return valueForLength(lh, 0, renderView); | |
| 1230 | |
| 1231 return lh.value(); | 1230 return lh.value(); |
| 1232 } | 1231 } |
| 1233 | 1232 |
| 1234 void RenderStyle::setWordSpacing(float v) { inherited.access()->font.setWordSpac
ing(v); } | 1233 void RenderStyle::setWordSpacing(float v) { inherited.access()->font.setWordSpac
ing(v); } |
| 1235 void RenderStyle::setLetterSpacing(float v) { inherited.access()->font.setLetter
Spacing(v); } | 1234 void RenderStyle::setLetterSpacing(float v) { inherited.access()->font.setLetter
Spacing(v); } |
| 1236 | 1235 |
| 1237 void RenderStyle::setFontSize(float size) | 1236 void RenderStyle::setFontSize(float size) |
| 1238 { | 1237 { |
| 1239 // size must be specifiedSize if Text Autosizing is enabled, but computedSiz
e if text | 1238 // size must be specifiedSize if Text Autosizing is enabled, but computedSiz
e if text |
| 1240 // zoom is enabled (if neither is enabled it's irrelevant as they're probabl
y the same). | 1239 // zoom is enabled (if neither is enabled it's irrelevant as they're probabl
y the same). |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1600 } | 1599 } |
| 1601 | 1600 |
| 1602 void RenderStyle::setBorderImageOutset(const BorderImageLengthBox& outset) | 1601 void RenderStyle::setBorderImageOutset(const BorderImageLengthBox& outset) |
| 1603 { | 1602 { |
| 1604 if (surround->border.m_image.outset() == outset) | 1603 if (surround->border.m_image.outset() == outset) |
| 1605 return; | 1604 return; |
| 1606 surround.access()->border.m_image.setOutset(outset); | 1605 surround.access()->border.m_image.setOutset(outset); |
| 1607 } | 1606 } |
| 1608 | 1607 |
| 1609 } // namespace WebCore | 1608 } // namespace WebCore |
| OLD | NEW |