| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 3 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) | 4 * (C) 2004-2005 Allan Sandfeld Jensen (kde@carewolf.com) |
| 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) | 5 * Copyright (C) 2006, 2007 Nicholas Shanks (webkit@nickshanks.com) |
| 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. | 6 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Apple Inc.
All rights reserved. |
| 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> | 7 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
| 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> | 8 * Copyright (C) 2007, 2008 Eric Seidel <eric@webkit.org> |
| 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 9 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
| 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. | 10 * Copyright (c) 2011, Code Aurora Forum. All rights reserved. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 #include "CSSValueKeywords.h" | 43 #include "CSSValueKeywords.h" |
| 44 #include "StyleBuilderFunctions.h" | 44 #include "StyleBuilderFunctions.h" |
| 45 #include "StylePropertyShorthand.h" | 45 #include "StylePropertyShorthand.h" |
| 46 #include "core/css/BasicShapeFunctions.h" | 46 #include "core/css/BasicShapeFunctions.h" |
| 47 #include "core/css/CSSAspectRatioValue.h" | 47 #include "core/css/CSSAspectRatioValue.h" |
| 48 #include "core/css/CSSCursorImageValue.h" | 48 #include "core/css/CSSCursorImageValue.h" |
| 49 #include "core/css/CSSGradientValue.h" | 49 #include "core/css/CSSGradientValue.h" |
| 50 #include "core/css/CSSGridTemplateValue.h" | 50 #include "core/css/CSSGridTemplateValue.h" |
| 51 #include "core/css/CSSImageSetValue.h" | 51 #include "core/css/CSSImageSetValue.h" |
| 52 #include "core/css/CSSLineBoxContainValue.h" | 52 #include "core/css/CSSLineBoxContainValue.h" |
| 53 #include "core/css/CSSParser.h" |
| 53 #include "core/css/CSSPrimitiveValueMappings.h" | 54 #include "core/css/CSSPrimitiveValueMappings.h" |
| 54 #include "core/css/CSSProperty.h" | 55 #include "core/css/CSSProperty.h" |
| 55 #include "core/css/CSSReflectValue.h" | 56 #include "core/css/CSSReflectValue.h" |
| 56 #include "core/css/CSSVariableValue.h" | 57 #include "core/css/CSSVariableValue.h" |
| 57 #include "core/css/Counter.h" | 58 #include "core/css/Counter.h" |
| 58 #include "core/css/FontValue.h" | 59 #include "core/css/FontValue.h" |
| 59 #include "core/css/Pair.h" | 60 #include "core/css/Pair.h" |
| 60 #include "core/css/Rect.h" | 61 #include "core/css/Rect.h" |
| 61 #include "core/css/ShadowValue.h" | 62 #include "core/css/ShadowValue.h" |
| 63 #include "core/css/StylePropertySet.h" |
| 62 #include "core/css/resolver/ElementStyleResources.h" | 64 #include "core/css/resolver/ElementStyleResources.h" |
| 63 #include "core/css/resolver/FilterOperationResolver.h" | 65 #include "core/css/resolver/FilterOperationResolver.h" |
| 64 #include "core/css/resolver/FontBuilder.h" | 66 #include "core/css/resolver/FontBuilder.h" |
| 65 #include "core/css/resolver/StyleResolver.h" | |
| 66 #include "core/css/resolver/StyleResolverState.h" | 67 #include "core/css/resolver/StyleResolverState.h" |
| 67 #include "core/css/resolver/TransformBuilder.h" | 68 #include "core/css/resolver/TransformBuilder.h" |
| 68 #include "core/page/Frame.h" | 69 #include "core/page/Frame.h" |
| 69 #include "core/page/Settings.h" | 70 #include "core/page/Settings.h" |
| 70 #include "core/platform/graphics/FontDescription.h" | 71 #include "core/platform/graphics/FontDescription.h" |
| 71 #include "core/rendering/style/CounterContent.h" | 72 #include "core/rendering/style/CounterContent.h" |
| 72 #include "core/rendering/style/CursorList.h" | 73 #include "core/rendering/style/CursorList.h" |
| 73 #include "core/rendering/style/QuotesData.h" | 74 #include "core/rendering/style/QuotesData.h" |
| 74 #include "core/rendering/style/RenderStyle.h" | 75 #include "core/rendering/style/RenderStyle.h" |
| 75 #include "core/rendering/style/RenderStyleConstants.h" | 76 #include "core/rendering/style/RenderStyleConstants.h" |
| 76 #include "core/rendering/style/SVGRenderStyle.h" | 77 #include "core/rendering/style/SVGRenderStyle.h" |
| 77 #include "core/rendering/style/SVGRenderStyleDefs.h" | 78 #include "core/rendering/style/SVGRenderStyleDefs.h" |
| 78 #include "core/rendering/style/ShadowData.h" | 79 #include "core/rendering/style/ShadowData.h" |
| 79 #include "core/rendering/style/StyleGeneratedImage.h" | 80 #include "core/rendering/style/StyleGeneratedImage.h" |
| 80 #include "core/svg/SVGColor.h" | 81 #include "core/svg/SVGColor.h" |
| 81 #include "core/svg/SVGPaint.h" | 82 #include "core/svg/SVGPaint.h" |
| 82 #include "core/svg/SVGURIReference.h" | 83 #include "core/svg/SVGURIReference.h" |
| 83 #include "wtf/MathExtras.h" | 84 #include "wtf/MathExtras.h" |
| 84 #include "wtf/StdLibExtras.h" | 85 #include "wtf/StdLibExtras.h" |
| 85 #include "wtf/Vector.h" | 86 #include "wtf/Vector.h" |
| 86 | 87 |
| 87 namespace WebCore { | 88 namespace WebCore { |
| 88 | 89 |
| 89 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue*
value) | 90 static Length clipConvertToLength(StyleResolverState& state, CSSPrimitiveValue*
value) |
| 90 { | 91 { |
| 91 return value->convertToLength<FixedIntegerConversion | PercentConversion | F
ractionConversion | AutoConversion>(state.style(), state.rootElementStyle(), sta
te.style()->effectiveZoom()); | 92 return value->convertToLength<FixedIntegerConversion | PercentConversion | F
ractionConversion | AutoConversion>(state.style(), state.rootElementStyle(), sta
te.style()->effectiveZoom()); |
| 92 } | 93 } |
| 93 | 94 |
| 94 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolver*, StyleRes
olverState& state) | 95 void StyleBuilderFunctions::applyInitialCSSPropertyClip(StyleResolverState& stat
e) |
| 95 { | 96 { |
| 96 state.style()->setClip(Length(), Length(), Length(), Length()); | 97 state.style()->setClip(Length(), Length(), Length(), Length()); |
| 97 state.style()->setHasClip(false); | 98 state.style()->setHasClip(false); |
| 98 } | 99 } |
| 99 | 100 |
| 100 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolver* styleReso
lver, StyleResolverState& state) | 101 void StyleBuilderFunctions::applyInheritCSSPropertyClip(StyleResolverState& stat
e) |
| 101 { | 102 { |
| 102 RenderStyle* parentStyle = state.parentStyle(); | 103 RenderStyle* parentStyle = state.parentStyle(); |
| 103 if (!parentStyle->hasClip()) | 104 if (!parentStyle->hasClip()) |
| 104 return applyInitialCSSPropertyClip(styleResolver, state); | 105 return applyInitialCSSPropertyClip(state); |
| 105 state.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), par
entStyle->clipBottom(), parentStyle->clipLeft()); | 106 state.style()->setClip(parentStyle->clipTop(), parentStyle->clipRight(), par
entStyle->clipBottom(), parentStyle->clipLeft()); |
| 106 state.style()->setHasClip(true); | 107 state.style()->setHasClip(true); |
| 107 } | 108 } |
| 108 | 109 |
| 109 void StyleBuilderFunctions::applyValueCSSPropertyClip(StyleResolver*, StyleResol
verState& state, CSSValue* value) | 110 void StyleBuilderFunctions::applyValueCSSPropertyClip(StyleResolverState& state,
CSSValue* value) |
| 110 { | 111 { |
| 111 if (!value->isPrimitiveValue()) | 112 if (!value->isPrimitiveValue()) |
| 112 return; | 113 return; |
| 113 | 114 |
| 114 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 115 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 115 | 116 |
| 116 if (Rect* rect = primitiveValue->getRectValue()) { | 117 if (Rect* rect = primitiveValue->getRectValue()) { |
| 117 Length top = clipConvertToLength(state, rect->top()); | 118 Length top = clipConvertToLength(state, rect->top()); |
| 118 Length right = clipConvertToLength(state, rect->right()); | 119 Length right = clipConvertToLength(state, rect->right()); |
| 119 Length bottom = clipConvertToLength(state, rect->bottom()); | 120 Length bottom = clipConvertToLength(state, rect->bottom()); |
| 120 Length left = clipConvertToLength(state, rect->left()); | 121 Length left = clipConvertToLength(state, rect->left()); |
| 121 state.style()->setClip(top, right, bottom, left); | 122 state.style()->setClip(top, right, bottom, left); |
| 122 state.style()->setHasClip(true); | 123 state.style()->setHasClip(true); |
| 123 } else if (primitiveValue->getValueID() == CSSValueAuto) { | 124 } else if (primitiveValue->getValueID() == CSSValueAuto) { |
| 124 state.style()->setClip(Length(), Length(), Length(), Length()); | 125 state.style()->setClip(Length(), Length(), Length(), Length()); |
| 125 state.style()->setHasClip(false); | 126 state.style()->setHasClip(false); |
| 126 } | 127 } |
| 127 } | 128 } |
| 128 | 129 |
| 129 void StyleBuilderFunctions::applyInitialCSSPropertyCursor(StyleResolver*, StyleR
esolverState& state) | 130 void StyleBuilderFunctions::applyInitialCSSPropertyCursor(StyleResolverState& st
ate) |
| 130 { | 131 { |
| 131 state.style()->clearCursorList(); | 132 state.style()->clearCursorList(); |
| 132 state.style()->setCursor(RenderStyle::initialCursor()); | 133 state.style()->setCursor(RenderStyle::initialCursor()); |
| 133 } | 134 } |
| 134 | 135 |
| 135 void StyleBuilderFunctions::applyInheritCSSPropertyCursor(StyleResolver*, StyleR
esolverState& state) | 136 void StyleBuilderFunctions::applyInheritCSSPropertyCursor(StyleResolverState& st
ate) |
| 136 { | 137 { |
| 137 state.style()->setCursor(state.parentStyle()->cursor()); | 138 state.style()->setCursor(state.parentStyle()->cursor()); |
| 138 state.style()->setCursorList(state.parentStyle()->cursors()); | 139 state.style()->setCursorList(state.parentStyle()->cursors()); |
| 139 } | 140 } |
| 140 | 141 |
| 141 void StyleBuilderFunctions::applyValueCSSPropertyCursor(StyleResolver*, StyleRes
olverState& state, CSSValue* value) | 142 void StyleBuilderFunctions::applyValueCSSPropertyCursor(StyleResolverState& stat
e, CSSValue* value) |
| 142 { | 143 { |
| 143 state.style()->clearCursorList(); | 144 state.style()->clearCursorList(); |
| 144 if (value->isValueList()) { | 145 if (value->isValueList()) { |
| 145 CSSValueList* list = toCSSValueList(value); | 146 CSSValueList* list = toCSSValueList(value); |
| 146 int len = list->length(); | 147 int len = list->length(); |
| 147 state.style()->setCursor(CURSOR_AUTO); | 148 state.style()->setCursor(CURSOR_AUTO); |
| 148 for (int i = 0; i < len; i++) { | 149 for (int i = 0; i < len; i++) { |
| 149 CSSValue* item = list->itemWithoutBoundsCheck(i); | 150 CSSValue* item = list->itemWithoutBoundsCheck(i); |
| 150 if (item->isCursorImageValue()) { | 151 if (item->isCursorImageValue()) { |
| 151 CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(i
tem); | 152 CSSCursorImageValue* image = static_cast<CSSCursorImageValue*>(i
tem); |
| 152 if (image->updateIfSVGCursorIsUsed(state.element())) // Elements
with SVG cursors are not allowed to share style. | 153 if (image->updateIfSVGCursorIsUsed(state.element())) // Elements
with SVG cursors are not allowed to share style. |
| 153 state.style()->setUnique(); | 154 state.style()->setUnique(); |
| 154 state.style()->addCursor(state.styleImage(CSSPropertyCursor, ima
ge), image->hotSpot()); | 155 state.style()->addCursor(state.styleImage(CSSPropertyCursor, ima
ge), image->hotSpot()); |
| 155 } else if (item->isPrimitiveValue()) { | 156 } else if (item->isPrimitiveValue()) { |
| 156 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item); | 157 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(item); |
| 157 if (primitiveValue->isValueID()) | 158 if (primitiveValue->isValueID()) |
| 158 state.style()->setCursor(*primitiveValue); | 159 state.style()->setCursor(*primitiveValue); |
| 159 } | 160 } |
| 160 } | 161 } |
| 161 } else if (value->isPrimitiveValue()) { | 162 } else if (value->isPrimitiveValue()) { |
| 162 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 163 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 163 if (primitiveValue->isValueID() && state.style()->cursor() != ECursor(*p
rimitiveValue)) | 164 if (primitiveValue->isValueID() && state.style()->cursor() != ECursor(*p
rimitiveValue)) |
| 164 state.style()->setCursor(*primitiveValue); | 165 state.style()->setCursor(*primitiveValue); |
| 165 } | 166 } |
| 166 } | 167 } |
| 167 | 168 |
| 168 void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolver*, Style
ResolverState& state, CSSValue* value) | 169 void StyleBuilderFunctions::applyValueCSSPropertyDirection(StyleResolverState& s
tate, CSSValue* value) |
| 169 { | 170 { |
| 170 state.style()->setDirection(*toCSSPrimitiveValue(value)); | 171 state.style()->setDirection(*toCSSPrimitiveValue(value)); |
| 171 Element* element = state.element(); | 172 Element* element = state.element(); |
| 172 if (element && element == element->document()->documentElement()) | 173 if (element && element == element->document()->documentElement()) |
| 173 element->document()->setDirectionSetOnDocumentElement(true); | 174 element->document()->setDirectionSetOnDocumentElement(true); |
| 174 } | 175 } |
| 175 | 176 |
| 176 static inline bool isValidDisplayValue(StyleResolverState& state, EDisplay displ
ayPropertyValue) | 177 static inline bool isValidDisplayValue(StyleResolverState& state, EDisplay displ
ayPropertyValue) |
| 177 { | 178 { |
| 178 if (state.element() && state.element()->isSVGElement() && state.style()->sty
leType() == NOPSEUDO) | 179 if (state.element() && state.element()->isSVGElement() && state.style()->sty
leType() == NOPSEUDO) |
| 179 return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK
|| displayPropertyValue == NONE); | 180 return (displayPropertyValue == INLINE || displayPropertyValue == BLOCK
|| displayPropertyValue == NONE); |
| 180 return true; | 181 return true; |
| 181 } | 182 } |
| 182 | 183 |
| 183 void StyleBuilderFunctions::applyInheritCSSPropertyDisplay(StyleResolver*, Style
ResolverState& state) | 184 void StyleBuilderFunctions::applyInheritCSSPropertyDisplay(StyleResolverState& s
tate) |
| 184 { | 185 { |
| 185 EDisplay display = state.parentStyle()->display(); | 186 EDisplay display = state.parentStyle()->display(); |
| 186 if (!isValidDisplayValue(state, display)) | 187 if (!isValidDisplayValue(state, display)) |
| 187 return; | 188 return; |
| 188 state.style()->setDisplay(display); | 189 state.style()->setDisplay(display); |
| 189 } | 190 } |
| 190 | 191 |
| 191 void StyleBuilderFunctions::applyValueCSSPropertyDisplay(StyleResolver*, StyleRe
solverState& state, CSSValue* value) | 192 void StyleBuilderFunctions::applyValueCSSPropertyDisplay(StyleResolverState& sta
te, CSSValue* value) |
| 192 { | 193 { |
| 193 if (!value->isPrimitiveValue()) | 194 if (!value->isPrimitiveValue()) |
| 194 return; | 195 return; |
| 195 | 196 |
| 196 EDisplay display = *toCSSPrimitiveValue(value); | 197 EDisplay display = *toCSSPrimitiveValue(value); |
| 197 | 198 |
| 198 if (!isValidDisplayValue(state, display)) | 199 if (!isValidDisplayValue(state, display)) |
| 199 return; | 200 return; |
| 200 | 201 |
| 201 state.style()->setDisplay(display); | 202 state.style()->setDisplay(display); |
| 202 } | 203 } |
| 203 | 204 |
| 204 void StyleBuilderFunctions::applyInitialCSSPropertyFontFamily(StyleResolver*, St
yleResolverState& state) | 205 void StyleBuilderFunctions::applyInitialCSSPropertyFontFamily(StyleResolverState
& state) |
| 205 { | 206 { |
| 206 state.fontBuilder().setFontFamilyInitial(state.style()->effectiveZoom()); | 207 state.fontBuilder().setFontFamilyInitial(state.style()->effectiveZoom()); |
| 207 } | 208 } |
| 208 | 209 |
| 209 void StyleBuilderFunctions::applyInheritCSSPropertyFontFamily(StyleResolver*, St
yleResolverState& state) | 210 void StyleBuilderFunctions::applyInheritCSSPropertyFontFamily(StyleResolverState
& state) |
| 210 { | 211 { |
| 211 state.fontBuilder().setFontFamilyInherit(state.parentFontDescription()); | 212 state.fontBuilder().setFontFamilyInherit(state.parentFontDescription()); |
| 212 } | 213 } |
| 213 | 214 |
| 214 void StyleBuilderFunctions::applyValueCSSPropertyFontFamily(StyleResolver*, Styl
eResolverState& state, CSSValue* value) | 215 void StyleBuilderFunctions::applyValueCSSPropertyFontFamily(StyleResolverState&
state, CSSValue* value) |
| 215 { | 216 { |
| 216 state.fontBuilder().setFontFamilyValue(value, state.style()->effectiveZoom()
); | 217 state.fontBuilder().setFontFamilyValue(value, state.style()->effectiveZoom()
); |
| 217 } | 218 } |
| 218 | 219 |
| 219 void StyleBuilderFunctions::applyInitialCSSPropertyFontSize(StyleResolver*, Styl
eResolverState& state) | 220 void StyleBuilderFunctions::applyInitialCSSPropertyFontSize(StyleResolverState&
state) |
| 220 { | 221 { |
| 221 state.fontBuilder().setFontSizeInitial(state.style()->effectiveZoom()); | 222 state.fontBuilder().setFontSizeInitial(state.style()->effectiveZoom()); |
| 222 } | 223 } |
| 223 | 224 |
| 224 void StyleBuilderFunctions::applyInheritCSSPropertyFontSize(StyleResolver*, Styl
eResolverState& state) | 225 void StyleBuilderFunctions::applyInheritCSSPropertyFontSize(StyleResolverState&
state) |
| 225 { | 226 { |
| 226 state.fontBuilder().setFontSizeInherit(state.parentFontDescription(), state.
style()->effectiveZoom()); | 227 state.fontBuilder().setFontSizeInherit(state.parentFontDescription(), state.
style()->effectiveZoom()); |
| 227 } | 228 } |
| 228 | 229 |
| 229 void StyleBuilderFunctions::applyValueCSSPropertyFontSize(StyleResolver*, StyleR
esolverState& state, CSSValue* value) | 230 void StyleBuilderFunctions::applyValueCSSPropertyFontSize(StyleResolverState& st
ate, CSSValue* value) |
| 230 { | 231 { |
| 231 state.fontBuilder().setFontSizeValue(value, state.parentStyle(), state.rootE
lementStyle(), state.style()->effectiveZoom()); | 232 state.fontBuilder().setFontSizeValue(value, state.parentStyle(), state.rootE
lementStyle(), state.style()->effectiveZoom()); |
| 232 } | 233 } |
| 233 | 234 |
| 234 void StyleBuilderFunctions::applyInitialCSSPropertyFontWeight(StyleResolver*, St
yleResolverState& state) | 235 void StyleBuilderFunctions::applyInitialCSSPropertyFontWeight(StyleResolverState
& state) |
| 235 { | 236 { |
| 236 state.fontBuilder().setWeight(FontWeightNormal); | 237 state.fontBuilder().setWeight(FontWeightNormal); |
| 237 } | 238 } |
| 238 | 239 |
| 239 void StyleBuilderFunctions::applyInheritCSSPropertyFontWeight(StyleResolver*, St
yleResolverState& state) | 240 void StyleBuilderFunctions::applyInheritCSSPropertyFontWeight(StyleResolverState
& state) |
| 240 { | 241 { |
| 241 state.fontBuilder().setWeight(state.parentFontDescription().weight()); | 242 state.fontBuilder().setWeight(state.parentFontDescription().weight()); |
| 242 } | 243 } |
| 243 | 244 |
| 244 void StyleBuilderFunctions::applyValueCSSPropertyFontWeight(StyleResolver*, Styl
eResolverState& state, CSSValue* value) | 245 void StyleBuilderFunctions::applyValueCSSPropertyFontWeight(StyleResolverState&
state, CSSValue* value) |
| 245 { | 246 { |
| 246 if (!value->isPrimitiveValue()) | 247 if (!value->isPrimitiveValue()) |
| 247 return; | 248 return; |
| 248 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 249 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 249 switch (primitiveValue->getValueID()) { | 250 switch (primitiveValue->getValueID()) { |
| 250 case CSSValueInvalid: | 251 case CSSValueInvalid: |
| 251 ASSERT_NOT_REACHED(); | 252 ASSERT_NOT_REACHED(); |
| 252 break; | 253 break; |
| 253 case CSSValueBolder: | 254 case CSSValueBolder: |
| 254 state.fontBuilder().setWeightBolder(); | 255 state.fontBuilder().setWeightBolder(); |
| 255 break; | 256 break; |
| 256 case CSSValueLighter: | 257 case CSSValueLighter: |
| 257 state.fontBuilder().setWeightLighter(); | 258 state.fontBuilder().setWeightLighter(); |
| 258 break; | 259 break; |
| 259 default: | 260 default: |
| 260 state.fontBuilder().setWeight(*primitiveValue); | 261 state.fontBuilder().setWeight(*primitiveValue); |
| 261 } | 262 } |
| 262 } | 263 } |
| 263 | 264 |
| 264 void StyleBuilderFunctions::applyValueCSSPropertyLineHeight(StyleResolver* style
Resolver, StyleResolverState& state, CSSValue* value) | 265 void StyleBuilderFunctions::applyValueCSSPropertyLineHeight(StyleResolverState&
state, CSSValue* value) |
| 265 { | 266 { |
| 266 if (!value->isPrimitiveValue()) | 267 if (!value->isPrimitiveValue()) |
| 267 return; | 268 return; |
| 268 | 269 |
| 269 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 270 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 270 Length lineHeight; | 271 Length lineHeight; |
| 271 | 272 |
| 272 if (primitiveValue->getValueID() == CSSValueNormal) { | 273 if (primitiveValue->getValueID() == CSSValueNormal) { |
| 273 lineHeight = RenderStyle::initialLineHeight(); | 274 lineHeight = RenderStyle::initialLineHeight(); |
| 274 } else if (primitiveValue->isLength()) { | 275 } else if (primitiveValue->isLength()) { |
| 275 double multiplier = state.style()->effectiveZoom(); | 276 double multiplier = state.style()->effectiveZoom(); |
| 276 if (Frame* frame = styleResolver->document()->frame()) | 277 if (Frame* frame = state.document()->frame()) |
| 277 multiplier *= frame->textZoomFactor(); | 278 multiplier *= frame->textZoomFactor(); |
| 278 lineHeight = primitiveValue->computeLength<Length>(state.style(), state.
rootElementStyle(), multiplier); | 279 lineHeight = primitiveValue->computeLength<Length>(state.style(), state.
rootElementStyle(), multiplier); |
| 279 } else if (primitiveValue->isPercentage()) { | 280 } else if (primitiveValue->isPercentage()) { |
| 280 // FIXME: percentage should not be restricted to an integer here. | 281 // FIXME: percentage should not be restricted to an integer here. |
| 281 lineHeight = Length((state.style()->fontSize() * primitiveValue->getIntV
alue()) / 100, Fixed); | 282 lineHeight = Length((state.style()->fontSize() * primitiveValue->getIntV
alue()) / 100, Fixed); |
| 282 } else if (primitiveValue->isNumber()) { | 283 } else if (primitiveValue->isNumber()) { |
| 283 // FIXME: number and percentage values should produce the same type of L
ength (ie. Fixed or Percent). | 284 // FIXME: number and percentage values should produce the same type of L
ength (ie. Fixed or Percent). |
| 284 lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent); | 285 lineHeight = Length(primitiveValue->getDoubleValue() * 100.0, Percent); |
| 285 } else if (primitiveValue->isViewportPercentageLength()) { | 286 } else if (primitiveValue->isViewportPercentageLength()) { |
| 286 lineHeight = primitiveValue->viewportPercentageLength(); | 287 lineHeight = primitiveValue->viewportPercentageLength(); |
| 287 } else { | 288 } else { |
| 288 return; | 289 return; |
| 289 } | 290 } |
| 290 state.style()->setLineHeight(lineHeight); | 291 state.style()->setLineHeight(lineHeight); |
| 291 } | 292 } |
| 292 | 293 |
| 293 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolver*,
StyleResolverState& state, CSSValue* value) | 294 void StyleBuilderFunctions::applyValueCSSPropertyListStyleImage(StyleResolverSta
te& state, CSSValue* value) |
| 294 { | 295 { |
| 295 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage,
value)); | 296 state.style()->setListStyleImage(state.styleImage(CSSPropertyListStyleImage,
value)); |
| 296 } | 297 } |
| 297 | 298 |
| 298 void StyleBuilderFunctions::applyInitialCSSPropertyOutlineStyle(StyleResolver*,
StyleResolverState& state) | 299 void StyleBuilderFunctions::applyInitialCSSPropertyOutlineStyle(StyleResolverSta
te& state) |
| 299 { | 300 { |
| 300 state.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto(
)); | 301 state.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto(
)); |
| 301 state.style()->setOutlineStyle(RenderStyle::initialBorderStyle()); | 302 state.style()->setOutlineStyle(RenderStyle::initialBorderStyle()); |
| 302 } | 303 } |
| 303 | 304 |
| 304 void StyleBuilderFunctions::applyInheritCSSPropertyOutlineStyle(StyleResolver*,
StyleResolverState& state) | 305 void StyleBuilderFunctions::applyInheritCSSPropertyOutlineStyle(StyleResolverSta
te& state) |
| 305 { | 306 { |
| 306 state.style()->setOutlineStyleIsAuto(state.parentStyle()->outlineStyleIsAuto
()); | 307 state.style()->setOutlineStyleIsAuto(state.parentStyle()->outlineStyleIsAuto
()); |
| 307 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle()); | 308 state.style()->setOutlineStyle(state.parentStyle()->outlineStyle()); |
| 308 } | 309 } |
| 309 | 310 |
| 310 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(StyleResolver*, St
yleResolverState& state, CSSValue* value) | 311 void StyleBuilderFunctions::applyValueCSSPropertyOutlineStyle(StyleResolverState
& state, CSSValue* value) |
| 311 { | 312 { |
| 312 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 313 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 313 state.style()->setOutlineStyleIsAuto(*primitiveValue); | 314 state.style()->setOutlineStyleIsAuto(*primitiveValue); |
| 314 state.style()->setOutlineStyle(*primitiveValue); | 315 state.style()->setOutlineStyle(*primitiveValue); |
| 315 } | 316 } |
| 316 | 317 |
| 317 void StyleBuilderFunctions::applyValueCSSPropertyResize(StyleResolver* styleReso
lver, StyleResolverState& state, CSSValue* value) | 318 void StyleBuilderFunctions::applyValueCSSPropertyResize(StyleResolverState& stat
e, CSSValue* value) |
| 318 { | 319 { |
| 319 if (!value->isPrimitiveValue()) | 320 if (!value->isPrimitiveValue()) |
| 320 return; | 321 return; |
| 321 | 322 |
| 322 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 323 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 323 | 324 |
| 324 EResize r = RESIZE_NONE; | 325 EResize r = RESIZE_NONE; |
| 325 switch (primitiveValue->getValueID()) { | 326 switch (primitiveValue->getValueID()) { |
| 326 case 0: | 327 case 0: |
| 327 return; | 328 return; |
| 328 case CSSValueAuto: | 329 case CSSValueAuto: |
| 329 if (Settings* settings = styleResolver->document()->settings()) | 330 if (Settings* settings = state.document()->settings()) |
| 330 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; | 331 r = settings->textAreasAreResizable() ? RESIZE_BOTH : RESIZE_NONE; |
| 331 break; | 332 break; |
| 332 default: | 333 default: |
| 333 r = *primitiveValue; | 334 r = *primitiveValue; |
| 334 } | 335 } |
| 335 state.style()->setResize(r); | 336 state.style()->setResize(r); |
| 336 } | 337 } |
| 337 | 338 |
| 338 static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrim
itiveValue::CSS_MM)->computeLength<Length>(0, 0); } | 339 static Length mmLength(double mm) { return CSSPrimitiveValue::create(mm, CSSPrim
itiveValue::CSS_MM)->computeLength<Length>(0, 0); } |
| 339 static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, C
SSPrimitiveValue::CSS_IN)->computeLength<Length>(0, 0); } | 340 static Length inchLength(double inch) { return CSSPrimitiveValue::create(inch, C
SSPrimitiveValue::CSS_IN)->computeLength<Length>(0, 0); } |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 case CSSValuePortrait: | 405 case CSSValuePortrait: |
| 405 // Nothing to do. | 406 // Nothing to do. |
| 406 break; | 407 break; |
| 407 default: | 408 default: |
| 408 return false; | 409 return false; |
| 409 } | 410 } |
| 410 } | 411 } |
| 411 return true; | 412 return true; |
| 412 } | 413 } |
| 413 | 414 |
| 414 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolver*, StyleRes
olverState&) { } | 415 void StyleBuilderFunctions::applyInitialCSSPropertySize(StyleResolverState&) { } |
| 415 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolver*, StyleRes
olverState&) { } | 416 void StyleBuilderFunctions::applyInheritCSSPropertySize(StyleResolverState&) { } |
| 416 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolver*, StyleResol
verState& state, CSSValue* value) | 417 void StyleBuilderFunctions::applyValueCSSPropertySize(StyleResolverState& state,
CSSValue* value) |
| 417 { | 418 { |
| 418 state.style()->resetPageSizeType(); | 419 state.style()->resetPageSizeType(); |
| 419 Length width; | 420 Length width; |
| 420 Length height; | 421 Length height; |
| 421 PageSizeType pageSizeType = PAGE_SIZE_AUTO; | 422 PageSizeType pageSizeType = PAGE_SIZE_AUTO; |
| 422 CSSValueListInspector inspector(value); | 423 CSSValueListInspector inspector(value); |
| 423 switch (inspector.length()) { | 424 switch (inspector.length()) { |
| 424 case 2: { | 425 case 2: { |
| 425 // <length>{2} | <page-size> <orientation> | 426 // <length>{2} | <page-size> <orientation> |
| 426 if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPri
mitiveValue()) | 427 if (!inspector.first()->isPrimitiveValue() || !inspector.second()->isPri
mitiveValue()) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 473 } | 474 } |
| 474 break; | 475 break; |
| 475 } | 476 } |
| 476 default: | 477 default: |
| 477 return; | 478 return; |
| 478 } | 479 } |
| 479 state.style()->setPageSizeType(pageSizeType); | 480 state.style()->setPageSizeType(pageSizeType); |
| 480 state.style()->setPageSize(LengthSize(width, height)); | 481 state.style()->setPageSize(LengthSize(width, height)); |
| 481 } | 482 } |
| 482 | 483 |
| 483 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolver*, Style
ResolverState& state, CSSValue* value) | 484 void StyleBuilderFunctions::applyValueCSSPropertyTextAlign(StyleResolverState& s
tate, CSSValue* value) |
| 484 { | 485 { |
| 485 if (!value->isPrimitiveValue()) | 486 if (!value->isPrimitiveValue()) |
| 486 return; | 487 return; |
| 487 | 488 |
| 488 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 489 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 489 // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <str
ing> but this is not implemented in the | 490 // FIXME : Per http://www.w3.org/TR/css3-text/#text-align0 can now take <str
ing> but this is not implemented in the |
| 490 // rendering code. | 491 // rendering code. |
| 491 if (primitiveValue->isString()) | 492 if (primitiveValue->isString()) |
| 492 return; | 493 return; |
| 493 | 494 |
| 494 if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueW
ebkitMatchParent) | 495 if (primitiveValue->isValueID() && primitiveValue->getValueID() != CSSValueW
ebkitMatchParent) |
| 495 state.style()->setTextAlign(*primitiveValue); | 496 state.style()->setTextAlign(*primitiveValue); |
| 496 else if (state.parentStyle()->textAlign() == TASTART) | 497 else if (state.parentStyle()->textAlign() == TASTART) |
| 497 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection(
) ? LEFT : RIGHT); | 498 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection(
) ? LEFT : RIGHT); |
| 498 else if (state.parentStyle()->textAlign() == TAEND) | 499 else if (state.parentStyle()->textAlign() == TAEND) |
| 499 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection(
) ? RIGHT : LEFT); | 500 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection(
) ? RIGHT : LEFT); |
| 500 else | 501 else |
| 501 state.style()->setTextAlign(state.parentStyle()->textAlign()); | 502 state.style()->setTextAlign(state.parentStyle()->textAlign()); |
| 502 } | 503 } |
| 503 | 504 |
| 504 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolver*,
StyleResolverState& state, CSSValue* value) | 505 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolverSta
te& state, CSSValue* value) |
| 505 { | 506 { |
| 506 TextDecoration t = RenderStyle::initialTextDecoration(); | 507 TextDecoration t = RenderStyle::initialTextDecoration(); |
| 507 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { | 508 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { |
| 508 CSSValue* item = i.value(); | 509 CSSValue* item = i.value(); |
| 509 t |= *toCSSPrimitiveValue(item); | 510 t |= *toCSSPrimitiveValue(item); |
| 510 } | 511 } |
| 511 state.style()->setTextDecoration(t); | 512 state.style()->setTextDecoration(t); |
| 512 } | 513 } |
| 513 | 514 |
| 514 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolver*, St
yleResolverState& state) | 515 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolverState
& state) |
| 515 { | 516 { |
| 516 state.style()->setTextIndent(state.parentStyle()->textIndent()); | 517 state.style()->setTextIndent(state.parentStyle()->textIndent()); |
| 517 #if ENABLE(CSS3_TEXT) | 518 #if ENABLE(CSS3_TEXT) |
| 518 state.style()->setTextIndentLine(state.parentStyle()->textIndentLine()); | 519 state.style()->setTextIndentLine(state.parentStyle()->textIndentLine()); |
| 519 #endif | 520 #endif |
| 520 } | 521 } |
| 521 | 522 |
| 522 void StyleBuilderFunctions::applyInitialCSSPropertyTextIndent(StyleResolver*, St
yleResolverState& state) | 523 void StyleBuilderFunctions::applyInitialCSSPropertyTextIndent(StyleResolverState
& state) |
| 523 { | 524 { |
| 524 state.style()->setTextIndent(RenderStyle::initialTextIndent()); | 525 state.style()->setTextIndent(RenderStyle::initialTextIndent()); |
| 525 #if ENABLE(CSS3_TEXT) | 526 #if ENABLE(CSS3_TEXT) |
| 526 state.style()->setTextIndentLine(RenderStyle::initialTextIndentLine()); | 527 state.style()->setTextIndentLine(RenderStyle::initialTextIndentLine()); |
| 527 #endif | 528 #endif |
| 528 } | 529 } |
| 529 | 530 |
| 530 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolver*, Styl
eResolverState& state, CSSValue* value) | 531 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolverState&
state, CSSValue* value) |
| 531 { | 532 { |
| 532 if (!value->isValueList()) | 533 if (!value->isValueList()) |
| 533 return; | 534 return; |
| 534 | 535 |
| 535 // [ <length> | <percentage> ] -webkit-each-line | 536 // [ <length> | <percentage> ] -webkit-each-line |
| 536 // The order is guaranteed. See CSSParser::parseTextIndent. | 537 // The order is guaranteed. See CSSParser::parseTextIndent. |
| 537 // The second value, -webkit-each-line is handled only when CSS3_TEXT is ena
bled. | 538 // The second value, -webkit-each-line is handled only when CSS3_TEXT is ena
bled. |
| 538 | 539 |
| 539 CSSValueList* valueList = toCSSValueList(value); | 540 CSSValueList* valueList = toCSSValueList(value); |
| 540 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho
utBoundsCheck(0)); | 541 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho
utBoundsCheck(0)); |
| 541 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntege
rConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.
style()->effectiveZoom()); | 542 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntege
rConversion | PercentConversion>(state.style(), state.rootElementStyle(), state.
style()->effectiveZoom()); |
| 542 ASSERT(!lengthOrPercentageValue.isUndefined()); | 543 ASSERT(!lengthOrPercentageValue.isUndefined()); |
| 543 state.style()->setTextIndent(lengthOrPercentageValue); | 544 state.style()->setTextIndent(lengthOrPercentageValue); |
| 544 | 545 |
| 545 #if ENABLE(CSS3_TEXT) | 546 #if ENABLE(CSS3_TEXT) |
| 546 ASSERT(valueList->length() <= 2); | 547 ASSERT(valueList->length() <= 2); |
| 547 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); | 548 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); |
| 548 if (eachLineValue) { | 549 if (eachLineValue) { |
| 549 ASSERT(eachLineValue->getValueID() == CSSValueWebkitEachLine); | 550 ASSERT(eachLineValue->getValueID() == CSSValueWebkitEachLine); |
| 550 state.style()->setTextIndentLine(TextIndentEachLine); | 551 state.style()->setTextIndentLine(TextIndentEachLine); |
| 551 } else { | 552 } else { |
| 552 state.style()->setTextIndentLine(TextIndentFirstLine); | 553 state.style()->setTextIndentLine(TextIndentFirstLine); |
| 553 } | 554 } |
| 554 #endif | 555 #endif |
| 555 } | 556 } |
| 556 | 557 |
| 557 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolver*, S
tyleResolverState& state, CSSValue* value) | 558 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverStat
e& state, CSSValue* value) |
| 558 { | 559 { |
| 559 if (!value->isPrimitiveValue()) | 560 if (!value->isPrimitiveValue()) |
| 560 return; | 561 return; |
| 561 | 562 |
| 562 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 563 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 563 | 564 |
| 564 if (primitiveValue->getValueID()) | 565 if (primitiveValue->getValueID()) |
| 565 return state.style()->setVerticalAlign(*primitiveValue); | 566 return state.style()->setVerticalAlign(*primitiveValue); |
| 566 | 567 |
| 567 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedI
ntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), s
tate.style()->effectiveZoom())); | 568 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedI
ntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), s
tate.style()->effectiveZoom())); |
| 568 } | 569 } |
| 569 | 570 |
| 570 static void resetEffectiveZoom(StyleResolverState& state) | 571 static void resetEffectiveZoom(StyleResolverState& state) |
| 571 { | 572 { |
| 572 // Reset the zoom in effect. This allows the setZoom method to accurately co
mpute a new zoom in effect. | 573 // Reset the zoom in effect. This allows the setZoom method to accurately co
mpute a new zoom in effect. |
| 573 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ
oom() : RenderStyle::initialZoom()); | 574 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ
oom() : RenderStyle::initialZoom()); |
| 574 } | 575 } |
| 575 | 576 |
| 576 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolver*, StyleRes
olverState& state) | 577 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& stat
e) |
| 577 { | 578 { |
| 578 resetEffectiveZoom(state); | 579 resetEffectiveZoom(state); |
| 579 state.setZoom(RenderStyle::initialZoom()); | 580 state.setZoom(RenderStyle::initialZoom()); |
| 580 } | 581 } |
| 581 | 582 |
| 582 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(StyleResolver*, StyleRes
olverState& state) | 583 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(StyleResolverState& stat
e) |
| 583 { | 584 { |
| 584 resetEffectiveZoom(state); | 585 resetEffectiveZoom(state); |
| 585 state.setZoom(state.parentStyle()->zoom()); | 586 state.setZoom(state.parentStyle()->zoom()); |
| 586 } | 587 } |
| 587 | 588 |
| 588 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolver*, StyleResol
verState& state, CSSValue* value) | 589 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolverState& state,
CSSValue* value) |
| 589 { | 590 { |
| 590 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); | 591 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); |
| 591 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 592 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 592 | 593 |
| 593 if (primitiveValue->getValueID() == CSSValueNormal) { | 594 if (primitiveValue->getValueID() == CSSValueNormal) { |
| 594 resetEffectiveZoom(state); | 595 resetEffectiveZoom(state); |
| 595 state.setZoom(RenderStyle::initialZoom()); | 596 state.setZoom(RenderStyle::initialZoom()); |
| 596 } else if (primitiveValue->getValueID() == CSSValueReset) { | 597 } else if (primitiveValue->getValueID() == CSSValueReset) { |
| 597 state.setEffectiveZoom(RenderStyle::initialZoom()); | 598 state.setEffectiveZoom(RenderStyle::initialZoom()); |
| 598 state.setZoom(RenderStyle::initialZoom()); | 599 state.setZoom(RenderStyle::initialZoom()); |
| 599 } else if (primitiveValue->getValueID() == CSSValueDocument) { | 600 } else if (primitiveValue->getValueID() == CSSValueDocument) { |
| 600 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoo
m() : RenderStyle::initialZoom(); | 601 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoo
m() : RenderStyle::initialZoom(); |
| 601 state.setEffectiveZoom(docZoom); | 602 state.setEffectiveZoom(docZoom); |
| 602 state.setZoom(docZoom); | 603 state.setZoom(docZoom); |
| 603 } else if (primitiveValue->isPercentage()) { | 604 } else if (primitiveValue->isPercentage()) { |
| 604 resetEffectiveZoom(state); | 605 resetEffectiveZoom(state); |
| 605 if (float percent = primitiveValue->getFloatValue()) | 606 if (float percent = primitiveValue->getFloatValue()) |
| 606 state.setZoom(percent / 100.0f); | 607 state.setZoom(percent / 100.0f); |
| 607 } else if (primitiveValue->isNumber()) { | 608 } else if (primitiveValue->isNumber()) { |
| 608 resetEffectiveZoom(state); | 609 resetEffectiveZoom(state); |
| 609 if (float number = primitiveValue->getFloatValue()) | 610 if (float number = primitiveValue->getFloatValue()) |
| 610 state.setZoom(number); | 611 state.setZoom(number); |
| 611 } | 612 } |
| 612 } | 613 } |
| 613 | 614 |
| 614 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAspectRatio(StyleResolv
er*, StyleResolverState& state) | 615 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAspectRatio(StyleResolv
erState& state) |
| 615 { | 616 { |
| 616 state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); | 617 state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); |
| 617 state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDeno
minator()); | 618 state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDeno
minator()); |
| 618 state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumera
tor()); | 619 state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumera
tor()); |
| 619 } | 620 } |
| 620 | 621 |
| 621 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAspectRatio(StyleResolv
er*, StyleResolverState& state) | 622 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAspectRatio(StyleResolv
erState& state) |
| 622 { | 623 { |
| 623 if (!state.parentStyle()->hasAspectRatio()) | 624 if (!state.parentStyle()->hasAspectRatio()) |
| 624 return; | 625 return; |
| 625 state.style()->setHasAspectRatio(true); | 626 state.style()->setHasAspectRatio(true); |
| 626 state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDen
ominator()); | 627 state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDen
ominator()); |
| 627 state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumer
ator()); | 628 state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumer
ator()); |
| 628 } | 629 } |
| 629 | 630 |
| 630 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolver
*, StyleResolverState& state, CSSValue* value) | 631 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolver
State& state, CSSValue* value) |
| 631 { | 632 { |
| 632 if (!value->isAspectRatioValue()) { | 633 if (!value->isAspectRatioValue()) { |
| 633 state.style()->setHasAspectRatio(false); | 634 state.style()->setHasAspectRatio(false); |
| 634 return; | 635 return; |
| 635 } | 636 } |
| 636 CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(va
lue); | 637 CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(va
lue); |
| 637 state.style()->setHasAspectRatio(true); | 638 state.style()->setHasAspectRatio(true); |
| 638 state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue(
)); | 639 state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue(
)); |
| 639 state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); | 640 state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); |
| 640 } | 641 } |
| 641 | 642 |
| 642 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolver* s
tyleResolver, StyleResolverState& state, CSSValue* value) | 643 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta
te& state, CSSValue* value) |
| 643 { | 644 { |
| 644 if (value->isPrimitiveValue()) { | 645 if (value->isPrimitiveValue()) { |
| 645 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 646 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 646 if (primitiveValue->getValueID() == CSSValueNone) { | 647 if (primitiveValue->getValueID() == CSSValueNone) { |
| 647 state.style()->setClipPath(0); | 648 state.style()->setClipPath(0); |
| 648 } else if (primitiveValue->isShape()) { | 649 } else if (primitiveValue->isShape()) { |
| 649 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape
ForValue(state, primitiveValue->getShapeValue()))); | 650 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape
ForValue(state, primitiveValue->getShapeValue()))); |
| 650 } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI
) { | 651 } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI
) { |
| 651 String cssURLValue = primitiveValue->getStringValue(); | 652 String cssURLValue = primitiveValue->getStringValue(); |
| 652 KURL url = styleResolver->document()->completeURL(cssURLValue); | 653 KURL url = state.document()->completeURL(cssURLValue); |
| 653 // FIXME: It doesn't work with forward or external SVG references (s
ee https://bugs.webkit.org/show_bug.cgi?id=90405) | 654 // FIXME: It doesn't work with forward or external SVG references (s
ee https://bugs.webkit.org/show_bug.cgi?id=90405) |
| 654 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL
Value, url.fragmentIdentifier())); | 655 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL
Value, url.fragmentIdentifier())); |
| 655 } | 656 } |
| 656 } | 657 } |
| 657 } | 658 } |
| 658 | 659 |
| 659 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitFontVariantLigatures(St
yleResolver*, StyleResolverState& state) | 660 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitFontVariantLigatures(St
yleResolverState& state) |
| 660 { | 661 { |
| 661 state.fontBuilder().setFontVariantLigaturesInitial(); | 662 state.fontBuilder().setFontVariantLigaturesInitial(); |
| 662 } | 663 } |
| 663 | 664 |
| 664 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitFontVariantLigatures(St
yleResolver*, StyleResolverState& state) | 665 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitFontVariantLigatures(St
yleResolverState& state) |
| 665 { | 666 { |
| 666 state.fontBuilder().setFontVariantLigaturesInherit(state.parentFontDescripti
on()); | 667 state.fontBuilder().setFontVariantLigaturesInherit(state.parentFontDescripti
on()); |
| 667 } | 668 } |
| 668 | 669 |
| 669 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFontVariantLigatures(Styl
eResolver*, StyleResolverState& state, CSSValue* value) | 670 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFontVariantLigatures(Styl
eResolverState& state, CSSValue* value) |
| 670 { | 671 { |
| 671 state.fontBuilder().setFontVariantLigaturesValue(value); | 672 state.fontBuilder().setFontVariantLigaturesValue(value); |
| 672 } | 673 } |
| 673 | 674 |
| 674 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeIncrement(StyleRes
olver*, StyleResolverState& state, CSSValue* value) | 675 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeIncrement(StyleRes
olverState& state, CSSValue* value) |
| 675 { | 676 { |
| 676 if (!value->isPrimitiveValue()) | 677 if (!value->isPrimitiveValue()) |
| 677 return; | 678 return; |
| 678 | 679 |
| 679 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 680 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 680 if (primitiveValue->getValueID()) { | 681 if (primitiveValue->getValueID()) { |
| 681 switch (primitiveValue->getValueID()) { | 682 switch (primitiveValue->getValueID()) { |
| 682 case CSSValueSmall: | 683 case CSSValueSmall: |
| 683 state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px. | 684 state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px. |
| 684 break; | 685 break; |
| 685 case CSSValueNormal: | 686 case CSSValueNormal: |
| 686 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi
nIE default. | 687 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi
nIE default. |
| 687 break; | 688 break; |
| 688 case CSSValueLarge: | 689 case CSSValueLarge: |
| 689 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. | 690 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. |
| 690 break; | 691 break; |
| 691 default: | 692 default: |
| 692 break; | 693 break; |
| 693 } | 694 } |
| 694 } else { | 695 } else { |
| 695 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength<
FixedIntegerConversion | PercentConversion | FractionConversion>(state.style(),
state.rootElementStyle()) : Length(Undefined); | 696 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength<
FixedIntegerConversion | PercentConversion | FractionConversion>(state.style(),
state.rootElementStyle()) : Length(Undefined); |
| 696 if (!marqueeLength.isUndefined()) | 697 if (!marqueeLength.isUndefined()) |
| 697 state.style()->setMarqueeIncrement(marqueeLength); | 698 state.style()->setMarqueeIncrement(marqueeLength); |
| 698 } | 699 } |
| 699 } | 700 } |
| 700 | 701 |
| 701 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeSpeed(StyleResolve
r*, StyleResolverState& state, CSSValue* value) | 702 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeSpeed(StyleResolve
rState& state, CSSValue* value) |
| 702 { | 703 { |
| 703 if (!value->isPrimitiveValue()) | 704 if (!value->isPrimitiveValue()) |
| 704 return; | 705 return; |
| 705 | 706 |
| 706 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 707 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 707 if (CSSValueID valueID = primitiveValue->getValueID()) { | 708 if (CSSValueID valueID = primitiveValue->getValueID()) { |
| 708 switch (valueID) { | 709 switch (valueID) { |
| 709 case CSSValueSlow: | 710 case CSSValueSlow: |
| 710 state.style()->setMarqueeSpeed(500); // 500 msec. | 711 state.style()->setMarqueeSpeed(500); // 500 msec. |
| 711 break; | 712 break; |
| 712 case CSSValueNormal: | 713 case CSSValueNormal: |
| 713 state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default. | 714 state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default. |
| 714 break; | 715 break; |
| 715 case CSSValueFast: | 716 case CSSValueFast: |
| 716 state.style()->setMarqueeSpeed(10); // 10msec. Super fast. | 717 state.style()->setMarqueeSpeed(10); // 10msec. Super fast. |
| 717 break; | 718 break; |
| 718 default: | 719 default: |
| 719 break; | 720 break; |
| 720 } | 721 } |
| 721 } else if (primitiveValue->isTime()) { | 722 } else if (primitiveValue->isTime()) { |
| 722 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimi
tiveValue::Milliseconds>()); | 723 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimi
tiveValue::Milliseconds>()); |
| 723 } else if (primitiveValue->isNumber()) { // For scrollamount support. | 724 } else if (primitiveValue->isNumber()) { // For scrollamount support. |
| 724 state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); | 725 state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); |
| 725 } | 726 } |
| 726 } | 727 } |
| 727 | 728 |
| 728 // FIXME: We should use the same system for this as the rest of the pseudo-short
hands (e.g. background-position) | 729 // FIXME: We should use the same system for this as the rest of the pseudo-short
hands (e.g. background-position) |
| 729 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(Style
Resolver* styleResolver, StyleResolverState& state) | 730 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(Style
ResolverState& state) |
| 730 { | 731 { |
| 731 applyInitialCSSPropertyWebkitPerspectiveOriginX(styleResolver, state); | 732 applyInitialCSSPropertyWebkitPerspectiveOriginX(state); |
| 732 applyInitialCSSPropertyWebkitPerspectiveOriginY(styleResolver, state); | 733 applyInitialCSSPropertyWebkitPerspectiveOriginY(state); |
| 733 } | 734 } |
| 734 | 735 |
| 735 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(Style
Resolver* styleResolver, StyleResolverState& state) | 736 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(Style
ResolverState& state) |
| 736 { | 737 { |
| 737 applyInheritCSSPropertyWebkitPerspectiveOriginX(styleResolver, state); | 738 applyInheritCSSPropertyWebkitPerspectiveOriginX(state); |
| 738 applyInheritCSSPropertyWebkitPerspectiveOriginY(styleResolver, state); | 739 applyInheritCSSPropertyWebkitPerspectiveOriginY(state); |
| 739 } | 740 } |
| 740 | 741 |
| 741 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleRe
solver*, StyleResolverState&, CSSValue* value) | 742 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleRe
solverState&, CSSValue* value) |
| 742 { | 743 { |
| 743 // This is expanded in the parser | 744 // This is expanded in the parser |
| 744 ASSERT_NOT_REACHED(); | 745 ASSERT_NOT_REACHED(); |
| 745 } | 746 } |
| 746 | 747 |
| 747 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style
Resolver*, StyleResolverState& state) | 748 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style
ResolverState& state) |
| 748 { | 749 { |
| 749 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); | 750 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); |
| 750 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); | 751 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); |
| 751 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCus
tomMark()); | 752 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCus
tomMark()); |
| 752 } | 753 } |
| 753 | 754 |
| 754 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(Style
Resolver*, StyleResolverState& state) | 755 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(Style
ResolverState& state) |
| 755 { | 756 { |
| 756 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); | 757 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); |
| 757 state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark()); | 758 state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark()); |
| 758 state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCu
stomMark()); | 759 state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCu
stomMark()); |
| 759 } | 760 } |
| 760 | 761 |
| 761 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleRe
solver*, StyleResolverState& state, CSSValue* value) | 762 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleRe
solverState& state, CSSValue* value) |
| 762 { | 763 { |
| 763 if (value->isValueList()) { | 764 if (value->isValueList()) { |
| 764 CSSValueList* list = toCSSValueList(value); | 765 CSSValueList* list = toCSSValueList(value); |
| 765 ASSERT(list->length() == 2); | 766 ASSERT(list->length() == 2); |
| 766 if (list->length() != 2) | 767 if (list->length() != 2) |
| 767 return; | 768 return; |
| 768 for (unsigned i = 0; i < 2; ++i) { | 769 for (unsigned i = 0; i < 2; ++i) { |
| 769 CSSValue* item = list->itemWithoutBoundsCheck(i); | 770 CSSValue* item = list->itemWithoutBoundsCheck(i); |
| 770 if (!item->isPrimitiveValue()) | 771 if (!item->isPrimitiveValue()) |
| 771 continue; | 772 continue; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 796 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal
ueID() == CSSValueOpen) { | 797 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal
ueID() == CSSValueOpen) { |
| 797 state.style()->setTextEmphasisFill(*primitiveValue); | 798 state.style()->setTextEmphasisFill(*primitiveValue); |
| 798 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); | 799 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); |
| 799 } else { | 800 } else { |
| 800 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); | 801 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); |
| 801 state.style()->setTextEmphasisMark(*primitiveValue); | 802 state.style()->setTextEmphasisMark(*primitiveValue); |
| 802 } | 803 } |
| 803 } | 804 } |
| 804 | 805 |
| 805 #if ENABLE(CSS3_TEXT) | 806 #if ENABLE(CSS3_TEXT) |
| 806 void StyleBuilderFunctions::applyValueCSSPropetyWebkitTextUnderlinePosition(Styl
eResolver*, StyleResolverState& state, CSSValue* value) | 807 void StyleBuilderFunctions::applyValueCSSPropetyWebkitTextUnderlinePosition(Styl
eResolverState& state, CSSValue* value) |
| 807 { | 808 { |
| 808 // This is true if value is 'auto' or 'alphabetic'. | 809 // This is true if value is 'auto' or 'alphabetic'. |
| 809 if (value->isPrimitiveValue()) { | 810 if (value->isPrimitiveValue()) { |
| 810 TextUnderlinePosition t = *toCSSPrimitiveValue(value); | 811 TextUnderlinePosition t = *toCSSPrimitiveValue(value); |
| 811 state.style()->setTextUnderlinePosition(t); | 812 state.style()->setTextUnderlinePosition(t); |
| 812 return; | 813 return; |
| 813 } | 814 } |
| 814 | 815 |
| 815 unsigned t = 0; | 816 unsigned t = 0; |
| 816 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { | 817 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1046 return numberToFloat(primitiveValue, out); | 1047 return numberToFloat(primitiveValue, out); |
| 1047 } | 1048 } |
| 1048 | 1049 |
| 1049 static String fragmentIdentifier(const CSSPrimitiveValue* primitiveValue, Docume
nt* document) | 1050 static String fragmentIdentifier(const CSSPrimitiveValue* primitiveValue, Docume
nt* document) |
| 1050 { | 1051 { |
| 1051 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_URI) | 1052 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_URI) |
| 1052 return String(); | 1053 return String(); |
| 1053 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->getS
tringValue(), document); | 1054 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->getS
tringValue(), document); |
| 1054 } | 1055 } |
| 1055 | 1056 |
| 1057 static inline bool isValidVisitedLinkProperty(CSSPropertyID id) |
| 1058 { |
| 1059 switch (id) { |
| 1060 case CSSPropertyBackgroundColor: |
| 1061 case CSSPropertyBorderLeftColor: |
| 1062 case CSSPropertyBorderRightColor: |
| 1063 case CSSPropertyBorderTopColor: |
| 1064 case CSSPropertyBorderBottomColor: |
| 1065 case CSSPropertyColor: |
| 1066 case CSSPropertyFill: |
| 1067 case CSSPropertyOutlineColor: |
| 1068 case CSSPropertyStroke: |
| 1069 case CSSPropertyTextDecorationColor: |
| 1070 case CSSPropertyWebkitColumnRuleColor: |
| 1071 case CSSPropertyWebkitTextEmphasisColor: |
| 1072 case CSSPropertyWebkitTextFillColor: |
| 1073 case CSSPropertyWebkitTextStrokeColor: |
| 1074 return true; |
| 1075 default: |
| 1076 break; |
| 1077 } |
| 1056 | 1078 |
| 1057 // FIXME: Every use of "styleResolver" in this function is a layering | 1079 return false; |
| 1058 // violation and should be removed. | 1080 } |
| 1059 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolver* styleResolv
er, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit) | 1081 |
| 1082 static bool hasVariableReference(CSSValue* value) |
| 1083 { |
| 1084 if (value->isPrimitiveValue()) { |
| 1085 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 1086 return primitiveValue->hasVariableReference(); |
| 1087 } |
| 1088 |
| 1089 if (value->isCalculationValue()) |
| 1090 return static_cast<CSSCalcValue*>(value)->hasVariableReference(); |
| 1091 |
| 1092 if (value->isReflectValue()) { |
| 1093 CSSReflectValue* reflectValue = static_cast<CSSReflectValue*>(value); |
| 1094 CSSPrimitiveValue* direction = reflectValue->direction(); |
| 1095 CSSPrimitiveValue* offset = reflectValue->offset(); |
| 1096 CSSValue* mask = reflectValue->mask(); |
| 1097 return (direction && hasVariableReference(direction)) || (offset && hasV
ariableReference(offset)) || (mask && hasVariableReference(mask)); |
| 1098 } |
| 1099 |
| 1100 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { |
| 1101 if (hasVariableReference(i.value())) |
| 1102 return true; |
| 1103 } |
| 1104 |
| 1105 return false; |
| 1106 } |
| 1107 |
| 1108 // FIXME: Resolving variables should be factored better. Maybe a resover-style c
lass? |
| 1109 static void resolveVariables(StyleResolverState& state, CSSPropertyID id, CSSVal
ue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) |
| 1110 { |
| 1111 std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVar
iables(*state.style()->variables())); |
| 1112 |
| 1113 if (knownExpressions.contains(expression)) |
| 1114 return; // cycle detected. |
| 1115 |
| 1116 knownExpressions.append(expression); |
| 1117 |
| 1118 // FIXME: It would be faster not to re-parse from strings, but for now CSS p
roperty validation lives inside the parser so we do it there. |
| 1119 RefPtr<MutableStylePropertySet> resultSet = MutableStylePropertySet::create(
); |
| 1120 if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, st
ate.document())) |
| 1121 return; // expression failed to parse. |
| 1122 |
| 1123 for (unsigned i = 0; i < resultSet->propertyCount(); i++) { |
| 1124 StylePropertySet::PropertyReference property = resultSet->propertyAt(i); |
| 1125 if (property.id() != CSSPropertyVariable && hasVariableReference(propert
y.value())) { |
| 1126 resolveVariables(state, property.id(), property.value(), knownExpres
sions); |
| 1127 } else { |
| 1128 StyleBuilder::applyProperty(property.id(), state, property.value()); |
| 1129 // All properties become dependent on their parent style when they u
se variables. |
| 1130 state.style()->setHasExplicitlyInheritedProperties(); |
| 1131 } |
| 1132 } |
| 1133 } |
| 1134 |
| 1135 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS
SValue* value) |
| 1136 { |
| 1137 if (id != CSSPropertyVariable && hasVariableReference(value)) { |
| 1138 Vector<std::pair<CSSPropertyID, String> > knownExpressions; |
| 1139 resolveVariables(state, id, value, knownExpressions); |
| 1140 return; |
| 1141 } |
| 1142 |
| 1143 // CSS variables don't resolve shorthands at parsing time, so this should be
*after* handling variables. |
| 1144 ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wa
sn't expanded at parsing time", id); |
| 1145 |
| 1146 bool isInherit = state.parentNode() && value->isInheritedValue(); |
| 1147 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i
sInheritedValue()); |
| 1148 |
| 1149 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial ->
!isInherit |
| 1150 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe
rit -> (state.parentNode() && state.parentStyle()) |
| 1151 |
| 1152 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi
nkStyle() || !isValidVisitedLinkProperty(id))) { |
| 1153 // Limit the properties that can be applied to only the ones honored by
:visited. |
| 1154 return; |
| 1155 } |
| 1156 |
| 1157 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() &&
!CSSProperty::isInheritedProperty(id)) |
| 1158 state.parentStyle()->setHasExplicitlyInheritedProperties(); |
| 1159 |
| 1160 if (id == CSSPropertyVariable) { |
| 1161 ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue()); |
| 1162 CSSVariableValue* variable = toCSSVariableValue(value); |
| 1163 ASSERT(!variable->name().isEmpty()); |
| 1164 ASSERT(!variable->value().isEmpty()); |
| 1165 state.style()->setVariable(variable->name(), variable->value()); |
| 1166 return; |
| 1167 } |
| 1168 |
| 1169 if (StyleBuilder::applyProperty(id, state, value, isInitial, isInherit)) |
| 1170 return; |
| 1171 |
| 1172 // Fall back to the old switch statement, which is now in StyleBuilderCustom
.cpp |
| 1173 StyleBuilder::oldApplyProperty(id, state, value, isInitial, isInherit); |
| 1174 } |
| 1175 |
| 1176 |
| 1177 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state,
CSSValue* value, bool isInitial, bool isInherit) |
| 1060 { | 1178 { |
| 1061 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti
veValue(value) : 0; | 1179 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti
veValue(value) : 0; |
| 1062 | 1180 |
| 1063 float zoomFactor = state.style()->effectiveZoom(); | 1181 float zoomFactor = state.style()->effectiveZoom(); |
| 1064 | 1182 |
| 1065 // What follows is a list that maps the CSS properties into their correspond
ing front-end | 1183 // What follows is a list that maps the CSS properties into their correspond
ing front-end |
| 1066 // RenderStyle values. | 1184 // RenderStyle values. |
| 1067 switch (id) { | 1185 switch (id) { |
| 1068 case CSSPropertyContent: | 1186 case CSSPropertyContent: |
| 1069 // list of string, uri, counter, attr, i | 1187 // list of string, uri, counter, attr, i |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1417 case CSSPropertyWebkitPaddingAfter: | 1535 case CSSPropertyWebkitPaddingAfter: |
| 1418 case CSSPropertyWebkitLogicalWidth: | 1536 case CSSPropertyWebkitLogicalWidth: |
| 1419 case CSSPropertyWebkitLogicalHeight: | 1537 case CSSPropertyWebkitLogicalHeight: |
| 1420 case CSSPropertyWebkitMinLogicalWidth: | 1538 case CSSPropertyWebkitMinLogicalWidth: |
| 1421 case CSSPropertyWebkitMinLogicalHeight: | 1539 case CSSPropertyWebkitMinLogicalHeight: |
| 1422 case CSSPropertyWebkitMaxLogicalWidth: | 1540 case CSSPropertyWebkitMaxLogicalWidth: |
| 1423 case CSSPropertyWebkitMaxLogicalHeight: | 1541 case CSSPropertyWebkitMaxLogicalHeight: |
| 1424 { | 1542 { |
| 1425 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, sta
te.style()->direction(), state.style()->writingMode()); | 1543 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, sta
te.style()->direction(), state.style()->writingMode()); |
| 1426 ASSERT(newId != id); | 1544 ASSERT(newId != id); |
| 1427 return styleResolver->applyProperty(state, newId, value); | 1545 return applyProperty(newId, state, value); |
| 1428 } | 1546 } |
| 1429 case CSSPropertyFontStretch: | 1547 case CSSPropertyFontStretch: |
| 1430 case CSSPropertyPage: | 1548 case CSSPropertyPage: |
| 1431 case CSSPropertyTextLineThroughColor: | 1549 case CSSPropertyTextLineThroughColor: |
| 1432 case CSSPropertyTextLineThroughMode: | 1550 case CSSPropertyTextLineThroughMode: |
| 1433 case CSSPropertyTextLineThroughStyle: | 1551 case CSSPropertyTextLineThroughStyle: |
| 1434 case CSSPropertyTextLineThroughWidth: | 1552 case CSSPropertyTextLineThroughWidth: |
| 1435 case CSSPropertyTextOverlineColor: | 1553 case CSSPropertyTextOverlineColor: |
| 1436 case CSSPropertyTextOverlineMode: | 1554 case CSSPropertyTextOverlineMode: |
| 1437 case CSSPropertyTextOverlineStyle: | 1555 case CSSPropertyTextOverlineStyle: |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2127 break; | 2245 break; |
| 2128 } | 2246 } |
| 2129 case CSSPropertyEnableBackground: | 2247 case CSSPropertyEnableBackground: |
| 2130 // Silently ignoring this property for now | 2248 // Silently ignoring this property for now |
| 2131 // http://bugs.webkit.org/show_bug.cgi?id=6022 | 2249 // http://bugs.webkit.org/show_bug.cgi?id=6022 |
| 2132 break; | 2250 break; |
| 2133 } | 2251 } |
| 2134 } | 2252 } |
| 2135 | 2253 |
| 2136 } // namespace WebCore | 2254 } // namespace WebCore |
| OLD | NEW |