|
1 /* |
|
2 * Copyright (C) 2004 Zack Rusin <zack@kde.org> |
|
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
|
4 * Copyright (C) 2007 Alexey Proskuryakov <ap@webkit.org> |
|
5 * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com> |
|
6 * |
|
7 * This library is free software; you can redistribute it and/or |
|
8 * modify it under the terms of the GNU Lesser General Public |
|
9 * License as published by the Free Software Foundation; either |
|
10 * version 2 of the License, or (at your option) any later version. |
|
11 * |
|
12 * This library is distributed in the hope that it will be useful, |
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
15 * Lesser General Public License for more details. |
|
16 * |
|
17 * You should have received a copy of the GNU Lesser General Public |
|
18 * License along with this library; if not, write to the Free Software |
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 * 02110-1301 USA |
|
21 */ |
|
22 |
|
23 #include "config.h" |
|
24 #include "CSSComputedStyleDeclaration.h" |
|
25 |
|
26 #include "AnimationController.h" |
|
27 #include "CSSBorderImageValue.h" |
|
28 #include "CSSMutableStyleDeclaration.h" |
|
29 #include "CSSPrimitiveValue.h" |
|
30 #include "CSSPrimitiveValueMappings.h" |
|
31 #include "CSSProperty.h" |
|
32 #include "CSSPropertyNames.h" |
|
33 #include "CSSReflectValue.h" |
|
34 #include "CSSSelector.h" |
|
35 #include "CSSTimingFunctionValue.h" |
|
36 #include "CSSValueList.h" |
|
37 #include "Document.h" |
|
38 #include "ExceptionCode.h" |
|
39 #include "Rect.h" |
|
40 #include "RenderBox.h" |
|
41 #include "RenderLayer.h" |
|
42 #include "ShadowValue.h" |
|
43 #include "WebKitCSSTransformValue.h" |
|
44 |
|
45 #if ENABLE(DASHBOARD_SUPPORT) |
|
46 #include "DashboardRegion.h" |
|
47 #endif |
|
48 |
|
49 namespace WebCore { |
|
50 |
|
51 // List of all properties we know how to compute, omitting shorthands. |
|
52 static const int computedProperties[] = { |
|
53 CSSPropertyBackgroundAttachment, |
|
54 CSSPropertyBackgroundClip, |
|
55 CSSPropertyBackgroundColor, |
|
56 CSSPropertyBackgroundImage, |
|
57 CSSPropertyBackgroundOrigin, |
|
58 CSSPropertyBackgroundPosition, // more-specific background-position-x/y are non-standard |
|
59 CSSPropertyBackgroundRepeat, |
|
60 CSSPropertyBackgroundSize, |
|
61 CSSPropertyBorderBottomColor, |
|
62 CSSPropertyBorderBottomLeftRadius, |
|
63 CSSPropertyBorderBottomRightRadius, |
|
64 CSSPropertyBorderBottomStyle, |
|
65 CSSPropertyBorderBottomWidth, |
|
66 CSSPropertyBorderCollapse, |
|
67 CSSPropertyBorderLeftColor, |
|
68 CSSPropertyBorderLeftStyle, |
|
69 CSSPropertyBorderLeftWidth, |
|
70 CSSPropertyBorderRightColor, |
|
71 CSSPropertyBorderRightStyle, |
|
72 CSSPropertyBorderRightWidth, |
|
73 CSSPropertyBorderTopColor, |
|
74 CSSPropertyBorderTopLeftRadius, |
|
75 CSSPropertyBorderTopRightRadius, |
|
76 CSSPropertyBorderTopStyle, |
|
77 CSSPropertyBorderTopWidth, |
|
78 CSSPropertyBottom, |
|
79 CSSPropertyCaptionSide, |
|
80 CSSPropertyClear, |
|
81 CSSPropertyClip, |
|
82 CSSPropertyColor, |
|
83 CSSPropertyCursor, |
|
84 CSSPropertyDirection, |
|
85 CSSPropertyDisplay, |
|
86 CSSPropertyEmptyCells, |
|
87 CSSPropertyFloat, |
|
88 CSSPropertyFontFamily, |
|
89 CSSPropertyFontSize, |
|
90 CSSPropertyFontStyle, |
|
91 CSSPropertyFontVariant, |
|
92 CSSPropertyFontWeight, |
|
93 CSSPropertyHeight, |
|
94 CSSPropertyLeft, |
|
95 CSSPropertyLetterSpacing, |
|
96 CSSPropertyLineHeight, |
|
97 CSSPropertyListStyleImage, |
|
98 CSSPropertyListStylePosition, |
|
99 CSSPropertyListStyleType, |
|
100 CSSPropertyMarginBottom, |
|
101 CSSPropertyMarginLeft, |
|
102 CSSPropertyMarginRight, |
|
103 CSSPropertyMarginTop, |
|
104 CSSPropertyMaxHeight, |
|
105 CSSPropertyMaxWidth, |
|
106 CSSPropertyMinHeight, |
|
107 CSSPropertyMinWidth, |
|
108 CSSPropertyOpacity, |
|
109 CSSPropertyOrphans, |
|
110 CSSPropertyOutlineColor, |
|
111 CSSPropertyOutlineStyle, |
|
112 CSSPropertyOutlineWidth, |
|
113 CSSPropertyOverflowX, |
|
114 CSSPropertyOverflowY, |
|
115 CSSPropertyPaddingBottom, |
|
116 CSSPropertyPaddingLeft, |
|
117 CSSPropertyPaddingRight, |
|
118 CSSPropertyPaddingTop, |
|
119 CSSPropertyPageBreakAfter, |
|
120 CSSPropertyPageBreakBefore, |
|
121 CSSPropertyPageBreakInside, |
|
122 CSSPropertyPointerEvents, |
|
123 CSSPropertyPosition, |
|
124 CSSPropertyResize, |
|
125 CSSPropertyRight, |
|
126 CSSPropertyTableLayout, |
|
127 CSSPropertyTextAlign, |
|
128 CSSPropertyTextDecoration, |
|
129 CSSPropertyTextIndent, |
|
130 CSSPropertyTextRendering, |
|
131 CSSPropertyTextShadow, |
|
132 CSSPropertyTextOverflow, |
|
133 CSSPropertyTextTransform, |
|
134 CSSPropertyTop, |
|
135 CSSPropertyUnicodeBidi, |
|
136 CSSPropertyVerticalAlign, |
|
137 CSSPropertyVisibility, |
|
138 CSSPropertyWhiteSpace, |
|
139 CSSPropertyWidows, |
|
140 CSSPropertyWidth, |
|
141 CSSPropertyWordBreak, |
|
142 CSSPropertyWordSpacing, |
|
143 CSSPropertyWordWrap, |
|
144 CSSPropertyZIndex, |
|
145 CSSPropertyZoom, |
|
146 |
|
147 CSSPropertyWebkitAnimationDelay, |
|
148 CSSPropertyWebkitAnimationDirection, |
|
149 CSSPropertyWebkitAnimationDuration, |
|
150 CSSPropertyWebkitAnimationFillMode, |
|
151 CSSPropertyWebkitAnimationIterationCount, |
|
152 CSSPropertyWebkitAnimationName, |
|
153 CSSPropertyWebkitAnimationPlayState, |
|
154 CSSPropertyWebkitAnimationTimingFunction, |
|
155 CSSPropertyWebkitAppearance, |
|
156 CSSPropertyWebkitBackfaceVisibility, |
|
157 CSSPropertyWebkitBackgroundClip, |
|
158 CSSPropertyWebkitBackgroundComposite, |
|
159 CSSPropertyWebkitBackgroundOrigin, |
|
160 CSSPropertyWebkitBackgroundSize, |
|
161 CSSPropertyWebkitBorderFit, |
|
162 CSSPropertyWebkitBorderHorizontalSpacing, |
|
163 CSSPropertyWebkitBorderImage, |
|
164 CSSPropertyWebkitBorderVerticalSpacing, |
|
165 CSSPropertyWebkitBoxAlign, |
|
166 CSSPropertyWebkitBoxDirection, |
|
167 CSSPropertyWebkitBoxFlex, |
|
168 CSSPropertyWebkitBoxFlexGroup, |
|
169 CSSPropertyWebkitBoxLines, |
|
170 CSSPropertyWebkitBoxOrdinalGroup, |
|
171 CSSPropertyWebkitBoxOrient, |
|
172 CSSPropertyWebkitBoxPack, |
|
173 CSSPropertyWebkitBoxReflect, |
|
174 CSSPropertyWebkitBoxShadow, |
|
175 CSSPropertyWebkitBoxSizing, |
|
176 CSSPropertyWebkitColorCorrection, |
|
177 CSSPropertyWebkitColumnBreakAfter, |
|
178 CSSPropertyWebkitColumnBreakBefore, |
|
179 CSSPropertyWebkitColumnBreakInside, |
|
180 CSSPropertyWebkitColumnCount, |
|
181 CSSPropertyWebkitColumnGap, |
|
182 CSSPropertyWebkitColumnRuleColor, |
|
183 CSSPropertyWebkitColumnRuleStyle, |
|
184 CSSPropertyWebkitColumnRuleWidth, |
|
185 CSSPropertyWebkitColumnSpan, |
|
186 CSSPropertyWebkitColumnWidth, |
|
187 #if ENABLE(DASHBOARD_SUPPORT) |
|
188 CSSPropertyWebkitDashboardRegion, |
|
189 #endif |
|
190 CSSPropertyWebkitFontSmoothing, |
|
191 CSSPropertyWebkitHighlight, |
|
192 CSSPropertyWebkitLineBreak, |
|
193 CSSPropertyWebkitLineClamp, |
|
194 CSSPropertyWebkitMarginBottomCollapse, |
|
195 CSSPropertyWebkitMarginTopCollapse, |
|
196 CSSPropertyWebkitMarqueeDirection, |
|
197 CSSPropertyWebkitMarqueeIncrement, |
|
198 CSSPropertyWebkitMarqueeRepetition, |
|
199 CSSPropertyWebkitMarqueeStyle, |
|
200 CSSPropertyWebkitMaskAttachment, |
|
201 CSSPropertyWebkitMaskBoxImage, |
|
202 CSSPropertyWebkitMaskClip, |
|
203 CSSPropertyWebkitMaskComposite, |
|
204 CSSPropertyWebkitMaskImage, |
|
205 CSSPropertyWebkitMaskOrigin, |
|
206 CSSPropertyWebkitMaskPosition, |
|
207 CSSPropertyWebkitMaskRepeat, |
|
208 CSSPropertyWebkitMaskSize, |
|
209 CSSPropertyWebkitNbspMode, |
|
210 CSSPropertyWebkitPerspective, |
|
211 CSSPropertyWebkitPerspectiveOrigin, |
|
212 CSSPropertyWebkitRtlOrdering, |
|
213 CSSPropertyWebkitTextDecorationsInEffect, |
|
214 CSSPropertyWebkitTextFillColor, |
|
215 CSSPropertyWebkitTextSecurity, |
|
216 CSSPropertyWebkitTextStrokeColor, |
|
217 CSSPropertyWebkitTextStrokeWidth, |
|
218 CSSPropertyWebkitTransform, |
|
219 CSSPropertyWebkitTransformOrigin, |
|
220 CSSPropertyWebkitTransformStyle, |
|
221 CSSPropertyWebkitTransitionDelay, |
|
222 CSSPropertyWebkitTransitionDuration, |
|
223 CSSPropertyWebkitTransitionProperty, |
|
224 CSSPropertyWebkitTransitionTimingFunction, |
|
225 CSSPropertyWebkitUserDrag, |
|
226 CSSPropertyWebkitUserModify, |
|
227 CSSPropertyWebkitUserSelect |
|
228 |
|
229 #if ENABLE(SVG) |
|
230 , |
|
231 CSSPropertyClipPath, |
|
232 CSSPropertyClipRule, |
|
233 CSSPropertyMask, |
|
234 CSSPropertyFilter, |
|
235 CSSPropertyFloodColor, |
|
236 CSSPropertyFloodOpacity, |
|
237 CSSPropertyLightingColor, |
|
238 CSSPropertyStopColor, |
|
239 CSSPropertyStopOpacity, |
|
240 CSSPropertyColorInterpolation, |
|
241 CSSPropertyColorInterpolationFilters, |
|
242 CSSPropertyColorRendering, |
|
243 CSSPropertyFill, |
|
244 CSSPropertyFillOpacity, |
|
245 CSSPropertyFillRule, |
|
246 CSSPropertyImageRendering, |
|
247 CSSPropertyMarkerEnd, |
|
248 CSSPropertyMarkerMid, |
|
249 CSSPropertyMarkerStart, |
|
250 CSSPropertyShapeRendering, |
|
251 CSSPropertyStroke, |
|
252 CSSPropertyStrokeDasharray, |
|
253 CSSPropertyStrokeDashoffset, |
|
254 CSSPropertyStrokeLinecap, |
|
255 CSSPropertyStrokeLinejoin, |
|
256 CSSPropertyStrokeMiterlimit, |
|
257 CSSPropertyStrokeOpacity, |
|
258 CSSPropertyStrokeWidth, |
|
259 CSSPropertyAlignmentBaseline, |
|
260 CSSPropertyBaselineShift, |
|
261 CSSPropertyDominantBaseline, |
|
262 CSSPropertyKerning, |
|
263 CSSPropertyTextAnchor, |
|
264 CSSPropertyWritingMode, |
|
265 CSSPropertyGlyphOrientationHorizontal, |
|
266 CSSPropertyGlyphOrientationVertical, |
|
267 CSSPropertyWebkitSvgShadow, |
|
268 CSSPropertyVectorEffect |
|
269 #endif |
|
270 }; |
|
271 |
|
272 const unsigned numComputedProperties = sizeof(computedProperties) / sizeof(computedProperties[0]); |
|
273 |
|
274 static int valueForRepeatRule(int rule) |
|
275 { |
|
276 switch (rule) { |
|
277 case RepeatImageRule: |
|
278 return CSSValueRepeat; |
|
279 case RoundImageRule: |
|
280 return CSSValueRound; |
|
281 default: |
|
282 return CSSValueStretch; |
|
283 } |
|
284 } |
|
285 |
|
286 static PassRefPtr<CSSValue> valueForNinePieceImage(const NinePieceImage& image) |
|
287 { |
|
288 if (!image.hasImage()) |
|
289 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
290 |
|
291 // Image first. |
|
292 RefPtr<CSSValue> imageValue; |
|
293 if (image.image()) |
|
294 imageValue = image.image()->cssValue(); |
|
295 |
|
296 // Create the slices. |
|
297 RefPtr<CSSPrimitiveValue> top; |
|
298 if (image.slices().top().isPercent()) |
|
299 top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
300 else |
|
301 top = CSSPrimitiveValue::create(image.slices().top().value(), CSSPrimitiveValue::CSS_NUMBER); |
|
302 |
|
303 RefPtr<CSSPrimitiveValue> right; |
|
304 if (image.slices().right().isPercent()) |
|
305 right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
306 else |
|
307 right = CSSPrimitiveValue::create(image.slices().right().value(), CSSPrimitiveValue::CSS_NUMBER); |
|
308 |
|
309 RefPtr<CSSPrimitiveValue> bottom; |
|
310 if (image.slices().bottom().isPercent()) |
|
311 bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
312 else |
|
313 bottom = CSSPrimitiveValue::create(image.slices().bottom().value(), CSSPrimitiveValue::CSS_NUMBER); |
|
314 |
|
315 RefPtr<CSSPrimitiveValue> left; |
|
316 if (image.slices().left().isPercent()) |
|
317 left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
318 else |
|
319 left = CSSPrimitiveValue::create(image.slices().left().value(), CSSPrimitiveValue::CSS_NUMBER); |
|
320 |
|
321 RefPtr<Rect> rect = Rect::create(); |
|
322 rect->setTop(top); |
|
323 rect->setRight(right); |
|
324 rect->setBottom(bottom); |
|
325 rect->setLeft(left); |
|
326 |
|
327 return CSSBorderImageValue::create(imageValue, rect, valueForRepeatRule(image.horizontalRule()), valueForRepeatRule(image.verticalRule())); |
|
328 } |
|
329 |
|
330 static PassRefPtr<CSSValue> valueForReflection(const StyleReflection* reflection) |
|
331 { |
|
332 if (!reflection) |
|
333 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
334 |
|
335 RefPtr<CSSPrimitiveValue> offset; |
|
336 if (reflection->offset().isPercent()) |
|
337 offset = CSSPrimitiveValue::create(reflection->offset().percent(), CSSPrimitiveValue::CSS_PERCENTAGE); |
|
338 else |
|
339 offset = CSSPrimitiveValue::create(reflection->offset().value(), CSSPrimitiveValue::CSS_PX); |
|
340 |
|
341 return CSSReflectValue::create(reflection->direction(), offset.release(), valueForNinePieceImage(reflection->mask())); |
|
342 } |
|
343 |
|
344 static PassRefPtr<CSSValue> getPositionOffsetValue(RenderStyle* style, int propertyID) |
|
345 { |
|
346 if (!style) |
|
347 return 0; |
|
348 |
|
349 Length l; |
|
350 switch (propertyID) { |
|
351 case CSSPropertyLeft: |
|
352 l = style->left(); |
|
353 break; |
|
354 case CSSPropertyRight: |
|
355 l = style->right(); |
|
356 break; |
|
357 case CSSPropertyTop: |
|
358 l = style->top(); |
|
359 break; |
|
360 case CSSPropertyBottom: |
|
361 l = style->bottom(); |
|
362 break; |
|
363 default: |
|
364 return 0; |
|
365 } |
|
366 |
|
367 if (style->position() == AbsolutePosition || style->position() == FixedPosition) |
|
368 return CSSPrimitiveValue::create(l); |
|
369 |
|
370 if (style->position() == RelativePosition) |
|
371 // FIXME: It's not enough to simply return "auto" values for one offset if the other side is defined. |
|
372 // In other words if left is auto and right is not auto, then left's computed value is negative right(). |
|
373 // So we should get the opposite length unit and see if it is auto. |
|
374 return CSSPrimitiveValue::create(l); |
|
375 |
|
376 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
377 } |
|
378 |
|
379 PassRefPtr<CSSPrimitiveValue> CSSComputedStyleDeclaration::currentColorOrValidColor(RenderStyle* style, const Color& color) const |
|
380 { |
|
381 // This function does NOT look at visited information, so that computed style doesn't expose that. |
|
382 if (!color.isValid()) |
|
383 return CSSPrimitiveValue::createColor(style->color().rgb()); |
|
384 return CSSPrimitiveValue::createColor(color.rgb()); |
|
385 } |
|
386 |
|
387 static PassRefPtr<CSSValue> getBorderRadiusCornerValue(IntSize radius) |
|
388 { |
|
389 if (radius.width() == radius.height()) |
|
390 return CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX); |
|
391 |
|
392 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
393 list->append(CSSPrimitiveValue::create(radius.width(), CSSPrimitiveValue::CSS_PX)); |
|
394 list->append(CSSPrimitiveValue::create(radius.height(), CSSPrimitiveValue::CSS_PX)); |
|
395 return list.release(); |
|
396 } |
|
397 |
|
398 static IntRect sizingBox(RenderObject* renderer) |
|
399 { |
|
400 if (!renderer->isBox()) |
|
401 return IntRect(); |
|
402 |
|
403 RenderBox* box = toRenderBox(renderer); |
|
404 return box->style()->boxSizing() == CONTENT_BOX ? box->contentBoxRect() : box->borderBoxRect(); |
|
405 } |
|
406 |
|
407 static inline bool hasCompositedLayer(RenderObject* renderer) |
|
408 { |
|
409 return renderer && renderer->hasLayer() && toRenderBoxModelObject(renderer)->layer()->isComposited(); |
|
410 } |
|
411 |
|
412 static PassRefPtr<CSSValue> computedTransform(RenderObject* renderer, const RenderStyle* style) |
|
413 { |
|
414 if (!renderer || style->transform().operations().isEmpty()) |
|
415 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
416 |
|
417 IntRect box = sizingBox(renderer); |
|
418 |
|
419 TransformationMatrix transform; |
|
420 style->applyTransform(transform, box.size(), RenderStyle::ExcludeTransformOrigin); |
|
421 // Note that this does not flatten to an affine transform if ENABLE(3D_RENDERING) is off, by design. |
|
422 |
|
423 RefPtr<WebKitCSSTransformValue> transformVal; |
|
424 |
|
425 // FIXME: Need to print out individual functions (https://bugs.webkit.org/show_bug.cgi?id=23924) |
|
426 if (transform.isAffine()) { |
|
427 transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::MatrixTransformOperation); |
|
428 |
|
429 transformVal->append(CSSPrimitiveValue::create(transform.a(), CSSPrimitiveValue::CSS_NUMBER)); |
|
430 transformVal->append(CSSPrimitiveValue::create(transform.b(), CSSPrimitiveValue::CSS_NUMBER)); |
|
431 transformVal->append(CSSPrimitiveValue::create(transform.c(), CSSPrimitiveValue::CSS_NUMBER)); |
|
432 transformVal->append(CSSPrimitiveValue::create(transform.d(), CSSPrimitiveValue::CSS_NUMBER)); |
|
433 transformVal->append(CSSPrimitiveValue::create(transform.e(), CSSPrimitiveValue::CSS_NUMBER)); |
|
434 transformVal->append(CSSPrimitiveValue::create(transform.f(), CSSPrimitiveValue::CSS_NUMBER)); |
|
435 } else { |
|
436 transformVal = WebKitCSSTransformValue::create(WebKitCSSTransformValue::Matrix3DTransformOperation); |
|
437 |
|
438 transformVal->append(CSSPrimitiveValue::create(transform.m11(), CSSPrimitiveValue::CSS_NUMBER)); |
|
439 transformVal->append(CSSPrimitiveValue::create(transform.m12(), CSSPrimitiveValue::CSS_NUMBER)); |
|
440 transformVal->append(CSSPrimitiveValue::create(transform.m13(), CSSPrimitiveValue::CSS_NUMBER)); |
|
441 transformVal->append(CSSPrimitiveValue::create(transform.m14(), CSSPrimitiveValue::CSS_NUMBER)); |
|
442 |
|
443 transformVal->append(CSSPrimitiveValue::create(transform.m21(), CSSPrimitiveValue::CSS_NUMBER)); |
|
444 transformVal->append(CSSPrimitiveValue::create(transform.m22(), CSSPrimitiveValue::CSS_NUMBER)); |
|
445 transformVal->append(CSSPrimitiveValue::create(transform.m23(), CSSPrimitiveValue::CSS_NUMBER)); |
|
446 transformVal->append(CSSPrimitiveValue::create(transform.m24(), CSSPrimitiveValue::CSS_NUMBER)); |
|
447 |
|
448 transformVal->append(CSSPrimitiveValue::create(transform.m31(), CSSPrimitiveValue::CSS_NUMBER)); |
|
449 transformVal->append(CSSPrimitiveValue::create(transform.m32(), CSSPrimitiveValue::CSS_NUMBER)); |
|
450 transformVal->append(CSSPrimitiveValue::create(transform.m33(), CSSPrimitiveValue::CSS_NUMBER)); |
|
451 transformVal->append(CSSPrimitiveValue::create(transform.m34(), CSSPrimitiveValue::CSS_NUMBER)); |
|
452 |
|
453 transformVal->append(CSSPrimitiveValue::create(transform.m41(), CSSPrimitiveValue::CSS_NUMBER)); |
|
454 transformVal->append(CSSPrimitiveValue::create(transform.m42(), CSSPrimitiveValue::CSS_NUMBER)); |
|
455 transformVal->append(CSSPrimitiveValue::create(transform.m43(), CSSPrimitiveValue::CSS_NUMBER)); |
|
456 transformVal->append(CSSPrimitiveValue::create(transform.m44(), CSSPrimitiveValue::CSS_NUMBER)); |
|
457 } |
|
458 |
|
459 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
460 list->append(transformVal); |
|
461 |
|
462 return list.release(); |
|
463 } |
|
464 |
|
465 static PassRefPtr<CSSValue> getDelayValue(const AnimationList* animList) |
|
466 { |
|
467 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
468 if (animList) { |
|
469 for (size_t i = 0; i < animList->size(); ++i) |
|
470 list->append(CSSPrimitiveValue::create(animList->animation(i)->delay(), CSSPrimitiveValue::CSS_S)); |
|
471 } else { |
|
472 // Note that initialAnimationDelay() is used for both transitions and animations |
|
473 list->append(CSSPrimitiveValue::create(Animation::initialAnimationDelay(), CSSPrimitiveValue::CSS_S)); |
|
474 } |
|
475 return list.release(); |
|
476 } |
|
477 |
|
478 static PassRefPtr<CSSValue> getDurationValue(const AnimationList* animList) |
|
479 { |
|
480 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
481 if (animList) { |
|
482 for (size_t i = 0; i < animList->size(); ++i) |
|
483 list->append(CSSPrimitiveValue::create(animList->animation(i)->duration(), CSSPrimitiveValue::CSS_S)); |
|
484 } else { |
|
485 // Note that initialAnimationDuration() is used for both transitions and animations |
|
486 list->append(CSSPrimitiveValue::create(Animation::initialAnimationDuration(), CSSPrimitiveValue::CSS_S)); |
|
487 } |
|
488 return list.release(); |
|
489 } |
|
490 |
|
491 static PassRefPtr<CSSValue> getTimingFunctionValue(const AnimationList* animList) |
|
492 { |
|
493 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
494 if (animList) { |
|
495 for (size_t i = 0; i < animList->size(); ++i) { |
|
496 const TimingFunction& tf = animList->animation(i)->timingFunction(); |
|
497 list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2())); |
|
498 } |
|
499 } else { |
|
500 // Note that initialAnimationTimingFunction() is used for both transitions and animations |
|
501 const TimingFunction& tf = Animation::initialAnimationTimingFunction(); |
|
502 list->append(CSSTimingFunctionValue::create(tf.x1(), tf.y1(), tf.x2(), tf.y2())); |
|
503 } |
|
504 return list.release(); |
|
505 } |
|
506 |
|
507 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(PassRefPtr<Node> n, bool allowVisitedStyle, const String& pseudoElementName) |
|
508 : m_node(n) |
|
509 , m_allowVisitedStyle(allowVisitedStyle) |
|
510 { |
|
511 unsigned nameWithoutColonsStart = pseudoElementName[0] == ':' ? (pseudoElementName[1] == ':' ? 2 : 1) : 0; |
|
512 m_pseudoElementSpecifier = CSSSelector::pseudoId(CSSSelector::parsePseudoType( |
|
513 AtomicString(pseudoElementName.substring(nameWithoutColonsStart)))); |
|
514 } |
|
515 |
|
516 CSSComputedStyleDeclaration::~CSSComputedStyleDeclaration() |
|
517 { |
|
518 } |
|
519 |
|
520 String CSSComputedStyleDeclaration::cssText() const |
|
521 { |
|
522 String result(""); |
|
523 |
|
524 for (unsigned i = 0; i < numComputedProperties; i++) { |
|
525 if (i) |
|
526 result += " "; |
|
527 result += getPropertyName(static_cast<CSSPropertyID>(computedProperties[i])); |
|
528 result += ": "; |
|
529 result += getPropertyValue(computedProperties[i]); |
|
530 result += ";"; |
|
531 } |
|
532 |
|
533 return result; |
|
534 } |
|
535 |
|
536 void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec) |
|
537 { |
|
538 ec = NO_MODIFICATION_ALLOWED_ERR; |
|
539 } |
|
540 |
|
541 static int cssIdentifierForFontSizeKeyword(int keywordSize) |
|
542 { |
|
543 ASSERT_ARG(keywordSize, keywordSize); |
|
544 ASSERT_ARG(keywordSize, keywordSize <= 8); |
|
545 return CSSValueXxSmall + keywordSize - 1; |
|
546 } |
|
547 |
|
548 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const |
|
549 { |
|
550 Node* node = m_node.get(); |
|
551 if (!node) |
|
552 return 0; |
|
553 |
|
554 node->document()->updateLayoutIgnorePendingStylesheets(); |
|
555 |
|
556 RefPtr<RenderStyle> style = node->computedStyle(m_pseudoElementSpecifier); |
|
557 if (!style) |
|
558 return 0; |
|
559 |
|
560 if (int keywordSize = style->fontDescription().keywordSize()) |
|
561 return CSSPrimitiveValue::createIdentifier(cssIdentifierForFontSizeKeyword(keywordSize)); |
|
562 |
|
563 return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); |
|
564 } |
|
565 |
|
566 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::valueForShadow(const ShadowData* shadow, int id) const |
|
567 { |
|
568 if (!shadow) |
|
569 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
570 |
|
571 CSSPropertyID propertyID = static_cast<CSSPropertyID>(id); |
|
572 |
|
573 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
574 for (const ShadowData* s = shadow; s; s = s->next()) { |
|
575 RefPtr<CSSPrimitiveValue> x = CSSPrimitiveValue::create(s->x(), CSSPrimitiveValue::CSS_PX); |
|
576 RefPtr<CSSPrimitiveValue> y = CSSPrimitiveValue::create(s->y(), CSSPrimitiveValue::CSS_PX); |
|
577 RefPtr<CSSPrimitiveValue> blur = CSSPrimitiveValue::create(s->blur(), CSSPrimitiveValue::CSS_PX); |
|
578 RefPtr<CSSPrimitiveValue> spread = propertyID == CSSPropertyTextShadow ? 0 : CSSPrimitiveValue::create(s->spread(), CSSPrimitiveValue::CSS_PX); |
|
579 RefPtr<CSSPrimitiveValue> style = propertyID == CSSPropertyTextShadow || s->style() == Normal ? 0 : CSSPrimitiveValue::createIdentifier(CSSValueInset); |
|
580 RefPtr<CSSPrimitiveValue> color = CSSPrimitiveValue::createColor(s->color().rgb()); |
|
581 list->prepend(ShadowValue::create(x.release(), y.release(), blur.release(), spread.release(), style.release(), color.release())); |
|
582 } |
|
583 return list.release(); |
|
584 } |
|
585 |
|
586 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const |
|
587 { |
|
588 return getPropertyCSSValue(propertyID, UpdateLayout); |
|
589 } |
|
590 |
|
591 static int identifierForFamily(const AtomicString& family) |
|
592 { |
|
593 DEFINE_STATIC_LOCAL(AtomicString, cursiveFamily, ("-webkit-cursive")); |
|
594 DEFINE_STATIC_LOCAL(AtomicString, fantasyFamily, ("-webkit-fantasy")); |
|
595 DEFINE_STATIC_LOCAL(AtomicString, monospaceFamily, ("-webkit-monospace")); |
|
596 DEFINE_STATIC_LOCAL(AtomicString, sansSerifFamily, ("-webkit-sans-serif")); |
|
597 DEFINE_STATIC_LOCAL(AtomicString, serifFamily, ("-webkit-serif")); |
|
598 if (family == cursiveFamily) |
|
599 return CSSValueCursive; |
|
600 if (family == fantasyFamily) |
|
601 return CSSValueFantasy; |
|
602 if (family == monospaceFamily) |
|
603 return CSSValueMonospace; |
|
604 if (family == sansSerifFamily) |
|
605 return CSSValueSansSerif; |
|
606 if (family == serifFamily) |
|
607 return CSSValueSerif; |
|
608 return 0; |
|
609 } |
|
610 |
|
611 static PassRefPtr<CSSPrimitiveValue> valueForFamily(const AtomicString& family) |
|
612 { |
|
613 if (int familyIdentifier = identifierForFamily(family)) |
|
614 return CSSPrimitiveValue::createIdentifier(familyIdentifier); |
|
615 return CSSPrimitiveValue::create(family.string(), CSSPrimitiveValue::CSS_STRING); |
|
616 } |
|
617 |
|
618 static PassRefPtr<CSSValue> renderTextDecorationFlagsToCSSValue(int textDecoration) |
|
619 { |
|
620 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
621 if (textDecoration & UNDERLINE) |
|
622 list->append(CSSPrimitiveValue::createIdentifier(CSSValueUnderline)); |
|
623 if (textDecoration & OVERLINE) |
|
624 list->append(CSSPrimitiveValue::createIdentifier(CSSValueOverline)); |
|
625 if (textDecoration & LINE_THROUGH) |
|
626 list->append(CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)); |
|
627 if (textDecoration & BLINK) |
|
628 list->append(CSSPrimitiveValue::createIdentifier(CSSValueBlink)); |
|
629 |
|
630 if (!list->length()) |
|
631 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
632 return list; |
|
633 } |
|
634 |
|
635 static PassRefPtr<CSSValue> fillRepeatToCSSValue(EFillRepeat xRepeat, EFillRepeat yRepeat) |
|
636 { |
|
637 // For backwards compatibility, if both values are equal, just return one of them. And |
|
638 // if the two values are equivalent to repeat-x or repeat-y, just return the shorthand. |
|
639 if (xRepeat == yRepeat) |
|
640 return CSSPrimitiveValue::create(xRepeat); |
|
641 if (xRepeat == RepeatFill && yRepeat == NoRepeatFill) |
|
642 return CSSPrimitiveValue::createIdentifier(CSSValueRepeatX); |
|
643 if (xRepeat == NoRepeatFill && yRepeat == RepeatFill) |
|
644 return CSSPrimitiveValue::createIdentifier(CSSValueRepeatY); |
|
645 |
|
646 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
647 list->append(CSSPrimitiveValue::create(xRepeat)); |
|
648 list->append(CSSPrimitiveValue::create(yRepeat)); |
|
649 return list.release(); |
|
650 } |
|
651 |
|
652 static void logUnimplementedPropertyID(int propertyID) |
|
653 { |
|
654 DEFINE_STATIC_LOCAL(HashSet<int>, propertyIDSet, ()); |
|
655 if (!propertyIDSet.add(propertyID).second) |
|
656 return; |
|
657 |
|
658 LOG_ERROR("WebKit does not yet implement getComputedStyle for '%s'.", getPropertyName(static_cast<CSSPropertyID>(propertyID))); |
|
659 } |
|
660 |
|
661 PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const |
|
662 { |
|
663 Node* node = m_node.get(); |
|
664 if (!node) |
|
665 return 0; |
|
666 |
|
667 // Make sure our layout is up to date before we allow a query on these attributes. |
|
668 if (updateLayout) |
|
669 node->document()->updateLayoutIgnorePendingStylesheets(); |
|
670 |
|
671 RenderObject* renderer = node->renderer(); |
|
672 |
|
673 RefPtr<RenderStyle> style; |
|
674 if (renderer && hasCompositedLayer(renderer) && AnimationController::supportsAcceleratedAnimationOfProperty(static_cast<CSSPropertyID>(propertyID))) { |
|
675 style = renderer->animation()->getAnimatedStyleForRenderer(renderer); |
|
676 if (m_pseudoElementSpecifier) { |
|
677 // FIXME: This cached pseudo style will only exist if the animation has been run at least once. |
|
678 style = style->getCachedPseudoStyle(m_pseudoElementSpecifier); |
|
679 } |
|
680 } else |
|
681 style = node->computedStyle(m_pseudoElementSpecifier); |
|
682 |
|
683 if (!style) |
|
684 return 0; |
|
685 |
|
686 propertyID = CSSProperty::resolveDirectionAwareProperty(propertyID, style->direction()); |
|
687 |
|
688 switch (static_cast<CSSPropertyID>(propertyID)) { |
|
689 case CSSPropertyInvalid: |
|
690 break; |
|
691 |
|
692 case CSSPropertyBackgroundColor: |
|
693 return CSSPrimitiveValue::createColor(m_allowVisitedStyle? style->visitedDependentColor(CSSPropertyBackgroundColor).rgb() : style->backgroundColor().rgb()); |
|
694 case CSSPropertyBackgroundImage: |
|
695 if (style->backgroundImage()) |
|
696 return style->backgroundImage()->cssValue(); |
|
697 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
698 case CSSPropertyBackgroundSize: |
|
699 case CSSPropertyWebkitBackgroundSize: { |
|
700 EFillSizeType size = style->backgroundSizeType(); |
|
701 if (size == Contain) |
|
702 return CSSPrimitiveValue::createIdentifier(CSSValueContain); |
|
703 if (size == Cover) |
|
704 return CSSPrimitiveValue::createIdentifier(CSSValueCover); |
|
705 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
706 list->append(CSSPrimitiveValue::create(style->backgroundSizeLength().width())); |
|
707 list->append(CSSPrimitiveValue::create(style->backgroundSizeLength().height())); |
|
708 return list.release(); |
|
709 } |
|
710 case CSSPropertyBackgroundRepeat: |
|
711 return fillRepeatToCSSValue(style->backgroundRepeatX(), style->backgroundRepeatY()); |
|
712 case CSSPropertyWebkitBackgroundComposite: |
|
713 return CSSPrimitiveValue::create(style->backgroundComposite()); |
|
714 case CSSPropertyBackgroundAttachment: |
|
715 return CSSPrimitiveValue::create(style->backgroundAttachment()); |
|
716 case CSSPropertyBackgroundClip: |
|
717 case CSSPropertyBackgroundOrigin: |
|
718 case CSSPropertyWebkitBackgroundClip: |
|
719 case CSSPropertyWebkitBackgroundOrigin: { |
|
720 EFillBox box = (propertyID == CSSPropertyWebkitBackgroundClip || propertyID == CSSPropertyBackgroundClip) ? style->backgroundClip() : style->backgroundOrigin(); |
|
721 return CSSPrimitiveValue::create(box); |
|
722 } |
|
723 case CSSPropertyBackgroundPosition: { |
|
724 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
725 |
|
726 list->append(CSSPrimitiveValue::create(style->backgroundXPosition())); |
|
727 list->append(CSSPrimitiveValue::create(style->backgroundYPosition())); |
|
728 |
|
729 return list.release(); |
|
730 } |
|
731 case CSSPropertyBackgroundPositionX: |
|
732 return CSSPrimitiveValue::create(style->backgroundXPosition()); |
|
733 case CSSPropertyBackgroundPositionY: |
|
734 return CSSPrimitiveValue::create(style->backgroundYPosition()); |
|
735 case CSSPropertyBorderCollapse: |
|
736 if (style->borderCollapse()) |
|
737 return CSSPrimitiveValue::createIdentifier(CSSValueCollapse); |
|
738 return CSSPrimitiveValue::createIdentifier(CSSValueSeparate); |
|
739 case CSSPropertyBorderSpacing: { |
|
740 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
741 list->append(CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); |
|
742 list->append(CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX)); |
|
743 return list.release(); |
|
744 } |
|
745 case CSSPropertyWebkitBorderHorizontalSpacing: |
|
746 return CSSPrimitiveValue::create(style->horizontalBorderSpacing(), CSSPrimitiveValue::CSS_PX); |
|
747 case CSSPropertyWebkitBorderVerticalSpacing: |
|
748 return CSSPrimitiveValue::create(style->verticalBorderSpacing(), CSSPrimitiveValue::CSS_PX); |
|
749 case CSSPropertyBorderTopColor: |
|
750 return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderTopColor).rgb()) : currentColorOrValidColor(style.get(), style->borderTopColor()); |
|
751 case CSSPropertyBorderRightColor: |
|
752 return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderRightColor).rgb()) : currentColorOrValidColor(style.get(), style->borderRightColor()); |
|
753 case CSSPropertyBorderBottomColor: |
|
754 return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderBottomColor).rgb()) : currentColorOrValidColor(style.get(), style->borderBottomColor()); |
|
755 case CSSPropertyBorderLeftColor: |
|
756 return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyBorderLeftColor).rgb()) : currentColorOrValidColor(style.get(), style->borderLeftColor()); |
|
757 case CSSPropertyBorderTopStyle: |
|
758 return CSSPrimitiveValue::create(style->borderTopStyle()); |
|
759 case CSSPropertyBorderRightStyle: |
|
760 return CSSPrimitiveValue::create(style->borderRightStyle()); |
|
761 case CSSPropertyBorderBottomStyle: |
|
762 return CSSPrimitiveValue::create(style->borderBottomStyle()); |
|
763 case CSSPropertyBorderLeftStyle: |
|
764 return CSSPrimitiveValue::create(style->borderLeftStyle()); |
|
765 case CSSPropertyBorderTopWidth: |
|
766 return CSSPrimitiveValue::create(style->borderTopWidth(), CSSPrimitiveValue::CSS_PX); |
|
767 case CSSPropertyBorderRightWidth: |
|
768 return CSSPrimitiveValue::create(style->borderRightWidth(), CSSPrimitiveValue::CSS_PX); |
|
769 case CSSPropertyBorderBottomWidth: |
|
770 return CSSPrimitiveValue::create(style->borderBottomWidth(), CSSPrimitiveValue::CSS_PX); |
|
771 case CSSPropertyBorderLeftWidth: |
|
772 return CSSPrimitiveValue::create(style->borderLeftWidth(), CSSPrimitiveValue::CSS_PX); |
|
773 case CSSPropertyBottom: |
|
774 return getPositionOffsetValue(style.get(), CSSPropertyBottom); |
|
775 case CSSPropertyWebkitBoxAlign: |
|
776 return CSSPrimitiveValue::create(style->boxAlign()); |
|
777 case CSSPropertyWebkitBoxDirection: |
|
778 return CSSPrimitiveValue::create(style->boxDirection()); |
|
779 case CSSPropertyWebkitBoxFlex: |
|
780 return CSSPrimitiveValue::create(style->boxFlex(), CSSPrimitiveValue::CSS_NUMBER); |
|
781 case CSSPropertyWebkitBoxFlexGroup: |
|
782 return CSSPrimitiveValue::create(style->boxFlexGroup(), CSSPrimitiveValue::CSS_NUMBER); |
|
783 case CSSPropertyWebkitBoxLines: |
|
784 return CSSPrimitiveValue::create(style->boxLines()); |
|
785 case CSSPropertyWebkitBoxOrdinalGroup: |
|
786 return CSSPrimitiveValue::create(style->boxOrdinalGroup(), CSSPrimitiveValue::CSS_NUMBER); |
|
787 case CSSPropertyWebkitBoxOrient: |
|
788 return CSSPrimitiveValue::create(style->boxOrient()); |
|
789 case CSSPropertyWebkitBoxPack: { |
|
790 EBoxAlignment boxPack = style->boxPack(); |
|
791 ASSERT(boxPack != BSTRETCH); |
|
792 ASSERT(boxPack != BBASELINE); |
|
793 if (boxPack == BJUSTIFY || boxPack== BBASELINE) |
|
794 return 0; |
|
795 return CSSPrimitiveValue::create(boxPack); |
|
796 } |
|
797 case CSSPropertyWebkitBoxReflect: |
|
798 return valueForReflection(style->boxReflect()); |
|
799 case CSSPropertyWebkitBoxShadow: |
|
800 return valueForShadow(style->boxShadow(), propertyID); |
|
801 case CSSPropertyCaptionSide: |
|
802 return CSSPrimitiveValue::create(style->captionSide()); |
|
803 case CSSPropertyClear: |
|
804 return CSSPrimitiveValue::create(style->clear()); |
|
805 case CSSPropertyColor: |
|
806 return CSSPrimitiveValue::createColor(m_allowVisitedStyle ? style->visitedDependentColor(CSSPropertyColor).rgb() : style->color().rgb()); |
|
807 case CSSPropertyWebkitColumnCount: |
|
808 if (style->hasAutoColumnCount()) |
|
809 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
810 return CSSPrimitiveValue::create(style->columnCount(), CSSPrimitiveValue::CSS_NUMBER); |
|
811 case CSSPropertyWebkitColumnGap: |
|
812 if (style->hasNormalColumnGap()) |
|
813 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
814 return CSSPrimitiveValue::create(style->columnGap(), CSSPrimitiveValue::CSS_NUMBER); |
|
815 case CSSPropertyWebkitColumnRuleColor: |
|
816 return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->columnRuleColor()); |
|
817 case CSSPropertyWebkitColumnRuleStyle: |
|
818 return CSSPrimitiveValue::create(style->columnRuleStyle()); |
|
819 case CSSPropertyWebkitColumnRuleWidth: |
|
820 return CSSPrimitiveValue::create(style->columnRuleWidth(), CSSPrimitiveValue::CSS_PX); |
|
821 case CSSPropertyWebkitColumnSpan: |
|
822 if (style->columnSpan()) |
|
823 return CSSPrimitiveValue::createIdentifier(CSSValueAll); |
|
824 return CSSPrimitiveValue::create(1, CSSPrimitiveValue::CSS_NUMBER); |
|
825 case CSSPropertyWebkitColumnBreakAfter: |
|
826 return CSSPrimitiveValue::create(style->columnBreakAfter()); |
|
827 case CSSPropertyWebkitColumnBreakBefore: |
|
828 return CSSPrimitiveValue::create(style->columnBreakBefore()); |
|
829 case CSSPropertyWebkitColumnBreakInside: |
|
830 return CSSPrimitiveValue::create(style->columnBreakInside()); |
|
831 case CSSPropertyWebkitColumnWidth: |
|
832 if (style->hasAutoColumnWidth()) |
|
833 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
834 return CSSPrimitiveValue::create(style->columnWidth(), CSSPrimitiveValue::CSS_NUMBER); |
|
835 case CSSPropertyCursor: { |
|
836 RefPtr<CSSValueList> list; |
|
837 CursorList* cursors = style->cursors(); |
|
838 if (cursors && cursors->size() > 0) { |
|
839 list = CSSValueList::createCommaSeparated(); |
|
840 for (unsigned i = 0; i < cursors->size(); ++i) |
|
841 list->append(CSSPrimitiveValue::create((*cursors)[i].image()->url(), CSSPrimitiveValue::CSS_URI)); |
|
842 } |
|
843 RefPtr<CSSValue> value = CSSPrimitiveValue::create(style->cursor()); |
|
844 if (list) { |
|
845 list->append(value); |
|
846 return list.release(); |
|
847 } |
|
848 return value.release(); |
|
849 } |
|
850 case CSSPropertyDirection: |
|
851 return CSSPrimitiveValue::create(style->direction()); |
|
852 case CSSPropertyDisplay: |
|
853 return CSSPrimitiveValue::create(style->display()); |
|
854 case CSSPropertyEmptyCells: |
|
855 return CSSPrimitiveValue::create(style->emptyCells()); |
|
856 case CSSPropertyFloat: |
|
857 return CSSPrimitiveValue::create(style->floating()); |
|
858 case CSSPropertyFontFamily: { |
|
859 const FontFamily& firstFamily = style->fontDescription().family(); |
|
860 if (!firstFamily.next()) |
|
861 return valueForFamily(firstFamily.family()); |
|
862 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
863 for (const FontFamily* family = &firstFamily; family; family = family->next()) |
|
864 list->append(valueForFamily(family->family())); |
|
865 return list.release(); |
|
866 } |
|
867 case CSSPropertyFontSize: |
|
868 return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX); |
|
869 case CSSPropertyWebkitBinding: |
|
870 break; |
|
871 case CSSPropertyFontStyle: |
|
872 if (style->fontDescription().italic()) |
|
873 return CSSPrimitiveValue::createIdentifier(CSSValueItalic); |
|
874 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
875 case CSSPropertyFontVariant: |
|
876 if (style->fontDescription().smallCaps()) |
|
877 return CSSPrimitiveValue::createIdentifier(CSSValueSmallCaps); |
|
878 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
879 case CSSPropertyFontWeight: |
|
880 switch (style->fontDescription().weight()) { |
|
881 case FontWeight100: |
|
882 return CSSPrimitiveValue::createIdentifier(CSSValue100); |
|
883 case FontWeight200: |
|
884 return CSSPrimitiveValue::createIdentifier(CSSValue200); |
|
885 case FontWeight300: |
|
886 return CSSPrimitiveValue::createIdentifier(CSSValue300); |
|
887 case FontWeightNormal: |
|
888 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
889 case FontWeight500: |
|
890 return CSSPrimitiveValue::createIdentifier(CSSValue500); |
|
891 case FontWeight600: |
|
892 return CSSPrimitiveValue::createIdentifier(CSSValue600); |
|
893 case FontWeightBold: |
|
894 return CSSPrimitiveValue::createIdentifier(CSSValueBold); |
|
895 case FontWeight800: |
|
896 return CSSPrimitiveValue::createIdentifier(CSSValue800); |
|
897 case FontWeight900: |
|
898 return CSSPrimitiveValue::createIdentifier(CSSValue900); |
|
899 } |
|
900 ASSERT_NOT_REACHED(); |
|
901 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
902 case CSSPropertyHeight: |
|
903 if (renderer) |
|
904 return CSSPrimitiveValue::create(sizingBox(renderer).height(), CSSPrimitiveValue::CSS_PX); |
|
905 return CSSPrimitiveValue::create(style->height()); |
|
906 case CSSPropertyWebkitHighlight: |
|
907 if (style->highlight() == nullAtom) |
|
908 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
909 return CSSPrimitiveValue::create(style->highlight(), CSSPrimitiveValue::CSS_STRING); |
|
910 case CSSPropertyWebkitHyphens: |
|
911 return CSSPrimitiveValue::create(style->hyphens()); |
|
912 case CSSPropertyWebkitHyphenateCharacter: |
|
913 if (style->hyphenateCharacter().isNull()) |
|
914 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
915 return CSSPrimitiveValue::create(style->hyphenateCharacter(), CSSPrimitiveValue::CSS_STRING); |
|
916 case CSSPropertyWebkitBorderFit: |
|
917 if (style->borderFit() == BorderFitBorder) |
|
918 return CSSPrimitiveValue::createIdentifier(CSSValueBorder); |
|
919 return CSSPrimitiveValue::createIdentifier(CSSValueLines); |
|
920 case CSSPropertyLeft: |
|
921 return getPositionOffsetValue(style.get(), CSSPropertyLeft); |
|
922 case CSSPropertyLetterSpacing: |
|
923 if (!style->letterSpacing()) |
|
924 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
925 return CSSPrimitiveValue::create(style->letterSpacing(), CSSPrimitiveValue::CSS_PX); |
|
926 case CSSPropertyWebkitLineClamp: |
|
927 if (style->lineClamp().isNone()) |
|
928 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
929 return CSSPrimitiveValue::create(style->lineClamp().value(), style->lineClamp().isPercentage() ? CSSPrimitiveValue::CSS_PERCENTAGE : CSSPrimitiveValue::CSS_NUMBER); |
|
930 case CSSPropertyLineHeight: { |
|
931 Length length = style->lineHeight(); |
|
932 if (length.isNegative()) |
|
933 return CSSPrimitiveValue::createIdentifier(CSSValueNormal); |
|
934 if (length.isPercent()) |
|
935 // This is imperfect, because it doesn't include the zoom factor and the real computation |
|
936 // for how high to be in pixels does include things like minimum font size and the zoom factor. |
|
937 // On the other hand, since font-size doesn't include the zoom factor, we really can't do |
|
938 // that here either. |
|
939 return CSSPrimitiveValue::create(static_cast<int>(length.percent() * style->fontDescription().specifiedSize()) / 100, CSSPrimitiveValue::CSS_PX); |
|
940 return CSSPrimitiveValue::create(length.value(), CSSPrimitiveValue::CSS_PX); |
|
941 } |
|
942 case CSSPropertyListStyleImage: |
|
943 if (style->listStyleImage()) |
|
944 return style->listStyleImage()->cssValue(); |
|
945 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
946 case CSSPropertyListStylePosition: |
|
947 return CSSPrimitiveValue::create(style->listStylePosition()); |
|
948 case CSSPropertyListStyleType: |
|
949 return CSSPrimitiveValue::create(style->listStyleType()); |
|
950 case CSSPropertyMarginTop: |
|
951 if (renderer && renderer->isBox()) |
|
952 // FIXME: Supposed to return the percentage if percentage was specified. |
|
953 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginTop(), CSSPrimitiveValue::CSS_PX); |
|
954 return CSSPrimitiveValue::create(style->marginTop()); |
|
955 case CSSPropertyMarginRight: |
|
956 if (renderer && renderer->isBox()) |
|
957 // FIXME: Supposed to return the percentage if percentage was specified. |
|
958 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginRight(), CSSPrimitiveValue::CSS_PX); |
|
959 return CSSPrimitiveValue::create(style->marginRight()); |
|
960 case CSSPropertyMarginBottom: |
|
961 if (renderer && renderer->isBox()) |
|
962 // FIXME: Supposed to return the percentage if percentage was specified. |
|
963 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginBottom(), CSSPrimitiveValue::CSS_PX); |
|
964 return CSSPrimitiveValue::create(style->marginBottom()); |
|
965 case CSSPropertyMarginLeft: |
|
966 if (renderer && renderer->isBox()) |
|
967 // FIXME: Supposed to return the percentage if percentage was specified. |
|
968 return CSSPrimitiveValue::create(toRenderBox(renderer)->marginLeft(), CSSPrimitiveValue::CSS_PX); |
|
969 return CSSPrimitiveValue::create(style->marginLeft()); |
|
970 case CSSPropertyWebkitMarqueeDirection: |
|
971 return CSSPrimitiveValue::create(style->marqueeDirection()); |
|
972 case CSSPropertyWebkitMarqueeIncrement: |
|
973 return CSSPrimitiveValue::create(style->marqueeIncrement()); |
|
974 case CSSPropertyWebkitMarqueeRepetition: |
|
975 if (style->marqueeLoopCount() < 0) |
|
976 return CSSPrimitiveValue::createIdentifier(CSSValueInfinite); |
|
977 return CSSPrimitiveValue::create(style->marqueeLoopCount(), CSSPrimitiveValue::CSS_NUMBER); |
|
978 case CSSPropertyWebkitMarqueeStyle: |
|
979 return CSSPrimitiveValue::create(style->marqueeBehavior()); |
|
980 case CSSPropertyWebkitMaskImage: |
|
981 if (style->maskImage()) |
|
982 return style->maskImage()->cssValue(); |
|
983 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
984 case CSSPropertyWebkitMaskSize: { |
|
985 EFillSizeType size = style->maskSizeType(); |
|
986 if (size == Contain) |
|
987 return CSSPrimitiveValue::createIdentifier(CSSValueContain); |
|
988 if (size == Cover) |
|
989 return CSSPrimitiveValue::createIdentifier(CSSValueCover); |
|
990 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
991 list->append(CSSPrimitiveValue::create(style->maskSizeLength().width())); |
|
992 list->append(CSSPrimitiveValue::create(style->maskSizeLength().height())); |
|
993 return list.release(); |
|
994 } |
|
995 case CSSPropertyWebkitMaskRepeat: |
|
996 return fillRepeatToCSSValue(style->maskRepeatX(), style->maskRepeatY()); |
|
997 case CSSPropertyWebkitMaskAttachment: |
|
998 return CSSPrimitiveValue::create(style->maskAttachment()); |
|
999 case CSSPropertyWebkitMaskComposite: |
|
1000 return CSSPrimitiveValue::create(style->maskComposite()); |
|
1001 case CSSPropertyWebkitMaskClip: |
|
1002 case CSSPropertyWebkitMaskOrigin: { |
|
1003 EFillBox box = (propertyID == CSSPropertyWebkitMaskClip ? style->maskClip() : style->maskOrigin()); |
|
1004 return CSSPrimitiveValue::create(box); |
|
1005 } |
|
1006 case CSSPropertyWebkitMaskPosition: { |
|
1007 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
1008 |
|
1009 list->append(CSSPrimitiveValue::create(style->maskXPosition())); |
|
1010 list->append(CSSPrimitiveValue::create(style->maskYPosition())); |
|
1011 |
|
1012 return list.release(); |
|
1013 } |
|
1014 case CSSPropertyWebkitMaskPositionX: |
|
1015 return CSSPrimitiveValue::create(style->maskXPosition()); |
|
1016 case CSSPropertyWebkitMaskPositionY: |
|
1017 return CSSPrimitiveValue::create(style->maskYPosition()); |
|
1018 case CSSPropertyWebkitUserModify: |
|
1019 return CSSPrimitiveValue::create(style->userModify()); |
|
1020 case CSSPropertyMaxHeight: { |
|
1021 const Length& maxHeight = style->maxHeight(); |
|
1022 if (maxHeight.isFixed() && maxHeight.value() == undefinedLength) |
|
1023 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
1024 return CSSPrimitiveValue::create(maxHeight); |
|
1025 } |
|
1026 case CSSPropertyMaxWidth: { |
|
1027 const Length& maxWidth = style->maxWidth(); |
|
1028 if (maxWidth.isFixed() && maxWidth.value() == undefinedLength) |
|
1029 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
1030 return CSSPrimitiveValue::create(maxWidth); |
|
1031 } |
|
1032 case CSSPropertyMinHeight: |
|
1033 return CSSPrimitiveValue::create(style->minHeight()); |
|
1034 case CSSPropertyMinWidth: |
|
1035 return CSSPrimitiveValue::create(style->minWidth()); |
|
1036 case CSSPropertyOpacity: |
|
1037 return CSSPrimitiveValue::create(style->opacity(), CSSPrimitiveValue::CSS_NUMBER); |
|
1038 case CSSPropertyOrphans: |
|
1039 return CSSPrimitiveValue::create(style->orphans(), CSSPrimitiveValue::CSS_NUMBER); |
|
1040 case CSSPropertyOutlineColor: |
|
1041 return m_allowVisitedStyle ? CSSPrimitiveValue::createColor(style->visitedDependentColor(CSSPropertyOutlineColor).rgb()) : currentColorOrValidColor(style.get(), style->outlineColor()); |
|
1042 case CSSPropertyOutlineStyle: |
|
1043 if (style->outlineStyleIsAuto()) |
|
1044 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
1045 return CSSPrimitiveValue::create(style->outlineStyle()); |
|
1046 case CSSPropertyOutlineWidth: |
|
1047 return CSSPrimitiveValue::create(style->outlineWidth(), CSSPrimitiveValue::CSS_PX); |
|
1048 case CSSPropertyOverflow: |
|
1049 return CSSPrimitiveValue::create(max(style->overflowX(), style->overflowY())); |
|
1050 case CSSPropertyOverflowX: |
|
1051 return CSSPrimitiveValue::create(style->overflowX()); |
|
1052 case CSSPropertyOverflowY: |
|
1053 return CSSPrimitiveValue::create(style->overflowY()); |
|
1054 case CSSPropertyPaddingTop: |
|
1055 if (renderer && renderer->isBox()) |
|
1056 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingTop(false), CSSPrimitiveValue::CSS_PX); |
|
1057 return CSSPrimitiveValue::create(style->paddingTop()); |
|
1058 case CSSPropertyPaddingRight: |
|
1059 if (renderer && renderer->isBox()) |
|
1060 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingRight(false), CSSPrimitiveValue::CSS_PX); |
|
1061 return CSSPrimitiveValue::create(style->paddingRight()); |
|
1062 case CSSPropertyPaddingBottom: |
|
1063 if (renderer && renderer->isBox()) |
|
1064 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingBottom(false), CSSPrimitiveValue::CSS_PX); |
|
1065 return CSSPrimitiveValue::create(style->paddingBottom()); |
|
1066 case CSSPropertyPaddingLeft: |
|
1067 if (renderer && renderer->isBox()) |
|
1068 return CSSPrimitiveValue::create(toRenderBox(renderer)->paddingLeft(false), CSSPrimitiveValue::CSS_PX); |
|
1069 return CSSPrimitiveValue::create(style->paddingLeft()); |
|
1070 case CSSPropertyPageBreakAfter: |
|
1071 return CSSPrimitiveValue::create(style->pageBreakAfter()); |
|
1072 case CSSPropertyPageBreakBefore: |
|
1073 return CSSPrimitiveValue::create(style->pageBreakBefore()); |
|
1074 case CSSPropertyPageBreakInside: { |
|
1075 EPageBreak pageBreak = style->pageBreakInside(); |
|
1076 ASSERT(pageBreak != PBALWAYS); |
|
1077 if (pageBreak == PBALWAYS) |
|
1078 return 0; |
|
1079 return CSSPrimitiveValue::create(style->pageBreakInside()); |
|
1080 } |
|
1081 case CSSPropertyPosition: |
|
1082 return CSSPrimitiveValue::create(style->position()); |
|
1083 case CSSPropertyRight: |
|
1084 return getPositionOffsetValue(style.get(), CSSPropertyRight); |
|
1085 case CSSPropertyTableLayout: |
|
1086 return CSSPrimitiveValue::create(style->tableLayout()); |
|
1087 case CSSPropertyTextAlign: |
|
1088 return CSSPrimitiveValue::create(style->textAlign()); |
|
1089 case CSSPropertyTextDecoration: |
|
1090 return renderTextDecorationFlagsToCSSValue(style->textDecoration()); |
|
1091 case CSSPropertyWebkitTextDecorationsInEffect: |
|
1092 return renderTextDecorationFlagsToCSSValue(style->textDecorationsInEffect()); |
|
1093 case CSSPropertyWebkitTextFillColor: |
|
1094 return currentColorOrValidColor(style.get(), style->textFillColor()); |
|
1095 case CSSPropertyTextIndent: |
|
1096 return CSSPrimitiveValue::create(style->textIndent()); |
|
1097 case CSSPropertyTextShadow: |
|
1098 return valueForShadow(style->textShadow(), propertyID); |
|
1099 case CSSPropertyTextRendering: |
|
1100 return CSSPrimitiveValue::create(style->fontDescription().textRenderingMode()); |
|
1101 case CSSPropertyTextOverflow: |
|
1102 if (style->textOverflow()) |
|
1103 return CSSPrimitiveValue::createIdentifier(CSSValueEllipsis); |
|
1104 return CSSPrimitiveValue::createIdentifier(CSSValueClip); |
|
1105 case CSSPropertyWebkitTextSecurity: |
|
1106 return CSSPrimitiveValue::create(style->textSecurity()); |
|
1107 case CSSPropertyWebkitTextSizeAdjust: |
|
1108 if (style->textSizeAdjust()) |
|
1109 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
1110 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
1111 case CSSPropertyWebkitTextStrokeColor: |
|
1112 return currentColorOrValidColor(style.get(), style->textStrokeColor()); |
|
1113 case CSSPropertyWebkitTextStrokeWidth: |
|
1114 return CSSPrimitiveValue::create(style->textStrokeWidth(), CSSPrimitiveValue::CSS_PX); |
|
1115 case CSSPropertyTextTransform: |
|
1116 return CSSPrimitiveValue::create(style->textTransform()); |
|
1117 case CSSPropertyTop: |
|
1118 return getPositionOffsetValue(style.get(), CSSPropertyTop); |
|
1119 case CSSPropertyUnicodeBidi: |
|
1120 return CSSPrimitiveValue::create(style->unicodeBidi()); |
|
1121 case CSSPropertyVerticalAlign: |
|
1122 switch (style->verticalAlign()) { |
|
1123 case BASELINE: |
|
1124 return CSSPrimitiveValue::createIdentifier(CSSValueBaseline); |
|
1125 case MIDDLE: |
|
1126 return CSSPrimitiveValue::createIdentifier(CSSValueMiddle); |
|
1127 case SUB: |
|
1128 return CSSPrimitiveValue::createIdentifier(CSSValueSub); |
|
1129 case SUPER: |
|
1130 return CSSPrimitiveValue::createIdentifier(CSSValueSuper); |
|
1131 case TEXT_TOP: |
|
1132 return CSSPrimitiveValue::createIdentifier(CSSValueTextTop); |
|
1133 case TEXT_BOTTOM: |
|
1134 return CSSPrimitiveValue::createIdentifier(CSSValueTextBottom); |
|
1135 case TOP: |
|
1136 return CSSPrimitiveValue::createIdentifier(CSSValueTop); |
|
1137 case BOTTOM: |
|
1138 return CSSPrimitiveValue::createIdentifier(CSSValueBottom); |
|
1139 case BASELINE_MIDDLE: |
|
1140 return CSSPrimitiveValue::createIdentifier(CSSValueWebkitBaselineMiddle); |
|
1141 case LENGTH: |
|
1142 return CSSPrimitiveValue::create(style->verticalAlignLength()); |
|
1143 } |
|
1144 ASSERT_NOT_REACHED(); |
|
1145 return 0; |
|
1146 case CSSPropertyVisibility: |
|
1147 return CSSPrimitiveValue::create(style->visibility()); |
|
1148 case CSSPropertyWhiteSpace: |
|
1149 return CSSPrimitiveValue::create(style->whiteSpace()); |
|
1150 case CSSPropertyWidows: |
|
1151 return CSSPrimitiveValue::create(style->widows(), CSSPrimitiveValue::CSS_NUMBER); |
|
1152 case CSSPropertyWidth: |
|
1153 if (renderer) |
|
1154 return CSSPrimitiveValue::create(sizingBox(renderer).width(), CSSPrimitiveValue::CSS_PX); |
|
1155 return CSSPrimitiveValue::create(style->width()); |
|
1156 case CSSPropertyWordBreak: |
|
1157 return CSSPrimitiveValue::create(style->wordBreak()); |
|
1158 case CSSPropertyWordSpacing: |
|
1159 return CSSPrimitiveValue::create(style->wordSpacing(), CSSPrimitiveValue::CSS_PX); |
|
1160 case CSSPropertyWordWrap: |
|
1161 return CSSPrimitiveValue::create(style->wordWrap()); |
|
1162 case CSSPropertyWebkitLineBreak: |
|
1163 return CSSPrimitiveValue::create(style->khtmlLineBreak()); |
|
1164 case CSSPropertyWebkitNbspMode: |
|
1165 return CSSPrimitiveValue::create(style->nbspMode()); |
|
1166 case CSSPropertyWebkitMatchNearestMailBlockquoteColor: |
|
1167 return CSSPrimitiveValue::create(style->matchNearestMailBlockquoteColor()); |
|
1168 case CSSPropertyResize: |
|
1169 return CSSPrimitiveValue::create(style->resize()); |
|
1170 case CSSPropertyWebkitFontSmoothing: |
|
1171 return CSSPrimitiveValue::create(style->fontDescription().fontSmoothing()); |
|
1172 case CSSPropertyZIndex: |
|
1173 if (style->hasAutoZIndex()) |
|
1174 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
1175 return CSSPrimitiveValue::create(style->zIndex(), CSSPrimitiveValue::CSS_NUMBER); |
|
1176 case CSSPropertyZoom: |
|
1177 return CSSPrimitiveValue::create(style->zoom(), CSSPrimitiveValue::CSS_NUMBER); |
|
1178 case CSSPropertyWebkitBoxSizing: |
|
1179 if (style->boxSizing() == CONTENT_BOX) |
|
1180 return CSSPrimitiveValue::createIdentifier(CSSValueContentBox); |
|
1181 return CSSPrimitiveValue::createIdentifier(CSSValueBorderBox); |
|
1182 #if ENABLE(DASHBOARD_SUPPORT) |
|
1183 case CSSPropertyWebkitDashboardRegion: |
|
1184 { |
|
1185 const Vector<StyleDashboardRegion>& regions = style->dashboardRegions(); |
|
1186 unsigned count = regions.size(); |
|
1187 if (count == 1 && regions[0].type == StyleDashboardRegion::None) |
|
1188 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
1189 |
|
1190 RefPtr<DashboardRegion> firstRegion; |
|
1191 DashboardRegion* previousRegion = 0; |
|
1192 for (unsigned i = 0; i < count; i++) { |
|
1193 RefPtr<DashboardRegion> region = DashboardRegion::create(); |
|
1194 StyleDashboardRegion styleRegion = regions[i]; |
|
1195 |
|
1196 region->m_label = styleRegion.label; |
|
1197 LengthBox offset = styleRegion.offset; |
|
1198 region->setTop(CSSPrimitiveValue::create(offset.top().value(), CSSPrimitiveValue::CSS_PX)); |
|
1199 region->setRight(CSSPrimitiveValue::create(offset.right().value(), CSSPrimitiveValue::CSS_PX)); |
|
1200 region->setBottom(CSSPrimitiveValue::create(offset.bottom().value(), CSSPrimitiveValue::CSS_PX)); |
|
1201 region->setLeft(CSSPrimitiveValue::create(offset.left().value(), CSSPrimitiveValue::CSS_PX)); |
|
1202 region->m_isRectangle = (styleRegion.type == StyleDashboardRegion::Rectangle); |
|
1203 region->m_isCircle = (styleRegion.type == StyleDashboardRegion::Circle); |
|
1204 |
|
1205 if (previousRegion) |
|
1206 previousRegion->m_next = region; |
|
1207 else |
|
1208 firstRegion = region; |
|
1209 previousRegion = region.get(); |
|
1210 } |
|
1211 return CSSPrimitiveValue::create(firstRegion.release()); |
|
1212 } |
|
1213 #endif |
|
1214 case CSSPropertyWebkitAnimationDelay: |
|
1215 return getDelayValue(style->animations()); |
|
1216 case CSSPropertyWebkitAnimationDirection: { |
|
1217 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
1218 const AnimationList* t = style->animations(); |
|
1219 if (t) { |
|
1220 for (size_t i = 0; i < t->size(); ++i) { |
|
1221 if (t->animation(i)->direction()) |
|
1222 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAlternate)); |
|
1223 else |
|
1224 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNormal)); |
|
1225 } |
|
1226 } else |
|
1227 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNormal)); |
|
1228 return list.release(); |
|
1229 } |
|
1230 case CSSPropertyWebkitAnimationDuration: |
|
1231 return getDurationValue(style->animations()); |
|
1232 case CSSPropertyWebkitAnimationFillMode: { |
|
1233 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
1234 const AnimationList* t = style->animations(); |
|
1235 if (t) { |
|
1236 for (size_t i = 0; i < t->size(); ++i) { |
|
1237 switch (t->animation(i)->fillMode()) { |
|
1238 case AnimationFillModeNone: |
|
1239 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone)); |
|
1240 break; |
|
1241 case AnimationFillModeForwards: |
|
1242 list->append(CSSPrimitiveValue::createIdentifier(CSSValueForwards)); |
|
1243 break; |
|
1244 case AnimationFillModeBackwards: |
|
1245 list->append(CSSPrimitiveValue::createIdentifier(CSSValueBackwards)); |
|
1246 break; |
|
1247 case AnimationFillModeBoth: |
|
1248 list->append(CSSPrimitiveValue::createIdentifier(CSSValueBoth)); |
|
1249 break; |
|
1250 } |
|
1251 } |
|
1252 } else |
|
1253 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone)); |
|
1254 return list.release(); |
|
1255 } |
|
1256 case CSSPropertyWebkitAnimationIterationCount: { |
|
1257 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
1258 const AnimationList* t = style->animations(); |
|
1259 if (t) { |
|
1260 for (size_t i = 0; i < t->size(); ++i) { |
|
1261 int iterationCount = t->animation(i)->iterationCount(); |
|
1262 if (iterationCount == Animation::IterationCountInfinite) |
|
1263 list->append(CSSPrimitiveValue::createIdentifier(CSSValueInfinite)); |
|
1264 else |
|
1265 list->append(CSSPrimitiveValue::create(iterationCount, CSSPrimitiveValue::CSS_NUMBER)); |
|
1266 } |
|
1267 } else |
|
1268 list->append(CSSPrimitiveValue::create(Animation::initialAnimationIterationCount(), CSSPrimitiveValue::CSS_NUMBER)); |
|
1269 return list.release(); |
|
1270 } |
|
1271 case CSSPropertyWebkitAnimationName: { |
|
1272 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
1273 const AnimationList* t = style->animations(); |
|
1274 if (t) { |
|
1275 for (size_t i = 0; i < t->size(); ++i) { |
|
1276 list->append(CSSPrimitiveValue::create(t->animation(i)->name(), CSSPrimitiveValue::CSS_STRING)); |
|
1277 } |
|
1278 } else |
|
1279 list->append(CSSPrimitiveValue::createIdentifier(CSSValueNone)); |
|
1280 return list.release(); |
|
1281 } |
|
1282 case CSSPropertyWebkitAnimationPlayState: { |
|
1283 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
1284 const AnimationList* t = style->animations(); |
|
1285 if (t) { |
|
1286 for (size_t i = 0; i < t->size(); ++i) { |
|
1287 int prop = t->animation(i)->playState(); |
|
1288 if (prop == AnimPlayStatePlaying) |
|
1289 list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning)); |
|
1290 else |
|
1291 list->append(CSSPrimitiveValue::createIdentifier(CSSValuePaused)); |
|
1292 } |
|
1293 } else |
|
1294 list->append(CSSPrimitiveValue::createIdentifier(CSSValueRunning)); |
|
1295 return list.release(); |
|
1296 } |
|
1297 case CSSPropertyWebkitAnimationTimingFunction: |
|
1298 return getTimingFunctionValue(style->animations()); |
|
1299 case CSSPropertyWebkitAppearance: |
|
1300 return CSSPrimitiveValue::create(style->appearance()); |
|
1301 case CSSPropertyWebkitBackfaceVisibility: |
|
1302 return CSSPrimitiveValue::createIdentifier((style->backfaceVisibility() == BackfaceVisibilityHidden) ? CSSValueHidden : CSSValueVisible); |
|
1303 case CSSPropertyWebkitBorderImage: |
|
1304 return valueForNinePieceImage(style->borderImage()); |
|
1305 case CSSPropertyWebkitMaskBoxImage: |
|
1306 return valueForNinePieceImage(style->maskBoxImage()); |
|
1307 case CSSPropertyWebkitFontSizeDelta: |
|
1308 // Not a real style property -- used by the editing engine -- so has no computed value. |
|
1309 break; |
|
1310 case CSSPropertyWebkitMarginBottomCollapse: |
|
1311 return CSSPrimitiveValue::create(style->marginBottomCollapse()); |
|
1312 case CSSPropertyWebkitMarginTopCollapse: |
|
1313 return CSSPrimitiveValue::create(style->marginTopCollapse()); |
|
1314 case CSSPropertyWebkitPerspective: |
|
1315 if (!style->hasPerspective()) |
|
1316 return CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
1317 return CSSPrimitiveValue::create(style->perspective(), CSSPrimitiveValue::CSS_NUMBER); |
|
1318 case CSSPropertyWebkitPerspectiveOrigin: { |
|
1319 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
1320 if (renderer) { |
|
1321 IntRect box = sizingBox(renderer); |
|
1322 list->append(CSSPrimitiveValue::create(style->perspectiveOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX)); |
|
1323 list->append(CSSPrimitiveValue::create(style->perspectiveOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX)); |
|
1324 } |
|
1325 else { |
|
1326 list->append(CSSPrimitiveValue::create(style->perspectiveOriginX())); |
|
1327 list->append(CSSPrimitiveValue::create(style->perspectiveOriginY())); |
|
1328 } |
|
1329 return list.release(); |
|
1330 } |
|
1331 case CSSPropertyWebkitRtlOrdering: |
|
1332 if (style->visuallyOrdered()) |
|
1333 return CSSPrimitiveValue::createIdentifier(CSSValueVisual); |
|
1334 return CSSPrimitiveValue::createIdentifier(CSSValueLogical); |
|
1335 case CSSPropertyWebkitUserDrag: |
|
1336 return CSSPrimitiveValue::create(style->userDrag()); |
|
1337 case CSSPropertyWebkitUserSelect: |
|
1338 return CSSPrimitiveValue::create(style->userSelect()); |
|
1339 case CSSPropertyBorderBottomLeftRadius: |
|
1340 return getBorderRadiusCornerValue(style->borderBottomLeftRadius()); |
|
1341 case CSSPropertyBorderBottomRightRadius: |
|
1342 return getBorderRadiusCornerValue(style->borderBottomRightRadius()); |
|
1343 case CSSPropertyBorderTopLeftRadius: |
|
1344 return getBorderRadiusCornerValue(style->borderTopLeftRadius()); |
|
1345 case CSSPropertyBorderTopRightRadius: |
|
1346 return getBorderRadiusCornerValue(style->borderTopRightRadius()); |
|
1347 case CSSPropertyClip: { |
|
1348 if (!style->hasClip()) |
|
1349 return CSSPrimitiveValue::createIdentifier(CSSValueAuto); |
|
1350 RefPtr<Rect> rect = Rect::create(); |
|
1351 rect->setTop(CSSPrimitiveValue::create(style->clip().top().value(), CSSPrimitiveValue::CSS_PX)); |
|
1352 rect->setRight(CSSPrimitiveValue::create(style->clip().right().value(), CSSPrimitiveValue::CSS_PX)); |
|
1353 rect->setBottom(CSSPrimitiveValue::create(style->clip().bottom().value(), CSSPrimitiveValue::CSS_PX)); |
|
1354 rect->setLeft(CSSPrimitiveValue::create(style->clip().left().value(), CSSPrimitiveValue::CSS_PX)); |
|
1355 return CSSPrimitiveValue::create(rect.release()); |
|
1356 } |
|
1357 case CSSPropertyWebkitTransform: |
|
1358 return computedTransform(renderer, style.get()); |
|
1359 case CSSPropertyWebkitTransformOrigin: { |
|
1360 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); |
|
1361 if (renderer) { |
|
1362 IntRect box = sizingBox(renderer); |
|
1363 list->append(CSSPrimitiveValue::create(style->transformOriginX().calcMinValue(box.width()), CSSPrimitiveValue::CSS_PX)); |
|
1364 list->append(CSSPrimitiveValue::create(style->transformOriginY().calcMinValue(box.height()), CSSPrimitiveValue::CSS_PX)); |
|
1365 if (style->transformOriginZ() != 0) |
|
1366 list->append(CSSPrimitiveValue::create(style->transformOriginZ(), CSSPrimitiveValue::CSS_PX)); |
|
1367 } else { |
|
1368 list->append(CSSPrimitiveValue::create(style->transformOriginX())); |
|
1369 list->append(CSSPrimitiveValue::create(style->transformOriginY())); |
|
1370 if (style->transformOriginZ() != 0) |
|
1371 list->append(CSSPrimitiveValue::create(style->transformOriginZ(), CSSPrimitiveValue::CSS_PX)); |
|
1372 } |
|
1373 return list.release(); |
|
1374 } |
|
1375 case CSSPropertyWebkitTransformStyle: |
|
1376 return CSSPrimitiveValue::createIdentifier((style->transformStyle3D() == TransformStyle3DPreserve3D) ? CSSValuePreserve3d : CSSValueFlat); |
|
1377 case CSSPropertyWebkitTransitionDelay: |
|
1378 return getDelayValue(style->transitions()); |
|
1379 case CSSPropertyWebkitTransitionDuration: |
|
1380 return getDurationValue(style->transitions()); |
|
1381 case CSSPropertyWebkitTransitionProperty: { |
|
1382 RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated(); |
|
1383 const AnimationList* t = style->transitions(); |
|
1384 if (t) { |
|
1385 for (size_t i = 0; i < t->size(); ++i) { |
|
1386 int prop = t->animation(i)->property(); |
|
1387 RefPtr<CSSValue> propertyValue; |
|
1388 if (prop == cAnimateNone) |
|
1389 propertyValue = CSSPrimitiveValue::createIdentifier(CSSValueNone); |
|
1390 else if (prop == cAnimateAll) |
|
1391 propertyValue = CSSPrimitiveValue::createIdentifier(CSSValueAll); |
|
1392 else |
|
1393 propertyValue = CSSPrimitiveValue::create(getPropertyName(static_cast<CSSPropertyID>(prop)), CSSPrimitiveValue::CSS_STRING); |
|
1394 list->append(propertyValue); |
|
1395 } |
|
1396 } else |
|
1397 list->append(CSSPrimitiveValue::createIdentifier(CSSValueAll)); |
|
1398 return list.release(); |
|
1399 } |
|
1400 case CSSPropertyWebkitTransitionTimingFunction: |
|
1401 return getTimingFunctionValue(style->transitions()); |
|
1402 case CSSPropertyPointerEvents: |
|
1403 return CSSPrimitiveValue::create(style->pointerEvents()); |
|
1404 case CSSPropertyWebkitColorCorrection: |
|
1405 return CSSPrimitiveValue::create(style->colorSpace()); |
|
1406 |
|
1407 /* Shorthand properties, currently not supported see bug 13658*/ |
|
1408 case CSSPropertyBackground: |
|
1409 case CSSPropertyBorder: |
|
1410 case CSSPropertyBorderBottom: |
|
1411 case CSSPropertyBorderColor: |
|
1412 case CSSPropertyBorderLeft: |
|
1413 case CSSPropertyBorderRadius: |
|
1414 case CSSPropertyBorderRight: |
|
1415 case CSSPropertyBorderStyle: |
|
1416 case CSSPropertyBorderTop: |
|
1417 case CSSPropertyBorderWidth: |
|
1418 case CSSPropertyFont: |
|
1419 case CSSPropertyListStyle: |
|
1420 case CSSPropertyMargin: |
|
1421 case CSSPropertyPadding: |
|
1422 break; |
|
1423 |
|
1424 /* Unimplemented CSS 3 properties (including CSS3 shorthand properties) */ |
|
1425 case CSSPropertyTextLineThrough: |
|
1426 case CSSPropertyTextLineThroughColor: |
|
1427 case CSSPropertyTextLineThroughMode: |
|
1428 case CSSPropertyTextLineThroughStyle: |
|
1429 case CSSPropertyTextLineThroughWidth: |
|
1430 case CSSPropertyTextOverline: |
|
1431 case CSSPropertyTextOverlineColor: |
|
1432 case CSSPropertyTextOverlineMode: |
|
1433 case CSSPropertyTextOverlineStyle: |
|
1434 case CSSPropertyTextOverlineWidth: |
|
1435 case CSSPropertyTextUnderline: |
|
1436 case CSSPropertyTextUnderlineColor: |
|
1437 case CSSPropertyTextUnderlineMode: |
|
1438 case CSSPropertyTextUnderlineStyle: |
|
1439 case CSSPropertyTextUnderlineWidth: |
|
1440 break; |
|
1441 |
|
1442 /* Directional properties are resolved by resolveDirectionAwareProperty() before the switch. */ |
|
1443 case CSSPropertyWebkitBorderEnd: |
|
1444 case CSSPropertyWebkitBorderEndColor: |
|
1445 case CSSPropertyWebkitBorderEndStyle: |
|
1446 case CSSPropertyWebkitBorderEndWidth: |
|
1447 case CSSPropertyWebkitBorderStart: |
|
1448 case CSSPropertyWebkitBorderStartColor: |
|
1449 case CSSPropertyWebkitBorderStartStyle: |
|
1450 case CSSPropertyWebkitBorderStartWidth: |
|
1451 case CSSPropertyWebkitMarginEnd: |
|
1452 case CSSPropertyWebkitMarginStart: |
|
1453 case CSSPropertyWebkitPaddingEnd: |
|
1454 case CSSPropertyWebkitPaddingStart: |
|
1455 ASSERT_NOT_REACHED(); |
|
1456 break; |
|
1457 |
|
1458 /* Unimplemented @font-face properties */ |
|
1459 case CSSPropertyFontStretch: |
|
1460 case CSSPropertySrc: |
|
1461 case CSSPropertyUnicodeRange: |
|
1462 break; |
|
1463 |
|
1464 /* Other unimplemented properties */ |
|
1465 case CSSPropertyBackgroundRepeatX: |
|
1466 case CSSPropertyBackgroundRepeatY: |
|
1467 case CSSPropertyContent: // FIXME: needs implementation, bug 23668 |
|
1468 case CSSPropertyCounterIncrement: |
|
1469 case CSSPropertyCounterReset: |
|
1470 case CSSPropertyOutline: // FIXME: needs implementation |
|
1471 case CSSPropertyOutlineOffset: // FIXME: needs implementation |
|
1472 case CSSPropertyPage: // for @page |
|
1473 case CSSPropertyQuotes: // FIXME: needs implementation |
|
1474 case CSSPropertySize: // for @page |
|
1475 break; |
|
1476 |
|
1477 /* Unimplemented -webkit- properties */ |
|
1478 case CSSPropertyWebkitAnimation: |
|
1479 case CSSPropertyWebkitBorderRadius: |
|
1480 case CSSPropertyWebkitColumns: |
|
1481 case CSSPropertyWebkitColumnRule: |
|
1482 case CSSPropertyWebkitMarginCollapse: |
|
1483 case CSSPropertyWebkitMarquee: |
|
1484 case CSSPropertyWebkitMarqueeSpeed: |
|
1485 case CSSPropertyWebkitMask: |
|
1486 case CSSPropertyWebkitMaskRepeatX: |
|
1487 case CSSPropertyWebkitMaskRepeatY: |
|
1488 case CSSPropertyWebkitPerspectiveOriginX: |
|
1489 case CSSPropertyWebkitPerspectiveOriginY: |
|
1490 case CSSPropertyWebkitTextStroke: |
|
1491 case CSSPropertyWebkitTransformOriginX: |
|
1492 case CSSPropertyWebkitTransformOriginY: |
|
1493 case CSSPropertyWebkitTransformOriginZ: |
|
1494 case CSSPropertyWebkitTransition: |
|
1495 case CSSPropertyWebkitVariableDeclarationBlock: |
|
1496 break; |
|
1497 #if ENABLE(SVG) |
|
1498 // FIXME: This default case ruins the point of using an enum for |
|
1499 // properties -- it prevents us from getting a warning when we |
|
1500 // forget to list a property above. |
|
1501 default: |
|
1502 return getSVGPropertyCSSValue(propertyID, DoNotUpdateLayout); |
|
1503 #endif |
|
1504 } |
|
1505 |
|
1506 logUnimplementedPropertyID(propertyID); |
|
1507 return 0; |
|
1508 } |
|
1509 |
|
1510 String CSSComputedStyleDeclaration::getPropertyValue(int propertyID) const |
|
1511 { |
|
1512 RefPtr<CSSValue> value = getPropertyCSSValue(propertyID); |
|
1513 if (value) |
|
1514 return value->cssText(); |
|
1515 return ""; |
|
1516 } |
|
1517 |
|
1518 bool CSSComputedStyleDeclaration::getPropertyPriority(int /*propertyID*/) const |
|
1519 { |
|
1520 // All computed styles have a priority of false (not "important"). |
|
1521 return false; |
|
1522 } |
|
1523 |
|
1524 String CSSComputedStyleDeclaration::removeProperty(int /*propertyID*/, ExceptionCode& ec) |
|
1525 { |
|
1526 ec = NO_MODIFICATION_ALLOWED_ERR; |
|
1527 return String(); |
|
1528 } |
|
1529 |
|
1530 void CSSComputedStyleDeclaration::setProperty(int /*propertyID*/, const String& /*value*/, bool /*important*/, ExceptionCode& ec) |
|
1531 { |
|
1532 ec = NO_MODIFICATION_ALLOWED_ERR; |
|
1533 } |
|
1534 |
|
1535 unsigned CSSComputedStyleDeclaration::virtualLength() const |
|
1536 { |
|
1537 Node* node = m_node.get(); |
|
1538 if (!node) |
|
1539 return 0; |
|
1540 |
|
1541 RenderStyle* style = node->computedStyle(m_pseudoElementSpecifier); |
|
1542 if (!style) |
|
1543 return 0; |
|
1544 |
|
1545 return numComputedProperties; |
|
1546 } |
|
1547 |
|
1548 String CSSComputedStyleDeclaration::item(unsigned i) const |
|
1549 { |
|
1550 if (i >= length()) |
|
1551 return ""; |
|
1552 |
|
1553 return getPropertyName(static_cast<CSSPropertyID>(computedProperties[i])); |
|
1554 } |
|
1555 |
|
1556 bool CSSComputedStyleDeclaration::cssPropertyMatches(const CSSProperty* property) const |
|
1557 { |
|
1558 if (property->id() == CSSPropertyFontSize && property->value()->isPrimitiveValue() && m_node) { |
|
1559 m_node->document()->updateLayoutIgnorePendingStylesheets(); |
|
1560 RenderStyle* style = m_node->computedStyle(m_pseudoElementSpecifier); |
|
1561 if (style && style->fontDescription().keywordSize()) { |
|
1562 int sizeValue = cssIdentifierForFontSizeKeyword(style->fontDescription().keywordSize()); |
|
1563 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(property->value()); |
|
1564 if (primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_IDENT && primitiveValue->getIdent() == sizeValue) |
|
1565 return true; |
|
1566 } |
|
1567 } |
|
1568 |
|
1569 return CSSStyleDeclaration::cssPropertyMatches(property); |
|
1570 } |
|
1571 |
|
1572 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copy() const |
|
1573 { |
|
1574 return copyPropertiesInSet(computedProperties, numComputedProperties); |
|
1575 } |
|
1576 |
|
1577 PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::makeMutable() |
|
1578 { |
|
1579 return copy(); |
|
1580 } |
|
1581 |
|
1582 } // namespace WebCore |