| 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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 #include "core/rendering/style/RenderStyle.h" | 68 #include "core/rendering/style/RenderStyle.h" |
| 69 #include "core/rendering/style/RenderStyleConstants.h" | 69 #include "core/rendering/style/RenderStyleConstants.h" |
| 70 #include "core/rendering/style/StyleGeneratedImage.h" | 70 #include "core/rendering/style/StyleGeneratedImage.h" |
| 71 #include "platform/fonts/FontDescription.h" | 71 #include "platform/fonts/FontDescription.h" |
| 72 #include "wtf/MathExtras.h" | 72 #include "wtf/MathExtras.h" |
| 73 #include "wtf/StdLibExtras.h" | 73 #include "wtf/StdLibExtras.h" |
| 74 #include "wtf/Vector.h" | 74 #include "wtf/Vector.h" |
| 75 | 75 |
| 76 namespace blink { | 76 namespace blink { |
| 77 | 77 |
| 78 namespace { | |
| 79 | |
| 80 static inline bool isValidVisitedLinkProperty(CSSPropertyID id) | |
| 81 { | |
| 82 switch (id) { | |
| 83 case CSSPropertyBackgroundColor: | |
| 84 case CSSPropertyBorderLeftColor: | |
| 85 case CSSPropertyBorderRightColor: | |
| 86 case CSSPropertyBorderTopColor: | |
| 87 case CSSPropertyBorderBottomColor: | |
| 88 case CSSPropertyColor: | |
| 89 case CSSPropertyOutlineColor: | |
| 90 case CSSPropertyTextDecorationColor: | |
| 91 case CSSPropertyWebkitTextEmphasisColor: | |
| 92 case CSSPropertyWebkitTextFillColor: | |
| 93 case CSSPropertyWebkitTextStrokeColor: | |
| 94 return true; | |
| 95 default: | |
| 96 return false; | |
| 97 } | |
| 98 } | |
| 99 | |
| 100 } // namespace | |
| 101 | |
| 102 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS
SValue* value) | 78 void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS
SValue* value) |
| 103 { | 79 { |
| 104 ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wa
sn't expanded at parsing time", id); | 80 ASSERT_WITH_MESSAGE(!isExpandedShorthand(id), "Shorthand property id = %d wa
sn't expanded at parsing time", id); |
| 105 | 81 |
| 106 bool isInherit = state.parentNode() && value->isInheritedValue(); | 82 bool isInherit = state.parentNode() && value->isInheritedValue(); |
| 107 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i
sInheritedValue()); | 83 bool isInitial = value->isInitialValue() || (!state.parentNode() && value->i
sInheritedValue()); |
| 108 | 84 |
| 109 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial ->
!isInherit | 85 ASSERT(!isInherit || !isInitial); // isInherit -> !isInitial && isInitial ->
!isInherit |
| 110 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe
rit -> (state.parentNode() && state.parentStyle()) | 86 ASSERT(!isInherit || (state.parentNode() && state.parentStyle())); // isInhe
rit -> (state.parentNode() && state.parentStyle()) |
| 111 | 87 |
| 112 if (!state.applyPropertyToRegularStyle() && (!state.applyPropertyToVisitedLi
nkStyle() || !isValidVisitedLinkProperty(id))) { | |
| 113 // Limit the properties that can be applied to only the ones honored by
:visited. | |
| 114 return; | |
| 115 } | |
| 116 | |
| 117 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti
veValue(value) : 0; | 88 CSSPrimitiveValue* primitiveValue = value->isPrimitiveValue() ? toCSSPrimiti
veValue(value) : 0; |
| 118 if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor) | 89 if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor) |
| 119 state.style()->setHasCurrentColor(); | 90 state.style()->setHasCurrentColor(); |
| 120 | 91 |
| 121 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() &&
!CSSPropertyMetadata::isInheritedProperty(id)) | 92 if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() &&
!CSSPropertyMetadata::isInheritedProperty(id)) |
| 122 state.parentStyle()->setHasExplicitlyInheritedProperties(); | 93 state.parentStyle()->setHasExplicitlyInheritedProperties(); |
| 123 | 94 |
| 124 StyleBuilder::applyProperty(id, state, value, isInitial, isInherit); | 95 StyleBuilder::applyProperty(id, state, value, isInitial, isInherit); |
| 125 } | 96 } |
| 126 | 97 |
| 127 void StyleBuilderFunctions::applyInitialCSSPropertyColor(StyleResolverState& sta
te) | 98 void StyleBuilderFunctions::applyInitialCSSPropertyColor(StyleResolverState& sta
te) |
| 128 { | 99 { |
| 129 Color color = RenderStyle::initialColor(); | 100 Color color = RenderStyle::initialColor(); |
| 130 if (state.applyPropertyToRegularStyle()) | 101 state.style()->setColor(color); |
| 131 state.style()->setColor(color); | |
| 132 if (state.applyPropertyToVisitedLinkStyle()) | |
| 133 state.style()->setVisitedLinkColor(color); | |
| 134 } | 102 } |
| 135 | 103 |
| 136 void StyleBuilderFunctions::applyInheritCSSPropertyColor(StyleResolverState& sta
te) | 104 void StyleBuilderFunctions::applyInheritCSSPropertyColor(StyleResolverState& sta
te) |
| 137 { | 105 { |
| 138 Color color = state.parentStyle()->color(); | 106 Color color = state.parentStyle()->color(); |
| 139 if (state.applyPropertyToRegularStyle()) | 107 state.style()->setColor(color); |
| 140 state.style()->setColor(color); | |
| 141 if (state.applyPropertyToVisitedLinkStyle()) | |
| 142 state.style()->setVisitedLinkColor(color); | |
| 143 } | 108 } |
| 144 | 109 |
| 145 void StyleBuilderFunctions::applyValueCSSPropertyColor(StyleResolverState& state
, CSSValue* value) | 110 void StyleBuilderFunctions::applyValueCSSPropertyColor(StyleResolverState& state
, CSSValue* value) |
| 146 { | 111 { |
| 147 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); | 112 CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
| 148 // As per the spec, 'color: currentColor' is treated as 'color: inherit' | 113 // As per the spec, 'color: currentColor' is treated as 'color: inherit' |
| 149 if (primitiveValue->getValueID() == CSSValueCurrentcolor) { | 114 if (primitiveValue->getValueID() == CSSValueCurrentcolor) { |
| 150 applyInheritCSSPropertyColor(state); | 115 applyInheritCSSPropertyColor(state); |
| 151 return; | 116 return; |
| 152 } | 117 } |
| 153 | 118 |
| 154 if (state.applyPropertyToRegularStyle()) | 119 state.style()->setColor(StyleBuilderConverter::convertColor(state, value)); |
| 155 state.style()->setColor(StyleBuilderConverter::convertColor(state, value
)); | |
| 156 if (state.applyPropertyToVisitedLinkStyle()) | |
| 157 state.style()->setVisitedLinkColor(StyleBuilderConverter::convertColor(s
tate, value, true)); | |
| 158 } | 120 } |
| 159 | 121 |
| 160 void StyleBuilderFunctions::applyInitialCSSPropertyJustifyItems(StyleResolverSta
te& state) | 122 void StyleBuilderFunctions::applyInitialCSSPropertyJustifyItems(StyleResolverSta
te& state) |
| 161 { | 123 { |
| 162 state.style()->setJustifyItems(RenderStyle::initialJustifyItems()); | 124 state.style()->setJustifyItems(RenderStyle::initialJustifyItems()); |
| 163 state.style()->setJustifyItemsOverflowAlignment(RenderStyle::initialJustifyI
temsOverflowAlignment()); | 125 state.style()->setJustifyItemsOverflowAlignment(RenderStyle::initialJustifyI
temsOverflowAlignment()); |
| 164 state.style()->setJustifyItemsPositionType(RenderStyle::initialJustifyItemsP
ositionType()); | 126 state.style()->setJustifyItemsPositionType(RenderStyle::initialJustifyItemsP
ositionType()); |
| 165 } | 127 } |
| 166 | 128 |
| 167 void StyleBuilderFunctions::applyInheritCSSPropertyJustifyItems(StyleResolverSta
te& state) | 129 void StyleBuilderFunctions::applyInheritCSSPropertyJustifyItems(StyleResolverSta
te& state) |
| (...skipping 971 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 break; | 1101 break; |
| 1140 default: | 1102 default: |
| 1141 ASSERT_NOT_REACHED(); | 1103 ASSERT_NOT_REACHED(); |
| 1142 break; | 1104 break; |
| 1143 } | 1105 } |
| 1144 | 1106 |
| 1145 state.style()->setGridAutoFlow(autoFlow); | 1107 state.style()->setGridAutoFlow(autoFlow); |
| 1146 } | 1108 } |
| 1147 | 1109 |
| 1148 } // namespace blink | 1110 } // namespace blink |
| OLD | NEW |