| OLD | NEW |
| 1 /** | 1 /** |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. | 3 * Copyright (C) 2004, 2005, 2006 Apple Computer, Inc. |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 void CSSProperty::wrapValueInCommaSeparatedList() | 48 void CSSProperty::wrapValueInCommaSeparatedList() |
| 49 { | 49 { |
| 50 RefPtr<CSSValue> value = m_value.release(); | 50 RefPtr<CSSValue> value = m_value.release(); |
| 51 m_value = CSSValueList::createCommaSeparated(); | 51 m_value = CSSValueList::createCommaSeparated(); |
| 52 toCSSValueList(m_value.get())->append(value.release()); | 52 toCSSValueList(m_value.get())->append(value.release()); |
| 53 } | 53 } |
| 54 | 54 |
| 55 enum LogicalBoxSide { BeforeSide, EndSide, AfterSide, StartSide }; | 55 enum LogicalBoxSide { BeforeSide, EndSide, AfterSide, StartSide }; |
| 56 enum PhysicalBoxSide { TopSide, RightSide, BottomSide, LeftSide }; | 56 enum PhysicalBoxSide { TopSide, RightSide, BottomSide, LeftSide }; |
| 57 | 57 |
| 58 static CSSPropertyID resolveToPhysicalProperty(TextDirection direction, WritingM
ode, LogicalBoxSide logicalSide, const StylePropertyShorthand& shorthand) | 58 static CSSPropertyID resolveToPhysicalProperty(TextDirection direction, LogicalB
oxSide logicalSide, const StylePropertyShorthand& shorthand) |
| 59 { | 59 { |
| 60 if (direction == LTR) { | 60 if (direction == LTR) { |
| 61 // The common case. The logical and physical box sides match. | 61 // The common case. The logical and physical box sides match. |
| 62 // Left = Start, Right = End, Before = Top, After = Bottom | 62 // Left = Start, Right = End, Before = Top, After = Bottom |
| 63 return shorthand.properties()[logicalSide]; | 63 return shorthand.properties()[logicalSide]; |
| 64 } | 64 } |
| 65 | 65 |
| 66 // FIXME(sky): Remove this. We no longer have logical properties beyond RTL. | 66 // FIXME(sky): Remove this. We no longer have logical properties beyond RTL. |
| 67 // Start = Right, End = Left, Before = Top, After = Bottom | 67 // Start = Right, End = Left, Before = Top, After = Bottom |
| 68 switch (logicalSide) { | 68 switch (logicalSide) { |
| 69 case StartSide: | 69 case StartSide: |
| 70 return shorthand.properties()[RightSide]; | 70 return shorthand.properties()[RightSide]; |
| 71 case EndSide: | 71 case EndSide: |
| 72 return shorthand.properties()[LeftSide]; | 72 return shorthand.properties()[LeftSide]; |
| 73 case BeforeSide: | 73 case BeforeSide: |
| 74 return shorthand.properties()[TopSide]; | 74 return shorthand.properties()[TopSide]; |
| 75 default: | 75 default: |
| 76 return shorthand.properties()[BottomSide]; | 76 return shorthand.properties()[BottomSide]; |
| 77 } | 77 } |
| 78 } | 78 } |
| 79 | 79 |
| 80 enum LogicalExtent { LogicalWidth, LogicalHeight }; | 80 enum LogicalExtent { LogicalWidth, LogicalHeight }; |
| 81 | 81 |
| 82 static CSSPropertyID resolveToPhysicalProperty(WritingMode, LogicalExtent logica
lSide, const CSSPropertyID* properties) | 82 static CSSPropertyID resolveToPhysicalProperty(LogicalExtent logicalSide, const
CSSPropertyID* properties) |
| 83 { | 83 { |
| 84 // FIXME(sky): Remove | 84 // FIXME(sky): Remove |
| 85 return properties[logicalSide]; | 85 return properties[logicalSide]; |
| 86 } | 86 } |
| 87 | 87 |
| 88 static const StylePropertyShorthand& borderDirections() | 88 static const StylePropertyShorthand& borderDirections() |
| 89 { | 89 { |
| 90 static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSProper
tyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft }; | 90 static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSProper
tyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft }; |
| 91 DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderDirections, (CSSPropertyBo
rder, properties, WTF_ARRAY_LENGTH(properties))); | 91 DEFINE_STATIC_LOCAL(StylePropertyShorthand, borderDirections, (CSSPropertyBo
rder, properties, WTF_ARRAY_LENGTH(properties))); |
| 92 return borderDirections; | 92 return borderDirections; |
| 93 } | 93 } |
| 94 | 94 |
| 95 CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI
D, TextDirection direction, WritingMode writingMode) | 95 CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI
D, TextDirection direction) |
| 96 { | 96 { |
| 97 switch (propertyID) { | 97 switch (propertyID) { |
| 98 case CSSPropertyWebkitMarginEnd: | 98 case CSSPropertyWebkitMarginEnd: |
| 99 return resolveToPhysicalProperty(direction, writingMode, EndSide, margin
Shorthand()); | 99 return resolveToPhysicalProperty(direction, EndSide, marginShorthand()); |
| 100 case CSSPropertyWebkitMarginStart: | 100 case CSSPropertyWebkitMarginStart: |
| 101 return resolveToPhysicalProperty(direction, writingMode, StartSide, marg
inShorthand()); | 101 return resolveToPhysicalProperty(direction, StartSide, marginShorthand()
); |
| 102 case CSSPropertyWebkitMarginBefore: | 102 case CSSPropertyWebkitMarginBefore: |
| 103 return resolveToPhysicalProperty(direction, writingMode, BeforeSide, mar
ginShorthand()); | 103 return resolveToPhysicalProperty(direction, BeforeSide, marginShorthand(
)); |
| 104 case CSSPropertyWebkitMarginAfter: | 104 case CSSPropertyWebkitMarginAfter: |
| 105 return resolveToPhysicalProperty(direction, writingMode, AfterSide, marg
inShorthand()); | 105 return resolveToPhysicalProperty(direction, AfterSide, marginShorthand()
); |
| 106 case CSSPropertyWebkitPaddingEnd: | 106 case CSSPropertyWebkitPaddingEnd: |
| 107 return resolveToPhysicalProperty(direction, writingMode, EndSide, paddin
gShorthand()); | 107 return resolveToPhysicalProperty(direction, EndSide, paddingShorthand())
; |
| 108 case CSSPropertyWebkitPaddingStart: | 108 case CSSPropertyWebkitPaddingStart: |
| 109 return resolveToPhysicalProperty(direction, writingMode, StartSide, padd
ingShorthand()); | 109 return resolveToPhysicalProperty(direction, StartSide, paddingShorthand(
)); |
| 110 case CSSPropertyWebkitPaddingBefore: | 110 case CSSPropertyWebkitPaddingBefore: |
| 111 return resolveToPhysicalProperty(direction, writingMode, BeforeSide, pad
dingShorthand()); | 111 return resolveToPhysicalProperty(direction, BeforeSide, paddingShorthand
()); |
| 112 case CSSPropertyWebkitPaddingAfter: | 112 case CSSPropertyWebkitPaddingAfter: |
| 113 return resolveToPhysicalProperty(direction, writingMode, AfterSide, padd
ingShorthand()); | 113 return resolveToPhysicalProperty(direction, AfterSide, paddingShorthand(
)); |
| 114 case CSSPropertyWebkitBorderEnd: | 114 case CSSPropertyWebkitBorderEnd: |
| 115 return resolveToPhysicalProperty(direction, writingMode, EndSide, border
Directions()); | 115 return resolveToPhysicalProperty(direction, EndSide, borderDirections())
; |
| 116 case CSSPropertyWebkitBorderStart: | 116 case CSSPropertyWebkitBorderStart: |
| 117 return resolveToPhysicalProperty(direction, writingMode, StartSide, bord
erDirections()); | 117 return resolveToPhysicalProperty(direction, StartSide, borderDirections(
)); |
| 118 case CSSPropertyWebkitBorderBefore: | 118 case CSSPropertyWebkitBorderBefore: |
| 119 return resolveToPhysicalProperty(direction, writingMode, BeforeSide, bor
derDirections()); | 119 return resolveToPhysicalProperty(direction, BeforeSide, borderDirections
()); |
| 120 case CSSPropertyWebkitBorderAfter: | 120 case CSSPropertyWebkitBorderAfter: |
| 121 return resolveToPhysicalProperty(direction, writingMode, AfterSide, bord
erDirections()); | 121 return resolveToPhysicalProperty(direction, AfterSide, borderDirections(
)); |
| 122 case CSSPropertyWebkitBorderEndColor: | 122 case CSSPropertyWebkitBorderEndColor: |
| 123 return resolveToPhysicalProperty(direction, writingMode, EndSide, border
ColorShorthand()); | 123 return resolveToPhysicalProperty(direction, EndSide, borderColorShorthan
d()); |
| 124 case CSSPropertyWebkitBorderStartColor: | 124 case CSSPropertyWebkitBorderStartColor: |
| 125 return resolveToPhysicalProperty(direction, writingMode, StartSide, bord
erColorShorthand()); | 125 return resolveToPhysicalProperty(direction, StartSide, borderColorShorth
and()); |
| 126 case CSSPropertyWebkitBorderBeforeColor: | 126 case CSSPropertyWebkitBorderBeforeColor: |
| 127 return resolveToPhysicalProperty(direction, writingMode, BeforeSide, bor
derColorShorthand()); | 127 return resolveToPhysicalProperty(direction, BeforeSide, borderColorShort
hand()); |
| 128 case CSSPropertyWebkitBorderAfterColor: | 128 case CSSPropertyWebkitBorderAfterColor: |
| 129 return resolveToPhysicalProperty(direction, writingMode, AfterSide, bord
erColorShorthand()); | 129 return resolveToPhysicalProperty(direction, AfterSide, borderColorShorth
and()); |
| 130 case CSSPropertyWebkitBorderEndStyle: | 130 case CSSPropertyWebkitBorderEndStyle: |
| 131 return resolveToPhysicalProperty(direction, writingMode, EndSide, border
StyleShorthand()); | 131 return resolveToPhysicalProperty(direction, EndSide, borderStyleShorthan
d()); |
| 132 case CSSPropertyWebkitBorderStartStyle: | 132 case CSSPropertyWebkitBorderStartStyle: |
| 133 return resolveToPhysicalProperty(direction, writingMode, StartSide, bord
erStyleShorthand()); | 133 return resolveToPhysicalProperty(direction, StartSide, borderStyleShorth
and()); |
| 134 case CSSPropertyWebkitBorderBeforeStyle: | 134 case CSSPropertyWebkitBorderBeforeStyle: |
| 135 return resolveToPhysicalProperty(direction, writingMode, BeforeSide, bor
derStyleShorthand()); | 135 return resolveToPhysicalProperty(direction, BeforeSide, borderStyleShort
hand()); |
| 136 case CSSPropertyWebkitBorderAfterStyle: | 136 case CSSPropertyWebkitBorderAfterStyle: |
| 137 return resolveToPhysicalProperty(direction, writingMode, AfterSide, bord
erStyleShorthand()); | 137 return resolveToPhysicalProperty(direction, AfterSide, borderStyleShorth
and()); |
| 138 case CSSPropertyWebkitBorderEndWidth: | 138 case CSSPropertyWebkitBorderEndWidth: |
| 139 return resolveToPhysicalProperty(direction, writingMode, EndSide, border
WidthShorthand()); | 139 return resolveToPhysicalProperty(direction, EndSide, borderWidthShorthan
d()); |
| 140 case CSSPropertyWebkitBorderStartWidth: | 140 case CSSPropertyWebkitBorderStartWidth: |
| 141 return resolveToPhysicalProperty(direction, writingMode, StartSide, bord
erWidthShorthand()); | 141 return resolveToPhysicalProperty(direction, StartSide, borderWidthShorth
and()); |
| 142 case CSSPropertyWebkitBorderBeforeWidth: | 142 case CSSPropertyWebkitBorderBeforeWidth: |
| 143 return resolveToPhysicalProperty(direction, writingMode, BeforeSide, bor
derWidthShorthand()); | 143 return resolveToPhysicalProperty(direction, BeforeSide, borderWidthShort
hand()); |
| 144 case CSSPropertyWebkitBorderAfterWidth: | 144 case CSSPropertyWebkitBorderAfterWidth: |
| 145 return resolveToPhysicalProperty(direction, writingMode, AfterSide, bord
erWidthShorthand()); | 145 return resolveToPhysicalProperty(direction, AfterSide, borderWidthShorth
and()); |
| 146 case CSSPropertyWebkitLogicalWidth: { | 146 case CSSPropertyWebkitLogicalWidth: { |
| 147 const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeigh
t }; | 147 const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeigh
t }; |
| 148 return resolveToPhysicalProperty(writingMode, LogicalWidth, properties); | 148 return resolveToPhysicalProperty(LogicalWidth, properties); |
| 149 } | 149 } |
| 150 case CSSPropertyWebkitLogicalHeight: { | 150 case CSSPropertyWebkitLogicalHeight: { |
| 151 const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeigh
t }; | 151 const CSSPropertyID properties[2] = { CSSPropertyWidth, CSSPropertyHeigh
t }; |
| 152 return resolveToPhysicalProperty(writingMode, LogicalHeight, properties)
; | 152 return resolveToPhysicalProperty(LogicalHeight, properties); |
| 153 } | 153 } |
| 154 case CSSPropertyWebkitMinLogicalWidth: { | 154 case CSSPropertyWebkitMinLogicalWidth: { |
| 155 const CSSPropertyID properties[2] = { CSSPropertyMinWidth, CSSPropertyMi
nHeight }; | 155 const CSSPropertyID properties[2] = { CSSPropertyMinWidth, CSSPropertyMi
nHeight }; |
| 156 return resolveToPhysicalProperty(writingMode, LogicalWidth, properties); | 156 return resolveToPhysicalProperty(LogicalWidth, properties); |
| 157 } | 157 } |
| 158 case CSSPropertyWebkitMinLogicalHeight: { | 158 case CSSPropertyWebkitMinLogicalHeight: { |
| 159 const CSSPropertyID properties[2] = { CSSPropertyMinWidth, CSSPropertyMi
nHeight }; | 159 const CSSPropertyID properties[2] = { CSSPropertyMinWidth, CSSPropertyMi
nHeight }; |
| 160 return resolveToPhysicalProperty(writingMode, LogicalHeight, properties)
; | 160 return resolveToPhysicalProperty(LogicalHeight, properties); |
| 161 } | 161 } |
| 162 case CSSPropertyWebkitMaxLogicalWidth: { | 162 case CSSPropertyWebkitMaxLogicalWidth: { |
| 163 const CSSPropertyID properties[2] = { CSSPropertyMaxWidth, CSSPropertyMa
xHeight }; | 163 const CSSPropertyID properties[2] = { CSSPropertyMaxWidth, CSSPropertyMa
xHeight }; |
| 164 return resolveToPhysicalProperty(writingMode, LogicalWidth, properties); | 164 return resolveToPhysicalProperty(LogicalWidth, properties); |
| 165 } | 165 } |
| 166 case CSSPropertyWebkitMaxLogicalHeight: { | 166 case CSSPropertyWebkitMaxLogicalHeight: { |
| 167 const CSSPropertyID properties[2] = { CSSPropertyMaxWidth, CSSPropertyMa
xHeight }; | 167 const CSSPropertyID properties[2] = { CSSPropertyMaxWidth, CSSPropertyMa
xHeight }; |
| 168 return resolveToPhysicalProperty(writingMode, LogicalHeight, properties)
; | 168 return resolveToPhysicalProperty(LogicalHeight, properties); |
| 169 } | 169 } |
| 170 default: | 170 default: |
| 171 return propertyID; | 171 return propertyID; |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 bool CSSProperty::isAffectedByAllProperty(CSSPropertyID propertyID) | 175 bool CSSProperty::isAffectedByAllProperty(CSSPropertyID propertyID) |
| 176 { | 176 { |
| 177 if (propertyID == CSSPropertyAll) | 177 if (propertyID == CSSPropertyAll) |
| 178 return false; | 178 return false; |
| 179 | 179 |
| 180 // all shorthand spec says: | 180 // all shorthand spec says: |
| 181 // The all property is a shorthand that resets all CSS properties except | 181 // The all property is a shorthand that resets all CSS properties except |
| 182 // direction and unicode-bidi. It only accepts the CSS-wide keywords. | 182 // direction and unicode-bidi. It only accepts the CSS-wide keywords. |
| 183 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand | 183 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand |
| 184 // So CSSPropertyUnicodeBidi and CSSPropertyDirection are not | 184 // So CSSPropertyUnicodeBidi and CSSPropertyDirection are not |
| 185 // affected by all property. | 185 // affected by all property. |
| 186 return propertyID != CSSPropertyUnicodeBidi && propertyID != CSSPropertyDire
ction; | 186 return propertyID != CSSPropertyUnicodeBidi && propertyID != CSSPropertyDire
ction; |
| 187 } | 187 } |
| 188 | 188 |
| 189 } // namespace blink | 189 } // namespace blink |
| OLD | NEW |