Chromium Code Reviews| 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.elementContext().document()->frame()) |
|
dglazkov
2013/08/01 21:47:49
not lgtm. This one does indeed cause a crash.
| |
| 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.elementContext().document()->settings()) |
|
eseidel
2013/08/01 21:09:53
Does this still risk changing behavior in the <can
dglazkov
2013/08/01 21:16:19
The good news is that in <canvas> we're only apply
| |
| 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 | 490 |
| 490 if (primitiveValue->getValueID() != CSSValueWebkitMatchParent) | 491 if (primitiveValue->getValueID() != CSSValueWebkitMatchParent) |
| 491 state.style()->setTextAlign(*primitiveValue); | 492 state.style()->setTextAlign(*primitiveValue); |
| 492 else if (state.parentStyle()->textAlign() == TASTART) | 493 else if (state.parentStyle()->textAlign() == TASTART) |
| 493 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? LEFT : RIGHT); | 494 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? LEFT : RIGHT); |
| 494 else if (state.parentStyle()->textAlign() == TAEND) | 495 else if (state.parentStyle()->textAlign() == TAEND) |
| 495 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? RIGHT : LEFT); | 496 state.style()->setTextAlign(state.parentStyle()->isLeftToRightDirection( ) ? RIGHT : LEFT); |
| 496 else | 497 else |
| 497 state.style()->setTextAlign(state.parentStyle()->textAlign()); | 498 state.style()->setTextAlign(state.parentStyle()->textAlign()); |
| 498 } | 499 } |
| 499 | 500 |
| 500 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolver*, StyleResolverState& state, CSSValue* value) | 501 void StyleBuilderFunctions::applyValueCSSPropertyTextDecoration(StyleResolverSta te& state, CSSValue* value) |
| 501 { | 502 { |
| 502 TextDecoration t = RenderStyle::initialTextDecoration(); | 503 TextDecoration t = RenderStyle::initialTextDecoration(); |
| 503 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { | 504 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { |
| 504 CSSValue* item = i.value(); | 505 CSSValue* item = i.value(); |
| 505 t |= *toCSSPrimitiveValue(item); | 506 t |= *toCSSPrimitiveValue(item); |
| 506 } | 507 } |
| 507 state.style()->setTextDecoration(t); | 508 state.style()->setTextDecoration(t); |
| 508 } | 509 } |
| 509 | 510 |
| 510 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolver*, St yleResolverState& state) | 511 void StyleBuilderFunctions::applyInheritCSSPropertyTextIndent(StyleResolverState & state) |
| 511 { | 512 { |
| 512 state.style()->setTextIndent(state.parentStyle()->textIndent()); | 513 state.style()->setTextIndent(state.parentStyle()->textIndent()); |
| 513 #if ENABLE(CSS3_TEXT) | 514 #if ENABLE(CSS3_TEXT) |
| 514 state.style()->setTextIndentLine(state.parentStyle()->textIndentLine()); | 515 state.style()->setTextIndentLine(state.parentStyle()->textIndentLine()); |
| 515 #endif | 516 #endif |
| 516 } | 517 } |
| 517 | 518 |
| 518 void StyleBuilderFunctions::applyInitialCSSPropertyTextIndent(StyleResolver*, St yleResolverState& state) | 519 void StyleBuilderFunctions::applyInitialCSSPropertyTextIndent(StyleResolverState & state) |
| 519 { | 520 { |
| 520 state.style()->setTextIndent(RenderStyle::initialTextIndent()); | 521 state.style()->setTextIndent(RenderStyle::initialTextIndent()); |
| 521 #if ENABLE(CSS3_TEXT) | 522 #if ENABLE(CSS3_TEXT) |
| 522 state.style()->setTextIndentLine(RenderStyle::initialTextIndentLine()); | 523 state.style()->setTextIndentLine(RenderStyle::initialTextIndentLine()); |
| 523 #endif | 524 #endif |
| 524 } | 525 } |
| 525 | 526 |
| 526 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolver*, Styl eResolverState& state, CSSValue* value) | 527 void StyleBuilderFunctions::applyValueCSSPropertyTextIndent(StyleResolverState& state, CSSValue* value) |
| 527 { | 528 { |
| 528 if (!value->isValueList()) | 529 if (!value->isValueList()) |
| 529 return; | 530 return; |
| 530 | 531 |
| 531 // [ <length> | <percentage> ] -webkit-each-line | 532 // [ <length> | <percentage> ] -webkit-each-line |
| 532 // The order is guaranteed. See CSSParser::parseTextIndent. | 533 // The order is guaranteed. See CSSParser::parseTextIndent. |
| 533 // The second value, -webkit-each-line is handled only when CSS3_TEXT is ena bled. | 534 // The second value, -webkit-each-line is handled only when CSS3_TEXT is ena bled. |
| 534 | 535 |
| 535 CSSValueList* valueList = toCSSValueList(value); | 536 CSSValueList* valueList = toCSSValueList(value); |
| 536 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho utBoundsCheck(0)); | 537 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(valueList->itemWitho utBoundsCheck(0)); |
| 537 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntege rConversion | PercentConversion>(state.style(), state.rootElementStyle(), state. style()->effectiveZoom()); | 538 Length lengthOrPercentageValue = primitiveValue->convertToLength<FixedIntege rConversion | PercentConversion>(state.style(), state.rootElementStyle(), state. style()->effectiveZoom()); |
| 538 ASSERT(!lengthOrPercentageValue.isUndefined()); | 539 ASSERT(!lengthOrPercentageValue.isUndefined()); |
| 539 state.style()->setTextIndent(lengthOrPercentageValue); | 540 state.style()->setTextIndent(lengthOrPercentageValue); |
| 540 | 541 |
| 541 #if ENABLE(CSS3_TEXT) | 542 #if ENABLE(CSS3_TEXT) |
| 542 ASSERT(valueList->length() <= 2); | 543 ASSERT(valueList->length() <= 2); |
| 543 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); | 544 CSSPrimitiveValue* eachLineValue = toCSSPrimitiveValue(valueList->item(1)); |
| 544 if (eachLineValue) { | 545 if (eachLineValue) { |
| 545 ASSERT(eachLineValue->getValueID() == CSSValueWebkitEachLine); | 546 ASSERT(eachLineValue->getValueID() == CSSValueWebkitEachLine); |
| 546 state.style()->setTextIndentLine(TextIndentEachLine); | 547 state.style()->setTextIndentLine(TextIndentEachLine); |
| 547 } else { | 548 } else { |
| 548 state.style()->setTextIndentLine(TextIndentFirstLine); | 549 state.style()->setTextIndentLine(TextIndentFirstLine); |
| 549 } | 550 } |
| 550 #endif | 551 #endif |
| 551 } | 552 } |
| 552 | 553 |
| 553 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolver*, S tyleResolverState& state, CSSValue* value) | 554 void StyleBuilderFunctions::applyValueCSSPropertyVerticalAlign(StyleResolverStat e& state, CSSValue* value) |
| 554 { | 555 { |
| 555 if (!value->isPrimitiveValue()) | 556 if (!value->isPrimitiveValue()) |
| 556 return; | 557 return; |
| 557 | 558 |
| 558 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 559 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 559 | 560 |
| 560 if (primitiveValue->getValueID()) | 561 if (primitiveValue->getValueID()) |
| 561 return state.style()->setVerticalAlign(*primitiveValue); | 562 return state.style()->setVerticalAlign(*primitiveValue); |
| 562 | 563 |
| 563 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedI ntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), s tate.style()->effectiveZoom())); | 564 state.style()->setVerticalAlignLength(primitiveValue->convertToLength<FixedI ntegerConversion | PercentConversion>(state.style(), state.rootElementStyle(), s tate.style()->effectiveZoom())); |
| 564 } | 565 } |
| 565 | 566 |
| 566 static void resetEffectiveZoom(StyleResolverState& state) | 567 static void resetEffectiveZoom(StyleResolverState& state) |
| 567 { | 568 { |
| 568 // Reset the zoom in effect. This allows the setZoom method to accurately co mpute a new zoom in effect. | 569 // Reset the zoom in effect. This allows the setZoom method to accurately co mpute a new zoom in effect. |
| 569 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ oom() : RenderStyle::initialZoom()); | 570 state.setEffectiveZoom(state.parentStyle() ? state.parentStyle()->effectiveZ oom() : RenderStyle::initialZoom()); |
| 570 } | 571 } |
| 571 | 572 |
| 572 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolver*, StyleRes olverState& state) | 573 void StyleBuilderFunctions::applyInitialCSSPropertyZoom(StyleResolverState& stat e) |
| 573 { | 574 { |
| 574 resetEffectiveZoom(state); | 575 resetEffectiveZoom(state); |
| 575 state.setZoom(RenderStyle::initialZoom()); | 576 state.setZoom(RenderStyle::initialZoom()); |
| 576 } | 577 } |
| 577 | 578 |
| 578 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(StyleResolver*, StyleRes olverState& state) | 579 void StyleBuilderFunctions::applyInheritCSSPropertyZoom(StyleResolverState& stat e) |
| 579 { | 580 { |
| 580 resetEffectiveZoom(state); | 581 resetEffectiveZoom(state); |
| 581 state.setZoom(state.parentStyle()->zoom()); | 582 state.setZoom(state.parentStyle()->zoom()); |
| 582 } | 583 } |
| 583 | 584 |
| 584 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolver*, StyleResol verState& state, CSSValue* value) | 585 void StyleBuilderFunctions::applyValueCSSPropertyZoom(StyleResolverState& state, CSSValue* value) |
| 585 { | 586 { |
| 586 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); | 587 ASSERT_WITH_SECURITY_IMPLICATION(value->isPrimitiveValue()); |
| 587 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 588 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 588 | 589 |
| 589 if (primitiveValue->getValueID() == CSSValueNormal) { | 590 if (primitiveValue->getValueID() == CSSValueNormal) { |
| 590 resetEffectiveZoom(state); | 591 resetEffectiveZoom(state); |
| 591 state.setZoom(RenderStyle::initialZoom()); | 592 state.setZoom(RenderStyle::initialZoom()); |
| 592 } else if (primitiveValue->getValueID() == CSSValueReset) { | 593 } else if (primitiveValue->getValueID() == CSSValueReset) { |
| 593 state.setEffectiveZoom(RenderStyle::initialZoom()); | 594 state.setEffectiveZoom(RenderStyle::initialZoom()); |
| 594 state.setZoom(RenderStyle::initialZoom()); | 595 state.setZoom(RenderStyle::initialZoom()); |
| 595 } else if (primitiveValue->getValueID() == CSSValueDocument) { | 596 } else if (primitiveValue->getValueID() == CSSValueDocument) { |
| 596 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoo m() : RenderStyle::initialZoom(); | 597 float docZoom = state.rootElementStyle() ? state.rootElementStyle()->zoo m() : RenderStyle::initialZoom(); |
| 597 state.setEffectiveZoom(docZoom); | 598 state.setEffectiveZoom(docZoom); |
| 598 state.setZoom(docZoom); | 599 state.setZoom(docZoom); |
| 599 } else if (primitiveValue->isPercentage()) { | 600 } else if (primitiveValue->isPercentage()) { |
| 600 resetEffectiveZoom(state); | 601 resetEffectiveZoom(state); |
| 601 if (float percent = primitiveValue->getFloatValue()) | 602 if (float percent = primitiveValue->getFloatValue()) |
| 602 state.setZoom(percent / 100.0f); | 603 state.setZoom(percent / 100.0f); |
| 603 } else if (primitiveValue->isNumber()) { | 604 } else if (primitiveValue->isNumber()) { |
| 604 resetEffectiveZoom(state); | 605 resetEffectiveZoom(state); |
| 605 if (float number = primitiveValue->getFloatValue()) | 606 if (float number = primitiveValue->getFloatValue()) |
| 606 state.setZoom(number); | 607 state.setZoom(number); |
| 607 } | 608 } |
| 608 } | 609 } |
| 609 | 610 |
| 610 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAspectRatio(StyleResolv er*, StyleResolverState& state) | 611 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitAspectRatio(StyleResolv erState& state) |
| 611 { | 612 { |
| 612 state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); | 613 state.style()->setHasAspectRatio(RenderStyle::initialHasAspectRatio()); |
| 613 state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDeno minator()); | 614 state.style()->setAspectRatioDenominator(RenderStyle::initialAspectRatioDeno minator()); |
| 614 state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumera tor()); | 615 state.style()->setAspectRatioNumerator(RenderStyle::initialAspectRatioNumera tor()); |
| 615 } | 616 } |
| 616 | 617 |
| 617 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAspectRatio(StyleResolv er*, StyleResolverState& state) | 618 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitAspectRatio(StyleResolv erState& state) |
| 618 { | 619 { |
| 619 if (!state.parentStyle()->hasAspectRatio()) | 620 if (!state.parentStyle()->hasAspectRatio()) |
| 620 return; | 621 return; |
| 621 state.style()->setHasAspectRatio(true); | 622 state.style()->setHasAspectRatio(true); |
| 622 state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDen ominator()); | 623 state.style()->setAspectRatioDenominator(state.parentStyle()->aspectRatioDen ominator()); |
| 623 state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumer ator()); | 624 state.style()->setAspectRatioNumerator(state.parentStyle()->aspectRatioNumer ator()); |
| 624 } | 625 } |
| 625 | 626 |
| 626 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolver *, StyleResolverState& state, CSSValue* value) | 627 void StyleBuilderFunctions::applyValueCSSPropertyWebkitAspectRatio(StyleResolver State& state, CSSValue* value) |
| 627 { | 628 { |
| 628 if (!value->isAspectRatioValue()) { | 629 if (!value->isAspectRatioValue()) { |
| 629 state.style()->setHasAspectRatio(false); | 630 state.style()->setHasAspectRatio(false); |
| 630 return; | 631 return; |
| 631 } | 632 } |
| 632 CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(va lue); | 633 CSSAspectRatioValue* aspectRatioValue = static_cast<CSSAspectRatioValue*>(va lue); |
| 633 state.style()->setHasAspectRatio(true); | 634 state.style()->setHasAspectRatio(true); |
| 634 state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue( )); | 635 state.style()->setAspectRatioDenominator(aspectRatioValue->denominatorValue( )); |
| 635 state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); | 636 state.style()->setAspectRatioNumerator(aspectRatioValue->numeratorValue()); |
| 636 } | 637 } |
| 637 | 638 |
| 638 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolver* s tyleResolver, StyleResolverState& state, CSSValue* value) | 639 void StyleBuilderFunctions::applyValueCSSPropertyWebkitClipPath(StyleResolverSta te& state, CSSValue* value) |
| 639 { | 640 { |
| 640 if (value->isPrimitiveValue()) { | 641 if (value->isPrimitiveValue()) { |
| 641 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 642 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 642 if (primitiveValue->getValueID() == CSSValueNone) { | 643 if (primitiveValue->getValueID() == CSSValueNone) { |
| 643 state.style()->setClipPath(0); | 644 state.style()->setClipPath(0); |
| 644 } else if (primitiveValue->isShape()) { | 645 } else if (primitiveValue->isShape()) { |
| 645 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape ForValue(state, primitiveValue->getShapeValue()))); | 646 state.style()->setClipPath(ShapeClipPathOperation::create(basicShape ForValue(state, primitiveValue->getShapeValue()))); |
| 646 } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI ) { | 647 } else if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI ) { |
| 647 String cssURLValue = primitiveValue->getStringValue(); | 648 String cssURLValue = primitiveValue->getStringValue(); |
| 648 KURL url = styleResolver->document()->completeURL(cssURLValue); | 649 KURL url = state.elementContext().document()->completeURL(cssURLValu e); |
|
eseidel
2013/08/01 21:09:53
Same comment. It's also not clear that we shoudl
| |
| 649 // FIXME: It doesn't work with forward or external SVG references (s ee https://bugs.webkit.org/show_bug.cgi?id=90405) | 650 // FIXME: It doesn't work with forward or external SVG references (s ee https://bugs.webkit.org/show_bug.cgi?id=90405) |
| 650 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL Value, url.fragmentIdentifier())); | 651 state.style()->setClipPath(ReferenceClipPathOperation::create(cssURL Value, url.fragmentIdentifier())); |
| 651 } | 652 } |
| 652 } | 653 } |
| 653 } | 654 } |
| 654 | 655 |
| 655 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitFontVariantLigatures(St yleResolver*, StyleResolverState& state) | 656 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitFontVariantLigatures(St yleResolverState& state) |
| 656 { | 657 { |
| 657 state.fontBuilder().setFontVariantLigaturesInitial(); | 658 state.fontBuilder().setFontVariantLigaturesInitial(); |
| 658 } | 659 } |
| 659 | 660 |
| 660 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitFontVariantLigatures(St yleResolver*, StyleResolverState& state) | 661 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitFontVariantLigatures(St yleResolverState& state) |
| 661 { | 662 { |
| 662 state.fontBuilder().setFontVariantLigaturesInherit(state.parentFontDescripti on()); | 663 state.fontBuilder().setFontVariantLigaturesInherit(state.parentFontDescripti on()); |
| 663 } | 664 } |
| 664 | 665 |
| 665 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFontVariantLigatures(Styl eResolver*, StyleResolverState& state, CSSValue* value) | 666 void StyleBuilderFunctions::applyValueCSSPropertyWebkitFontVariantLigatures(Styl eResolverState& state, CSSValue* value) |
| 666 { | 667 { |
| 667 state.fontBuilder().setFontVariantLigaturesValue(value); | 668 state.fontBuilder().setFontVariantLigaturesValue(value); |
| 668 } | 669 } |
| 669 | 670 |
| 670 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeIncrement(StyleRes olver*, StyleResolverState& state, CSSValue* value) | 671 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeIncrement(StyleRes olverState& state, CSSValue* value) |
| 671 { | 672 { |
| 672 if (!value->isPrimitiveValue()) | 673 if (!value->isPrimitiveValue()) |
| 673 return; | 674 return; |
| 674 | 675 |
| 675 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 676 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 676 if (primitiveValue->getValueID()) { | 677 if (primitiveValue->getValueID()) { |
| 677 switch (primitiveValue->getValueID()) { | 678 switch (primitiveValue->getValueID()) { |
| 678 case CSSValueSmall: | 679 case CSSValueSmall: |
| 679 state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px. | 680 state.style()->setMarqueeIncrement(Length(1, Fixed)); // 1px. |
| 680 break; | 681 break; |
| 681 case CSSValueNormal: | 682 case CSSValueNormal: |
| 682 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi nIE default. | 683 state.style()->setMarqueeIncrement(Length(6, Fixed)); // 6px. The Wi nIE default. |
| 683 break; | 684 break; |
| 684 case CSSValueLarge: | 685 case CSSValueLarge: |
| 685 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. | 686 state.style()->setMarqueeIncrement(Length(36, Fixed)); // 36px. |
| 686 break; | 687 break; |
| 687 default: | 688 default: |
| 688 break; | 689 break; |
| 689 } | 690 } |
| 690 } else { | 691 } else { |
| 691 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength< FixedIntegerConversion | PercentConversion | FractionConversion>(state.style(), state.rootElementStyle()) : Length(Undefined); | 692 Length marqueeLength = primitiveValue ? primitiveValue->convertToLength< FixedIntegerConversion | PercentConversion | FractionConversion>(state.style(), state.rootElementStyle()) : Length(Undefined); |
| 692 if (!marqueeLength.isUndefined()) | 693 if (!marqueeLength.isUndefined()) |
| 693 state.style()->setMarqueeIncrement(marqueeLength); | 694 state.style()->setMarqueeIncrement(marqueeLength); |
| 694 } | 695 } |
| 695 } | 696 } |
| 696 | 697 |
| 697 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeSpeed(StyleResolve r*, StyleResolverState& state, CSSValue* value) | 698 void StyleBuilderFunctions::applyValueCSSPropertyWebkitMarqueeSpeed(StyleResolve rState& state, CSSValue* value) |
| 698 { | 699 { |
| 699 if (!value->isPrimitiveValue()) | 700 if (!value->isPrimitiveValue()) |
| 700 return; | 701 return; |
| 701 | 702 |
| 702 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 703 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 703 if (CSSValueID valueID = primitiveValue->getValueID()) { | 704 if (CSSValueID valueID = primitiveValue->getValueID()) { |
| 704 switch (valueID) { | 705 switch (valueID) { |
| 705 case CSSValueSlow: | 706 case CSSValueSlow: |
| 706 state.style()->setMarqueeSpeed(500); // 500 msec. | 707 state.style()->setMarqueeSpeed(500); // 500 msec. |
| 707 break; | 708 break; |
| 708 case CSSValueNormal: | 709 case CSSValueNormal: |
| 709 state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default. | 710 state.style()->setMarqueeSpeed(85); // 85msec. The WinIE default. |
| 710 break; | 711 break; |
| 711 case CSSValueFast: | 712 case CSSValueFast: |
| 712 state.style()->setMarqueeSpeed(10); // 10msec. Super fast. | 713 state.style()->setMarqueeSpeed(10); // 10msec. Super fast. |
| 713 break; | 714 break; |
| 714 default: | 715 default: |
| 715 break; | 716 break; |
| 716 } | 717 } |
| 717 } else if (primitiveValue->isTime()) { | 718 } else if (primitiveValue->isTime()) { |
| 718 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimi tiveValue::Milliseconds>()); | 719 state.style()->setMarqueeSpeed(primitiveValue->computeTime<int, CSSPrimi tiveValue::Milliseconds>()); |
| 719 } else if (primitiveValue->isNumber()) { // For scrollamount support. | 720 } else if (primitiveValue->isNumber()) { // For scrollamount support. |
| 720 state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); | 721 state.style()->setMarqueeSpeed(primitiveValue->getIntValue()); |
| 721 } | 722 } |
| 722 } | 723 } |
| 723 | 724 |
| 724 // FIXME: We should use the same system for this as the rest of the pseudo-short hands (e.g. background-position) | 725 // FIXME: We should use the same system for this as the rest of the pseudo-short hands (e.g. background-position) |
| 725 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(Style Resolver* styleResolver, StyleResolverState& state) | 726 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitPerspectiveOrigin(Style ResolverState& state) |
| 726 { | 727 { |
| 727 applyInitialCSSPropertyWebkitPerspectiveOriginX(styleResolver, state); | 728 applyInitialCSSPropertyWebkitPerspectiveOriginX(state); |
| 728 applyInitialCSSPropertyWebkitPerspectiveOriginY(styleResolver, state); | 729 applyInitialCSSPropertyWebkitPerspectiveOriginY(state); |
| 729 } | 730 } |
| 730 | 731 |
| 731 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(Style Resolver* styleResolver, StyleResolverState& state) | 732 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitPerspectiveOrigin(Style ResolverState& state) |
| 732 { | 733 { |
| 733 applyInheritCSSPropertyWebkitPerspectiveOriginX(styleResolver, state); | 734 applyInheritCSSPropertyWebkitPerspectiveOriginX(state); |
| 734 applyInheritCSSPropertyWebkitPerspectiveOriginY(styleResolver, state); | 735 applyInheritCSSPropertyWebkitPerspectiveOriginY(state); |
| 735 } | 736 } |
| 736 | 737 |
| 737 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleRe solver*, StyleResolverState&, CSSValue* value) | 738 void StyleBuilderFunctions::applyValueCSSPropertyWebkitPerspectiveOrigin(StyleRe solverState&, CSSValue* value) |
| 738 { | 739 { |
| 739 // This is expanded in the parser | 740 // This is expanded in the parser |
| 740 ASSERT_NOT_REACHED(); | 741 ASSERT_NOT_REACHED(); |
| 741 } | 742 } |
| 742 | 743 |
| 743 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style Resolver*, StyleResolverState& state) | 744 void StyleBuilderFunctions::applyInitialCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state) |
| 744 { | 745 { |
| 745 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); | 746 state.style()->setTextEmphasisFill(RenderStyle::initialTextEmphasisFill()); |
| 746 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); | 747 state.style()->setTextEmphasisMark(RenderStyle::initialTextEmphasisMark()); |
| 747 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCus tomMark()); | 748 state.style()->setTextEmphasisCustomMark(RenderStyle::initialTextEmphasisCus tomMark()); |
| 748 } | 749 } |
| 749 | 750 |
| 750 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(Style Resolver*, StyleResolverState& state) | 751 void StyleBuilderFunctions::applyInheritCSSPropertyWebkitTextEmphasisStyle(Style ResolverState& state) |
| 751 { | 752 { |
| 752 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); | 753 state.style()->setTextEmphasisFill(state.parentStyle()->textEmphasisFill()); |
| 753 state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark()); | 754 state.style()->setTextEmphasisMark(state.parentStyle()->textEmphasisMark()); |
| 754 state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCu stomMark()); | 755 state.style()->setTextEmphasisCustomMark(state.parentStyle()->textEmphasisCu stomMark()); |
| 755 } | 756 } |
| 756 | 757 |
| 757 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleRe solver*, StyleResolverState& state, CSSValue* value) | 758 void StyleBuilderFunctions::applyValueCSSPropertyWebkitTextEmphasisStyle(StyleRe solverState& state, CSSValue* value) |
| 758 { | 759 { |
| 759 if (value->isValueList()) { | 760 if (value->isValueList()) { |
| 760 CSSValueList* list = toCSSValueList(value); | 761 CSSValueList* list = toCSSValueList(value); |
| 761 ASSERT(list->length() == 2); | 762 ASSERT(list->length() == 2); |
| 762 if (list->length() != 2) | 763 if (list->length() != 2) |
| 763 return; | 764 return; |
| 764 for (unsigned i = 0; i < 2; ++i) { | 765 for (unsigned i = 0; i < 2; ++i) { |
| 765 CSSValue* item = list->itemWithoutBoundsCheck(i); | 766 CSSValue* item = list->itemWithoutBoundsCheck(i); |
| 766 if (!item->isPrimitiveValue()) | 767 if (!item->isPrimitiveValue()) |
| 767 continue; | 768 continue; |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 792 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) { | 793 if (primitiveValue->getValueID() == CSSValueFilled || primitiveValue->getVal ueID() == CSSValueOpen) { |
| 793 state.style()->setTextEmphasisFill(*primitiveValue); | 794 state.style()->setTextEmphasisFill(*primitiveValue); |
| 794 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); | 795 state.style()->setTextEmphasisMark(TextEmphasisMarkAuto); |
| 795 } else { | 796 } else { |
| 796 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); | 797 state.style()->setTextEmphasisFill(TextEmphasisFillFilled); |
| 797 state.style()->setTextEmphasisMark(*primitiveValue); | 798 state.style()->setTextEmphasisMark(*primitiveValue); |
| 798 } | 799 } |
| 799 } | 800 } |
| 800 | 801 |
| 801 #if ENABLE(CSS3_TEXT) | 802 #if ENABLE(CSS3_TEXT) |
| 802 void StyleBuilderFunctions::applyValueCSSPropetyWebkitTextUnderlinePosition(Styl eResolver*, StyleResolverState& state, CSSValue* value) | 803 void StyleBuilderFunctions::applyValueCSSPropetyWebkitTextUnderlinePosition(Styl eResolverState& state, CSSValue* value) |
| 803 { | 804 { |
| 804 // This is true if value is 'auto' or 'alphabetic'. | 805 // This is true if value is 'auto' or 'alphabetic'. |
| 805 if (value->isPrimitiveValue()) { | 806 if (value->isPrimitiveValue()) { |
| 806 TextUnderlinePosition t = *toCSSPrimitiveValue(value); | 807 TextUnderlinePosition t = *toCSSPrimitiveValue(value); |
| 807 state.style()->setTextUnderlinePosition(t); | 808 state.style()->setTextUnderlinePosition(t); |
| 808 return; | 809 return; |
| 809 } | 810 } |
| 810 | 811 |
| 811 unsigned t = 0; | 812 unsigned t = 0; |
| 812 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { | 813 for (CSSValueListIterator i(value); i.hasMore(); i.advance()) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1042 return numberToFloat(primitiveValue, out); | 1043 return numberToFloat(primitiveValue, out); |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 static String fragmentIdentifier(const CSSPrimitiveValue* primitiveValue, Docume nt* document) | 1046 static String fragmentIdentifier(const CSSPrimitiveValue* primitiveValue, Docume nt* document) |
| 1046 { | 1047 { |
| 1047 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_URI) | 1048 if (primitiveValue->primitiveType() != CSSPrimitiveValue::CSS_URI) |
| 1048 return String(); | 1049 return String(); |
| 1049 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->getS tringValue(), document); | 1050 return SVGURIReference::fragmentIdentifierFromIRIString(primitiveValue->getS tringValue(), document); |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1053 static inline bool isValidVisitedLinkProperty(CSSPropertyID id) | |
| 1054 { | |
| 1055 switch (id) { | |
| 1056 case CSSPropertyBackgroundColor: | |
| 1057 case CSSPropertyBorderLeftColor: | |
| 1058 case CSSPropertyBorderRightColor: | |
| 1059 case CSSPropertyBorderTopColor: | |
| 1060 case CSSPropertyBorderBottomColor: | |
| 1061 case CSSPropertyColor: | |
| 1062 case CSSPropertyFill: | |
| 1063 case CSSPropertyOutlineColor: | |
| 1064 case CSSPropertyStroke: | |
| 1065 case CSSPropertyTextDecorationColor: | |
| 1066 case CSSPropertyWebkitColumnRuleColor: | |
| 1067 case CSSPropertyWebkitTextEmphasisColor: | |
| 1068 case CSSPropertyWebkitTextFillColor: | |
| 1069 case CSSPropertyWebkitTextStrokeColor: | |
| 1070 return true; | |
| 1071 default: | |
| 1072 break; | |
| 1073 } | |
| 1052 | 1074 |
| 1053 // FIXME: Every use of "styleResolver" in this function is a layering | 1075 return false; |
| 1054 // violation and should be removed. | 1076 } |
| 1055 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolver* styleResolv er, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit) | 1077 |
| 1078 static bool hasVariableReference(CSSValue* value) | |
| 1079 { | |
| 1080 if (value->isPrimitiveValue()) { | |
| 1081 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | |
| 1082 return primitiveValue->hasVariableReference(); | |
| 1083 } | |
| 1084 | |
| 1085 if (value->isCalculationValue()) | |
| 1086 return static_cast<CSSCalcValue*>(value)->hasVariableReference(); | |
| 1087 | |
| 1088 if (value->isReflectValue()) { | |
| 1089 CSSReflectValue* reflectValue = static_cast<CSSReflectValue*>(value); | |
| 1090 CSSPrimitiveValue* direction = reflectValue->direction(); | |
| 1091 CSSPrimitiveValue* offset = reflectValue->offset(); | |
| 1092 CSSValue* mask = reflectValue->mask(); | |
| 1093 return (direction && hasVariableReference(direction)) || (offset && hasV ariableReference(offset)) || (mask && hasVariableReference(mask)); | |
| 1094 } | |
| 1095 | |
| 1096 for (CSSValueListIterator i = value; i.hasMore(); i.advance()) { | |
| 1097 if (hasVariableReference(i.value())) | |
| 1098 return true; | |
| 1099 } | |
| 1100 | |
| 1101 return false; | |
| 1102 } | |
| 1103 | |
| 1104 // FIXME: Resolving variables should be factored better. Maybe a resover-style c lass? | |
| 1105 static void resolveVariables(StyleResolverState& state, CSSPropertyID id, CSSVal ue* value, Vector<std::pair<CSSPropertyID, String> >& knownExpressions) | |
| 1106 { | |
| 1107 std::pair<CSSPropertyID, String> expression(id, value->serializeResolvingVar iables(*state.style()->variables())); | |
| 1108 | |
| 1109 if (knownExpressions.contains(expression)) | |
| 1110 return; // cycle detected. | |
| 1111 | |
| 1112 knownExpressions.append(expression); | |
| 1113 | |
| 1114 // 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. | |
| 1115 RefPtr<MutableStylePropertySet> resultSet = MutableStylePropertySet::create( ); | |
| 1116 if (!CSSParser::parseValue(resultSet.get(), id, expression.second, false, st ate.elementContext().document())) | |
| 1117 return; // expression failed to parse. | |
| 1118 | |
| 1119 for (unsigned i = 0; i < resultSet->propertyCount(); i++) { | |
| 1120 StylePropertySet::PropertyReference property = resultSet->propertyAt(i); | |
| 1121 if (property.id() != CSSPropertyVariable && hasVariableReference(propert y.value())) { | |
| 1122 resolveVariables(state, property.id(), property.value(), knownExpres sions); | |
| 1123 } else { | |
| 1124 StyleBuilder::applyProperty(property.id(), state, property.value()); | |
| 1125 // All properties become dependent on their parent style when they u se variables. | |
| 1126 state.style()->setHasExplicitlyInheritedProperties(); | |
| 1127 } | |
| 1128 } | |
| 1129 } | |
| 1130 | |
| 1131 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS SValue* value) | |
| 1132 { | |
| 1133 if (id != CSSPropertyVariable && hasVariableReference(value)) { | |
| 1134 Vector<std::pair<CSSPropertyID, String> > knownExpressions; | |
| 1135 resolveVariables(state, id, value, knownExpressions); | |
| 1136 return; | |
| 1137 } | |
| 1138 | |
| 1139 // CSS variables don't resolve shorthands at parsing time, so this should be *after* handling variables. | |
| 1140 ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wa sn't expanded at parsing time", id); | |
| 1141 | |
| 1142 bool isInherit = state.parentNode() && value->isInheritedValue(); | |
| 1143 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i sInheritedValue()); | |
| 1144 | |
| 1145 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial -> !isInherit | |
| 1146 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe rit -> (state.parentNode() && state.parentStyle()) | |
| 1147 | |
| 1148 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi nkStyle() || !isValidVisitedLinkProperty(id))) { | |
| 1149 // Limit the properties that can be applied to only the ones honored by :visited. | |
| 1150 return; | |
| 1151 } | |
| 1152 | |
| 1153 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id)) | |
| 1154 state.parentStyle()->setHasExplicitlyInheritedProperties(); | |
| 1155 | |
| 1156 if (id == CSSPropertyVariable) { | |
| 1157 ASSERT_WITH_SECURITY_IMPLICATION(value->isVariableValue()); | |
| 1158 CSSVariableValue* variable = toCSSVariableValue(value); | |
| 1159 ASSERT(!variable->name().isEmpty()); | |
| 1160 ASSERT(!variable->value().isEmpty()); | |
| 1161 state.style()->setVariable(variable->name(), variable->value()); | |
| 1162 return; | |
| 1163 } | |
| 1164 | |
| 1165 if (StyleBuilder::applyProperty(id, state, value, isInitial, isInherit)) | |
| 1166 return; | |
| 1167 | |
| 1168 // Fall back to the old switch statement, which is now in StyleBuilderCustom .cpp | |
|
eseidel
2013/08/01 21:09:53
This comment probably isn't needed anymore. :)
| |
| 1169 StyleBuilder::oldApplyProperty(id, state, value, isInitial, isInherit); | |
| 1170 } | |
| 1171 | |
| 1172 | |
| 1173 void StyleBuilder::oldApplyProperty(CSSPropertyID id, StyleResolverState& state, CSSValue* value, bool isInitial, bool isInherit) | |
| 1056 { | 1174 { |
| 1057 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0; | 1175 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti veValue(value) : 0; |
| 1058 | 1176 |
| 1059 float zoomFactor = state.style()->effectiveZoom(); | 1177 float zoomFactor = state.style()->effectiveZoom(); |
| 1060 | 1178 |
| 1061 // What follows is a list that maps the CSS properties into their correspond ing front-end | 1179 // What follows is a list that maps the CSS properties into their correspond ing front-end |
| 1062 // RenderStyle values. | 1180 // RenderStyle values. |
| 1063 switch (id) { | 1181 switch (id) { |
| 1064 case CSSPropertyContent: | 1182 case CSSPropertyContent: |
| 1065 // list of string, uri, counter, attr, i | 1183 // list of string, uri, counter, attr, i |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1413 case CSSPropertyWebkitPaddingAfter: | 1531 case CSSPropertyWebkitPaddingAfter: |
| 1414 case CSSPropertyWebkitLogicalWidth: | 1532 case CSSPropertyWebkitLogicalWidth: |
| 1415 case CSSPropertyWebkitLogicalHeight: | 1533 case CSSPropertyWebkitLogicalHeight: |
| 1416 case CSSPropertyWebkitMinLogicalWidth: | 1534 case CSSPropertyWebkitMinLogicalWidth: |
| 1417 case CSSPropertyWebkitMinLogicalHeight: | 1535 case CSSPropertyWebkitMinLogicalHeight: |
| 1418 case CSSPropertyWebkitMaxLogicalWidth: | 1536 case CSSPropertyWebkitMaxLogicalWidth: |
| 1419 case CSSPropertyWebkitMaxLogicalHeight: | 1537 case CSSPropertyWebkitMaxLogicalHeight: |
| 1420 { | 1538 { |
| 1421 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, sta te.style()->direction(), state.style()->writingMode()); | 1539 CSSPropertyID newId = CSSProperty::resolveDirectionAwareProperty(id, sta te.style()->direction(), state.style()->writingMode()); |
| 1422 ASSERT(newId != id); | 1540 ASSERT(newId != id); |
| 1423 return styleResolver->applyProperty(state, newId, value); | 1541 return applyProperty(newId, state, value); |
| 1424 } | 1542 } |
| 1425 case CSSPropertyFontStretch: | 1543 case CSSPropertyFontStretch: |
| 1426 case CSSPropertyPage: | 1544 case CSSPropertyPage: |
| 1427 case CSSPropertyTextLineThroughColor: | 1545 case CSSPropertyTextLineThroughColor: |
| 1428 case CSSPropertyTextLineThroughMode: | 1546 case CSSPropertyTextLineThroughMode: |
| 1429 case CSSPropertyTextLineThroughStyle: | 1547 case CSSPropertyTextLineThroughStyle: |
| 1430 case CSSPropertyTextLineThroughWidth: | 1548 case CSSPropertyTextLineThroughWidth: |
| 1431 case CSSPropertyTextOverlineColor: | 1549 case CSSPropertyTextOverlineColor: |
| 1432 case CSSPropertyTextOverlineMode: | 1550 case CSSPropertyTextOverlineMode: |
| 1433 case CSSPropertyTextOverlineStyle: | 1551 case CSSPropertyTextOverlineStyle: |
| (...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2123 break; | 2241 break; |
| 2124 } | 2242 } |
| 2125 case CSSPropertyEnableBackground: | 2243 case CSSPropertyEnableBackground: |
| 2126 // Silently ignoring this property for now | 2244 // Silently ignoring this property for now |
| 2127 // http://bugs.webkit.org/show_bug.cgi?id=6022 | 2245 // http://bugs.webkit.org/show_bug.cgi?id=6022 |
| 2128 break; | 2246 break; |
| 2129 } | 2247 } |
| 2130 } | 2248 } |
| 2131 | 2249 |
| 2132 } // namespace WebCore | 2250 } // namespace WebCore |
| OLD | NEW |