| 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 WTF::Vector<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 yValue; |
| 664 const CSSValue* nextValue = values[j + 1]; | 660 NullableCSSValue nextValue = values[j + 1]; |
| 665 if (nextValue->isValueList()) | 661 if (nextValue && nextValue->isValueList()) |
| 666 yValue = toCSSValueList(nextValue)->item(i); | 662 yValue = toCSSValueList(nextValue)->item(i); |
| 667 else | 663 else |
| 668 yValue = nextValue; | 664 yValue = nextValue; |
| 669 | 665 |
| 670 // background-repeat-x(y) or mask-repeat-x(y) may be like th
is : "initial, repeat". We can omit the implicit initial values | 666 // 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. | 667 // before starting to compare their values. |
| 672 if (value->isImplicitInitialValue() || yValue->isImplicitIni
tialValue()) | 668 if (value->isImplicitInitialValue() || yValue->isImplicitIni
tialValue()) |
| 673 continue; | 669 continue; |
| 674 | 670 |
| 675 // FIXME: At some point we need to fix this code to avoid re
turning an invalid shorthand, | 671 // FIXME: At some point we need to fix this code to avoid re
turning an invalid shorthand, |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 750 return String(); | 746 return String(); |
| 751 return result.toString(); | 747 return result.toString(); |
| 752 } | 748 } |
| 753 | 749 |
| 754 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const | 750 String StylePropertySerializer::getShorthandValue(const StylePropertyShorthand&
shorthand, String separator) const |
| 755 { | 751 { |
| 756 String commonValue; | 752 String commonValue; |
| 757 StringBuilder result; | 753 StringBuilder result; |
| 758 for (unsigned i = 0; i < shorthand.length(); ++i) { | 754 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 759 if (!m_propertySet.isPropertyImplicit(shorthand.properties()[i])) { | 755 if (!m_propertySet.isPropertyImplicit(shorthand.properties()[i])) { |
| 760 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.
properties()[i]); | 756 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(sho
rthand.properties()[i]); |
| 761 if (!value) | 757 if (!value) |
| 762 return String(); | 758 return String(); |
| 763 String valueText = value->cssText(); | 759 String valueText = value->cssText(); |
| 764 if (!i) | 760 if (!i) |
| 765 commonValue = valueText; | 761 commonValue = valueText; |
| 766 else if (!commonValue.isNull() && commonValue != valueText) | 762 else if (!commonValue.isNull() && commonValue != valueText) |
| 767 commonValue = String(); | 763 commonValue = String(); |
| 768 if (value->isInitialValue()) | 764 if (value->isInitialValue()) |
| 769 continue; | 765 continue; |
| 770 if (!result.isEmpty()) | 766 if (!result.isEmpty()) |
| 771 result.append(separator); | 767 result.append(separator); |
| 772 result.append(valueText); | 768 result.append(valueText); |
| 773 } else | 769 } else |
| 774 commonValue = String(); | 770 commonValue = String(); |
| 775 } | 771 } |
| 776 if (isInitialOrInherit(commonValue)) | 772 if (isInitialOrInherit(commonValue)) |
| 777 return commonValue; | 773 return commonValue; |
| 778 if (result.isEmpty()) | 774 if (result.isEmpty()) |
| 779 return String(); | 775 return String(); |
| 780 return result.toString(); | 776 return result.toString(); |
| 781 } | 777 } |
| 782 | 778 |
| 783 // only returns a non-null value if all properties have the same, non-null value | 779 // only returns a non-null value if all properties have the same, non-null value |
| 784 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const | 780 String StylePropertySerializer::getCommonValue(const StylePropertyShorthand& sho
rthand) const |
| 785 { | 781 { |
| 786 String res; | 782 String res; |
| 787 bool lastPropertyWasImportant = false; | 783 bool lastPropertyWasImportant = false; |
| 788 for (unsigned i = 0; i < shorthand.length(); ++i) { | 784 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 789 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 785 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
| 790 // FIXME: CSSInitialValue::cssText should generate the right value. | 786 // FIXME: CSSInitialValue::cssText should generate the right value. |
| 791 if (!value) | 787 if (!value) |
| 792 return String(); | 788 return String(); |
| 793 String text = value->cssText(); | 789 String text = value->cssText(); |
| 794 if (text.isNull()) | 790 if (text.isNull()) |
| 795 return String(); | 791 return String(); |
| 796 if (res.isNull()) | 792 if (res.isNull()) |
| 797 res = text; | 793 res = text; |
| 798 else if (res != text) | 794 else if (res != text) |
| 799 return String(); | 795 return String(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 builder.appendLiteral("repeat-x"); | 846 builder.appendLiteral("repeat-x"); |
| 851 } else { | 847 } else { |
| 852 builder.append(repeatX.cssText()); | 848 builder.append(repeatX.cssText()); |
| 853 builder.appendLiteral(" "); | 849 builder.appendLiteral(" "); |
| 854 builder.append(repeatY.cssText()); | 850 builder.append(repeatY.cssText()); |
| 855 } | 851 } |
| 856 } | 852 } |
| 857 | 853 |
| 858 String StylePropertySerializer::backgroundRepeatPropertyValue() const | 854 String StylePropertySerializer::backgroundRepeatPropertyValue() const |
| 859 { | 855 { |
| 860 const CSSValue* repeatX = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatX); | 856 const NullableCSSValue repeatX = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundRepeatX); |
| 861 const CSSValue* repeatY = m_propertySet.getPropertyCSSValue(CSSPropertyBackg
roundRepeatY); | 857 const NullableCSSValue repeatY = m_propertySet.getPropertyCSSValue(CSSProper
tyBackgroundRepeatY); |
| 862 if (!repeatX || !repeatY) | 858 if (!repeatX || !repeatY) |
| 863 return String(); | 859 return String(); |
| 864 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) | 860 if (m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX) != m_pro
pertySet.propertyIsImportant(CSSPropertyBackgroundRepeatY)) |
| 865 return String(); | 861 return String(); |
| 866 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is
InheritedValue() && repeatY->isInheritedValue())) | 862 if ((repeatX->isInitialValue() && repeatY->isInitialValue()) || (repeatX->is
InheritedValue() && repeatY->isInheritedValue())) |
| 867 return repeatX->cssText(); | 863 return repeatX->cssText(); |
| 868 | 864 |
| 869 const CSSValueList* repeatXList = 0; | 865 const CSSValueList* repeatXList = 0; |
| 870 int repeatXLength = 1; | 866 int repeatXLength = 1; |
| 871 if (repeatX->isValueList()) { | 867 if (repeatX->isValueList()) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 883 } else if (!repeatY->isPrimitiveValue()) { | 879 } else if (!repeatY->isPrimitiveValue()) { |
| 884 return String(); | 880 return String(); |
| 885 } | 881 } |
| 886 | 882 |
| 887 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); | 883 size_t shorthandLength = lowestCommonMultiple(repeatXLength, repeatYLength); |
| 888 StringBuilder builder; | 884 StringBuilder builder; |
| 889 for (size_t i = 0; i < shorthandLength; ++i) { | 885 for (size_t i = 0; i < shorthandLength; ++i) { |
| 890 if (i) | 886 if (i) |
| 891 builder.appendLiteral(", "); | 887 builder.appendLiteral(", "); |
| 892 | 888 |
| 893 const CSSValue* xValue = repeatXList ? repeatXList->item(i % repeatXList
->length()) : repeatX; | 889 const CSSValue xValue = repeatXList ? repeatXList->item(i % repeatXList-
>length()) : *repeatX; |
| 894 const CSSValue* yValue = repeatYList ? repeatYList->item(i % repeatYList
->length()) : repeatY; | 890 const CSSValue yValue = repeatYList ? repeatYList->item(i % repeatYList-
>length()) : *repeatY; |
| 895 appendBackgroundRepeatValue(builder, *xValue, *yValue); | 891 appendBackgroundRepeatValue(builder, xValue, yValue); |
| 896 } | 892 } |
| 897 return builder.toString(); | 893 return builder.toString(); |
| 898 } | 894 } |
| 899 | 895 |
| 900 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const | 896 void StylePropertySerializer::appendBackgroundPropertyAsText(StringBuilder& resu
lt, unsigned& numDecls) const |
| 901 { | 897 { |
| 902 if (isPropertyShorthandAvailable(backgroundShorthand())) { | 898 if (isPropertyShorthandAvailable(backgroundShorthand())) { |
| 903 String backgroundValue = getPropertyValue(CSSPropertyBackground); | 899 String backgroundValue = getPropertyValue(CSSPropertyBackground); |
| 904 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 900 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
| 905 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); | 901 result.append(getPropertyText(CSSPropertyBackground, backgroundValue, is
Important, numDecls++)); |
| 906 return; | 902 return; |
| 907 } | 903 } |
| 908 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { | 904 if (shorthandHasOnlyInitialOrInheritedValue(backgroundShorthand())) { |
| 909 const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBac
kgroundImage); | 905 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp
ertyBackgroundImage); |
| 906 ASSERT(value); |
| 910 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); | 907 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndImage); |
| 911 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); | 908 result.append(getPropertyText(CSSPropertyBackground, value->cssText(), i
sImportant, numDecls++)); |
| 912 return; | 909 return; |
| 913 } | 910 } |
| 914 | 911 |
| 915 // backgroundShorthandProperty without layered shorhand properties | 912 // backgroundShorthandProperty without layered shorhand properties |
| 916 const CSSPropertyID backgroundPropertyIds[] = { | 913 const CSSPropertyID backgroundPropertyIds[] = { |
| 917 CSSPropertyBackgroundImage, | 914 CSSPropertyBackgroundImage, |
| 918 CSSPropertyBackgroundAttachment, | 915 CSSPropertyBackgroundAttachment, |
| 919 CSSPropertyBackgroundColor, | 916 CSSPropertyBackgroundColor, |
| 920 CSSPropertyBackgroundSize, | 917 CSSPropertyBackgroundSize, |
| 921 CSSPropertyBackgroundOrigin, | 918 CSSPropertyBackgroundOrigin, |
| 922 CSSPropertyBackgroundClip | 919 CSSPropertyBackgroundClip |
| 923 }; | 920 }; |
| 924 | 921 |
| 925 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { | 922 for (unsigned i = 0; i < WTF_ARRAY_LENGTH(backgroundPropertyIds); ++i) { |
| 926 CSSPropertyID propertyID = backgroundPropertyIds[i]; | 923 CSSPropertyID propertyID = backgroundPropertyIds[i]; |
| 927 const CSSValue* value = m_propertySet.getPropertyCSSValue(propertyID); | 924 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(propert
yID); |
| 928 if (!value) | 925 if (!value) |
| 929 continue; | 926 continue; |
| 930 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); | 927 result.append(getPropertyText(propertyID, value->cssText(), m_propertySe
t.propertyIsImportant(propertyID), numDecls++)); |
| 931 } | 928 } |
| 932 | 929 |
| 933 // FIXME: This is a not-so-nice way to turn x/y positions into single backgr
ound-position in output. | 930 // 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 | 931 // 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>) | 932 // would not work in Firefox (<rdar://problem/5143183>) |
| 936 // It would be a better solution if background-position was CSS_PAIR. | 933 // It would be a better solution if background-position was CSS_PAIR. |
| 937 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ | 934 if (shorthandHasOnlyInitialOrInheritedValue(backgroundPositionShorthand()))
{ |
| 938 const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropertyBac
kgroundPositionX); | 935 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSSProp
ertyBackgroundPositionX); |
| 936 ASSERT(value); |
| 939 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 937 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
| 940 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); | 938 result.append(getPropertyText(CSSPropertyBackgroundPosition, value->cssT
ext(), isImportant, numDecls++)); |
| 941 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { | 939 } else if (isPropertyShorthandAvailable(backgroundPositionShorthand())) { |
| 942 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); | 940 String positionValue = m_propertySet.getPropertyValue(CSSPropertyBackgro
undPosition); |
| 943 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); | 941 bool isImportant = m_propertySet.propertyIsImportant(CSSPropertyBackgrou
ndPositionX); |
| 944 if (!positionValue.isNull()) | 942 if (!positionValue.isNull()) |
| 945 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); | 943 result.append(getPropertyText(CSSPropertyBackgroundPosition, positio
nValue, isImportant, numDecls++)); |
| 946 } else { | 944 } else { |
| 947 // should check background-position-x or background-position-y. | 945 // should check background-position-x or background-position-y. |
| 948 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yBackgroundPositionX)) { | 946 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundPositionX)) { |
| 949 if (!value->isImplicitInitialValue()) { | 947 if (value && !value->isImplicitInitialValue()) { |
| 950 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); | 948 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionX); |
| 951 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); | 949 result.append(getPropertyText(CSSPropertyBackgroundPositionX, va
lue->cssText(), isImportant, numDecls++)); |
| 952 } | 950 } |
| 953 } | 951 } |
| 954 if (const CSSValue* value = m_propertySet.getPropertyCSSValue(CSSPropert
yBackgroundPositionY)) { | 952 if (const NullableCSSValue value = m_propertySet.getPropertyCSSValue(CSS
PropertyBackgroundPositionY)) { |
| 955 if (!value->isImplicitInitialValue()) { | 953 if (value && !value->isImplicitInitialValue()) { |
| 956 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); | 954 bool isImportant = m_propertySet.propertyIsImportant(CSSProperty
BackgroundPositionY); |
| 957 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); | 955 result.append(getPropertyText(CSSPropertyBackgroundPositionY, va
lue->cssText(), isImportant, numDecls++)); |
| 958 } | 956 } |
| 959 } | 957 } |
| 960 } | 958 } |
| 961 | 959 |
| 962 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); | 960 String repeatValue = m_propertySet.getPropertyValue(CSSPropertyBackgroundRep
eat); |
| 963 if (!repeatValue.isNull()) | 961 if (!repeatValue.isNull()) |
| 964 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); | 962 result.append(getPropertyText(CSSPropertyBackgroundRepeat, repeatValue,
m_propertySet.propertyIsImportant(CSSPropertyBackgroundRepeatX), numDecls++)); |
| 965 } | 963 } |
| 966 | 964 |
| 967 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const | 965 bool StylePropertySerializer::isPropertyShorthandAvailable(const StylePropertySh
orthand& shorthand) const |
| 968 { | 966 { |
| 969 ASSERT(shorthand.length() > 0); | 967 ASSERT(shorthand.length() > 0); |
| 970 | 968 |
| 971 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 969 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
| 972 for (unsigned i = 0; i < shorthand.length(); ++i) { | 970 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 973 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 971 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
| 974 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) | 972 if (!value || (value->isInitialValue() && !value->isImplicitInitialValue
()) || value->isInheritedValue()) |
| 975 return false; | 973 return false; |
| 976 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 974 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
| 977 return false; | 975 return false; |
| 978 } | 976 } |
| 979 return true; | 977 return true; |
| 980 } | 978 } |
| 981 | 979 |
| 982 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const | 980 bool StylePropertySerializer::shorthandHasOnlyInitialOrInheritedValue(const Styl
ePropertyShorthand& shorthand) const |
| 983 { | 981 { |
| 984 ASSERT(shorthand.length() > 0); | 982 ASSERT(shorthand.length() > 0); |
| 985 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); | 983 bool isImportant = m_propertySet.propertyIsImportant(shorthand.properties()[
0]); |
| 986 bool isInitialValue = true; | 984 bool isInitialValue = true; |
| 987 bool isInheritedValue = true; | 985 bool isInheritedValue = true; |
| 988 for (unsigned i = 0; i < shorthand.length(); ++i) { | 986 for (unsigned i = 0; i < shorthand.length(); ++i) { |
| 989 const CSSValue* value = m_propertySet.getPropertyCSSValue(shorthand.prop
erties()[i]); | 987 const NullableCSSValue value = m_propertySet.getPropertyCSSValue(shortha
nd.properties()[i]); |
| 990 if (!value) | 988 if (!value) |
| 991 return false; | 989 return false; |
| 992 if (!value->isInitialValue()) | 990 if (!value->isInitialValue()) |
| 993 isInitialValue = false; | 991 isInitialValue = false; |
| 994 if (!value->isInheritedValue()) | 992 if (!value->isInheritedValue()) |
| 995 isInheritedValue = false; | 993 isInheritedValue = false; |
| 996 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) | 994 if (isImportant != m_propertySet.propertyIsImportant(shorthand.propertie
s()[i])) |
| 997 return false; | 995 return false; |
| 998 } | 996 } |
| 999 return isInitialValue || isInheritedValue; | 997 return isInitialValue || isInheritedValue; |
| 1000 } | 998 } |
| 1001 | 999 |
| 1002 } | 1000 } |
| OLD | NEW |