Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: sky/engine/core/css/CSSProperty.cpp

Issue 689743002: First past at removing writing mode. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/css/CSSProperties.in ('k') | sky/engine/core/css/CSSValueKeywords.in » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 writingMode, LogicalBoxSide logicalSide, const StylePropertyShorthand& short hand) 58 static CSSPropertyID resolveToPhysicalProperty(TextDirection direction, WritingM ode, LogicalBoxSide logicalSide, const StylePropertyShorthand& shorthand)
59 { 59 {
60 if (direction == LTR) { 60 if (direction == LTR) {
61 if (writingMode == TopToBottomWritingMode) { 61 // The common case. The logical and physical box sides match.
62 // The common case. The logical and physical box sides match. 62 // Left = Start, Right = End, Before = Top, After = Bottom
63 // Left = Start, Right = End, Before = Top, After = Bottom 63 return shorthand.properties()[logicalSide];
64 return shorthand.properties()[logicalSide];
65 }
66
67 if (writingMode == BottomToTopWritingMode) {
68 // Start = Left, End = Right, Before = Bottom, After = Top.
69 switch (logicalSide) {
70 case StartSide:
71 return shorthand.properties()[LeftSide];
72 case EndSide:
73 return shorthand.properties()[RightSide];
74 case BeforeSide:
75 return shorthand.properties()[BottomSide];
76 default:
77 return shorthand.properties()[TopSide];
78 }
79 }
80
81 if (writingMode == LeftToRightWritingMode) {
82 // Start = Top, End = Bottom, Before = Left, After = Right.
83 switch (logicalSide) {
84 case StartSide:
85 return shorthand.properties()[TopSide];
86 case EndSide:
87 return shorthand.properties()[BottomSide];
88 case BeforeSide:
89 return shorthand.properties()[LeftSide];
90 default:
91 return shorthand.properties()[RightSide];
92 }
93 }
94
95 // Start = Top, End = Bottom, Before = Right, After = Left
96 switch (logicalSide) {
97 case StartSide:
98 return shorthand.properties()[TopSide];
99 case EndSide:
100 return shorthand.properties()[BottomSide];
101 case BeforeSide:
102 return shorthand.properties()[RightSide];
103 default:
104 return shorthand.properties()[LeftSide];
105 }
106 } 64 }
107 65
108 if (writingMode == TopToBottomWritingMode) { 66 // FIXME(sky): Remove this. We no longer have logical properties beyond RTL.
109 // Start = Right, End = Left, Before = Top, After = Bottom 67 // Start = Right, End = Left, Before = Top, After = Bottom
110 switch (logicalSide) {
111 case StartSide:
112 return shorthand.properties()[RightSide];
113 case EndSide:
114 return shorthand.properties()[LeftSide];
115 case BeforeSide:
116 return shorthand.properties()[TopSide];
117 default:
118 return shorthand.properties()[BottomSide];
119 }
120 }
121
122 if (writingMode == BottomToTopWritingMode) {
123 // Start = Right, End = Left, Before = Bottom, After = Top
124 switch (logicalSide) {
125 case StartSide:
126 return shorthand.properties()[RightSide];
127 case EndSide:
128 return shorthand.properties()[LeftSide];
129 case BeforeSide:
130 return shorthand.properties()[BottomSide];
131 default:
132 return shorthand.properties()[TopSide];
133 }
134 }
135
136 if (writingMode == LeftToRightWritingMode) {
137 // Start = Bottom, End = Top, Before = Left, After = Right
138 switch (logicalSide) {
139 case StartSide:
140 return shorthand.properties()[BottomSide];
141 case EndSide:
142 return shorthand.properties()[TopSide];
143 case BeforeSide:
144 return shorthand.properties()[LeftSide];
145 default:
146 return shorthand.properties()[RightSide];
147 }
148 }
149
150 // Start = Bottom, End = Top, Before = Right, After = Left
151 switch (logicalSide) { 68 switch (logicalSide) {
152 case StartSide: 69 case StartSide:
70 return shorthand.properties()[RightSide];
71 case EndSide:
72 return shorthand.properties()[LeftSide];
73 case BeforeSide:
74 return shorthand.properties()[TopSide];
75 default:
153 return shorthand.properties()[BottomSide]; 76 return shorthand.properties()[BottomSide];
154 case EndSide:
155 return shorthand.properties()[TopSide];
156 case BeforeSide:
157 return shorthand.properties()[RightSide];
158 default:
159 return shorthand.properties()[LeftSide];
160 } 77 }
161 } 78 }
162 79
163 enum LogicalExtent { LogicalWidth, LogicalHeight }; 80 enum LogicalExtent { LogicalWidth, LogicalHeight };
164 81
165 static CSSPropertyID resolveToPhysicalProperty(WritingMode writingMode, LogicalE xtent logicalSide, const CSSPropertyID* properties) 82 static CSSPropertyID resolveToPhysicalProperty(WritingMode, LogicalExtent logica lSide, const CSSPropertyID* properties)
166 { 83 {
167 if (writingMode == TopToBottomWritingMode || writingMode == BottomToTopWriti ngMode) 84 // FIXME(sky): Remove
168 return properties[logicalSide]; 85 return properties[logicalSide];
169 return logicalSide == LogicalWidth ? properties[1] : properties[0];
170 } 86 }
171 87
172 static const StylePropertyShorthand& borderDirections() 88 static const StylePropertyShorthand& borderDirections()
173 { 89 {
174 static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSProper tyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft }; 90 static const CSSPropertyID properties[4] = { CSSPropertyBorderTop, CSSProper tyBorderRight, CSSPropertyBorderBottom, CSSPropertyBorderLeft };
175 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)));
176 return borderDirections; 92 return borderDirections;
177 } 93 }
178 94
179 CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI D, TextDirection direction, WritingMode writingMode) 95 CSSPropertyID CSSProperty::resolveDirectionAwareProperty(CSSPropertyID propertyI D, TextDirection direction, WritingMode writingMode)
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // all shorthand spec says: 180 // all shorthand spec says:
265 // 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
266 // direction and unicode-bidi. It only accepts the CSS-wide keywords. 182 // direction and unicode-bidi. It only accepts the CSS-wide keywords.
267 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand 183 // c.f. http://dev.w3.org/csswg/css-cascade/#all-shorthand
268 // So CSSPropertyUnicodeBidi and CSSPropertyDirection are not 184 // So CSSPropertyUnicodeBidi and CSSPropertyDirection are not
269 // affected by all property. 185 // affected by all property.
270 return propertyID != CSSPropertyUnicodeBidi && propertyID != CSSPropertyDire ction; 186 return propertyID != CSSPropertyUnicodeBidi && propertyID != CSSPropertyDire ction;
271 } 187 }
272 188
273 } // namespace blink 189 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/CSSProperties.in ('k') | sky/engine/core/css/CSSValueKeywords.in » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698