OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc. All r
ights reserved. |
4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. | 4 * Copyright (C) 2011 Research In Motion Limited. All rights reserved. |
5 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 5 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 return; | 48 return; |
49 | 49 |
50 StylePropertySet::PropertyReference allProperty = m_propertySet.propertyAt(m
_allIndex); | 50 StylePropertySet::PropertyReference allProperty = m_propertySet.propertyAt(m
_allIndex); |
51 for (unsigned i = 0; i < m_propertySet.propertyCount(); ++i) { | 51 for (unsigned i = 0; i < m_propertySet.propertyCount(); ++i) { |
52 StylePropertySet::PropertyReference property = m_propertySet.propertyAt(
i); | 52 StylePropertySet::PropertyReference property = m_propertySet.propertyAt(
i); |
53 if (CSSProperty::isAffectedByAllProperty(property.id())) { | 53 if (CSSProperty::isAffectedByAllProperty(property.id())) { |
54 if (allProperty.isImportant() && !property.isImportant()) | 54 if (allProperty.isImportant() && !property.isImportant()) |
55 continue; | 55 continue; |
56 if (static_cast<unsigned>(m_allIndex) >= i) | 56 if (static_cast<unsigned>(m_allIndex) >= i) |
57 continue; | 57 continue; |
58 if (property.value()->equals(*allProperty.value()) | 58 if (property.value().equals(allProperty.value()) |
59 && property.isImportant() == allProperty.isImportant()) | 59 && property.isImportant() == allProperty.isImportant()) |
60 continue; | 60 continue; |
61 m_needToExpandAll = true; | 61 m_needToExpandAll = true; |
62 } | 62 } |
63 m_longhandPropertyUsed.set(property.id() - firstCSSProperty); | 63 m_longhandPropertyUsed.set(property.id() - firstCSSProperty); |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 unsigned StylePropertySerializer::StylePropertySetForSerializer::propertyCount()
const | 67 unsigned StylePropertySerializer::StylePropertySetForSerializer::propertyCount()
const |
68 { | 68 { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 return true; | 121 return true; |
122 } | 122 } |
123 | 123 |
124 int StylePropertySerializer::StylePropertySetForSerializer::findPropertyIndex(CS
SPropertyID propertyID) const | 124 int StylePropertySerializer::StylePropertySetForSerializer::findPropertyIndex(CS
SPropertyID propertyID) const |
125 { | 125 { |
126 if (!hasExpandedAllProperty()) | 126 if (!hasExpandedAllProperty()) |
127 return m_propertySet.findPropertyIndex(propertyID); | 127 return m_propertySet.findPropertyIndex(propertyID); |
128 return propertyID - firstCSSProperty; | 128 return propertyID - firstCSSProperty; |
129 } | 129 } |
130 | 130 |
131 const CSSValue* StylePropertySerializer::StylePropertySetForSerializer::getPrope
rtyCSSValue(CSSPropertyID propertyID) const | 131 const NullableCSSValue StylePropertySerializer::StylePropertySetForSerializer::g
etPropertyCSSValue(CSSPropertyID propertyID) const |
132 { | 132 { |
133 int index = findPropertyIndex(propertyID); | 133 int index = findPropertyIndex(propertyID); |
134 if (index == -1) | 134 if (index == -1) |
135 return 0; | 135 return nullptr; |
136 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index
); | 136 StylePropertySerializer::PropertyValueForSerializer value = propertyAt(index
); |
137 return value.value(); | 137 return value.value(); |
138 } | 138 } |
139 | 139 |
140 String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue(
CSSPropertyID propertyID) const | 140 String StylePropertySerializer::StylePropertySetForSerializer::getPropertyValue(
CSSPropertyID propertyID) const |
141 { | 141 { |
142 if (!hasExpandedAllProperty()) | 142 if (!hasExpandedAllProperty()) |
143 return m_propertySet.getPropertyValue(propertyID); | 143 return m_propertySet.getPropertyValue(propertyID); |
144 | 144 |
145 const CSSValue* value = getPropertyCSSValue(propertyID); | 145 const NullableCSSValue value = getPropertyCSSValue(propertyID); |
146 if (!value) | 146 if (!value) |
147 return String(); | 147 return String(); |
148 return value->cssText(); | 148 return value->cssText(); |
149 } | 149 } |
150 | 150 |
151 bool StylePropertySerializer::StylePropertySetForSerializer::isPropertyImplicit(
CSSPropertyID propertyID) const | 151 bool StylePropertySerializer::StylePropertySetForSerializer::isPropertyImplicit(
CSSPropertyID propertyID) const |
152 { | 152 { |
153 int index = findPropertyIndex(propertyID); | 153 int index = findPropertyIndex(propertyID); |
154 if (index == -1) | 154 if (index == -1) |
155 return false; | 155 return false; |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 case CSSPropertyWebkitMaskRepeatX: | 331 case CSSPropertyWebkitMaskRepeatX: |
332 case CSSPropertyWebkitMaskRepeatY: | 332 case CSSPropertyWebkitMaskRepeatY: |
333 case CSSPropertyWebkitMaskImage: | 333 case CSSPropertyWebkitMaskImage: |
334 case CSSPropertyWebkitMaskRepeat: | 334 case CSSPropertyWebkitMaskRepeat: |
335 case CSSPropertyWebkitMaskPosition: | 335 case CSSPropertyWebkitMaskPosition: |
336 case CSSPropertyWebkitMaskClip: | 336 case CSSPropertyWebkitMaskClip: |
337 case CSSPropertyWebkitMaskOrigin: | 337 case CSSPropertyWebkitMaskOrigin: |
338 shorthandPropertyID = CSSPropertyWebkitMask; | 338 shorthandPropertyID = CSSPropertyWebkitMask; |
339 break; | 339 break; |
340 case CSSPropertyAll: | 340 case CSSPropertyAll: |
341 result.append(getPropertyText(propertyID, property.value()->cssText(
), property.isImportant(), numDecls++)); | 341 result.append(getPropertyText(propertyID, property.value().cssText()
, property.isImportant(), numDecls++)); |
342 continue; | 342 continue; |
343 default: | 343 default: |
344 break; | 344 break; |
345 } | 345 } |
346 | 346 |
347 unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty; | 347 unsigned shortPropertyIndex = shorthandPropertyID - firstCSSProperty; |
348 if (shorthandPropertyID) { | 348 if (shorthandPropertyID) { |
349 if (shorthandPropertyUsed.get(shortPropertyIndex)) | 349 if (shorthandPropertyUsed.get(shortPropertyIndex)) |
350 continue; | 350 continue; |
351 if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNu
ll()) | 351 if (!shorthandPropertyAppeared.get(shortPropertyIndex) && value.isNu
ll()) |
352 value = m_propertySet.getPropertyValue(shorthandPropertyID); | 352 value = m_propertySet.getPropertyValue(shorthandPropertyID); |
353 shorthandPropertyAppeared.set(shortPropertyIndex); | 353 shorthandPropertyAppeared.set(shortPropertyIndex); |
354 } | 354 } |
355 | 355 |
356 if (!value.isNull()) { | 356 if (!value.isNull()) { |
357 if (shorthandPropertyID) { | 357 if (shorthandPropertyID) { |
358 propertyID = shorthandPropertyID; | 358 propertyID = shorthandPropertyID; |
359 shorthandPropertyUsed.set(shortPropertyIndex); | 359 shorthandPropertyUsed.set(shortPropertyIndex); |
360 } | 360 } |
361 } else { | 361 } else { |
362 // We should not show "initial" when the "initial" is implicit. | 362 // We should not show "initial" when the "initial" is implicit. |
363 // If explicit "initial", we need to show. | 363 // If explicit "initial", we need to show. |
364 if (property.value()->isImplicitInitialValue()) | 364 if (property.value().isImplicitInitialValue()) |
365 continue; | 365 continue; |
366 value = property.value()->cssText(); | 366 value = property.value().cssText(); |
367 } | 367 } |
368 | 368 |
369 result.append(getPropertyText(propertyID, value, property.isImportant(),
numDecls++)); | 369 result.append(getPropertyText(propertyID, value, property.isImportant(),
numDecls++)); |
370 } | 370 } |
371 | 371 |
372 if (shorthandPropertyAppeared.get(CSSPropertyBackground - firstCSSProperty)) | 372 if (shorthandPropertyAppeared.get(CSSPropertyBackground - firstCSSProperty)) |
373 appendBackgroundPropertyAsText(result, numDecls); | 373 appendBackgroundPropertyAsText(result, numDecls); |
374 | 374 |
375 ASSERT(!numDecls ^ !result.isEmpty()); | 375 ASSERT(!numDecls ^ !result.isEmpty()); |
376 return result.toString(); | 376 return result.toString(); |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 return getLayeredShorthandValue(webkitMaskPositionShorthand()); | 442 return getLayeredShorthandValue(webkitMaskPositionShorthand()); |
443 case CSSPropertyWebkitMaskRepeat: | 443 case CSSPropertyWebkitMaskRepeat: |
444 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); | 444 return getLayeredShorthandValue(webkitMaskRepeatShorthand()); |
445 case CSSPropertyWebkitMask: | 445 case CSSPropertyWebkitMask: |
446 return getLayeredShorthandValue(webkitMaskShorthand()); | 446 return getLayeredShorthandValue(webkitMaskShorthand()); |
447 case CSSPropertyWebkitTextEmphasis: | 447 case CSSPropertyWebkitTextEmphasis: |
448 return getShorthandValue(webkitTextEmphasisShorthand()); | 448 return getShorthandValue(webkitTextEmphasisShorthand()); |
449 case CSSPropertyWebkitTextStroke: | 449 case CSSPropertyWebkitTextStroke: |
450 return getShorthandValue(webkitTextStrokeShorthand()); | 450 return getShorthandValue(webkitTextStrokeShorthand()); |
451 case CSSPropertyMarker: { | 451 case CSSPropertyMarker: { |
452 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yMarkerStart)) | 452 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyMarkerStart)) |
453 return value->cssText(); | 453 return value->cssText(); |
454 return String(); | 454 return String(); |
455 } | 455 } |
456 case CSSPropertyBorderRadius: | 456 case CSSPropertyBorderRadius: |
457 return get4Values(borderRadiusShorthand()); | 457 return get4Values(borderRadiusShorthand()); |
458 default: | 458 default: |
459 return String(); | 459 return String(); |
460 } | 460 } |
461 } | 461 } |
462 | 462 |
463 String StylePropertySerializer::borderSpacingValue(const StylePropertyShorthand&
shorthand) const | 463 String StylePropertySerializer::borderSpacingValue(const StylePropertyShorthand&
shorthand) const |
464 { | 464 { |
465 const CSSValue* horizontalValue = m_propertySet.getPropertyCSSValue(shorthan
d.properties()[0]); | 465 const NullableCSSValue horizontalValue = m_propertySet.getPropertyCSSValue(s
horthand.properties()[0]); |
466 const CSSValue* verticalValue = m_propertySet.getPropertyCSSValue(shorthand.
properties()[1]); | 466 const NullableCSSValue verticalValue = m_propertySet.getPropertyCSSValue(sho
rthand.properties()[1]); |
467 | 467 |
468 // While standard border-spacing property does not allow specifying border-s
pacing-vertical without | 468 // While standard border-spacing property does not allow specifying border-s
pacing-vertical without |
469 // specifying border-spacing-horizontal <http://www.w3.org/TR/CSS21/tables.h
tml#separated-borders>, | 469 // specifying border-spacing-horizontal <http://www.w3.org/TR/CSS21/tables.h
tml#separated-borders>, |
470 // -webkit-border-spacing-vertical can be set without -webkit-border-spacing
-horizontal. | 470 // -webkit-border-spacing-vertical can be set without -webkit-border-spacing
-horizontal. |
471 if (!horizontalValue || !verticalValue) | 471 if (!horizontalValue || !verticalValue) |
472 return String(); | 472 return String(); |
473 | 473 |
474 String horizontalValueCSSText = horizontalValue->cssText(); | 474 String horizontalValueCSSText = horizontalValue->cssText(); |
475 String verticalValueCSSText = verticalValue->cssText(); | 475 String verticalValueCSSText = verticalValue->cssText(); |
476 if (horizontalValueCSSText == verticalValueCSSText) | 476 if (horizontalValueCSSText == verticalValueCSSText) |
477 return horizontalValueCSSText; | 477 return horizontalValueCSSText; |
478 return horizontalValueCSSText + ' ' + verticalValueCSSText; | 478 return horizontalValueCSSText + ' ' + verticalValueCSSText; |
479 } | 479 } |
480 | 480 |
481 void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p
ropertyID, StringBuilder& result, String& commonValue) const | 481 void StylePropertySerializer::appendFontLonghandValueIfNotNormal(CSSPropertyID p
ropertyID, StringBuilder& result, String& commonValue) const |
482 { | 482 { |
483 int foundPropertyIndex = m_propertySet.findPropertyIndex(propertyID); | 483 int foundPropertyIndex = m_propertySet.findPropertyIndex(propertyID); |
484 if (foundPropertyIndex == -1) | 484 if (foundPropertyIndex == -1) |
485 return; | 485 return; |
486 | 486 |
487 const CSSValue* val = m_propertySet.propertyAt(foundPropertyIndex).value(); | 487 const CSSValue val = m_propertySet.propertyAt(foundPropertyIndex).value(); |
488 if (val->isPrimitiveValue() && toCSSPrimitiveValue(val)->getValueID() == CSS
ValueNormal) { | 488 if (val.isPrimitiveValue() && toCSSPrimitiveValue(val).getValueID() == CSSVa
lueNormal) { |
489 commonValue = String(); | 489 commonValue = String(); |
490 return; | 490 return; |
491 } | 491 } |
492 | 492 |
493 char prefix = '\0'; | 493 char prefix = '\0'; |
494 switch (propertyID) { | 494 switch (propertyID) { |
495 case CSSPropertyFontStyle: | 495 case CSSPropertyFontStyle: |
496 break; // No prefix. | 496 break; // No prefix. |
497 case CSSPropertyFontFamily: | 497 case CSSPropertyFontFamily: |
498 case CSSPropertyFontStretch: | 498 case CSSPropertyFontStretch: |
499 case CSSPropertyFontVariant: | 499 case CSSPropertyFontVariant: |
500 case CSSPropertyFontWeight: | 500 case CSSPropertyFontWeight: |
501 prefix = ' '; | 501 prefix = ' '; |
502 break; | 502 break; |
503 case CSSPropertyLineHeight: | 503 case CSSPropertyLineHeight: |
504 prefix = '/'; | 504 prefix = '/'; |
505 break; | 505 break; |
506 default: | 506 default: |
507 ASSERT_NOT_REACHED(); | 507 ASSERT_NOT_REACHED(); |
508 } | 508 } |
509 | 509 |
510 if (prefix && !result.isEmpty()) | 510 if (prefix && !result.isEmpty()) |
511 result.append(prefix); | 511 result.append(prefix); |
512 String value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText
(); | 512 String value = m_propertySet.propertyAt(foundPropertyIndex).value().cssText(
); |
513 result.append(value); | 513 result.append(value); |
514 if (!commonValue.isNull() && commonValue != value) | 514 if (!commonValue.isNull() && commonValue != value) |
515 commonValue = String(); | 515 commonValue = String(); |
516 } | 516 } |
517 | 517 |
518 String StylePropertySerializer::fontValue() const | 518 String StylePropertySerializer::fontValue() const |
519 { | 519 { |
520 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS
ize); | 520 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS
ize); |
521 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon
tFamily); | 521 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon
tFamily); |
522 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) | 522 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) |
523 return emptyString(); | 523 return emptyString(); |
524 | 524 |
525 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS
izePropertyIndex); | 525 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS
izePropertyIndex); |
526 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon
tFamilyPropertyIndex); | 526 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon
tFamilyPropertyIndex); |
527 | 527 |
528 String commonValue = fontSizeProperty.value()->cssText(); | 528 String commonValue = fontSizeProperty.value().cssText(); |
529 StringBuilder result; | 529 StringBuilder result; |
530 appendFontLonghandValueIfNotNormal(CSSPropertyFontStyle, result, commonValue
); | 530 appendFontLonghandValueIfNotNormal(CSSPropertyFontStyle, result, commonValue
); |
531 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariant, result, commonVal
ue); | 531 appendFontLonghandValueIfNotNormal(CSSPropertyFontVariant, result, commonVal
ue); |
532 appendFontLonghandValueIfNotNormal(CSSPropertyFontWeight, result, commonValu
e); | 532 appendFontLonghandValueIfNotNormal(CSSPropertyFontWeight, result, commonValu
e); |
533 appendFontLonghandValueIfNotNormal(CSSPropertyFontStretch, result, commonVal
ue); | 533 appendFontLonghandValueIfNotNormal(CSSPropertyFontStretch, result, commonVal
ue); |
534 if (!result.isEmpty()) | 534 if (!result.isEmpty()) |
535 result.append(' '); | 535 result.append(' '); |
536 result.append(fontSizeProperty.value()->cssText()); | 536 result.append(fontSizeProperty.value().cssText()); |
537 appendFontLonghandValueIfNotNormal(CSSPropertyLineHeight, result, commonValu
e); | 537 appendFontLonghandValueIfNotNormal(CSSPropertyLineHeight, result, commonValu
e); |
538 if (!result.isEmpty()) | 538 if (!result.isEmpty()) |
539 result.append(' '); | 539 result.append(' '); |
540 result.append(fontFamilyProperty.value()->cssText()); | 540 result.append(fontFamilyProperty.value().cssText()); |
541 if (isInitialOrInherit(commonValue)) | 541 if (isInitialOrInherit(commonValue)) |
542 return commonValue; | 542 return commonValue; |
543 return result.toString(); | 543 return result.toString(); |
544 } | 544 } |
545 | 545 |
546 String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha
nd) const | 546 String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha
nd) const |
547 { | 547 { |
548 // Assume the properties are in the usual order top, right, bottom, left. | 548 // Assume the properties are in the usual order top, right, bottom, left. |
549 int topValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[0
]); | 549 int topValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[0
]); |
550 int rightValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()
[1]); | 550 int rightValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()
[1]); |
551 int bottomValueIndex = m_propertySet.findPropertyIndex(shorthand.properties(
)[2]); | 551 int bottomValueIndex = m_propertySet.findPropertyIndex(shorthand.properties(
)[2]); |
552 int leftValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[
3]); | 552 int leftValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[
3]); |
553 | 553 |
554 if (topValueIndex == -1 || rightValueIndex == -1 || bottomValueIndex == -1 |
| leftValueIndex == -1) | 554 if (topValueIndex == -1 || rightValueIndex == -1 || bottomValueIndex == -1 |
| leftValueIndex == -1) |
555 return String(); | 555 return String(); |
556 | 556 |
557 PropertyValueForSerializer top = m_propertySet.propertyAt(topValueIndex); | 557 PropertyValueForSerializer top = m_propertySet.propertyAt(topValueIndex); |
558 PropertyValueForSerializer right = m_propertySet.propertyAt(rightValueIndex)
; | 558 PropertyValueForSerializer right = m_propertySet.propertyAt(rightValueIndex)
; |
559 PropertyValueForSerializer bottom = m_propertySet.propertyAt(bottomValueInde
x); | 559 PropertyValueForSerializer bottom = m_propertySet.propertyAt(bottomValueInde
x); |
560 PropertyValueForSerializer left = m_propertySet.propertyAt(leftValueIndex); | 560 PropertyValueForSerializer left = m_propertySet.propertyAt(leftValueIndex); |
561 | 561 |
562 // All 4 properties must be specified. | |
563 if (!top.value() || !right.value() || !bottom.value() || !left.value()) | |
564 return String(); | |
565 | |
566 if (top.isImportant() != right.isImportant() || right.isImportant() != botto
m.isImportant() || bottom.isImportant() != left.isImportant()) | 562 if (top.isImportant() != right.isImportant() || right.isImportant() != botto
m.isImportant() || bottom.isImportant() != left.isImportant()) |
567 return String(); | 563 return String(); |
568 | 564 |
569 if (top.isInherited() && right.isInherited() && bottom.isInherited() && left
.isInherited()) | 565 if (top.isInherited() && right.isInherited() && bottom.isInherited() && left
.isInherited()) |
570 return getValueName(CSSValueInherit); | 566 return getValueName(CSSValueInherit); |
571 | 567 |
572 unsigned numInitial = top.value()->isInitialValue() + right.value()->isIniti
alValue() + bottom.value()->isInitialValue() + left.value()->isInitialValue(); | 568 unsigned numInitial = top.value().isInitialValue() + right.value().isInitial
Value() + bottom.value().isInitialValue() + left.value().isInitialValue(); |
573 if (numInitial == 4) | 569 if (numInitial == 4) |
574 return getValueName(CSSValueInitial); | 570 return getValueName(CSSValueInitial); |
575 if (numInitial > 0) | 571 if (numInitial > 0) |
576 return String(); | 572 return String(); |
577 | 573 |
578 bool showLeft = !right.value()->equals(*left.value()); | 574 bool showLeft = !right.value().equals(left.value()); |
579 bool showBottom = !top.value()->equals(*bottom.value()) || showLeft; | 575 bool showBottom = !top.value().equals(bottom.value()) || showLeft; |
580 bool showRight = !top.value()->equals(*right.value()) || showBottom; | 576 bool showRight = !top.value().equals(right.value()) || showBottom; |
581 | 577 |
582 StringBuilder result; | 578 StringBuilder result; |
583 result.append(top.value()->cssText()); | 579 result.append(top.value().cssText()); |
584 if (showRight) { | 580 if (showRight) { |
585 result.append(' '); | 581 result.append(' '); |
586 result.append(right.value()->cssText()); | 582 result.append(right.value().cssText()); |
587 } | 583 } |
588 if (showBottom) { | 584 if (showBottom) { |
589 result.append(' '); | 585 result.append(' '); |
590 result.append(bottom.value()->cssText()); | 586 result.append(bottom.value().cssText()); |
591 } | 587 } |
592 if (showLeft) { | 588 if (showLeft) { |
593 result.append(' '); | 589 result.append(' '); |
594 result.append(left.value()->cssText()); | 590 result.append(left.value().cssText()); |
595 } | 591 } |
596 return result.toString(); | 592 return result.toString(); |
597 } | 593 } |
598 | 594 |
599 String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
thand& shorthand) const | 595 String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
thand& shorthand) const |
600 { | 596 { |
601 const unsigned size = shorthand.length(); | 597 const unsigned size = shorthand.length(); |
602 | 598 |
603 // Begin by collecting the properties into a vector. | 599 // Begin by collecting the properties into a vector. |
604 WillBeHeapVector<const CSSValue*> values(size); | 600 WillBeHeapVector<NullableCSSValue> values(size); |
605 // If the below loop succeeds, there should always be at minimum 1 layer. | 601 // If the below loop succeeds, there should always be at minimum 1 layer. |
606 size_t numLayers = 1U; | 602 size_t numLayers = 1U; |
607 | 603 |
608 for (size_t i = 0; i < size; i++) { | 604 for (size_t i = 0; i < size; i++) { |
609 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i])
; | 605 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i])
; |
610 // A shorthand is not available if getPropertyCSSValue didn't resolve to
anything. | 606 // A shorthand is not available if getPropertyCSSValue didn't resolve to
anything. |
611 if (!values[i]) | 607 if (!values[i]) |
612 return String(); | 608 return String(); |
613 if (values[i]->isBaseValueList()) { | 609 if (values[i]->isBaseValueList()) { |
614 const CSSValueList* valueList = toCSSValueList(values[i]); | 610 const CSSValueList* valueList = toCSSValueList(values[i]); |
615 numLayers = std::max(numLayers, valueList->length()); | 611 numLayers = std::max(numLayers, valueList->length()); |
616 } | 612 } |
617 } | 613 } |
618 | 614 |
619 StringBuilder result; | 615 StringBuilder result; |
620 // Tracks whether or not all the values are initial or all the values are in
herit. | 616 // Tracks whether or not all the values are initial or all the values are in
herit. |
621 // Start out assuming there is a common value. It will get set to false belo
w if there isn't one. | 617 // Start out assuming there is a common value. It will get set to false belo
w if there isn't one. |
622 bool hasCommonValue = true; | 618 bool hasCommonValue = true; |
623 const CSSValue* commonValue = nullptr; | 619 NullableCSSValue commonValue = nullptr; |
624 | 620 |
625 // Now stitch the properties together. Implicit initial values are flagged a
s such and | 621 // Now stitch the properties together. Implicit initial values are flagged a
s such and |
626 // can safely be omitted. | 622 // can safely be omitted. |
627 for (size_t layer = 0; layer < numLayers; layer++) { | 623 for (size_t layer = 0; layer < numLayers; layer++) { |
628 StringBuilder layerResult; | 624 StringBuilder layerResult; |
629 bool useRepeatXShorthand = false; | 625 bool useRepeatXShorthand = false; |
630 bool useRepeatYShorthand = false; | 626 bool useRepeatYShorthand = false; |
631 bool useSingleWordShorthand = false; | 627 bool useSingleWordShorthand = false; |
632 bool foundPositionYCSSProperty = false; | 628 bool foundPositionYCSSProperty = false; |
633 | 629 |
634 for (unsigned propertyIndex = 0; propertyIndex < size; propertyIndex++)
{ | 630 for (unsigned propertyIndex = 0; propertyIndex < size; propertyIndex++)
{ |
635 const CSSValue* value = nullptr; | 631 NullableCSSValue value = nullptr; |
636 CSSPropertyID property = shorthand.properties()[propertyIndex]; | 632 CSSPropertyID property = shorthand.properties()[propertyIndex]; |
637 | 633 |
638 // Get a CSSValue for this property and layer. | 634 // Get a CSSValue for this property and layer. |
639 if (values[propertyIndex]->isBaseValueList()) { | 635 if (values[propertyIndex]->isBaseValueList()) { |
640 // Might return 0 if there is not an item for this layer for thi
s property. | 636 // Might return 0 if there is not an item for this layer for thi
s property. |
641 value = toCSSValueList(values[propertyIndex])->itemWithBoundsChe
ck(layer); | 637 value = toCSSValueList(values[propertyIndex])->itemWithBoundsChe
ck(layer); |
642 } else if (layer == 0 || (layer != numLayers - 1 && property == CSSP
ropertyBackgroundColor)) { | 638 } else if (layer == 0 || (layer != numLayers - 1 && property == CSSP
ropertyBackgroundColor)) { |
643 // Singletons except background color belong in the 0th layer. | 639 // Singletons except background color belong in the 0th layer. |
644 // Background color belongs in the last layer. | 640 // Background color belongs in the last layer. |
645 value = values[propertyIndex]; | 641 value = values[propertyIndex]; |
646 } | 642 } |
647 // No point proceeding if there's not a value to look at. | 643 // No point proceeding if there's not a value to look at. |
648 if (!value) | 644 if (!value) |
649 continue; | 645 continue; |
650 | 646 |
651 // Special case for background-repeat. | 647 // Special case for background-repeat. |
652 if ((propertyIndex < size - 1 && m_propertySet.isPropertyImplicit(pr
operty)) | 648 if ((propertyIndex < size - 1 && m_propertySet.isPropertyImplicit(pr
operty)) |
653 && (property == CSSPropertyBackgroundRepeatX || property == CSSP
ropertyWebkitMaskRepeatX)) { | 649 && (property == CSSPropertyBackgroundRepeatX || property == CSSP
ropertyWebkitMaskRepeatX)) { |
654 ASSERT(shorthand.properties()[propertyIndex + 1] == CSSPropertyB
ackgroundRepeatY | 650 ASSERT(shorthand.properties()[propertyIndex + 1] == CSSPropertyB
ackgroundRepeatY |
655 || shorthand.properties()[propertyIndex + 1] == CSSPropertyW
ebkitMaskRepeatY); | 651 || shorthand.properties()[propertyIndex + 1] == CSSPropertyW
ebkitMaskRepeatY); |
656 const CSSValue* yValue = values[propertyIndex + 1]->isValueList(
) ? | 652 NullableCSSValue yValue = values[propertyIndex + 1]->isValueList
() ? |
657 toCSSValueList(values[propertyIndex + 1])->item(layer) : val
ues[propertyIndex + 1]; | 653 toCSSValueList(values[propertyIndex + 1])->item(layer) : val
ues[propertyIndex + 1]; |
658 | 654 |
659 | 655 |
660 // FIXME: At some point we need to fix this code to avoid return
ing an invalid shorthand, | 656 // FIXME: At some point we need to fix this code to avoid return
ing an invalid shorthand, |
661 // since some longhand combinations are not serializable into a
single shorthand. | 657 // since some longhand combinations are not serializable into a
single shorthand. |
662 if (!value->isPrimitiveValue() || !yValue->isPrimitiveValue()) | 658 if (!value->isPrimitiveValue() || !yValue->isPrimitiveValue()) |
663 continue; | 659 continue; |
664 | 660 |
665 CSSValueID xId = toCSSPrimitiveValue(value)->getValueID(); | 661 CSSValueID xId = toCSSPrimitiveValue(value)->getValueID(); |
666 CSSValueID yId = toCSSPrimitiveValue(yValue)->getValueID(); | 662 CSSValueID yId = toCSSPrimitiveValue(yValue)->getValueID(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 return commonValue->cssText(); | 720 return commonValue->cssText(); |
725 | 721 |
726 return result.toString(); | 722 return result.toString(); |
727 } | 723 } |
728 | 724 |
729 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const | 725 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const |
730 { | 726 { |
731 String commonValue; | 727 String commonValue; |
732 StringBuilder result; | 728 StringBuilder result; |
733 for (unsigned i = 0; i < shorthand.length(); ++i) { | 729 for (unsigned i = 0; i < shorthand.length(); ++i) { |
734 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 730 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
735 if (!value) | 731 if (!value) |
736 return String(); | 732 return String(); |
737 String valueText = value->cssText(); | 733 String valueText = value->cssText(); |
738 if (!i) | 734 if (!i) |
739 commonValue = valueText; | 735 commonValue = valueText; |
740 else if (!commonValue.isNull() && commonValue != valueText) | 736 else if (!commonValue.isNull() && commonValue != valueText) |
741 commonValue = String(); | 737 commonValue = String(); |
742 if (value->isInitialValue()) | 738 if (value->isInitialValue()) |
743 continue; | 739 continue; |
744 if (!result.isEmpty()) | 740 if (!result.isEmpty()) |
745 result.append(separator); | 741 result.append(separator); |
746 result.append(valueText); | 742 result.append(valueText); |
747 } | 743 } |
748 if (isInitialOrInherit(commonValue)) | 744 if (isInitialOrInherit(commonValue)) |
749 return commonValue; | 745 return commonValue; |
750 return result.toString(); | 746 return result.toString(); |
751 } | 747 } |
752 | 748 |
753 // only returns a non-null value if all properties have the same, non-null value | 749 // only returns a non-null value if all properties have the same, non-null value |
754 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const | 750 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const |
755 { | 751 { |
756 String res; | 752 String res; |
757 bool lastPropertyWasImportant = false; | 753 bool lastPropertyWasImportant = false; |
758 for (unsigned i = 0; i < shorthand.length(); ++i) { | 754 for (unsigned i = 0; i < shorthand.length(); ++i) { |
759 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 755 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
760 // FIXME: CSSInitialValue::cssText should generate the right value. | 756 // FIXME: CSSInitialValue::cssText should generate the right value. |
761 if (!value) | 757 if (!value) |
762 return String(); | 758 return String(); |
763 String text = value->cssText(); | 759 String text = value->cssText(); |
764 if (text.isNull()) | 760 if (text.isNull()) |
765 return String(); | 761 return String(); |
766 if (res.isNull()) | 762 if (res.isNull()) |
767 res = text; | 763 res = text; |
768 else if (res != text) | 764 else if (res != text) |
769 return String(); | 765 return String(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 builder.appendLiteral("repeat-x"); | 816 builder.appendLiteral("repeat-x"); |
821 } else { | 817 } else { |
822 builder.append(repeatX.cssText()); | 818 builder.append(repeatX.cssText()); |
823 builder.appendLiteral(" "); | 819 builder.appendLiteral(" "); |
824 builder.append(repeatY.cssText()); | 820 builder.append(repeatY.cssText()); |
825 } | 821 } |
826 } | 822 } |
827 | 823 |
828 String StylePropertySerializer::backgroundRepeatPropertyValue() const | 824 String StylePropertySerializer::backgroundRepeatPropertyValue() const |
829 { | 825 { |
830 const CSSValue* repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatX); | 826 const NullableCSSValue repeatX = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundRepeatX); |
831 const CSSValue* repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatY); | 827 const NullableCSSValue repeatY = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundRepeatY); |
832 if (!repeatX || !repeatY) | 828 if (!repeatX || !repeatY) |
833 return String(); | 829 return String(); |
834 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) | 830 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) |
835 return String(); | 831 return String(); |
836 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is
InheritedValue() && repeatY->isInheritedValue())) | 832 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is
InheritedValue() && repeatY->isInheritedValue())) |
837 return repeatX->cssText(); | 833 return repeatX->cssText(); |
838 | 834 |
839 const CSSValueList* repeatXList = 0; | 835 const CSSValueList* repeatXList = 0; |
840 int repeatXLength = 1; | 836 int repeatXLength = 1; |
841 if (repeatX->isValueList()) { | 837 if (repeatX->isValueList()) { |
(...skipping 11 matching lines...) Expand all Loading... |
853 } else if (!repeatY->isPrimitiveValue()) { | 849 } else if (!repeatY->isPrimitiveValue()) { |
854 return String(); | 850 return String(); |
855 } | 851 } |
856 | 852 |
857 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); | 853 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); |
858 StringBuilder builder; | 854 StringBuilder builder; |
859 for (size_t i = 0; i < shorthandLength; ++i) { | 855 for (size_t i = 0; i < shorthandLength; ++i) { |
860 if (i) | 856 if (i) |
861 builder.appendLiteral(", "); | 857 builder.appendLiteral(", "); |
862 | 858 |
863 const CSSValue* xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 859 const CSSValue xValue = repeatXList ? repeatXList->item(i % repeatXList-
>length()) : *repeatX; |
864 const CSSValue* yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 860 const CSSValue yValue = repeatYList ? repeatYList->item(i % repeatYList-
>length()) : *repeatY; |
865 appendBackgroundRepeatValue(builder, *xValue, *yValue); | 861 appendBackgroundRepeatValue(builder, xValue, yValue); |
866 } | 862 } |
867 return builder.toString(); | 863 return builder.toString(); |
868 } | 864 } |
869 | 865 |
870 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const | 866 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const |
871 { | 867 { |
872 if (isPropertyShorthandAvailable(backgroundShorthand())) { | 868 if (isPropertyShorthandAvailable(backgroundShorthand())) { |
873 String backgroundValue = getPropertyValue(CSSPropertyBackground); | 869 String backgroundValue = getPropertyValue(CSSPropertyBackground); |
874 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 870 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
875 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); | 871 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); |
876 return; | 872 return; |
877 } | 873 } |
878 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { | 874 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { |
879 const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBac
kgroundImage); | 875 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp
ertyBackgroundImage); |
| 876 ASSERT(value); |
880 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 877 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
881 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); | 878 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); |
882 return; | 879 return; |
883 } | 880 } |
884 | 881 |
885 // backgroundShorthandProperty without layered shorhand properties | 882 // backgroundShorthandProperty without layered shorhand properties |
886 const CSSPropertyID backgroundPropertyIds[] = { | 883 const CSSPropertyID backgroundPropertyIds[] = { |
887 CSSPropertyBackgroundImage, | 884 CSSPropertyBackgroundImage, |
888 CSSPropertyBackgroundAttachment, | 885 CSSPropertyBackgroundAttachment, |
889 CSSPropertyBackgroundColor, | 886 CSSPropertyBackgroundColor, |
890 CSSPropertyBackgroundSize, | 887 CSSPropertyBackgroundSize, |
891 CSSPropertyBackgroundOrigin, | 888 CSSPropertyBackgroundOrigin, |
892 CSSPropertyBackgroundClip | 889 CSSPropertyBackgroundClip |
893 }; | 890 }; |
894 | 891 |
895 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { | 892 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { |
896 CSSPropertyID propertyID = backgroundPropertyIds[i]; | 893 CSSPropertyID propertyID = backgroundPropertyIds[i]; |
897 const CSSValue* value = m_propertySet.getPropertyCSSValue(propertyID); | 894 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(propert
yID); |
898 if (!value) | 895 if (!value) |
899 continue; | 896 continue; |
900 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); | 897 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); |
901 } | 898 } |
902 | 899 |
903 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. | 900 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. |
904 // It is required because background-position-x/y are non-standard propertie
s and WebKit generated output | 901 // It is required because background-position-x/y are non-standard propertie
s and WebKit generated output |
905 // would not work in Firefox (<rdar://problem/5143183>) | 902 // would not work in Firefox (<rdar://problem/5143183>) |
906 // It would be a better solution if background-position was CSS_PAIR. | 903 // It would be a better solution if background-position was CSS_PAIR. |
907 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ | 904 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ |
908 const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBac
kgroundPositionX); | 905 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp
ertyBackgroundPositionX); |
| 906 ASSERT(value); |
909 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 907 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
910 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); | 908 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); |
911 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { | 909 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { |
912 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); | 910 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); |
913 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 911 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
914 if (!positionValue.isNull()) | 912 if (!positionValue.isNull()) |
915 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); | 913 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); |
916 } else { | 914 } else { |
917 // should check background-position-x or background-position-y. | 915 // should check background-position-x or background-position-y. |
918 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yBackgroundPositionX)) { | 916 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundPositionX)) { |
919 if (!value->isImplicitInitialValue()) { | 917 if (value && !value->isImplicitInitialValue()) { |
920 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); | 918 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); |
921 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); | 919 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); |
922 } | 920 } |
923 } | 921 } |
924 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yBackgroundPositionY)) { | 922 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundPositionY)) { |
925 if (!value->isImplicitInitialValue()) { | 923 if (value && !value->isImplicitInitialValue()) { |
926 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); | 924 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); |
927 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); | 925 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); |
928 } | 926 } |
929 } | 927 } |
930 } | 928 } |
931 | 929 |
932 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); | 930 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); |
933 if (!repeatValue.isNull()) | 931 if (!repeatValue.isNull()) |
934 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); | 932 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); |
935 } | 933 } |
936 | 934 |
937 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const | 935 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const |
938 { | 936 { |
939 ASSERT(shorthand.length() > 0); | 937 ASSERT(shorthand.length() > 0); |
940 | 938 |
941 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 939 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
942 for (unsigned i = 0; i < shorthand.length(); ++i) { | 940 for (unsigned i = 0; i < shorthand.length(); ++i) { |
943 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 941 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
944 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) | 942 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) |
945 return false; | 943 return false; |
946 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 944 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
947 return false; | 945 return false; |
948 } | 946 } |
949 return true; | 947 return true; |
950 } | 948 } |
951 | 949 |
952 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const | 950 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const |
953 { | 951 { |
954 ASSERT(shorthand.length() > 0); | 952 ASSERT(shorthand.length() > 0); |
955 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 953 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
956 bool isInitialValue = true; | 954 bool isInitialValue = true; |
957 bool isInheritedValue = true; | 955 bool isInheritedValue = true; |
958 for (unsigned i = 0; i < shorthand.length(); ++i) { | 956 for (unsigned i = 0; i < shorthand.length(); ++i) { |
959 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 957 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
960 if (!value) | 958 if (!value) |
961 return false; | 959 return false; |
962 if (!value->isInitialValue()) | 960 if (!value->isInitialValue()) |
963 isInitialValue = false; | 961 isInitialValue = false; |
964 if (!value->isInheritedValue()) | 962 if (!value->isInheritedValue()) |
965 isInheritedValue = false; | 963 isInheritedValue = false; |
966 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 964 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
967 return false; | 965 return false; |
968 } | 966 } |
969 return isInitialValue || isInheritedValue; | 967 return isInitialValue || isInheritedValue; |
970 } | 968 } |
971 | 969 |
972 } | 970 } |
OLD | NEW |