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