| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. | 2 * Copyright (C) 2007, 2008, 2009 Apple Computer, Inc. |
| 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. | 3 * Copyright (C) 2010, 2011 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie
sType type = OnlyInheritableEditingProperties) | 142 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> editingStyleFromComputedS
tyle(PassRefPtrWillBeRawPtr<CSSComputedStyleDeclaration> style, EditingPropertie
sType type = OnlyInheritableEditingProperties) |
| 143 { | 143 { |
| 144 if (!style) | 144 if (!style) |
| 145 return MutableStylePropertySet::create(); | 145 return MutableStylePropertySet::create(); |
| 146 return copyEditingProperties(style.get(), type); | 146 return copyEditingProperties(style.get(), type); |
| 147 } | 147 } |
| 148 | 148 |
| 149 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); | 149 static PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleP
ropertySet* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle); |
| 150 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; | 150 enum LegacyFontSizeMode { AlwaysUseLegacyFontSize, UseLegacyFontSizeOnlyIfPixelV
aluesMatch }; |
| 151 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); | 151 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool, Legac
yFontSizeMode); |
| 152 static bool isTransparentColorValue(NullableCSSValue); | 152 static bool isTransparentColorValue(const NullableCSSValue&); |
| 153 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); | 153 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*); |
| 154 static bool hasTransparentBackgroundColor(StylePropertySet*); | 154 static bool hasTransparentBackgroundColor(StylePropertySet*); |
| 155 static NullableCSSValue backgroundColorInEffect(Node*); | 155 static NullableCSSValue backgroundColorInEffect(Node*); |
| 156 | 156 |
| 157 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { | 157 class HTMLElementEquivalent : public NoBaseWillBeGarbageCollected<HTMLElementEqu
ivalent> { |
| 158 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); | 158 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED(HTMLElementEquivalent); |
| 159 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); | 159 DECLARE_EMPTY_VIRTUAL_DESTRUCTOR_WILL_BE_REMOVED(HTMLElementEquivalent); |
| 160 public: | 160 public: |
| 161 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) | 161 static PassOwnPtrWillBeRawPtr<HTMLElementEquivalent> create(CSSPropertyID pr
opertyID, CSSValueID primitiveValue, const HTMLQualifiedName& tagName) |
| 162 { | 162 { |
| (...skipping 1030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 | 1193 |
| 1194 // The property value, if it's a percentage, may not reflect the actual comp
uted value. | 1194 // The property value, if it's a percentage, may not reflect the actual comp
uted value. |
| 1195 // For example: style="height: 1%; overflow: visible;" in quirksmode | 1195 // For example: style="height: 1%; overflow: visible;" in quirksmode |
| 1196 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot
copy/paste fidelity problem | 1196 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot
copy/paste fidelity problem |
| 1197 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS
SComputedStyleDeclaration::create(element); | 1197 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> computedStyleForElement = CS
SComputedStyleDeclaration::create(element); |
| 1198 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle
PropertySet::create(); | 1198 RefPtrWillBeRawPtr<MutableStylePropertySet> fromComputedStyle = MutableStyle
PropertySet::create(); |
| 1199 { | 1199 { |
| 1200 unsigned propertyCount = m_mutableStyle->propertyCount(); | 1200 unsigned propertyCount = m_mutableStyle->propertyCount(); |
| 1201 for (unsigned i = 0; i < propertyCount; ++i) { | 1201 for (unsigned i = 0; i < propertyCount; ++i) { |
| 1202 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); | 1202 StylePropertySet::PropertyReference property = m_mutableStyle->prope
rtyAt(i); |
| 1203 CSSValue value = property.value(); | 1203 const CSSValue& value = property.value(); |
| 1204 if (!value.isPrimitiveValue()) | 1204 if (!value.isPrimitiveValue()) |
| 1205 continue; | 1205 continue; |
| 1206 if (toCSSPrimitiveValue(value).isPercentage()) { | 1206 if (toCSSPrimitiveValue(value).isPercentage()) { |
| 1207 if (NullableCSSValue computedPropertyValue = computedStyleForEle
ment->getPropertyCSSValue(property.id())) | 1207 if (NullableCSSValue computedPropertyValue = computedStyleForEle
ment->getPropertyCSSValue(property.id())) |
| 1208 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), *computedPropertyValue)); | 1208 fromComputedStyle->addRespectingCascade(CSSProperty(property
.id(), *computedPropertyValue)); |
| 1209 } | 1209 } |
| 1210 } | 1210 } |
| 1211 } | 1211 } |
| 1212 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); | 1212 m_mutableStyle->mergeAndOverrideOnConflict(fromComputedStyle.get()); |
| 1213 } | 1213 } |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1563 | 1563 |
| 1564 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco
ration)->copy(); | 1564 RefPtrWillBeRawPtr<CSSValueList> newTextDecoration = toCSSValueList(textDeco
ration)->copy(); |
| 1565 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); | 1565 CSSValueList* valuesInRefTextDecoration = toCSSValueList(refTextDecoration); |
| 1566 | 1566 |
| 1567 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) | 1567 for (size_t i = 0; i < valuesInRefTextDecoration->length(); i++) |
| 1568 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); | 1568 newTextDecoration->removeAll(valuesInRefTextDecoration->item(i)); |
| 1569 | 1569 |
| 1570 setTextDecorationProperty(style, newTextDecoration.get(), propertyID); | 1570 setTextDecorationProperty(style, newTextDecoration.get(), propertyID); |
| 1571 } | 1571 } |
| 1572 | 1572 |
| 1573 static bool fontWeightIsBold(CSSValue fontWeight) | 1573 static bool fontWeightIsBold(const CSSValue& fontWeight) |
| 1574 { | 1574 { |
| 1575 if (!fontWeight.isPrimitiveValue()) | 1575 if (!fontWeight.isPrimitiveValue()) |
| 1576 return false; | 1576 return false; |
| 1577 | 1577 |
| 1578 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. | 1578 // Because b tag can only bold text, there are only two states in plain html
: bold and not bold. |
| 1579 // Collapse all other values to either one of these two states for editing p
urposes. | 1579 // Collapse all other values to either one of these two states for editing p
urposes. |
| 1580 switch (toCSSPrimitiveValue(fontWeight).getValueID()) { | 1580 switch (toCSSPrimitiveValue(fontWeight).getValueID()) { |
| 1581 case CSSValue100: | 1581 case CSSValue100: |
| 1582 case CSSValue200: | 1582 case CSSValue200: |
| 1583 case CSSValue300: | 1583 case CSSValue300: |
| 1584 case CSSValue400: | 1584 case CSSValue400: |
| 1585 case CSSValue500: | 1585 case CSSValue500: |
| 1586 case CSSValueNormal: | 1586 case CSSValueNormal: |
| 1587 return false; | 1587 return false; |
| 1588 case CSSValueBold: | 1588 case CSSValueBold: |
| 1589 case CSSValue600: | 1589 case CSSValue600: |
| 1590 case CSSValue700: | 1590 case CSSValue700: |
| 1591 case CSSValue800: | 1591 case CSSValue800: |
| 1592 case CSSValue900: | 1592 case CSSValue900: |
| 1593 return true; | 1593 return true; |
| 1594 default: | 1594 default: |
| 1595 break; | 1595 break; |
| 1596 } | 1596 } |
| 1597 | 1597 |
| 1598 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter | 1598 ASSERT_NOT_REACHED(); // For CSSValueBolder and CSSValueLighter |
| 1599 return false; | 1599 return false; |
| 1600 } | 1600 } |
| 1601 | 1601 |
| 1602 static bool fontWeightNeedsResolving(CSSValue fontWeight) | 1602 static bool fontWeightNeedsResolving(const CSSValue& fontWeight) |
| 1603 { | 1603 { |
| 1604 if (!fontWeight.isPrimitiveValue()) | 1604 if (!fontWeight.isPrimitiveValue()) |
| 1605 return true; | 1605 return true; |
| 1606 | 1606 |
| 1607 CSSValueID value = toCSSPrimitiveValue(fontWeight).getValueID(); | 1607 CSSValueID value = toCSSPrimitiveValue(fontWeight).getValueID(); |
| 1608 return value == CSSValueLighter || value == CSSValueBolder; | 1608 return value == CSSValueLighter || value == CSSValueBolder; |
| 1609 } | 1609 } |
| 1610 | 1610 |
| 1611 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) | 1611 PassRefPtrWillBeRawPtr<MutableStylePropertySet> getPropertiesNotIn(StyleProperty
Set* styleWithRedundantProperties, CSSStyleDeclaration* baseStyle) |
| 1612 { | 1612 { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 | 1674 |
| 1675 return 0; | 1675 return 0; |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) | 1678 if (CSSValueXSmall <= value->getValueID() && value->getValueID() <= CSSValue
WebkitXxxLarge) |
| 1679 return value->getValueID() - CSSValueXSmall + 1; | 1679 return value->getValueID() - CSSValueXSmall + 1; |
| 1680 | 1680 |
| 1681 return 0; | 1681 return 0; |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 bool isTransparentColorValue(NullableCSSValue cssValue) | 1684 bool isTransparentColorValue(const NullableCSSValue& cssValue) |
| 1685 { | 1685 { |
| 1686 if (!cssValue) | 1686 if (!cssValue) |
| 1687 return true; | 1687 return true; |
| 1688 if (!cssValue->isPrimitiveValue()) | 1688 if (!cssValue->isPrimitiveValue()) |
| 1689 return false; | 1689 return false; |
| 1690 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); | 1690 CSSPrimitiveValue* value = toCSSPrimitiveValue(cssValue); |
| 1691 if (value->isRGBColor()) | 1691 if (value->isRGBColor()) |
| 1692 return !alphaChannel(value->getRGBA32Value()); | 1692 return !alphaChannel(value->getRGBA32Value()); |
| 1693 return value->getValueID() == CSSValueTransparent; | 1693 return value->getValueID() == CSSValueTransparent; |
| 1694 } | 1694 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1709 { | 1709 { |
| 1710 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { | 1710 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { |
| 1711 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); | 1711 RefPtrWillBeRawPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSCompu
tedStyleDeclaration::create(ancestor); |
| 1712 if (!hasTransparentBackgroundColor(ancestorStyle.get())) | 1712 if (!hasTransparentBackgroundColor(ancestorStyle.get())) |
| 1713 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); | 1713 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor
); |
| 1714 } | 1714 } |
| 1715 return nullptr; | 1715 return nullptr; |
| 1716 } | 1716 } |
| 1717 | 1717 |
| 1718 } | 1718 } |
| OLD | NEW |