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