|
1 /** |
|
2 * |
|
3 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
|
4 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Lesser General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Lesser General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public |
|
17 * License along with this library; if not, write to the Free Software |
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
19 * 02110-1301 USA |
|
20 */ |
|
21 |
|
22 #include "config.h" |
|
23 #include "CSSComputedStyleDeclaration.h" |
|
24 |
|
25 #include "CSSMutableStyleDeclaration.h" |
|
26 #include "CSSPrimitiveValue.h" |
|
27 #include "CSSPropertyNames.h" |
|
28 #include "CSSValueKeywords.h" |
|
29 #include "CSSValueList.h" |
|
30 #include "CachedImage.h" |
|
31 #include "DashboardRegion.h" |
|
32 #include "Document.h" |
|
33 #include "ExceptionCode.h" |
|
34 #include "Pair.h" |
|
35 #include "RenderObject.h" |
|
36 #include "ShadowValue.h" |
|
37 |
|
38 namespace WebCore { |
|
39 |
|
40 // List of all properties we know how to compute, omitting shorthands. |
|
41 static const int computedProperties[] = { |
|
42 CSS_PROP_BACKGROUND_ATTACHMENT, |
|
43 CSS_PROP_BACKGROUND_COLOR, |
|
44 CSS_PROP_BACKGROUND_IMAGE, |
|
45 // more specific background-position-x/y are non-standard |
|
46 CSS_PROP_BACKGROUND_POSITION, |
|
47 CSS_PROP_BACKGROUND_REPEAT, |
|
48 CSS_PROP_BORDER_BOTTOM_COLOR, |
|
49 CSS_PROP_BORDER_BOTTOM_STYLE, |
|
50 CSS_PROP_BORDER_BOTTOM_WIDTH, |
|
51 CSS_PROP_BORDER_COLLAPSE, |
|
52 CSS_PROP_BORDER_LEFT_COLOR, |
|
53 CSS_PROP_BORDER_LEFT_STYLE, |
|
54 CSS_PROP_BORDER_LEFT_WIDTH, |
|
55 CSS_PROP_BORDER_RIGHT_COLOR, |
|
56 CSS_PROP_BORDER_RIGHT_STYLE, |
|
57 CSS_PROP_BORDER_RIGHT_WIDTH, |
|
58 CSS_PROP_BORDER_TOP_COLOR, |
|
59 CSS_PROP_BORDER_TOP_STYLE, |
|
60 CSS_PROP_BORDER_TOP_WIDTH, |
|
61 CSS_PROP_BOTTOM, |
|
62 CSS_PROP_CAPTION_SIDE, |
|
63 CSS_PROP_CLEAR, |
|
64 CSS_PROP_COLOR, |
|
65 CSS_PROP_CURSOR, |
|
66 CSS_PROP_DIRECTION, |
|
67 CSS_PROP_DISPLAY, |
|
68 CSS_PROP_EMPTY_CELLS, |
|
69 CSS_PROP_FLOAT, |
|
70 CSS_PROP_FONT_FAMILY, |
|
71 CSS_PROP_FONT_SIZE, |
|
72 CSS_PROP_FONT_STYLE, |
|
73 CSS_PROP_FONT_VARIANT, |
|
74 CSS_PROP_FONT_WEIGHT, |
|
75 CSS_PROP_HEIGHT, |
|
76 CSS_PROP_LEFT, |
|
77 CSS_PROP_LETTER_SPACING, |
|
78 CSS_PROP_LINE_HEIGHT, |
|
79 CSS_PROP_LIST_STYLE_IMAGE, |
|
80 CSS_PROP_LIST_STYLE_POSITION, |
|
81 CSS_PROP_LIST_STYLE_TYPE, |
|
82 CSS_PROP_MARGIN_BOTTOM, |
|
83 CSS_PROP_MARGIN_LEFT, |
|
84 CSS_PROP_MARGIN_RIGHT, |
|
85 CSS_PROP_MARGIN_TOP, |
|
86 CSS_PROP_MAX_HEIGHT, |
|
87 CSS_PROP_MAX_WIDTH, |
|
88 CSS_PROP_MIN_HEIGHT, |
|
89 CSS_PROP_MIN_WIDTH, |
|
90 CSS_PROP_OPACITY, |
|
91 CSS_PROP_ORPHANS, |
|
92 CSS_PROP_OUTLINE_COLOR, |
|
93 CSS_PROP_OUTLINE_STYLE, |
|
94 CSS_PROP_OUTLINE_WIDTH, |
|
95 CSS_PROP_OVERFLOW_X, |
|
96 CSS_PROP_OVERFLOW_Y, |
|
97 CSS_PROP_PADDING_BOTTOM, |
|
98 CSS_PROP_PADDING_LEFT, |
|
99 CSS_PROP_PADDING_RIGHT, |
|
100 CSS_PROP_PADDING_TOP, |
|
101 CSS_PROP_PAGE_BREAK_AFTER, |
|
102 CSS_PROP_PAGE_BREAK_BEFORE, |
|
103 CSS_PROP_PAGE_BREAK_INSIDE, |
|
104 CSS_PROP_POSITION, |
|
105 CSS_PROP_RESIZE, |
|
106 CSS_PROP_RIGHT, |
|
107 CSS_PROP_TABLE_LAYOUT, |
|
108 CSS_PROP_TEXT_ALIGN, |
|
109 CSS_PROP_TEXT_DECORATION, |
|
110 CSS_PROP_TEXT_INDENT, |
|
111 CSS_PROP_TEXT_SHADOW, |
|
112 CSS_PROP_TEXT_TRANSFORM, |
|
113 CSS_PROP_TOP, |
|
114 CSS_PROP_UNICODE_BIDI, |
|
115 CSS_PROP_VERTICAL_ALIGN, |
|
116 CSS_PROP_VISIBILITY, |
|
117 CSS_PROP_WHITE_SPACE, |
|
118 CSS_PROP_WIDOWS, |
|
119 CSS_PROP_WIDTH, |
|
120 CSS_PROP_WORD_SPACING, |
|
121 CSS_PROP_WORD_WRAP, |
|
122 CSS_PROP_Z_INDEX, |
|
123 |
|
124 CSS_PROP__WEBKIT_APPEARANCE, |
|
125 CSS_PROP__WEBKIT_BACKGROUND_CLIP, |
|
126 CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE, |
|
127 CSS_PROP__WEBKIT_BACKGROUND_ORIGIN, |
|
128 CSS_PROP__WEBKIT_BACKGROUND_SIZE, |
|
129 CSS_PROP__WEBKIT_BORDER_FIT, |
|
130 CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING, |
|
131 CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING, |
|
132 CSS_PROP__WEBKIT_BOX_ALIGN, |
|
133 CSS_PROP__WEBKIT_BOX_DIRECTION, |
|
134 CSS_PROP__WEBKIT_BOX_FLEX, |
|
135 CSS_PROP__WEBKIT_BOX_FLEX_GROUP, |
|
136 CSS_PROP__WEBKIT_BOX_LINES, |
|
137 CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP, |
|
138 CSS_PROP__WEBKIT_BOX_ORIENT, |
|
139 CSS_PROP__WEBKIT_BOX_PACK, |
|
140 CSS_PROP__WEBKIT_BOX_SHADOW, |
|
141 CSS_PROP__WEBKIT_BOX_SIZING, |
|
142 CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER, |
|
143 CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE, |
|
144 CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE, |
|
145 CSS_PROP__WEBKIT_COLUMN_COUNT, |
|
146 CSS_PROP__WEBKIT_COLUMN_GAP, |
|
147 CSS_PROP__WEBKIT_COLUMN_RULE_COLOR, |
|
148 CSS_PROP__WEBKIT_COLUMN_RULE_STYLE, |
|
149 CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH, |
|
150 CSS_PROP__WEBKIT_COLUMN_WIDTH, |
|
151 CSS_PROP__WEBKIT_HIGHLIGHT, |
|
152 CSS_PROP__WEBKIT_LINE_BREAK, |
|
153 CSS_PROP__WEBKIT_LINE_CLAMP, |
|
154 CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE, |
|
155 CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE, |
|
156 CSS_PROP__WEBKIT_MARQUEE_DIRECTION, |
|
157 CSS_PROP__WEBKIT_MARQUEE_INCREMENT, |
|
158 CSS_PROP__WEBKIT_MARQUEE_REPETITION, |
|
159 CSS_PROP__WEBKIT_MARQUEE_STYLE, |
|
160 CSS_PROP__WEBKIT_NBSP_MODE, |
|
161 CSS_PROP__WEBKIT_RTL_ORDERING, |
|
162 CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, |
|
163 CSS_PROP__WEBKIT_TEXT_FILL_COLOR, |
|
164 CSS_PROP__WEBKIT_TEXT_SECURITY, |
|
165 CSS_PROP__WEBKIT_TEXT_STROKE_COLOR, |
|
166 CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH, |
|
167 CSS_PROP__WEBKIT_USER_DRAG, |
|
168 CSS_PROP__WEBKIT_USER_MODIFY, |
|
169 CSS_PROP__WEBKIT_USER_SELECT, |
|
170 CSS_PROP__WEBKIT_DASHBOARD_REGION, |
|
171 CSS_PROP__WEBKIT_BORDER_BOTTOM_LEFT_RADIUS, |
|
172 CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS, |
|
173 CSS_PROP__WEBKIT_BORDER_TOP_LEFT_RADIUS, |
|
174 CSS_PROP__WEBKIT_BORDER_TOP_RIGHT_RADIUS |
|
175 #if PLATFORM(SYMBIAN) |
|
176 ,CSS_PROP__WAP_MARQUEE_DIR, |
|
177 CSS_PROP__WAP_MARQUEE_LOOP, |
|
178 CSS_PROP__WAP_MARQUEE_SPEED, |
|
179 CSS_PROP__WAP_MARQUEE_STYLE |
|
180 #endif |
|
181 }; |
|
182 |
|
183 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]); |
|
184 |
|
185 static PassRefPtr<CSSValue> valueForLength(const Length& length) |
|
186 { |
|
187 switch (length.type()) { |
|
188 case Auto: |
|
189 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
190 case WebCore::Fixed: |
|
191 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX); |
|
192 case Intrinsic: |
|
193 return new CSSPrimitiveValue(CSS_VAL_INTRINSIC); |
|
194 case MinIntrinsic: |
|
195 return new CSSPrimitiveValue(CSS_VAL_MIN_INTRINSIC); |
|
196 case Percent: |
|
197 return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
198 case Relative: |
|
199 case Static: |
|
200 break; |
|
201 } |
|
202 ASSERT_NOT_REACHED(); |
|
203 return 0; |
|
204 } |
|
205 |
|
206 // Handles special value for "none". |
|
207 static PassRefPtr<CSSValue> valueForMaxLength(const Length& length) |
|
208 { |
|
209 if (length.isFixed() && length.value() == undefinedLength) |
|
210 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
211 return valueForLength(length); |
|
212 } |
|
213 |
|
214 static PassRefPtr<CSSValue> valueForBorderStyle(EBorderStyle style) |
|
215 { |
|
216 switch (style) { |
|
217 case BNONE: |
|
218 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
219 case BHIDDEN: |
|
220 return new CSSPrimitiveValue(CSS_VAL_HIDDEN); |
|
221 case INSET: |
|
222 return new CSSPrimitiveValue(CSS_VAL_INSET); |
|
223 case GROOVE: |
|
224 return new CSSPrimitiveValue(CSS_VAL_GROOVE); |
|
225 case RIDGE: |
|
226 return new CSSPrimitiveValue(CSS_VAL_RIDGE); |
|
227 case OUTSET: |
|
228 return new CSSPrimitiveValue(CSS_VAL_OUTSET); |
|
229 case DOTTED: |
|
230 return new CSSPrimitiveValue(CSS_VAL_DOTTED); |
|
231 case DASHED: |
|
232 return new CSSPrimitiveValue(CSS_VAL_DASHED); |
|
233 case SOLID: |
|
234 return new CSSPrimitiveValue(CSS_VAL_SOLID); |
|
235 case DOUBLE: |
|
236 return new CSSPrimitiveValue(CSS_VAL_DOUBLE); |
|
237 } |
|
238 ASSERT_NOT_REACHED(); |
|
239 return 0; |
|
240 } |
|
241 |
|
242 static PassRefPtr<CSSValue> valueForTextAlign(ETextAlign align) |
|
243 { |
|
244 switch (align) { |
|
245 case TAAUTO: |
|
246 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
247 case LEFT: |
|
248 return new CSSPrimitiveValue(CSS_VAL_LEFT); |
|
249 case RIGHT: |
|
250 return new CSSPrimitiveValue(CSS_VAL_RIGHT); |
|
251 case CENTER: |
|
252 return new CSSPrimitiveValue(CSS_VAL_CENTER); |
|
253 case JUSTIFY: |
|
254 return new CSSPrimitiveValue(CSS_VAL_JUSTIFY); |
|
255 case WEBKIT_LEFT: |
|
256 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_LEFT); |
|
257 case WEBKIT_RIGHT: |
|
258 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_RIGHT); |
|
259 case WEBKIT_CENTER: |
|
260 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_CENTER); |
|
261 } |
|
262 ASSERT_NOT_REACHED(); |
|
263 return 0; |
|
264 } |
|
265 |
|
266 static PassRefPtr<CSSValue> valueForAppearance(EAppearance appearance) |
|
267 { |
|
268 switch (appearance) { |
|
269 case NoAppearance: |
|
270 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
271 case CheckboxAppearance: |
|
272 return new CSSPrimitiveValue(CSS_VAL_CHECKBOX); |
|
273 case RadioAppearance: |
|
274 return new CSSPrimitiveValue(CSS_VAL_RADIO); |
|
275 case PushButtonAppearance: |
|
276 return new CSSPrimitiveValue(CSS_VAL_PUSH_BUTTON); |
|
277 case SquareButtonAppearance: |
|
278 return new CSSPrimitiveValue(CSS_VAL_SQUARE_BUTTON); |
|
279 case ButtonAppearance: |
|
280 return new CSSPrimitiveValue(CSS_VAL_BUTTON); |
|
281 case ButtonBevelAppearance: |
|
282 return new CSSPrimitiveValue(CSS_VAL_BUTTON_BEVEL); |
|
283 case ListboxAppearance: |
|
284 return new CSSPrimitiveValue(CSS_VAL_LISTBOX); |
|
285 case ListItemAppearance: |
|
286 return new CSSPrimitiveValue(CSS_VAL_LISTITEM); |
|
287 case MenulistAppearance: |
|
288 return new CSSPrimitiveValue(CSS_VAL_MENULIST); |
|
289 case MenulistButtonAppearance: |
|
290 return new CSSPrimitiveValue(CSS_VAL_MENULIST_BUTTON); |
|
291 case MenulistTextAppearance: |
|
292 return new CSSPrimitiveValue(CSS_VAL_MENULIST_TEXT); |
|
293 case MenulistTextFieldAppearance: |
|
294 return new CSSPrimitiveValue(CSS_VAL_MENULIST_TEXTFIELD); |
|
295 case ScrollbarButtonUpAppearance: |
|
296 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_UP); |
|
297 case ScrollbarButtonDownAppearance: |
|
298 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_DOWN); |
|
299 case ScrollbarButtonLeftAppearance: |
|
300 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_LEFT); |
|
301 case ScrollbarButtonRightAppearance: |
|
302 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARBUTTON_RIGHT); |
|
303 case ScrollbarTrackHorizontalAppearance: |
|
304 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTRACK_HORIZONTAL); |
|
305 case ScrollbarTrackVerticalAppearance: |
|
306 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTRACK_VERTICAL); |
|
307 case ScrollbarThumbHorizontalAppearance: |
|
308 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTHUMB_HORIZONTAL); |
|
309 case ScrollbarThumbVerticalAppearance: |
|
310 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARTHUMB_VERTICAL); |
|
311 case ScrollbarGripperHorizontalAppearance: |
|
312 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARGRIPPER_HORIZONTAL); |
|
313 case ScrollbarGripperVerticalAppearance: |
|
314 return new CSSPrimitiveValue(CSS_VAL_SCROLLBARGRIPPER_VERTICAL); |
|
315 case SliderHorizontalAppearance: |
|
316 return new CSSPrimitiveValue(CSS_VAL_SLIDER_HORIZONTAL); |
|
317 case SliderVerticalAppearance: |
|
318 return new CSSPrimitiveValue(CSS_VAL_SLIDER_VERTICAL); |
|
319 case SliderThumbHorizontalAppearance: |
|
320 return new CSSPrimitiveValue(CSS_VAL_SLIDERTHUMB_HORIZONTAL); |
|
321 case SliderThumbVerticalAppearance: |
|
322 return new CSSPrimitiveValue(CSS_VAL_SLIDERTHUMB_VERTICAL); |
|
323 case CaretAppearance: |
|
324 return new CSSPrimitiveValue(CSS_VAL_CARET); |
|
325 case SearchFieldAppearance: |
|
326 return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD); |
|
327 case SearchFieldDecorationAppearance: |
|
328 return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_DECORATION); |
|
329 case SearchFieldResultsDecorationAppearance: |
|
330 return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_RESULTS_DECORATION); |
|
331 case SearchFieldResultsButtonAppearance: |
|
332 return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_RESULTS_BUTTON); |
|
333 case SearchFieldCancelButtonAppearance: |
|
334 return new CSSPrimitiveValue(CSS_VAL_SEARCHFIELD_CANCEL_BUTTON); |
|
335 case TextFieldAppearance: |
|
336 return new CSSPrimitiveValue(CSS_VAL_TEXTFIELD); |
|
337 case TextAreaAppearance: |
|
338 return new CSSPrimitiveValue(CSS_VAL_TEXTAREA); |
|
339 } |
|
340 ASSERT_NOT_REACHED(); |
|
341 return 0; |
|
342 } |
|
343 |
|
344 static PassRefPtr<CSSValue> valueForMarginCollapse(EMarginCollapse collapse) |
|
345 { |
|
346 switch (collapse) { |
|
347 case MCOLLAPSE: |
|
348 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE); |
|
349 case MSEPARATE: |
|
350 return new CSSPrimitiveValue(CSS_VAL_SEPARATE); |
|
351 case MDISCARD: |
|
352 return new CSSPrimitiveValue(CSS_VAL_DISCARD); |
|
353 } |
|
354 ASSERT_NOT_REACHED(); |
|
355 return 0; |
|
356 } |
|
357 |
|
358 static PassRefPtr<CSSValue> valueForShadow(const ShadowData* shadow) |
|
359 { |
|
360 if (!shadow) |
|
361 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
362 |
|
363 RefPtr<CSSValueList> list = new CSSValueList; |
|
364 for (const ShadowData* s = shadow; s; s = s->next) { |
|
365 RefPtr<CSSPrimitiveValue> x = new CSSPrimitiveValue(s->x, CSSPrimitiveValue::CSS_PX); |
|
366 RefPtr<CSSPrimitiveValue> y = new CSSPrimitiveValue(s->y, CSSPrimitiveValue::CSS_PX); |
|
367 RefPtr<CSSPrimitiveValue> blur = new CSSPrimitiveValue(s->blur, CSSPrimitiveValue::CSS_PX); |
|
368 RefPtr<CSSPrimitiveValue> color = new CSSPrimitiveValue(s->color.rgb()); |
|
369 list->append(new ShadowValue(x.release(), y.release(), blur.release(), color.release())); |
|
370 } |
|
371 return list.release(); |
|
372 } |
|
373 |
|
374 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID) |
|
375 { |
|
376 if (!style) |
|
377 return 0; |
|
378 |
|
379 Length l; |
|
380 switch (propertyID) { |
|
381 case CSS_PROP_LEFT: |
|
382 l = style->left(); |
|
383 break; |
|
384 case CSS_PROP_RIGHT: |
|
385 l = style->right(); |
|
386 break; |
|
387 case CSS_PROP_TOP: |
|
388 l = style->top(); |
|
389 break; |
|
390 case CSS_PROP_BOTTOM: |
|
391 l = style->bottom(); |
|
392 break; |
|
393 default: |
|
394 return 0; |
|
395 } |
|
396 |
|
397 if (style->position() == AbsolutePosition || style->position() == FixedPosition) |
|
398 return valueForLength(l); |
|
399 |
|
400 if (style->position() == RelativePosition) |
|
401 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined. |
|
402 // In other words if left is auto and right is not auto, then left's computed value is negative right. |
|
403 // So we should get the opposite length unit and see if it is auto. |
|
404 return valueForLength(l); |
|
405 |
|
406 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
407 } |
|
408 |
|
409 static PassRefPtr<CSSPrimitiveValue> currentColorOrValidColor(RenderStyle* style, const Color& color) |
|
410 { |
|
411 if (!color.isValid()) |
|
412 return new CSSPrimitiveValue(style->color().rgb()); |
|
413 return new CSSPrimitiveValue(color.rgb()); |
|
414 } |
|
415 |
|
416 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(IntSize radius) |
|
417 { |
|
418 if (radius.width() == radius.height()) |
|
419 return new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX); |
|
420 |
|
421 RefPtr<CSSValueList> list = new CSSValueList(true); |
|
422 list->append(new CSSPrimitiveValue(radius.width(), CSSPrimitiveValue::CSS_PX)); |
|
423 list->append(new CSSPrimitiveValue(radius.height(), CSSPrimitiveValue::CSS_PX)); |
|
424 return list.release(); |
|
425 } |
|
426 |
|
427 static IntRect sizingBox(RenderObject* renderer) |
|
428 { |
|
429 return renderer->style()->boxSizing() == CONTENT_BOX ? renderer->contentBox() : renderer->borderBox(); |
|
430 } |
|
431 |
|
432 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n) |
|
433 : m_node(n) |
|
434 { |
|
435 } |
|
436 |
|
437 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() |
|
438 { |
|
439 } |
|
440 |
|
441 String CSSComputedStyleDeclaration::cssText() const |
|
442 { |
|
443 String result(""); |
|
444 |
|
445 for (unsigned i = 0; i < numComputedProperties; i++) { |
|
446 if (i) |
|
447 result += " "; |
|
448 result += getPropertyName(static_cast<CSSPropertyID>(computedProperties[i])); |
|
449 result += ": "; |
|
450 result += getPropertyValue(computedProperties[i]); |
|
451 result += ";"; |
|
452 } |
|
453 |
|
454 return result; |
|
455 } |
|
456 |
|
457 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec) |
|
458 { |
|
459 ec = NO_MODIFICATION_ALLOWED_ERR; |
|
460 } |
|
461 |
|
462 // Display integers in integer format instead of "1.0". |
|
463 static String numberAsString(double n) |
|
464 { |
|
465 long i = static_cast<long>(n); |
|
466 return i == n ? String::number(i) : String::number(n); |
|
467 } |
|
468 |
|
469 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const |
|
470 { |
|
471 return getPropertyCSSValue(propertyID, UpdateLayout); |
|
472 } |
|
473 |
|
474 PassRefPtr<CSSPrimitiveValue> primitiveValueFromLength(Length length) |
|
475 { |
|
476 String string; |
|
477 switch (length.type()) { |
|
478 case Percent: |
|
479 string = numberAsString(length.percent()) + "%"; |
|
480 break; |
|
481 case Fixed: |
|
482 string = numberAsString(length.calcMinValue(0)); |
|
483 break; |
|
484 case Auto: |
|
485 string = "auto"; |
|
486 break; |
|
487 default: |
|
488 break; |
|
489 } |
|
490 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING); |
|
491 } |
|
492 |
|
493 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const |
|
494 { |
|
495 Node* node = m_node.get(); |
|
496 if (!node) |
|
497 return 0; |
|
498 |
|
499 // Make sure our layout is up to date before we allow a query on these attributes. |
|
500 if (updateLayout) |
|
501 node->document()->updateLayout(); |
|
502 |
|
503 RenderObject* renderer = node->renderer(); |
|
504 |
|
505 RenderStyle* style = node->computedStyle(); |
|
506 if (!style) |
|
507 return 0; |
|
508 |
|
509 switch (static_cast<CSSPropertyID>(propertyID)) { |
|
510 case CSS_PROP_INVALID: |
|
511 break; |
|
512 |
|
513 case CSS_PROP_BACKGROUND_COLOR: |
|
514 return new CSSPrimitiveValue(style->backgroundColor().rgb()); |
|
515 case CSS_PROP_BACKGROUND_IMAGE: |
|
516 if (style->backgroundImage()) |
|
517 return new CSSPrimitiveValue(style->backgroundImage()->url(), CSSPrimitiveValue::CSS_URI); |
|
518 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
519 case CSS_PROP__WEBKIT_BACKGROUND_SIZE: { |
|
520 RefPtr<CSSValueList> list = new CSSValueList(true); |
|
521 list->append(valueForLength(style->backgroundSize().width)); |
|
522 list->append(valueForLength(style->backgroundSize().height)); |
|
523 return list.release(); |
|
524 } |
|
525 case CSS_PROP_BACKGROUND_REPEAT: |
|
526 switch (style->backgroundRepeat()) { |
|
527 case REPEAT: |
|
528 return new CSSPrimitiveValue(CSS_VAL_REPEAT); |
|
529 case REPEAT_X: |
|
530 return new CSSPrimitiveValue(CSS_VAL_REPEAT_X); |
|
531 case REPEAT_Y: |
|
532 return new CSSPrimitiveValue(CSS_VAL_REPEAT_Y); |
|
533 case NO_REPEAT: |
|
534 return new CSSPrimitiveValue(CSS_VAL_NO_REPEAT); |
|
535 } |
|
536 ASSERT_NOT_REACHED(); |
|
537 return 0; |
|
538 case CSS_PROP__WEBKIT_BACKGROUND_COMPOSITE: |
|
539 switch (style->backgroundComposite()) { |
|
540 case CompositeClear: |
|
541 return new CSSPrimitiveValue(CSS_VAL_CLEAR); |
|
542 case CompositeCopy: |
|
543 return new CSSPrimitiveValue(CSS_VAL_COPY); |
|
544 case CompositeSourceOver: |
|
545 return new CSSPrimitiveValue(CSS_VAL_SOURCE_OVER); |
|
546 case CompositeSourceIn: |
|
547 return new CSSPrimitiveValue(CSS_VAL_SOURCE_IN); |
|
548 case CompositeSourceOut: |
|
549 return new CSSPrimitiveValue(CSS_VAL_SOURCE_OUT); |
|
550 case CompositeSourceAtop: |
|
551 return new CSSPrimitiveValue(CSS_VAL_SOURCE_ATOP); |
|
552 case CompositeDestinationOver: |
|
553 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OVER); |
|
554 case CompositeDestinationIn: |
|
555 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_IN); |
|
556 case CompositeDestinationOut: |
|
557 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_OUT); |
|
558 case CompositeDestinationAtop: |
|
559 return new CSSPrimitiveValue(CSS_VAL_DESTINATION_ATOP); |
|
560 case CompositeXOR: |
|
561 return new CSSPrimitiveValue(CSS_VAL_XOR); |
|
562 case CompositePlusDarker: |
|
563 return new CSSPrimitiveValue(CSS_VAL_PLUS_DARKER); |
|
564 case CompositeHighlight: |
|
565 return new CSSPrimitiveValue(CSS_VAL_HIGHLIGHT); |
|
566 case CompositePlusLighter: |
|
567 return new CSSPrimitiveValue(CSS_VAL_PLUS_LIGHTER); |
|
568 } |
|
569 ASSERT_NOT_REACHED(); |
|
570 return 0; |
|
571 case CSS_PROP_BACKGROUND_ATTACHMENT: |
|
572 if (style->backgroundAttachment()) |
|
573 return new CSSPrimitiveValue(CSS_VAL_SCROLL); |
|
574 return new CSSPrimitiveValue(CSS_VAL_FIXED); |
|
575 case CSS_PROP__WEBKIT_BACKGROUND_CLIP: |
|
576 case CSS_PROP__WEBKIT_BACKGROUND_ORIGIN: { |
|
577 EBackgroundBox box = (propertyID == CSS_PROP__WEBKIT_BACKGROUND_CLIP ? style->backgroundClip() : style->backgroundOrigin()); |
|
578 switch (box) { |
|
579 case BGBORDER: |
|
580 return new CSSPrimitiveValue(CSS_VAL_BORDER); |
|
581 case BGPADDING: |
|
582 return new CSSPrimitiveValue(CSS_VAL_PADDING); |
|
583 case BGCONTENT: |
|
584 return new CSSPrimitiveValue(CSS_VAL_CONTENT); |
|
585 } |
|
586 ASSERT_NOT_REACHED(); |
|
587 return 0; |
|
588 } |
|
589 case CSS_PROP_BACKGROUND_POSITION: { |
|
590 RefPtr<CSSValueList> list = new CSSValueList(true); |
|
591 |
|
592 Length length(style->backgroundXPosition()); |
|
593 if (length.isPercent()) |
|
594 list->append(new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE)); |
|
595 else |
|
596 list->append(new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX)); |
|
597 |
|
598 length = style->backgroundYPosition(); |
|
599 if (length.isPercent()) |
|
600 list->append(new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE)); |
|
601 else |
|
602 list->append(new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX)); |
|
603 |
|
604 return list.release(); |
|
605 } |
|
606 case CSS_PROP_BACKGROUND_POSITION_X: { |
|
607 Length length(style->backgroundXPosition()); |
|
608 if (length.isPercent()) |
|
609 return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
610 else |
|
611 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX); |
|
612 } |
|
613 case CSS_PROP_BACKGROUND_POSITION_Y: { |
|
614 Length length(style->backgroundYPosition()); |
|
615 if (length.isPercent()) |
|
616 return new CSSPrimitiveValue(length.percent(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
617 else |
|
618 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX); |
|
619 } |
|
620 case CSS_PROP_BORDER_COLLAPSE: |
|
621 if (style->borderCollapse()) |
|
622 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE); |
|
623 return new CSSPrimitiveValue(CSS_VAL_SEPARATE); |
|
624 case CSS_PROP_BORDER_SPACING: { |
|
625 RefPtr<CSSValueList> list = new CSSValueList(true); |
|
626 list->append(new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); |
|
627 list->append(new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); |
|
628 return list.release(); |
|
629 } |
|
630 case CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING: |
|
631 return new CSSPrimitiveValue(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX); |
|
632 case CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING: |
|
633 return new CSSPrimitiveValue(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX); |
|
634 case CSS_PROP_BORDER_TOP_COLOR: |
|
635 return currentColorOrValidColor(style, style->borderTopColor()); |
|
636 case CSS_PROP_BORDER_RIGHT_COLOR: |
|
637 return currentColorOrValidColor(style, style->borderRightColor()); |
|
638 case CSS_PROP_BORDER_BOTTOM_COLOR: |
|
639 return currentColorOrValidColor(style, style->borderBottomColor()); |
|
640 case CSS_PROP_BORDER_LEFT_COLOR: |
|
641 return currentColorOrValidColor(style, style->borderLeftColor()); |
|
642 case CSS_PROP_BORDER_TOP_STYLE: |
|
643 return valueForBorderStyle(style->borderTopStyle()); |
|
644 case CSS_PROP_BORDER_RIGHT_STYLE: |
|
645 return valueForBorderStyle(style->borderRightStyle()); |
|
646 case CSS_PROP_BORDER_BOTTOM_STYLE: |
|
647 return valueForBorderStyle(style->borderBottomStyle()); |
|
648 case CSS_PROP_BORDER_LEFT_STYLE: |
|
649 return valueForBorderStyle(style->borderLeftStyle()); |
|
650 case CSS_PROP_BORDER_TOP_WIDTH: |
|
651 return new CSSPrimitiveValue(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX); |
|
652 case CSS_PROP_BORDER_RIGHT_WIDTH: |
|
653 return new CSSPrimitiveValue(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX); |
|
654 case CSS_PROP_BORDER_BOTTOM_WIDTH: |
|
655 return new CSSPrimitiveValue(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX); |
|
656 case CSS_PROP_BORDER_LEFT_WIDTH: |
|
657 return new CSSPrimitiveValue(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX); |
|
658 case CSS_PROP_BOTTOM: |
|
659 return getPositionOffsetValue(style, CSS_PROP_BOTTOM); |
|
660 case CSS_PROP__WEBKIT_BOX_ALIGN: |
|
661 switch (style->boxAlign()) { |
|
662 case BSTRETCH: |
|
663 return new CSSPrimitiveValue(CSS_VAL_STRETCH); |
|
664 case BSTART: |
|
665 return new CSSPrimitiveValue(CSS_VAL_START); |
|
666 case BCENTER: |
|
667 return new CSSPrimitiveValue(CSS_VAL_CENTER); |
|
668 case BEND: |
|
669 return new CSSPrimitiveValue(CSS_VAL_END); |
|
670 case BBASELINE: |
|
671 return new CSSPrimitiveValue(CSS_VAL_BASELINE); |
|
672 case BJUSTIFY: |
|
673 break; // not allowed |
|
674 } |
|
675 ASSERT_NOT_REACHED(); |
|
676 return 0; |
|
677 case CSS_PROP__WEBKIT_BOX_DIRECTION: |
|
678 switch (style->boxDirection()) { |
|
679 case BNORMAL: |
|
680 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
681 case BREVERSE: |
|
682 return new CSSPrimitiveValue(CSS_VAL_REVERSE); |
|
683 } |
|
684 ASSERT_NOT_REACHED(); |
|
685 return 0; |
|
686 case CSS_PROP__WEBKIT_BOX_FLEX: |
|
687 return new CSSPrimitiveValue(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER); |
|
688 case CSS_PROP__WEBKIT_BOX_FLEX_GROUP: |
|
689 return new CSSPrimitiveValue(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER); |
|
690 case CSS_PROP__WEBKIT_BOX_LINES: |
|
691 switch (style->boxLines()) { |
|
692 case SINGLE: |
|
693 return new CSSPrimitiveValue(CSS_VAL_SINGLE); |
|
694 case MULTIPLE: |
|
695 return new CSSPrimitiveValue(CSS_VAL_MULTIPLE); |
|
696 } |
|
697 ASSERT_NOT_REACHED(); |
|
698 return 0; |
|
699 case CSS_PROP__WEBKIT_BOX_ORDINAL_GROUP: |
|
700 return new CSSPrimitiveValue(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER); |
|
701 case CSS_PROP__WEBKIT_BOX_ORIENT: |
|
702 switch (style->boxOrient()) { |
|
703 case HORIZONTAL: |
|
704 return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL); |
|
705 case VERTICAL: |
|
706 return new CSSPrimitiveValue(CSS_VAL_VERTICAL); |
|
707 } |
|
708 ASSERT_NOT_REACHED(); |
|
709 return 0; |
|
710 case CSS_PROP__WEBKIT_BOX_PACK: |
|
711 switch (style->boxPack()) { |
|
712 case BSTART: |
|
713 return new CSSPrimitiveValue(CSS_VAL_START); |
|
714 case BEND: |
|
715 return new CSSPrimitiveValue(CSS_VAL_END); |
|
716 case BCENTER: |
|
717 return new CSSPrimitiveValue(CSS_VAL_CENTER); |
|
718 case BJUSTIFY: |
|
719 return new CSSPrimitiveValue(CSS_VAL_JUSTIFY); |
|
720 case BSTRETCH: |
|
721 case BBASELINE: |
|
722 break; // not allowed |
|
723 } |
|
724 ASSERT_NOT_REACHED(); |
|
725 return 0; |
|
726 case CSS_PROP__WEBKIT_BOX_SHADOW: |
|
727 return valueForShadow(style->boxShadow()); |
|
728 case CSS_PROP_CAPTION_SIDE: |
|
729 switch (style->captionSide()) { |
|
730 case CAPLEFT: |
|
731 return new CSSPrimitiveValue(CSS_VAL_LEFT); |
|
732 case CAPRIGHT: |
|
733 return new CSSPrimitiveValue(CSS_VAL_RIGHT); |
|
734 case CAPTOP: |
|
735 return new CSSPrimitiveValue(CSS_VAL_TOP); |
|
736 case CAPBOTTOM: |
|
737 return new CSSPrimitiveValue(CSS_VAL_BOTTOM); |
|
738 } |
|
739 ASSERT_NOT_REACHED(); |
|
740 return 0; |
|
741 case CSS_PROP_CLEAR: |
|
742 switch (style->clear()) { |
|
743 case CNONE: |
|
744 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
745 case CLEFT: |
|
746 return new CSSPrimitiveValue(CSS_VAL_LEFT); |
|
747 case CRIGHT: |
|
748 return new CSSPrimitiveValue(CSS_VAL_RIGHT); |
|
749 case CBOTH: |
|
750 return new CSSPrimitiveValue(CSS_VAL_BOTH); |
|
751 } |
|
752 ASSERT_NOT_REACHED(); |
|
753 return 0; |
|
754 case CSS_PROP_COLOR: |
|
755 return new CSSPrimitiveValue(style->color().rgb()); |
|
756 case CSS_PROP__WEBKIT_COLUMN_COUNT: |
|
757 if (style->hasAutoColumnCount()) |
|
758 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
759 return new CSSPrimitiveValue(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER); |
|
760 case CSS_PROP__WEBKIT_COLUMN_GAP: |
|
761 if (style->hasNormalColumnGap()) |
|
762 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
763 return new CSSPrimitiveValue(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER); |
|
764 case CSS_PROP__WEBKIT_COLUMN_RULE_COLOR: |
|
765 return currentColorOrValidColor(style, style->columnRuleColor()); |
|
766 case CSS_PROP__WEBKIT_COLUMN_RULE_STYLE: |
|
767 return valueForBorderStyle(style->columnRuleStyle()); |
|
768 case CSS_PROP__WEBKIT_COLUMN_RULE_WIDTH: |
|
769 return new CSSPrimitiveValue(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX); |
|
770 case CSS_PROP__WEBKIT_COLUMN_BREAK_AFTER: |
|
771 switch (style->columnBreakAfter()) { |
|
772 case PBAUTO: |
|
773 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
774 case PBALWAYS: |
|
775 return new CSSPrimitiveValue(CSS_VAL_ALWAYS); |
|
776 case PBAVOID: |
|
777 return new CSSPrimitiveValue(CSS_VAL_AVOID); |
|
778 } |
|
779 ASSERT_NOT_REACHED(); |
|
780 return 0; |
|
781 case CSS_PROP__WEBKIT_COLUMN_BREAK_BEFORE: |
|
782 switch (style->columnBreakBefore()) { |
|
783 case PBAUTO: |
|
784 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
785 case PBALWAYS: |
|
786 return new CSSPrimitiveValue(CSS_VAL_ALWAYS); |
|
787 case PBAVOID: |
|
788 return new CSSPrimitiveValue(CSS_VAL_AVOID); |
|
789 } |
|
790 ASSERT_NOT_REACHED(); |
|
791 return 0; |
|
792 case CSS_PROP__WEBKIT_COLUMN_BREAK_INSIDE: |
|
793 switch (style->columnBreakInside()) { |
|
794 case PBAUTO: |
|
795 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
796 case PBAVOID: |
|
797 return new CSSPrimitiveValue(CSS_VAL_AVOID); |
|
798 case PBALWAYS: |
|
799 break; // not allowed |
|
800 } |
|
801 ASSERT_NOT_REACHED(); |
|
802 return 0; |
|
803 case CSS_PROP__WEBKIT_COLUMN_WIDTH: |
|
804 if (style->hasAutoColumnWidth()) |
|
805 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
806 return new CSSPrimitiveValue(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER); |
|
807 case CSS_PROP_CURSOR: { |
|
808 RefPtr<CSSValueList> list; |
|
809 CursorList* cursors = style->cursors(); |
|
810 if (cursors && cursors->size() > 0) { |
|
811 list = new CSSValueList; |
|
812 for (unsigned i = 0; i < cursors->size(); ++i) |
|
813 list->append(new CSSPrimitiveValue((*cursors)[i].cursorImage->url(), CSSPrimitiveValue::CSS_URI)); |
|
814 } |
|
815 RefPtr<CSSValue> value; |
|
816 switch (style->cursor()) { |
|
817 case CURSOR_AUTO: |
|
818 value = new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
819 break; |
|
820 case CURSOR_CROSS: |
|
821 value = new CSSPrimitiveValue(CSS_VAL_CROSSHAIR); |
|
822 break; |
|
823 case CURSOR_DEFAULT: |
|
824 value = new CSSPrimitiveValue(CSS_VAL_DEFAULT); |
|
825 break; |
|
826 case CURSOR_POINTER: |
|
827 value = new CSSPrimitiveValue(CSS_VAL_POINTER); |
|
828 break; |
|
829 case CURSOR_MOVE: |
|
830 value = new CSSPrimitiveValue(CSS_VAL_MOVE); |
|
831 break; |
|
832 case CURSOR_CELL: |
|
833 value = new CSSPrimitiveValue(CSS_VAL_CELL); |
|
834 break; |
|
835 case CURSOR_VERTICAL_TEXT: |
|
836 value = new CSSPrimitiveValue(CSS_VAL_VERTICAL_TEXT); |
|
837 break; |
|
838 case CURSOR_CONTEXT_MENU: |
|
839 value = new CSSPrimitiveValue(CSS_VAL_CONTEXT_MENU); |
|
840 break; |
|
841 case CURSOR_ALIAS: |
|
842 value = new CSSPrimitiveValue(CSS_VAL_ALIAS); |
|
843 break; |
|
844 case CURSOR_COPY: |
|
845 value = new CSSPrimitiveValue(CSS_VAL_COPY); |
|
846 break; |
|
847 case CURSOR_NONE: |
|
848 value = new CSSPrimitiveValue(CSS_VAL_NONE); |
|
849 break; |
|
850 case CURSOR_PROGRESS: |
|
851 value = new CSSPrimitiveValue(CSS_VAL_PROGRESS); |
|
852 break; |
|
853 case CURSOR_NO_DROP: |
|
854 value = new CSSPrimitiveValue(CSS_VAL_NO_DROP); |
|
855 break; |
|
856 case CURSOR_NOT_ALLOWED: |
|
857 value = new CSSPrimitiveValue(CSS_VAL_NOT_ALLOWED); |
|
858 break; |
|
859 case CURSOR_WEBKIT_ZOOM_IN: |
|
860 value = new CSSPrimitiveValue(CSS_VAL__WEBKIT_ZOOM_IN); |
|
861 break; |
|
862 case CURSOR_WEBKIT_ZOOM_OUT: |
|
863 value = new CSSPrimitiveValue(CSS_VAL__WEBKIT_ZOOM_OUT); |
|
864 break; |
|
865 case CURSOR_E_RESIZE: |
|
866 value = new CSSPrimitiveValue(CSS_VAL_E_RESIZE); |
|
867 break; |
|
868 case CURSOR_NE_RESIZE: |
|
869 value = new CSSPrimitiveValue(CSS_VAL_NE_RESIZE); |
|
870 break; |
|
871 case CURSOR_NW_RESIZE: |
|
872 value = new CSSPrimitiveValue(CSS_VAL_NW_RESIZE); |
|
873 break; |
|
874 case CURSOR_N_RESIZE: |
|
875 value = new CSSPrimitiveValue(CSS_VAL_N_RESIZE); |
|
876 break; |
|
877 case CURSOR_SE_RESIZE: |
|
878 value = new CSSPrimitiveValue(CSS_VAL_SE_RESIZE); |
|
879 break; |
|
880 case CURSOR_SW_RESIZE: |
|
881 value = new CSSPrimitiveValue(CSS_VAL_SW_RESIZE); |
|
882 break; |
|
883 case CURSOR_S_RESIZE: |
|
884 value = new CSSPrimitiveValue(CSS_VAL_S_RESIZE); |
|
885 break; |
|
886 case CURSOR_W_RESIZE: |
|
887 value = new CSSPrimitiveValue(CSS_VAL_W_RESIZE); |
|
888 break; |
|
889 case CURSOR_EW_RESIZE: |
|
890 value = new CSSPrimitiveValue(CSS_VAL_EW_RESIZE); |
|
891 break; |
|
892 case CURSOR_NS_RESIZE: |
|
893 value = new CSSPrimitiveValue(CSS_VAL_NS_RESIZE); |
|
894 break; |
|
895 case CURSOR_NESW_RESIZE: |
|
896 value = new CSSPrimitiveValue(CSS_VAL_NESW_RESIZE); |
|
897 break; |
|
898 case CURSOR_NWSE_RESIZE: |
|
899 value = new CSSPrimitiveValue(CSS_VAL_NWSE_RESIZE); |
|
900 break; |
|
901 case CURSOR_COL_RESIZE: |
|
902 value = new CSSPrimitiveValue(CSS_VAL_COL_RESIZE); |
|
903 break; |
|
904 case CURSOR_ROW_RESIZE: |
|
905 value = new CSSPrimitiveValue(CSS_VAL_ROW_RESIZE); |
|
906 break; |
|
907 case CURSOR_TEXT: |
|
908 value = new CSSPrimitiveValue(CSS_VAL_TEXT); |
|
909 break; |
|
910 case CURSOR_WAIT: |
|
911 value = new CSSPrimitiveValue(CSS_VAL_WAIT); |
|
912 break; |
|
913 case CURSOR_HELP: |
|
914 value = new CSSPrimitiveValue(CSS_VAL_HELP); |
|
915 break; |
|
916 case CURSOR_ALL_SCROLL: |
|
917 value = new CSSPrimitiveValue(CSS_VAL_ALL_SCROLL); |
|
918 break; |
|
919 } |
|
920 ASSERT(value); |
|
921 if (list) { |
|
922 list->append(value); |
|
923 return list.release(); |
|
924 } |
|
925 return value.release(); |
|
926 } |
|
927 case CSS_PROP_DIRECTION: |
|
928 switch (style->direction()) { |
|
929 case LTR: |
|
930 return new CSSPrimitiveValue(CSS_VAL_LTR); |
|
931 case RTL: |
|
932 return new CSSPrimitiveValue(CSS_VAL_RTL); |
|
933 } |
|
934 ASSERT_NOT_REACHED(); |
|
935 return 0; |
|
936 case CSS_PROP_DISPLAY: |
|
937 switch (style->display()) { |
|
938 case INLINE: |
|
939 return new CSSPrimitiveValue(CSS_VAL_INLINE); |
|
940 case BLOCK: |
|
941 return new CSSPrimitiveValue(CSS_VAL_BLOCK); |
|
942 case LIST_ITEM: |
|
943 return new CSSPrimitiveValue(CSS_VAL_LIST_ITEM); |
|
944 case RUN_IN: |
|
945 return new CSSPrimitiveValue(CSS_VAL_RUN_IN); |
|
946 case COMPACT: |
|
947 return new CSSPrimitiveValue(CSS_VAL_COMPACT); |
|
948 case INLINE_BLOCK: |
|
949 return new CSSPrimitiveValue(CSS_VAL_INLINE_BLOCK); |
|
950 case TABLE: |
|
951 return new CSSPrimitiveValue(CSS_VAL_TABLE); |
|
952 case INLINE_TABLE: |
|
953 return new CSSPrimitiveValue(CSS_VAL_INLINE_TABLE); |
|
954 case TABLE_ROW_GROUP: |
|
955 return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW_GROUP); |
|
956 case TABLE_HEADER_GROUP: |
|
957 return new CSSPrimitiveValue(CSS_VAL_TABLE_HEADER_GROUP); |
|
958 case TABLE_FOOTER_GROUP: |
|
959 return new CSSPrimitiveValue(CSS_VAL_TABLE_FOOTER_GROUP); |
|
960 case TABLE_ROW: |
|
961 return new CSSPrimitiveValue(CSS_VAL_TABLE_ROW); |
|
962 case TABLE_COLUMN_GROUP: |
|
963 return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN_GROUP); |
|
964 case TABLE_COLUMN: |
|
965 return new CSSPrimitiveValue(CSS_VAL_TABLE_COLUMN); |
|
966 case TABLE_CELL: |
|
967 return new CSSPrimitiveValue(CSS_VAL_TABLE_CELL); |
|
968 case TABLE_CAPTION: |
|
969 return new CSSPrimitiveValue(CSS_VAL_TABLE_CAPTION); |
|
970 case BOX: |
|
971 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BOX); |
|
972 case INLINE_BOX: |
|
973 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_INLINE_BOX); |
|
974 #if PLATFORM(SYMBIAN) |
|
975 case WAP_MARQUEE: |
|
976 return new CSSPrimitiveValue(CSS_VAL__WAP_MARQUEE); |
|
977 #endif |
|
978 case NONE: |
|
979 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
980 } |
|
981 ASSERT_NOT_REACHED(); |
|
982 return 0; |
|
983 case CSS_PROP_EMPTY_CELLS: |
|
984 switch (style->emptyCells()) { |
|
985 case SHOW: |
|
986 return new CSSPrimitiveValue(CSS_VAL_SHOW); |
|
987 case HIDE: |
|
988 return new CSSPrimitiveValue(CSS_VAL_HIDE); |
|
989 } |
|
990 ASSERT_NOT_REACHED(); |
|
991 return 0; |
|
992 case CSS_PROP_FLOAT: |
|
993 switch (style->floating()) { |
|
994 case FNONE: |
|
995 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
996 case FLEFT: |
|
997 return new CSSPrimitiveValue(CSS_VAL_LEFT); |
|
998 case FRIGHT: |
|
999 return new CSSPrimitiveValue(CSS_VAL_RIGHT); |
|
1000 } |
|
1001 ASSERT_NOT_REACHED(); |
|
1002 return 0; |
|
1003 case CSS_PROP_FONT_FAMILY: |
|
1004 // FIXME: This only returns the first family. |
|
1005 return new CSSPrimitiveValue(style->fontDescription().family().family().domString(), CSSPrimitiveValue::CSS_STRING); |
|
1006 case CSS_PROP_FONT_SIZE: |
|
1007 return new CSSPrimitiveValue(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); |
|
1008 case CSS_PROP__WEBKIT_BINDING: |
|
1009 break; |
|
1010 case CSS_PROP_FONT_STYLE: |
|
1011 if (style->fontDescription().italic()) |
|
1012 return new CSSPrimitiveValue(CSS_VAL_ITALIC); |
|
1013 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1014 case CSS_PROP_FONT_VARIANT: |
|
1015 if (style->fontDescription().smallCaps()) |
|
1016 return new CSSPrimitiveValue(CSS_VAL_SMALL_CAPS); |
|
1017 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1018 case CSS_PROP_FONT_WEIGHT: |
|
1019 // FIXME: this does not reflect the full range of weights |
|
1020 // that can be expressed with CSS |
|
1021 if (style->fontDescription().weight() == cBoldWeight) |
|
1022 return new CSSPrimitiveValue(CSS_VAL_BOLD); |
|
1023 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1024 case CSS_PROP_HEIGHT: |
|
1025 if (renderer) |
|
1026 return new CSSPrimitiveValue(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX); |
|
1027 return valueForLength(style->height()); |
|
1028 case CSS_PROP__WEBKIT_HIGHLIGHT: |
|
1029 if (style->highlight() == nullAtom) |
|
1030 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1031 return new CSSPrimitiveValue(style->highlight(), CSSPrimitiveValue::CSS_STRING); |
|
1032 case CSS_PROP__WEBKIT_BORDER_FIT: |
|
1033 if (style->borderFit() == BorderFitBorder) |
|
1034 return new CSSPrimitiveValue(CSS_VAL_BORDER); |
|
1035 return new CSSPrimitiveValue(CSS_VAL_LINES); |
|
1036 case CSS_PROP_LEFT: |
|
1037 return getPositionOffsetValue(style, CSS_PROP_LEFT); |
|
1038 case CSS_PROP_LETTER_SPACING: |
|
1039 if (!style->letterSpacing()) |
|
1040 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1041 return new CSSPrimitiveValue(style->letterSpacing(), CSSPrimitiveValue::CSS_PX); |
|
1042 case CSS_PROP__WEBKIT_LINE_CLAMP: |
|
1043 if (style->lineClamp() == -1) |
|
1044 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1045 return new CSSPrimitiveValue(style->lineClamp(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
1046 case CSS_PROP_LINE_HEIGHT: { |
|
1047 Length length = style->lineHeight(); |
|
1048 if (length.isNegative()) |
|
1049 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1050 if (length.isPercent()) |
|
1051 // This is imperfect, because it doesn't include the zoom factor and the real computation |
|
1052 // for how high to be in pixels does include things like minimum font size and the zoom factor. |
|
1053 // On the other hand, since font-size doesn't include the zoom factor, we really can't do |
|
1054 // that here either. |
|
1055 return new CSSPrimitiveValue(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX); |
|
1056 return new CSSPrimitiveValue(length.value(), CSSPrimitiveValue::CSS_PX); |
|
1057 } |
|
1058 case CSS_PROP_LIST_STYLE_IMAGE: |
|
1059 if (style->listStyleImage()) |
|
1060 return new CSSPrimitiveValue(style->listStyleImage()->url(), CSSPrimitiveValue::CSS_URI); |
|
1061 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1062 case CSS_PROP_LIST_STYLE_POSITION: |
|
1063 switch (style->listStylePosition()) { |
|
1064 case OUTSIDE: |
|
1065 return new CSSPrimitiveValue(CSS_VAL_OUTSIDE); |
|
1066 case INSIDE: |
|
1067 return new CSSPrimitiveValue(CSS_VAL_INSIDE); |
|
1068 } |
|
1069 ASSERT_NOT_REACHED(); |
|
1070 return 0; |
|
1071 case CSS_PROP_LIST_STYLE_TYPE: |
|
1072 switch (style->listStyleType()) { |
|
1073 case LNONE: |
|
1074 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1075 case DISC: |
|
1076 return new CSSPrimitiveValue(CSS_VAL_DISC); |
|
1077 case CIRCLE: |
|
1078 return new CSSPrimitiveValue(CSS_VAL_CIRCLE); |
|
1079 case SQUARE: |
|
1080 return new CSSPrimitiveValue(CSS_VAL_SQUARE); |
|
1081 case LDECIMAL: |
|
1082 return new CSSPrimitiveValue(CSS_VAL_DECIMAL); |
|
1083 case DECIMAL_LEADING_ZERO: |
|
1084 return new CSSPrimitiveValue(CSS_VAL_DECIMAL_LEADING_ZERO); |
|
1085 case LOWER_ROMAN: |
|
1086 return new CSSPrimitiveValue(CSS_VAL_LOWER_ROMAN); |
|
1087 case UPPER_ROMAN: |
|
1088 return new CSSPrimitiveValue(CSS_VAL_UPPER_ROMAN); |
|
1089 case LOWER_GREEK: |
|
1090 return new CSSPrimitiveValue(CSS_VAL_LOWER_GREEK); |
|
1091 case LOWER_ALPHA: |
|
1092 return new CSSPrimitiveValue(CSS_VAL_LOWER_ALPHA); |
|
1093 case LOWER_LATIN: |
|
1094 return new CSSPrimitiveValue(CSS_VAL_LOWER_LATIN); |
|
1095 case UPPER_ALPHA: |
|
1096 return new CSSPrimitiveValue(CSS_VAL_UPPER_ALPHA); |
|
1097 case UPPER_LATIN: |
|
1098 return new CSSPrimitiveValue(CSS_VAL_UPPER_LATIN); |
|
1099 case HEBREW: |
|
1100 return new CSSPrimitiveValue(CSS_VAL_HEBREW); |
|
1101 case ARMENIAN: |
|
1102 return new CSSPrimitiveValue(CSS_VAL_ARMENIAN); |
|
1103 case GEORGIAN: |
|
1104 return new CSSPrimitiveValue(CSS_VAL_GEORGIAN); |
|
1105 case CJK_IDEOGRAPHIC: |
|
1106 return new CSSPrimitiveValue(CSS_VAL_CJK_IDEOGRAPHIC); |
|
1107 case HIRAGANA: |
|
1108 return new CSSPrimitiveValue(CSS_VAL_HIRAGANA); |
|
1109 case KATAKANA: |
|
1110 return new CSSPrimitiveValue(CSS_VAL_KATAKANA); |
|
1111 case HIRAGANA_IROHA: |
|
1112 return new CSSPrimitiveValue(CSS_VAL_HIRAGANA_IROHA); |
|
1113 case KATAKANA_IROHA: |
|
1114 return new CSSPrimitiveValue(CSS_VAL_KATAKANA_IROHA); |
|
1115 } |
|
1116 ASSERT_NOT_REACHED(); |
|
1117 return 0; |
|
1118 case CSS_PROP_MARGIN_TOP: |
|
1119 if (renderer) |
|
1120 // FIXME: Supposed to return the percentage if percentage was specified. |
|
1121 return new CSSPrimitiveValue(renderer->marginTop(), CSSPrimitiveValue::CSS_PX); |
|
1122 return valueForLength(style->marginTop()); |
|
1123 case CSS_PROP_MARGIN_RIGHT: |
|
1124 if (renderer) |
|
1125 // FIXME: Supposed to return the percentage if percentage was specified. |
|
1126 return new CSSPrimitiveValue(renderer->marginRight(), CSSPrimitiveValue::CSS_PX); |
|
1127 return valueForLength(style->marginRight()); |
|
1128 case CSS_PROP_MARGIN_BOTTOM: |
|
1129 if (renderer) |
|
1130 // FIXME: Supposed to return the percentage if percentage was specified. |
|
1131 return new CSSPrimitiveValue(renderer->marginBottom(), CSSPrimitiveValue::CSS_PX); |
|
1132 return valueForLength(style->marginBottom()); |
|
1133 case CSS_PROP_MARGIN_LEFT: |
|
1134 if (renderer) |
|
1135 // FIXME: Supposed to return the percentage if percentage was specified. |
|
1136 return new CSSPrimitiveValue(renderer->marginLeft(), CSSPrimitiveValue::CSS_PX); |
|
1137 return valueForLength(style->marginLeft()); |
|
1138 #if PLATFORM(SYMBIAN) |
|
1139 case CSS_PROP__WAP_MARQUEE_DIR: |
|
1140 #endif |
|
1141 case CSS_PROP__WEBKIT_MARQUEE_DIRECTION: |
|
1142 switch (style->marqueeDirection()) { |
|
1143 case MFORWARD: |
|
1144 return new CSSPrimitiveValue(CSS_VAL_FORWARDS); |
|
1145 case MBACKWARD: |
|
1146 return new CSSPrimitiveValue(CSS_VAL_BACKWARDS); |
|
1147 case MAUTO: |
|
1148 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1149 case MUP: |
|
1150 return new CSSPrimitiveValue(CSS_VAL_UP); |
|
1151 case MDOWN: |
|
1152 return new CSSPrimitiveValue(CSS_VAL_DOWN); |
|
1153 case MLEFT: |
|
1154 return new CSSPrimitiveValue(CSS_VAL_LEFT); |
|
1155 case MRIGHT: |
|
1156 return new CSSPrimitiveValue(CSS_VAL_RIGHT); |
|
1157 } |
|
1158 ASSERT_NOT_REACHED(); |
|
1159 return 0; |
|
1160 case CSS_PROP__WEBKIT_MARQUEE_INCREMENT: |
|
1161 return valueForLength(style->marqueeIncrement()); |
|
1162 #if PLATFORM(SYMBIAN) |
|
1163 case CSS_PROP__WAP_MARQUEE_LOOP: |
|
1164 #endif |
|
1165 case CSS_PROP__WEBKIT_MARQUEE_REPETITION: |
|
1166 if (style->marqueeLoopCount() < 0) |
|
1167 return new CSSPrimitiveValue(CSS_VAL_INFINITE); |
|
1168 return new CSSPrimitiveValue(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER); |
|
1169 #if PLATFORM(SYMBIAN) |
|
1170 case CSS_PROP__WAP_MARQUEE_SPEED: |
|
1171 // FIXME: unimplemented |
|
1172 break; |
|
1173 case CSS_PROP__WAP_MARQUEE_STYLE: |
|
1174 #endif |
|
1175 case CSS_PROP__WEBKIT_MARQUEE_STYLE: |
|
1176 switch (style->marqueeBehavior()) { |
|
1177 case MNONE: |
|
1178 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1179 case MSCROLL: |
|
1180 return new CSSPrimitiveValue(CSS_VAL_SCROLL); |
|
1181 case MSLIDE: |
|
1182 return new CSSPrimitiveValue(CSS_VAL_SLIDE); |
|
1183 case MALTERNATE: |
|
1184 return new CSSPrimitiveValue(CSS_VAL_ALTERNATE); |
|
1185 } |
|
1186 ASSERT_NOT_REACHED(); |
|
1187 return 0; |
|
1188 case CSS_PROP__WEBKIT_USER_MODIFY: |
|
1189 switch (style->userModify()) { |
|
1190 case READ_ONLY: |
|
1191 return new CSSPrimitiveValue(CSS_VAL_READ_ONLY); |
|
1192 case READ_WRITE: |
|
1193 return new CSSPrimitiveValue(CSS_VAL_READ_WRITE); |
|
1194 case READ_WRITE_PLAINTEXT_ONLY: |
|
1195 return new CSSPrimitiveValue(CSS_VAL_READ_WRITE_PLAINTEXT_ONLY); |
|
1196 } |
|
1197 ASSERT_NOT_REACHED(); |
|
1198 return 0; |
|
1199 case CSS_PROP_MAX_HEIGHT: |
|
1200 return valueForMaxLength(style->maxHeight()); |
|
1201 case CSS_PROP_MAX_WIDTH: |
|
1202 return valueForMaxLength(style->maxWidth()); |
|
1203 case CSS_PROP_MIN_HEIGHT: |
|
1204 return valueForLength(style->minHeight()); |
|
1205 case CSS_PROP_MIN_WIDTH: |
|
1206 return valueForLength(style->minWidth()); |
|
1207 case CSS_PROP_OPACITY: |
|
1208 return new CSSPrimitiveValue(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); |
|
1209 case CSS_PROP_ORPHANS: |
|
1210 return new CSSPrimitiveValue(style->orphans(), CSSPrimitiveValue::CSS_NUMBER); |
|
1211 case CSS_PROP_OUTLINE_COLOR: |
|
1212 return currentColorOrValidColor(style, style->outlineColor()); |
|
1213 case CSS_PROP_OUTLINE_STYLE: |
|
1214 if (style->outlineStyleIsAuto()) |
|
1215 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1216 return valueForBorderStyle(style->outlineStyle()); |
|
1217 case CSS_PROP_OUTLINE_WIDTH: |
|
1218 return new CSSPrimitiveValue(style->outlineWidth(), CSSPrimitiveValue::CSS_PX); |
|
1219 case CSS_PROP_OVERFLOW: |
|
1220 case CSS_PROP_OVERFLOW_X: |
|
1221 case CSS_PROP_OVERFLOW_Y: { |
|
1222 EOverflow overflow; |
|
1223 switch (propertyID) { |
|
1224 case CSS_PROP_OVERFLOW_X: |
|
1225 overflow = style->overflowX(); |
|
1226 break; |
|
1227 case CSS_PROP_OVERFLOW_Y: |
|
1228 overflow = style->overflowY(); |
|
1229 break; |
|
1230 default: |
|
1231 overflow = max(style->overflowX(), style->overflowY()); |
|
1232 } |
|
1233 switch (overflow) { |
|
1234 case OVISIBLE: |
|
1235 return new CSSPrimitiveValue(CSS_VAL_VISIBLE); |
|
1236 case OHIDDEN: |
|
1237 return new CSSPrimitiveValue(CSS_VAL_HIDDEN); |
|
1238 case OSCROLL: |
|
1239 return new CSSPrimitiveValue(CSS_VAL_SCROLL); |
|
1240 case OAUTO: |
|
1241 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1242 case OMARQUEE: |
|
1243 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_MARQUEE); |
|
1244 case OOVERLAY: |
|
1245 return new CSSPrimitiveValue(CSS_VAL_OVERLAY); |
|
1246 } |
|
1247 ASSERT_NOT_REACHED(); |
|
1248 return 0; |
|
1249 } |
|
1250 case CSS_PROP_PADDING_TOP: |
|
1251 if (renderer) |
|
1252 return new CSSPrimitiveValue(renderer->paddingTop(), CSSPrimitiveValue::CSS_PX); |
|
1253 return valueForLength(style->paddingTop()); |
|
1254 case CSS_PROP_PADDING_RIGHT: |
|
1255 if (renderer) |
|
1256 return new CSSPrimitiveValue(renderer->paddingRight(), CSSPrimitiveValue::CSS_PX); |
|
1257 return valueForLength(style->paddingRight()); |
|
1258 case CSS_PROP_PADDING_BOTTOM: |
|
1259 if (renderer) |
|
1260 return new CSSPrimitiveValue(renderer->paddingBottom(), CSSPrimitiveValue::CSS_PX); |
|
1261 return valueForLength(style->paddingBottom()); |
|
1262 case CSS_PROP_PADDING_LEFT: |
|
1263 if (renderer) |
|
1264 return new CSSPrimitiveValue(renderer->paddingLeft(), CSSPrimitiveValue::CSS_PX); |
|
1265 return valueForLength(style->paddingLeft()); |
|
1266 case CSS_PROP_PAGE_BREAK_AFTER: |
|
1267 switch (style->pageBreakAfter()) { |
|
1268 case PBAUTO: |
|
1269 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1270 case PBALWAYS: |
|
1271 return new CSSPrimitiveValue(CSS_VAL_ALWAYS); |
|
1272 case PBAVOID: |
|
1273 return new CSSPrimitiveValue(CSS_VAL_AVOID); |
|
1274 } |
|
1275 ASSERT_NOT_REACHED(); |
|
1276 return 0; |
|
1277 case CSS_PROP_PAGE_BREAK_BEFORE: |
|
1278 switch (style->pageBreakBefore()) { |
|
1279 case PBAUTO: |
|
1280 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1281 case PBALWAYS: |
|
1282 return new CSSPrimitiveValue(CSS_VAL_ALWAYS); |
|
1283 case PBAVOID: |
|
1284 return new CSSPrimitiveValue(CSS_VAL_AVOID); |
|
1285 } |
|
1286 ASSERT_NOT_REACHED(); |
|
1287 return 0; |
|
1288 case CSS_PROP_PAGE_BREAK_INSIDE: |
|
1289 switch (style->pageBreakInside()) { |
|
1290 case PBAUTO: |
|
1291 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1292 case PBAVOID: |
|
1293 return new CSSPrimitiveValue(CSS_VAL_AVOID); |
|
1294 case PBALWAYS: |
|
1295 break; // not allowed |
|
1296 } |
|
1297 ASSERT_NOT_REACHED(); |
|
1298 return 0; |
|
1299 case CSS_PROP_POSITION: |
|
1300 switch (style->position()) { |
|
1301 case StaticPosition: |
|
1302 return new CSSPrimitiveValue(CSS_VAL_STATIC); |
|
1303 case RelativePosition: |
|
1304 return new CSSPrimitiveValue(CSS_VAL_RELATIVE); |
|
1305 case AbsolutePosition: |
|
1306 return new CSSPrimitiveValue(CSS_VAL_ABSOLUTE); |
|
1307 case FixedPosition: |
|
1308 return new CSSPrimitiveValue(CSS_VAL_FIXED); |
|
1309 } |
|
1310 ASSERT_NOT_REACHED(); |
|
1311 return 0; |
|
1312 case CSS_PROP_RIGHT: |
|
1313 return getPositionOffsetValue(style, CSS_PROP_RIGHT); |
|
1314 case CSS_PROP_TABLE_LAYOUT: |
|
1315 switch (style->tableLayout()) { |
|
1316 case TAUTO: |
|
1317 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1318 case TFIXED: |
|
1319 return new CSSPrimitiveValue(CSS_VAL_FIXED); |
|
1320 } |
|
1321 ASSERT_NOT_REACHED(); |
|
1322 return 0; |
|
1323 case CSS_PROP_TEXT_ALIGN: |
|
1324 return valueForTextAlign(style->textAlign()); |
|
1325 case CSS_PROP_TEXT_DECORATION: { |
|
1326 String string; |
|
1327 if (style->textDecoration() & UNDERLINE) |
|
1328 string += "underline"; |
|
1329 if (style->textDecoration() & OVERLINE) { |
|
1330 if (string.length()) |
|
1331 string += " "; |
|
1332 string += "overline"; |
|
1333 } |
|
1334 if (style->textDecoration() & LINE_THROUGH) { |
|
1335 if (string.length()) |
|
1336 string += " "; |
|
1337 string += "line-through"; |
|
1338 } |
|
1339 if (style->textDecoration() & BLINK) { |
|
1340 if (string.length()) |
|
1341 string += " "; |
|
1342 string += "blink"; |
|
1343 } |
|
1344 if (!string.length()) |
|
1345 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1346 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING); |
|
1347 } |
|
1348 case CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT: { |
|
1349 String string; |
|
1350 if (style->textDecorationsInEffect() & UNDERLINE) |
|
1351 string += "underline"; |
|
1352 if (style->textDecorationsInEffect() & OVERLINE) { |
|
1353 if (string.length()) |
|
1354 string += " "; |
|
1355 string += "overline"; |
|
1356 } |
|
1357 if (style->textDecorationsInEffect() & LINE_THROUGH) { |
|
1358 if (string.length()) |
|
1359 string += " "; |
|
1360 string += "line-through"; |
|
1361 } |
|
1362 if (style->textDecorationsInEffect() & BLINK) { |
|
1363 if (string.length()) |
|
1364 string += " "; |
|
1365 string += "blink"; |
|
1366 } |
|
1367 if (!string.length()) |
|
1368 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1369 return new CSSPrimitiveValue(string, CSSPrimitiveValue::CSS_STRING); |
|
1370 } |
|
1371 case CSS_PROP__WEBKIT_TEXT_FILL_COLOR: |
|
1372 return currentColorOrValidColor(style, style->textFillColor()); |
|
1373 case CSS_PROP_TEXT_INDENT: |
|
1374 return valueForLength(style->textIndent()); |
|
1375 case CSS_PROP_TEXT_SHADOW: |
|
1376 return valueForShadow(style->textShadow()); |
|
1377 case CSS_PROP__WEBKIT_TEXT_SECURITY: |
|
1378 switch (style->textSecurity()) { |
|
1379 case TSNONE: |
|
1380 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1381 case TSDISC: |
|
1382 return new CSSPrimitiveValue(CSS_VAL_DISC); |
|
1383 case TSCIRCLE: |
|
1384 return new CSSPrimitiveValue(CSS_VAL_CIRCLE); |
|
1385 case TSSQUARE: |
|
1386 return new CSSPrimitiveValue(CSS_VAL_SQUARE); |
|
1387 } |
|
1388 ASSERT_NOT_REACHED(); |
|
1389 return 0; |
|
1390 case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST: |
|
1391 if (style->textSizeAdjust()) |
|
1392 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1393 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1394 case CSS_PROP__WEBKIT_TEXT_STROKE_COLOR: |
|
1395 return currentColorOrValidColor(style, style->textStrokeColor()); |
|
1396 case CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH: |
|
1397 return new CSSPrimitiveValue(style->textStrokeWidth(), CSSPrimitiveValue::CSS_NUMBER); |
|
1398 case CSS_PROP_TEXT_TRANSFORM: |
|
1399 switch (style->textTransform()) { |
|
1400 case CAPITALIZE: |
|
1401 return new CSSPrimitiveValue(CSS_VAL_CAPITALIZE); |
|
1402 case UPPERCASE: |
|
1403 return new CSSPrimitiveValue(CSS_VAL_UPPERCASE); |
|
1404 case LOWERCASE: |
|
1405 return new CSSPrimitiveValue(CSS_VAL_LOWERCASE); |
|
1406 case TTNONE: |
|
1407 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1408 } |
|
1409 ASSERT_NOT_REACHED(); |
|
1410 return 0; |
|
1411 case CSS_PROP_TOP: |
|
1412 return getPositionOffsetValue(style, CSS_PROP_TOP); |
|
1413 case CSS_PROP_UNICODE_BIDI: |
|
1414 switch (style->unicodeBidi()) { |
|
1415 case UBNormal: |
|
1416 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1417 case Embed: |
|
1418 return new CSSPrimitiveValue(CSS_VAL_EMBED); |
|
1419 case Override: |
|
1420 return new CSSPrimitiveValue(CSS_VAL_BIDI_OVERRIDE); |
|
1421 } |
|
1422 ASSERT_NOT_REACHED(); |
|
1423 return 0; |
|
1424 case CSS_PROP_VERTICAL_ALIGN: |
|
1425 switch (style->verticalAlign()) { |
|
1426 case BASELINE: |
|
1427 return new CSSPrimitiveValue(CSS_VAL_BASELINE); |
|
1428 case MIDDLE: |
|
1429 return new CSSPrimitiveValue(CSS_VAL_MIDDLE); |
|
1430 case SUB: |
|
1431 return new CSSPrimitiveValue(CSS_VAL_SUB); |
|
1432 case SUPER: |
|
1433 return new CSSPrimitiveValue(CSS_VAL_SUPER); |
|
1434 case TEXT_TOP: |
|
1435 return new CSSPrimitiveValue(CSS_VAL_TEXT_TOP); |
|
1436 case TEXT_BOTTOM: |
|
1437 return new CSSPrimitiveValue(CSS_VAL_TEXT_BOTTOM); |
|
1438 case TOP: |
|
1439 return new CSSPrimitiveValue(CSS_VAL_TOP); |
|
1440 case BOTTOM: |
|
1441 return new CSSPrimitiveValue(CSS_VAL_BOTTOM); |
|
1442 case BASELINE_MIDDLE: |
|
1443 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_BASELINE_MIDDLE); |
|
1444 case LENGTH: |
|
1445 return valueForLength(style->verticalAlignLength()); |
|
1446 } |
|
1447 ASSERT_NOT_REACHED(); |
|
1448 return 0; |
|
1449 case CSS_PROP_VISIBILITY: |
|
1450 switch (style->visibility()) { |
|
1451 case VISIBLE: |
|
1452 return new CSSPrimitiveValue(CSS_VAL_VISIBLE); |
|
1453 case HIDDEN: |
|
1454 return new CSSPrimitiveValue(CSS_VAL_HIDDEN); |
|
1455 case COLLAPSE: |
|
1456 return new CSSPrimitiveValue(CSS_VAL_COLLAPSE); |
|
1457 } |
|
1458 ASSERT_NOT_REACHED(); |
|
1459 return 0; |
|
1460 case CSS_PROP_WHITE_SPACE: |
|
1461 switch (style->whiteSpace()) { |
|
1462 case NORMAL: |
|
1463 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1464 case PRE: |
|
1465 return new CSSPrimitiveValue(CSS_VAL_PRE); |
|
1466 case PRE_WRAP: |
|
1467 return new CSSPrimitiveValue(CSS_VAL_PRE_WRAP); |
|
1468 case PRE_LINE: |
|
1469 return new CSSPrimitiveValue(CSS_VAL_PRE_LINE); |
|
1470 case NOWRAP: |
|
1471 return new CSSPrimitiveValue(CSS_VAL_NOWRAP); |
|
1472 case KHTML_NOWRAP: |
|
1473 return new CSSPrimitiveValue(CSS_VAL__WEBKIT_NOWRAP); |
|
1474 } |
|
1475 ASSERT_NOT_REACHED(); |
|
1476 return 0; |
|
1477 case CSS_PROP_WIDOWS: |
|
1478 return new CSSPrimitiveValue(style->widows(), CSSPrimitiveValue::CSS_NUMBER); |
|
1479 case CSS_PROP_WIDTH: |
|
1480 if (renderer) |
|
1481 return new CSSPrimitiveValue(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX); |
|
1482 return valueForLength(style->width()); |
|
1483 case CSS_PROP_WORD_BREAK: |
|
1484 switch (style->wordBreak()) { |
|
1485 case NormalWordBreak: |
|
1486 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1487 case BreakAllWordBreak: |
|
1488 return new CSSPrimitiveValue(CSS_VAL_BREAK_ALL); |
|
1489 case BreakWordBreak: |
|
1490 return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD); |
|
1491 } |
|
1492 case CSS_PROP_WORD_SPACING: |
|
1493 return new CSSPrimitiveValue(style->wordSpacing(), CSSPrimitiveValue::CSS_PX); |
|
1494 case CSS_PROP_WORD_WRAP: |
|
1495 switch (style->wordWrap()) { |
|
1496 case NormalWordWrap: |
|
1497 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1498 case BreakWordWrap: |
|
1499 return new CSSPrimitiveValue(CSS_VAL_BREAK_WORD); |
|
1500 } |
|
1501 ASSERT_NOT_REACHED(); |
|
1502 return 0; |
|
1503 case CSS_PROP__WEBKIT_LINE_BREAK: |
|
1504 switch (style->khtmlLineBreak()) { |
|
1505 case LBNORMAL: |
|
1506 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1507 case AFTER_WHITE_SPACE: |
|
1508 return new CSSPrimitiveValue(CSS_VAL_AFTER_WHITE_SPACE); |
|
1509 } |
|
1510 ASSERT_NOT_REACHED(); |
|
1511 return 0; |
|
1512 case CSS_PROP__WEBKIT_NBSP_MODE: |
|
1513 switch (style->nbspMode()) { |
|
1514 case NBNORMAL: |
|
1515 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1516 case SPACE: |
|
1517 return new CSSPrimitiveValue(CSS_VAL_SPACE); |
|
1518 } |
|
1519 ASSERT_NOT_REACHED(); |
|
1520 return 0; |
|
1521 case CSS_PROP__WEBKIT_MATCH_NEAREST_MAIL_BLOCKQUOTE_COLOR: |
|
1522 switch (style->matchNearestMailBlockquoteColor()) { |
|
1523 case BCNORMAL: |
|
1524 return new CSSPrimitiveValue(CSS_VAL_NORMAL); |
|
1525 case MATCH: |
|
1526 return new CSSPrimitiveValue(CSS_VAL_MATCH); |
|
1527 } |
|
1528 ASSERT_NOT_REACHED(); |
|
1529 return 0; |
|
1530 case CSS_PROP_RESIZE: |
|
1531 switch (style->resize()) { |
|
1532 case RESIZE_BOTH: |
|
1533 return new CSSPrimitiveValue(CSS_VAL_BOTH); |
|
1534 case RESIZE_HORIZONTAL: |
|
1535 return new CSSPrimitiveValue(CSS_VAL_HORIZONTAL); |
|
1536 case RESIZE_VERTICAL: |
|
1537 return new CSSPrimitiveValue(CSS_VAL_VERTICAL); |
|
1538 case RESIZE_NONE: |
|
1539 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1540 } |
|
1541 ASSERT_NOT_REACHED(); |
|
1542 return 0; |
|
1543 case CSS_PROP_Z_INDEX: |
|
1544 if (style->hasAutoZIndex()) |
|
1545 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1546 return new CSSPrimitiveValue(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER); |
|
1547 case CSS_PROP__WEBKIT_BOX_SIZING: |
|
1548 if (style->boxSizing() == CONTENT_BOX) |
|
1549 return new CSSPrimitiveValue(CSS_VAL_CONTENT_BOX); |
|
1550 return new CSSPrimitiveValue(CSS_VAL_BORDER_BOX); |
|
1551 case CSS_PROP__WEBKIT_DASHBOARD_REGION: |
|
1552 { |
|
1553 const Vector<StyleDashboardRegion>& regions = style->dashboardRegions(); |
|
1554 unsigned count = regions.size(); |
|
1555 if (count == 1 && regions[0].type == StyleDashboardRegion::None) |
|
1556 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1557 |
|
1558 RefPtr<DashboardRegion> firstRegion; |
|
1559 DashboardRegion* previousRegion = 0; |
|
1560 for (unsigned i = 0; i < count; i++) { |
|
1561 RefPtr<DashboardRegion> region = new DashboardRegion; |
|
1562 StyleDashboardRegion styleRegion = regions[i]; |
|
1563 |
|
1564 region->m_label = styleRegion.label; |
|
1565 LengthBox offset = styleRegion.offset; |
|
1566 region->setTop(new CSSPrimitiveValue(offset.top.value(), CSSPrimitiveValue::CSS_PX)); |
|
1567 region->setRight(new CSSPrimitiveValue(offset.right.value(), CSSPrimitiveValue::CSS_PX)); |
|
1568 region->setBottom(new CSSPrimitiveValue(offset.bottom.value(), CSSPrimitiveValue::CSS_PX)); |
|
1569 region->setLeft(new CSSPrimitiveValue(offset.left.value(), CSSPrimitiveValue::CSS_PX)); |
|
1570 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); |
|
1571 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle); |
|
1572 |
|
1573 if (previousRegion) |
|
1574 previousRegion->m_next = region; |
|
1575 else |
|
1576 firstRegion = region; |
|
1577 previousRegion = region.get(); |
|
1578 } |
|
1579 return new CSSPrimitiveValue(firstRegion.release()); |
|
1580 } |
|
1581 case CSS_PROP__WEBKIT_APPEARANCE: |
|
1582 return valueForAppearance(style->appearance()); |
|
1583 case CSS_PROP__WEBKIT_FONT_SIZE_DELTA: |
|
1584 // Not a real style property -- used by the editing engine -- so has no computed value. |
|
1585 break; |
|
1586 case CSS_PROP__WEBKIT_MARGIN_BOTTOM_COLLAPSE: |
|
1587 return valueForMarginCollapse(style->marginBottomCollapse()); |
|
1588 case CSS_PROP__WEBKIT_MARGIN_TOP_COLLAPSE: |
|
1589 return valueForMarginCollapse(style->marginTopCollapse()); |
|
1590 case CSS_PROP__WEBKIT_RTL_ORDERING: |
|
1591 if (style->visuallyOrdered()) |
|
1592 return new CSSPrimitiveValue(CSS_VAL_VISUAL); |
|
1593 return new CSSPrimitiveValue(CSS_VAL_LOGICAL); |
|
1594 case CSS_PROP__WEBKIT_USER_DRAG: |
|
1595 switch (style->userDrag()) { |
|
1596 case DRAG_AUTO: |
|
1597 return new CSSPrimitiveValue(CSS_VAL_AUTO); |
|
1598 case DRAG_NONE: |
|
1599 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1600 case DRAG_ELEMENT: |
|
1601 return new CSSPrimitiveValue(CSS_VAL_ELEMENT); |
|
1602 } |
|
1603 break; |
|
1604 case CSS_PROP__WEBKIT_USER_SELECT: |
|
1605 switch (style->userSelect()) { |
|
1606 case SELECT_NONE: |
|
1607 return new CSSPrimitiveValue(CSS_VAL_NONE); |
|
1608 case SELECT_TEXT: |
|
1609 return new CSSPrimitiveValue(CSS_VAL_TEXT); |
|
1610 } |
|
1611 break; |
|
1612 case CSS_PROP__WEBKIT_BORDER_BOTTOM_LEFT_RADIUS: |
|
1613 return getBorderRadiusCornerValue(style->borderBottomLeftRadius()); |
|
1614 case CSS_PROP__WEBKIT_BORDER_BOTTOM_RIGHT_RADIUS: |
|
1615 return getBorderRadiusCornerValue(style->borderBottomRightRadius()); |
|
1616 case CSS_PROP__WEBKIT_BORDER_TOP_LEFT_RADIUS: |
|
1617 return getBorderRadiusCornerValue(style->borderTopLeftRadius()); |
|
1618 case CSS_PROP__WEBKIT_BORDER_TOP_RIGHT_RADIUS: |
|
1619 return getBorderRadiusCornerValue(style->borderTopRightRadius()); |
|
1620 case CSS_PROP_BACKGROUND: |
|
1621 case CSS_PROP_BORDER: |
|
1622 case CSS_PROP_BORDER_BOTTOM: |
|
1623 case CSS_PROP_BORDER_COLOR: |
|
1624 case CSS_PROP_BORDER_LEFT: |
|
1625 case CSS_PROP_BORDER_RIGHT: |
|
1626 case CSS_PROP_BORDER_STYLE: |
|
1627 case CSS_PROP_BORDER_TOP: |
|
1628 case CSS_PROP_BORDER_WIDTH: |
|
1629 case CSS_PROP_CLIP: |
|
1630 case CSS_PROP_CONTENT: |
|
1631 case CSS_PROP_COUNTER_INCREMENT: |
|
1632 case CSS_PROP_COUNTER_RESET: |
|
1633 case CSS_PROP_FONT: |
|
1634 case CSS_PROP_FONT_STRETCH: |
|
1635 case CSS_PROP_LIST_STYLE: |
|
1636 case CSS_PROP_MARGIN: |
|
1637 case CSS_PROP_OUTLINE: |
|
1638 case CSS_PROP_OUTLINE_OFFSET: |
|
1639 case CSS_PROP_PADDING: |
|
1640 case CSS_PROP_PAGE: |
|
1641 case CSS_PROP_QUOTES: |
|
1642 case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR: |
|
1643 case CSS_PROP_SCROLLBAR_ARROW_COLOR: |
|
1644 case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR: |
|
1645 case CSS_PROP_SCROLLBAR_FACE_COLOR: |
|
1646 case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR: |
|
1647 case CSS_PROP_SCROLLBAR_SHADOW_COLOR: |
|
1648 case CSS_PROP_SCROLLBAR_TRACK_COLOR: |
|
1649 case CSS_PROP_SIZE: |
|
1650 case CSS_PROP_TEXT_LINE_THROUGH: |
|
1651 case CSS_PROP_TEXT_LINE_THROUGH_COLOR: |
|
1652 case CSS_PROP_TEXT_LINE_THROUGH_MODE: |
|
1653 case CSS_PROP_TEXT_LINE_THROUGH_STYLE: |
|
1654 case CSS_PROP_TEXT_LINE_THROUGH_WIDTH: |
|
1655 case CSS_PROP_TEXT_OVERFLOW: |
|
1656 case CSS_PROP_TEXT_OVERLINE: |
|
1657 case CSS_PROP_TEXT_OVERLINE_COLOR: |
|
1658 case CSS_PROP_TEXT_OVERLINE_MODE: |
|
1659 case CSS_PROP_TEXT_OVERLINE_STYLE: |
|
1660 case CSS_PROP_TEXT_OVERLINE_WIDTH: |
|
1661 case CSS_PROP_TEXT_UNDERLINE: |
|
1662 case CSS_PROP_TEXT_UNDERLINE_COLOR: |
|
1663 case CSS_PROP_TEXT_UNDERLINE_MODE: |
|
1664 case CSS_PROP_TEXT_UNDERLINE_STYLE: |
|
1665 case CSS_PROP_TEXT_UNDERLINE_WIDTH: |
|
1666 case CSS_PROP__WEBKIT_BORDER_IMAGE: |
|
1667 case CSS_PROP__WEBKIT_BORDER_RADIUS: |
|
1668 case CSS_PROP__WEBKIT_COLUMNS: |
|
1669 case CSS_PROP__WEBKIT_COLUMN_RULE: |
|
1670 case CSS_PROP__WEBKIT_MARGIN_COLLAPSE: |
|
1671 case CSS_PROP__WEBKIT_MARGIN_START: |
|
1672 case CSS_PROP__WEBKIT_MARQUEE: |
|
1673 case CSS_PROP__WEBKIT_MARQUEE_SPEED: |
|
1674 case CSS_PROP__WEBKIT_PADDING_START: |
|
1675 case CSS_PROP__WEBKIT_TEXT_STROKE: |
|
1676 // FIXME: The above are unimplemented. |
|
1677 break; |
|
1678 } |
|
1679 |
|
1680 LOG_ERROR("unimplemented propertyID: %d", propertyID); |
|
1681 return 0; |
|
1682 } |
|
1683 |
|
1684 String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const |
|
1685 { |
|
1686 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
|
1687 if (value) |
|
1688 return value->cssText(); |
|
1689 return ""; |
|
1690 } |
|
1691 |
|
1692 bool CSSComputedStyleDeclaration::getPropertyPriority(int /*propertyID*/) const |
|
1693 { |
|
1694 // All computed styles have a priority of false (not "important"). |
|
1695 return false; |
|
1696 } |
|
1697 |
|
1698 String CSSComputedStyleDeclaration::removeProperty(int /*propertyID*/, ExceptionCode& ec) |
|
1699 { |
|
1700 ec = NO_MODIFICATION_ALLOWED_ERR; |
|
1701 return String(); |
|
1702 } |
|
1703 |
|
1704 void CSSComputedStyleDeclaration::setProperty(int /*propertyID*/, const String& /*value*/, bool /*important*/, ExceptionCode& ec) |
|
1705 { |
|
1706 ec = NO_MODIFICATION_ALLOWED_ERR; |
|
1707 } |
|
1708 |
|
1709 unsigned CSSComputedStyleDeclaration::length() const |
|
1710 { |
|
1711 Node* node = m_node.get(); |
|
1712 if (!node) |
|
1713 return 0; |
|
1714 |
|
1715 RenderStyle* style = node->computedStyle(); |
|
1716 if (!style) |
|
1717 return 0; |
|
1718 |
|
1719 return numComputedProperties; |
|
1720 } |
|
1721 |
|
1722 String CSSComputedStyleDeclaration::item(unsigned i) const |
|
1723 { |
|
1724 if (i >= length()) |
|
1725 return String(); |
|
1726 |
|
1727 return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i])); |
|
1728 } |
|
1729 |
|
1730 // This is the list of properties we want to copy in the copyInheritableProperties() function. |
|
1731 // It is the intersection of the list of inherited CSS properties and the |
|
1732 // properties for which we have a computed implementation in this file. |
|
1733 const int inheritableProperties[] = { |
|
1734 CSS_PROP_BORDER_COLLAPSE, |
|
1735 CSS_PROP_COLOR, |
|
1736 CSS_PROP_FONT_FAMILY, |
|
1737 CSS_PROP_FONT_SIZE, |
|
1738 CSS_PROP_FONT_STYLE, |
|
1739 CSS_PROP_FONT_VARIANT, |
|
1740 CSS_PROP_FONT_WEIGHT, |
|
1741 CSS_PROP_LETTER_SPACING, |
|
1742 CSS_PROP_LINE_HEIGHT, |
|
1743 CSS_PROP_ORPHANS, |
|
1744 CSS_PROP_TEXT_ALIGN, |
|
1745 CSS_PROP_TEXT_INDENT, |
|
1746 CSS_PROP_TEXT_TRANSFORM, |
|
1747 CSS_PROP_WHITE_SPACE, |
|
1748 CSS_PROP_WIDOWS, |
|
1749 CSS_PROP_WORD_SPACING, |
|
1750 CSS_PROP__WEBKIT_BORDER_HORIZONTAL_SPACING, |
|
1751 CSS_PROP__WEBKIT_BORDER_VERTICAL_SPACING, |
|
1752 CSS_PROP__WEBKIT_TEXT_DECORATIONS_IN_EFFECT, |
|
1753 CSS_PROP__WEBKIT_TEXT_FILL_COLOR, |
|
1754 CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST, |
|
1755 CSS_PROP__WEBKIT_TEXT_STROKE_COLOR, |
|
1756 CSS_PROP__WEBKIT_TEXT_STROKE_WIDTH, |
|
1757 }; |
|
1758 |
|
1759 const unsigned numInheritableProperties = sizeof(inheritableProperties) / sizeof(inheritableProperties[0]); |
|
1760 |
|
1761 void CSSComputedStyleDeclaration::removeComputedInheritablePropertiesFrom(CSSMutableStyleDeclaration* declaration) |
|
1762 { |
|
1763 declaration->removePropertiesInSet(inheritableProperties, numInheritableProperties); |
|
1764 } |
|
1765 |
|
1766 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInheritableProperties() const |
|
1767 { |
|
1768 RefPtr<CSSMutableStyleDeclaration> style = copyPropertiesInSet(inheritableProperties, numInheritableProperties); |
|
1769 if (style && m_node && m_node->computedStyle()) { |
|
1770 // If a node's text fill color is invalid, then its children use |
|
1771 // their font-color as their text fill color (they don't |
|
1772 // inherit it). Likewise for stroke color. |
|
1773 ExceptionCode ec = 0; |
|
1774 if (!m_node->computedStyle()->textFillColor().isValid()) |
|
1775 style->removeProperty(CSS_PROP__WEBKIT_TEXT_FILL_COLOR, ec); |
|
1776 if (!m_node->computedStyle()->textStrokeColor().isValid()) |
|
1777 style->removeProperty(CSS_PROP__WEBKIT_TEXT_STROKE_COLOR, ec); |
|
1778 ASSERT(ec == 0); |
|
1779 } |
|
1780 return style.release(); |
|
1781 } |
|
1782 |
|
1783 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const |
|
1784 { |
|
1785 return copyPropertiesInSet(computedProperties, numComputedProperties); |
|
1786 } |
|
1787 |
|
1788 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable() |
|
1789 { |
|
1790 return copy(); |
|
1791 } |
|
1792 |
|
1793 PassRefPtr<CSSComputedStyleDeclaration> computedStyle(Node* node) |
|
1794 { |
|
1795 return new CSSComputedStyleDeclaration(node); |
|
1796 } |
|
1797 |
|
1798 } // namespace WebCore |