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) |
(...skipping 24 matching lines...) Expand all Loading... |
501 break; | 501 break; |
502 case CSSPropertyLineHeight: | 502 case CSSPropertyLineHeight: |
503 prefix = '/'; | 503 prefix = '/'; |
504 break; | 504 break; |
505 default: | 505 default: |
506 ASSERT_NOT_REACHED(); | 506 ASSERT_NOT_REACHED(); |
507 } | 507 } |
508 | 508 |
509 if (prefix && !result.isEmpty()) | 509 if (prefix && !result.isEmpty()) |
510 result.append(prefix); | 510 result.append(prefix); |
511 String value = m_propertySet.propertyAt(foundPropertyIndex).value()->cssText
(); | 511 String value = m_propertySet.propertyAt(foundPropertyIndex).value().cssText(
); |
512 result.append(value); | 512 result.append(value); |
513 if (!commonValue.isNull() && commonValue != value) | 513 if (!commonValue.isNull() && commonValue != value) |
514 commonValue = String(); | 514 commonValue = String(); |
515 } | 515 } |
516 | 516 |
517 String StylePropertySerializer::fontValue() const | 517 String StylePropertySerializer::fontValue() const |
518 { | 518 { |
519 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS
ize); | 519 int fontSizePropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFontS
ize); |
520 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon
tFamily); | 520 int fontFamilyPropertyIndex = m_propertySet.findPropertyIndex(CSSPropertyFon
tFamily); |
521 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) | 521 if (fontSizePropertyIndex == -1 || fontFamilyPropertyIndex == -1) |
522 return emptyString(); | 522 return emptyString(); |
523 | 523 |
524 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS
izePropertyIndex); | 524 PropertyValueForSerializer fontSizeProperty = m_propertySet.propertyAt(fontS
izePropertyIndex); |
525 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon
tFamilyPropertyIndex); | 525 PropertyValueForSerializer fontFamilyProperty = m_propertySet.propertyAt(fon
tFamilyPropertyIndex); |
526 if (fontSizeProperty.isImplicit() || fontFamilyProperty.isImplicit()) | 526 if (fontSizeProperty.isImplicit() || fontFamilyProperty.isImplicit()) |
527 return emptyString(); | 527 return emptyString(); |
528 | 528 |
529 String commonValue = fontSizeProperty.value()->cssText(); | 529 String commonValue = fontSizeProperty.value().cssText(); |
530 StringBuilder result; | 530 StringBuilder result; |
531 appendFontLonghandValueIfExplicit(CSSPropertyFontStyle, result, commonValue)
; | 531 appendFontLonghandValueIfExplicit(CSSPropertyFontStyle, result, commonValue)
; |
532 appendFontLonghandValueIfExplicit(CSSPropertyFontVariant, result, commonValu
e); | 532 appendFontLonghandValueIfExplicit(CSSPropertyFontVariant, result, commonValu
e); |
533 appendFontLonghandValueIfExplicit(CSSPropertyFontWeight, result, commonValue
); | 533 appendFontLonghandValueIfExplicit(CSSPropertyFontWeight, result, commonValue
); |
534 appendFontLonghandValueIfExplicit(CSSPropertyFontStretch, result, commonValu
e); | 534 appendFontLonghandValueIfExplicit(CSSPropertyFontStretch, result, commonValu
e); |
535 if (!result.isEmpty()) | 535 if (!result.isEmpty()) |
536 result.append(' '); | 536 result.append(' '); |
537 result.append(fontSizeProperty.value()->cssText()); | 537 result.append(fontSizeProperty.value().cssText()); |
538 appendFontLonghandValueIfExplicit(CSSPropertyLineHeight, result, commonValue
); | 538 appendFontLonghandValueIfExplicit(CSSPropertyLineHeight, result, commonValue
); |
539 if (!result.isEmpty()) | 539 if (!result.isEmpty()) |
540 result.append(' '); | 540 result.append(' '); |
541 result.append(fontFamilyProperty.value()->cssText()); | 541 result.append(fontFamilyProperty.value().cssText()); |
542 if (isInitialOrInherit(commonValue)) | 542 if (isInitialOrInherit(commonValue)) |
543 return commonValue; | 543 return commonValue; |
544 return result.toString(); | 544 return result.toString(); |
545 } | 545 } |
546 | 546 |
547 String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha
nd) const | 547 String StylePropertySerializer::get4Values(const StylePropertyShorthand& shortha
nd) const |
548 { | 548 { |
549 // Assume the properties are in the usual order top, right, bottom, left. | 549 // Assume the properties are in the usual order top, right, bottom, left. |
550 int topValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[0
]); | 550 int topValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[0
]); |
551 int rightValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()
[1]); | 551 int rightValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()
[1]); |
552 int bottomValueIndex = m_propertySet.findPropertyIndex(shorthand.properties(
)[2]); | 552 int bottomValueIndex = m_propertySet.findPropertyIndex(shorthand.properties(
)[2]); |
553 int leftValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[
3]); | 553 int leftValueIndex = m_propertySet.findPropertyIndex(shorthand.properties()[
3]); |
554 | 554 |
555 if (topValueIndex == -1 || rightValueIndex == -1 || bottomValueIndex == -1 |
| leftValueIndex == -1) | 555 if (topValueIndex == -1 || rightValueIndex == -1 || bottomValueIndex == -1 |
| leftValueIndex == -1) |
556 return String(); | 556 return String(); |
557 | 557 |
558 PropertyValueForSerializer top = m_propertySet.propertyAt(topValueIndex); | 558 PropertyValueForSerializer top = m_propertySet.propertyAt(topValueIndex); |
559 PropertyValueForSerializer right = m_propertySet.propertyAt(rightValueIndex)
; | 559 PropertyValueForSerializer right = m_propertySet.propertyAt(rightValueIndex)
; |
560 PropertyValueForSerializer bottom = m_propertySet.propertyAt(bottomValueInde
x); | 560 PropertyValueForSerializer bottom = m_propertySet.propertyAt(bottomValueInde
x); |
561 PropertyValueForSerializer left = m_propertySet.propertyAt(leftValueIndex); | 561 PropertyValueForSerializer left = m_propertySet.propertyAt(leftValueIndex); |
562 | 562 |
563 // All 4 properties must be specified. | |
564 if (!top.value() || !right.value() || !bottom.value() || !left.value()) | |
565 return String(); | |
566 | |
567 if (top.isImportant() != right.isImportant() || right.isImportant() != botto
m.isImportant() || bottom.isImportant() != left.isImportant()) | 563 if (top.isImportant() != right.isImportant() || right.isImportant() != botto
m.isImportant() || bottom.isImportant() != left.isImportant()) |
568 return String(); | 564 return String(); |
569 | 565 |
570 if (top.isInherited() && right.isInherited() && bottom.isInherited() && left
.isInherited()) | 566 if (top.isInherited() && right.isInherited() && bottom.isInherited() && left
.isInherited()) |
571 return getValueName(CSSValueInherit); | 567 return getValueName(CSSValueInherit); |
572 | 568 |
573 unsigned numInitial = top.value()->isInitialValue() + right.value()->isIniti
alValue() + bottom.value()->isInitialValue() + left.value()->isInitialValue(); | 569 unsigned numInitial = top.value().isInitialValue() + right.value().isInitial
Value() + bottom.value().isInitialValue() + left.value().isInitialValue(); |
574 if (numInitial == 4) | 570 if (numInitial == 4) |
575 return getValueName(CSSValueInitial); | 571 return getValueName(CSSValueInitial); |
576 if (numInitial > 0) | 572 if (numInitial > 0) |
577 return String(); | 573 return String(); |
578 | 574 |
579 bool showLeft = !right.value()->equals(*left.value()); | 575 bool showLeft = !right.value().equals(left.value()); |
580 bool showBottom = !top.value()->equals(*bottom.value()) || showLeft; | 576 bool showBottom = !top.value().equals(bottom.value()) || showLeft; |
581 bool showRight = !top.value()->equals(*right.value()) || showBottom; | 577 bool showRight = !top.value().equals(right.value()) || showBottom; |
582 | 578 |
583 StringBuilder result; | 579 StringBuilder result; |
584 result.append(top.value()->cssText()); | 580 result.append(top.value().cssText()); |
585 if (showRight) { | 581 if (showRight) { |
586 result.append(' '); | 582 result.append(' '); |
587 result.append(right.value()->cssText()); | 583 result.append(right.value().cssText()); |
588 } | 584 } |
589 if (showBottom) { | 585 if (showBottom) { |
590 result.append(' '); | 586 result.append(' '); |
591 result.append(bottom.value()->cssText()); | 587 result.append(bottom.value().cssText()); |
592 } | 588 } |
593 if (showLeft) { | 589 if (showLeft) { |
594 result.append(' '); | 590 result.append(' '); |
595 result.append(left.value()->cssText()); | 591 result.append(left.value().cssText()); |
596 } | 592 } |
597 return result.toString(); | 593 return result.toString(); |
598 } | 594 } |
599 | 595 |
600 String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
thand& shorthand, bool checkShorthandAvailable) const | 596 String StylePropertySerializer::getLayeredShorthandValue(const StylePropertyShor
thand& shorthand, bool checkShorthandAvailable) const |
601 { | 597 { |
602 StringBuilder result; | 598 StringBuilder result; |
603 | 599 |
604 const unsigned size = shorthand.length(); | 600 const unsigned size = shorthand.length(); |
605 // Begin by collecting the properties into an array. | 601 // Begin by collecting the properties into an array. |
606 WillBeHeapVector<const CSSValue*> values(size); | 602 WillBeHeapVector<NullableCSSValue> values(size); |
607 size_t numLayers = 0; | 603 size_t numLayers = 0; |
608 | 604 |
609 for (unsigned i = 0; i < size; ++i) { | 605 for (unsigned i = 0; i < size; ++i) { |
610 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i])
; | 606 values[i] = m_propertySet.getPropertyCSSValue(shorthand.properties()[i])
; |
611 if (values[i]) { | 607 if (values[i]) { |
612 if (values[i]->isBaseValueList()) { | 608 if (values[i]->isBaseValueList()) { |
613 const CSSValueList* valueList = toCSSValueList(values[i]); | 609 const CSSValueList* valueList = toCSSValueList(values[i]); |
614 numLayers = std::max(valueList->length(), numLayers); | 610 numLayers = std::max(valueList->length(), numLayers); |
615 } else { | 611 } else { |
616 numLayers = std::max<size_t>(1U, numLayers); | 612 numLayers = std::max<size_t>(1U, numLayers); |
617 } | 613 } |
618 } else if (checkShorthandAvailable) { | 614 } else if (checkShorthandAvailable) { |
619 return String(); | 615 return String(); |
620 } | 616 } |
621 } | 617 } |
622 | 618 |
623 | 619 |
624 String commonValue; | 620 String commonValue; |
625 bool commonValueInitialized = false; | 621 bool commonValueInitialized = false; |
626 | 622 |
627 // Now stitch the properties together. Implicit initial values are flagged a
s such and | 623 // Now stitch the properties together. Implicit initial values are flagged a
s such and |
628 // can safely be omitted. | 624 // can safely be omitted. |
629 for (size_t i = 0; i < numLayers; i++) { | 625 for (size_t i = 0; i < numLayers; i++) { |
630 StringBuilder layerResult; | 626 StringBuilder layerResult; |
631 bool useRepeatXShorthand = false; | 627 bool useRepeatXShorthand = false; |
632 bool useRepeatYShorthand = false; | 628 bool useRepeatYShorthand = false; |
633 bool useSingleWordShorthand = false; | 629 bool useSingleWordShorthand = false; |
634 bool foundPositionYCSSProperty = false; | 630 bool foundPositionYCSSProperty = false; |
635 for (unsigned j = 0; j < size; j++) { | 631 for (unsigned j = 0; j < size; j++) { |
636 const CSSValue* value = 0; | 632 NullableCSSValue value; |
637 if (values[j]) { | 633 if (values[j]) { |
638 if (values[j]->isBaseValueList()) { | 634 if (values[j]->isBaseValueList()) { |
639 value = toCSSValueList(values[j])->itemWithBoundsCheck(i); | 635 value = toCSSValueList(values[j])->itemWithBoundsCheck(i); |
640 } else { | 636 } else { |
641 value = values[j]; | 637 value = values[j]; |
642 | 638 |
643 // Color only belongs in the last layer. | 639 // Color only belongs in the last layer. |
644 if (shorthand.properties()[j] == CSSPropertyBackgroundColor)
{ | 640 if (shorthand.properties()[j] == CSSPropertyBackgroundColor)
{ |
645 if (i != numLayers - 1) | 641 if (i != numLayers - 1) |
646 value = 0; | 642 value = nullptr; |
647 } else if (i) { | 643 } else if (i) { |
648 // Other singletons only belong in the first layer. | 644 // Other singletons only belong in the first layer. |
649 value = 0; | 645 value = nullptr; |
650 } | 646 } |
651 } | 647 } |
652 } | 648 } |
653 | 649 |
654 // We need to report background-repeat as it was written in the CSS.
If the property is implicit, | 650 // We need to report background-repeat as it was written in the CSS.
If the property is implicit, |
655 // then it was written with only one value. Here we figure out which
value that was so we can | 651 // then it was written with only one value. Here we figure out which
value that was so we can |
656 // report back correctly. | 652 // report back correctly. |
657 if ((shorthand.properties()[j] == CSSPropertyBackgroundRepeatX && m_
propertySet.isPropertyImplicit(shorthand.properties()[j])) | 653 if ((shorthand.properties()[j] == CSSPropertyBackgroundRepeatX && m_
propertySet.isPropertyImplicit(shorthand.properties()[j])) |
658 || (shorthand.properties()[j] == CSSPropertyWebkitMaskRepeatX &&
m_propertySet.isPropertyImplicit(shorthand.properties()[j]))) { | 654 || (shorthand.properties()[j] == CSSPropertyWebkitMaskRepeatX &&
m_propertySet.isPropertyImplicit(shorthand.properties()[j]))) { |
659 | 655 |
660 // BUG 49055: make sure the value was not reset in the layer che
ck just above. | 656 // BUG 49055: make sure the value was not reset in the layer che
ck just above. |
661 if ((j < size - 1 && shorthand.properties()[j + 1] == CSSPropert
yBackgroundRepeatY && value) | 657 if ((j < size - 1 && shorthand.properties()[j + 1] == CSSPropert
yBackgroundRepeatY && value) |
662 || (j < size - 1 && shorthand.properties()[j + 1] == CSSProp
ertyWebkitMaskRepeatY && value)) { | 658 || (j < size - 1 && shorthand.properties()[j + 1] == CSSProp
ertyWebkitMaskRepeatY && value)) { |
663 const CSSValue* yValue = 0; | 659 NullableCSSValue nextValue = values[j + 1]; |
664 const CSSValue* nextValue = values[j + 1]; | 660 NullableCSSValue yValue = nextValue; |
665 if (nextValue->isValueList()) | 661 if (nextValue && nextValue->isValueList()) |
666 yValue = toCSSValueList(nextValue)->item(i); | 662 yValue = toCSSValueList(nextValue)->item(i); |
667 else | |
668 yValue = nextValue; | |
669 | 663 |
670 // background-repeat-x(y) or mask-repeat-x(y) may be like th
is : "initial, repeat". We can omit the implicit initial values | 664 // background-repeat-x(y) or mask-repeat-x(y) may be like th
is : "initial, repeat". We can omit the implicit initial values |
671 // before starting to compare their values. | 665 // before starting to compare their values. |
672 if (value->isImplicitInitialValue() || yValue->isImplicitIni
tialValue()) | 666 if (value->isImplicitInitialValue() || yValue->isImplicitIni
tialValue()) |
673 continue; | 667 continue; |
674 | 668 |
675 // FIXME: At some point we need to fix this code to avoid re
turning an invalid shorthand, | 669 // FIXME: At some point we need to fix this code to avoid re
turning an invalid shorthand, |
676 // since some longhand combinations are not serializable int
o a single shorthand. | 670 // since some longhand combinations are not serializable int
o a single shorthand. |
677 if (!value->isPrimitiveValue() || !yValue->isPrimitiveValue(
)) | 671 if (!value->isPrimitiveValue() || !yValue->isPrimitiveValue(
)) |
678 continue; | 672 continue; |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
750 return String(); | 744 return String(); |
751 return result.toString(); | 745 return result.toString(); |
752 } | 746 } |
753 | 747 |
754 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const | 748 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const |
755 { | 749 { |
756 String commonValue; | 750 String commonValue; |
757 StringBuilder result; | 751 StringBuilder result; |
758 for (unsigned i = 0; i < shorthand.length(); ++i) { | 752 for (unsigned i = 0; i < shorthand.length(); ++i) { |
759 if (!m_propertySet.isPropertyImplicit(shorthand.properties()[i])) { | 753 if (!m_propertySet.isPropertyImplicit(shorthand.properties()[i])) { |
760 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.
properties()[i]); | 754 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(sho
rthand.properties()[i]); |
761 if (!value) | 755 if (!value) |
762 return String(); | 756 return String(); |
763 String valueText = value->cssText(); | 757 String valueText = value->cssText(); |
764 if (!i) | 758 if (!i) |
765 commonValue = valueText; | 759 commonValue = valueText; |
766 else if (!commonValue.isNull() && commonValue != valueText) | 760 else if (!commonValue.isNull() && commonValue != valueText) |
767 commonValue = String(); | 761 commonValue = String(); |
768 if (value->isInitialValue()) | 762 if (value->isInitialValue()) |
769 continue; | 763 continue; |
770 if (!result.isEmpty()) | 764 if (!result.isEmpty()) |
771 result.append(separator); | 765 result.append(separator); |
772 result.append(valueText); | 766 result.append(valueText); |
773 } else | 767 } else |
774 commonValue = String(); | 768 commonValue = String(); |
775 } | 769 } |
776 if (isInitialOrInherit(commonValue)) | 770 if (isInitialOrInherit(commonValue)) |
777 return commonValue; | 771 return commonValue; |
778 if (result.isEmpty()) | 772 if (result.isEmpty()) |
779 return String(); | 773 return String(); |
780 return result.toString(); | 774 return result.toString(); |
781 } | 775 } |
782 | 776 |
783 // only returns a non-null value if all properties have the same, non-null value | 777 // only returns a non-null value if all properties have the same, non-null value |
784 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const | 778 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const |
785 { | 779 { |
786 String res; | 780 String res; |
787 bool lastPropertyWasImportant = false; | 781 bool lastPropertyWasImportant = false; |
788 for (unsigned i = 0; i < shorthand.length(); ++i) { | 782 for (unsigned i = 0; i < shorthand.length(); ++i) { |
789 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 783 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
790 // FIXME: CSSInitialValue::cssText should generate the right value. | 784 // FIXME: CSSInitialValue::cssText should generate the right value. |
791 if (!value) | 785 if (!value) |
792 return String(); | 786 return String(); |
793 String text = value->cssText(); | 787 String text = value->cssText(); |
794 if (text.isNull()) | 788 if (text.isNull()) |
795 return String(); | 789 return String(); |
796 if (res.isNull()) | 790 if (res.isNull()) |
797 res = text; | 791 res = text; |
798 else if (res != text) | 792 else if (res != text) |
799 return String(); | 793 return String(); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
850 builder.appendLiteral("repeat-x"); | 844 builder.appendLiteral("repeat-x"); |
851 } else { | 845 } else { |
852 builder.append(repeatX.cssText()); | 846 builder.append(repeatX.cssText()); |
853 builder.appendLiteral(" "); | 847 builder.appendLiteral(" "); |
854 builder.append(repeatY.cssText()); | 848 builder.append(repeatY.cssText()); |
855 } | 849 } |
856 } | 850 } |
857 | 851 |
858 String StylePropertySerializer::backgroundRepeatPropertyValue() const | 852 String StylePropertySerializer::backgroundRepeatPropertyValue() const |
859 { | 853 { |
860 const CSSValue* repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatX); | 854 const NullableCSSValue repeatX = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundRepeatX); |
861 const CSSValue* repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatY); | 855 const NullableCSSValue repeatY = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundRepeatY); |
862 if (!repeatX || !repeatY) | 856 if (!repeatX || !repeatY) |
863 return String(); | 857 return String(); |
864 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) | 858 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) |
865 return String(); | 859 return String(); |
866 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is
InheritedValue() && repeatY->isInheritedValue())) | 860 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is
InheritedValue() && repeatY->isInheritedValue())) |
867 return repeatX->cssText(); | 861 return repeatX->cssText(); |
868 | 862 |
869 const CSSValueList* repeatXList = 0; | 863 const CSSValueList* repeatXList = 0; |
870 int repeatXLength = 1; | 864 int repeatXLength = 1; |
871 if (repeatX->isValueList()) { | 865 if (repeatX->isValueList()) { |
(...skipping 11 matching lines...) Expand all Loading... |
883 } else if (!repeatY->isPrimitiveValue()) { | 877 } else if (!repeatY->isPrimitiveValue()) { |
884 return String(); | 878 return String(); |
885 } | 879 } |
886 | 880 |
887 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); | 881 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); |
888 StringBuilder builder; | 882 StringBuilder builder; |
889 for (size_t i = 0; i < shorthandLength; ++i) { | 883 for (size_t i = 0; i < shorthandLength; ++i) { |
890 if (i) | 884 if (i) |
891 builder.appendLiteral(", "); | 885 builder.appendLiteral(", "); |
892 | 886 |
893 const CSSValue* xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 887 const CSSValue xValue = repeatXList ? repeatXList->item(i % repeatXList-
>length()) : *repeatX; |
894 const CSSValue* yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 888 const CSSValue yValue = repeatYList ? repeatYList->item(i % repeatYList-
>length()) : *repeatY; |
895 appendBackgroundRepeatValue(builder, *xValue, *yValue); | 889 appendBackgroundRepeatValue(builder, xValue, yValue); |
896 } | 890 } |
897 return builder.toString(); | 891 return builder.toString(); |
898 } | 892 } |
899 | 893 |
900 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const | 894 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const |
901 { | 895 { |
902 if (isPropertyShorthandAvailable(backgroundShorthand())) { | 896 if (isPropertyShorthandAvailable(backgroundShorthand())) { |
903 String backgroundValue = getPropertyValue(CSSPropertyBackground); | 897 String backgroundValue = getPropertyValue(CSSPropertyBackground); |
904 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 898 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
905 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); | 899 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); |
906 return; | 900 return; |
907 } | 901 } |
908 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { | 902 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { |
909 const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBac
kgroundImage); | 903 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp
ertyBackgroundImage); |
| 904 ASSERT(value); |
910 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 905 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
911 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); | 906 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); |
912 return; | 907 return; |
913 } | 908 } |
914 | 909 |
915 // backgroundShorthandProperty without layered shorhand properties | 910 // backgroundShorthandProperty without layered shorhand properties |
916 const CSSPropertyID backgroundPropertyIds[] = { | 911 const CSSPropertyID backgroundPropertyIds[] = { |
917 CSSPropertyBackgroundImage, | 912 CSSPropertyBackgroundImage, |
918 CSSPropertyBackgroundAttachment, | 913 CSSPropertyBackgroundAttachment, |
919 CSSPropertyBackgroundColor, | 914 CSSPropertyBackgroundColor, |
920 CSSPropertyBackgroundSize, | 915 CSSPropertyBackgroundSize, |
921 CSSPropertyBackgroundOrigin, | 916 CSSPropertyBackgroundOrigin, |
922 CSSPropertyBackgroundClip | 917 CSSPropertyBackgroundClip |
923 }; | 918 }; |
924 | 919 |
925 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { | 920 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { |
926 CSSPropertyID propertyID = backgroundPropertyIds[i]; | 921 CSSPropertyID propertyID = backgroundPropertyIds[i]; |
927 const CSSValue* value = m_propertySet.getPropertyCSSValue(propertyID); | 922 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(propert
yID); |
928 if (!value) | 923 if (!value) |
929 continue; | 924 continue; |
930 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); | 925 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); |
931 } | 926 } |
932 | 927 |
933 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. | 928 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. |
934 // It is required because background-position-x/y are non-standard propertie
s and WebKit generated output | 929 // It is required because background-position-x/y are non-standard propertie
s and WebKit generated output |
935 // would not work in Firefox (<rdar://problem/5143183>) | 930 // would not work in Firefox (<rdar://problem/5143183>) |
936 // It would be a better solution if background-position was CSS_PAIR. | 931 // It would be a better solution if background-position was CSS_PAIR. |
937 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ | 932 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ |
938 const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBac
kgroundPositionX); | 933 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp
ertyBackgroundPositionX); |
| 934 ASSERT(value); |
939 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 935 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
940 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); | 936 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); |
941 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { | 937 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { |
942 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); | 938 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); |
943 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 939 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
944 if (!positionValue.isNull()) | 940 if (!positionValue.isNull()) |
945 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); | 941 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); |
946 } else { | 942 } else { |
947 // should check background-position-x or background-position-y. | 943 // should check background-position-x or background-position-y. |
948 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yBackgroundPositionX)) { | 944 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundPositionX)) { |
949 if (!value->isImplicitInitialValue()) { | 945 if (value && !value->isImplicitInitialValue()) { |
950 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); | 946 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); |
951 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); | 947 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); |
952 } | 948 } |
953 } | 949 } |
954 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yBackgroundPositionY)) { | 950 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundPositionY)) { |
955 if (!value->isImplicitInitialValue()) { | 951 if (value && !value->isImplicitInitialValue()) { |
956 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); | 952 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); |
957 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); | 953 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); |
958 } | 954 } |
959 } | 955 } |
960 } | 956 } |
961 | 957 |
962 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); | 958 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); |
963 if (!repeatValue.isNull()) | 959 if (!repeatValue.isNull()) |
964 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); | 960 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); |
965 } | 961 } |
966 | 962 |
967 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const | 963 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const |
968 { | 964 { |
969 ASSERT(shorthand.length() > 0); | 965 ASSERT(shorthand.length() > 0); |
970 | 966 |
971 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 967 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
972 for (unsigned i = 0; i < shorthand.length(); ++i) { | 968 for (unsigned i = 0; i < shorthand.length(); ++i) { |
973 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 969 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
974 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) | 970 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) |
975 return false; | 971 return false; |
976 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 972 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
977 return false; | 973 return false; |
978 } | 974 } |
979 return true; | 975 return true; |
980 } | 976 } |
981 | 977 |
982 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const | 978 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const |
983 { | 979 { |
984 ASSERT(shorthand.length() > 0); | 980 ASSERT(shorthand.length() > 0); |
985 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 981 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
986 bool isInitialValue = true; | 982 bool isInitialValue = true; |
987 bool isInheritedValue = true; | 983 bool isInheritedValue = true; |
988 for (unsigned i = 0; i < shorthand.length(); ++i) { | 984 for (unsigned i = 0; i < shorthand.length(); ++i) { |
989 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 985 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
990 if (!value) | 986 if (!value) |
991 return false; | 987 return false; |
992 if (!value->isInitialValue()) | 988 if (!value->isInitialValue()) |
993 isInitialValue = false; | 989 isInitialValue = false; |
994 if (!value->isInheritedValue()) | 990 if (!value->isInheritedValue()) |
995 isInheritedValue = false; | 991 isInheritedValue = false; |
996 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 992 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
997 return false; | 993 return false; |
998 } | 994 } |
999 return isInitialValue || isInheritedValue; | 995 return isInitialValue || isInheritedValue; |
1000 } | 996 } |
1001 | 997 |
1002 } | 998 } |
OLD | NEW |