Changeset 150945 in webkit
- Timestamp:
- May 29, 2013 9:11:39 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150944 r150945 1 2013-05-29 Andreas Kling <akling@apple.com> 2 3 Take ComputedStyleExtractor for a spin. 4 <http://webkit.org/b/116968> 5 6 Reviewed by Antti Koivisto. 7 8 Convert some editing and SVG code to use ComputedStyleExtractor instead of creating full 9 blown CSSComputedStyleDeclaration objects. 10 11 * editing/ApplyStyleCommand.cpp: 12 (WebCore::ApplyStyleCommand::splitAncestorsWithUnicodeBidi): 13 (WebCore::ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock): 14 (WebCore::highestEmbeddingAncestor): 15 (WebCore::ApplyStyleCommand::computedFontSize): 16 * editing/EditingStyle.cpp: 17 (WebCore::EditingStyle::mergeStyleFromRulesForSerialization): 18 (WebCore::EditingStyle::textDirectionForSelection): 19 (WebCore::getIdentifierValue): 20 (WebCore::backgroundColorInEffect): 21 * editing/EditingStyle.h: 22 * svg/SVGAnimationElement.cpp: 23 (WebCore::SVGAnimationElement::computeCSSPropertyValue): 24 1 25 2013-05-29 Benjamin Poulain <bpoulain@apple.com> 2 26 -
trunk/Source/WebCore/editing/ApplyStyleCommand.cpp
r150702 r150945 457 457 int highestAncestorUnicodeBidi = 0; 458 458 for (Node* n = node->parentNode(); n != block; n = n->parentNode()) { 459 int unicodeBidi = getIdentifierValue( CSSComputedStyleDeclaration::create(n).get(), CSSPropertyUnicodeBidi);459 int unicodeBidi = getIdentifierValue(n, CSSPropertyUnicodeBidi); 460 460 if (unicodeBidi && unicodeBidi != CSSValueNormal) { 461 461 highestAncestorUnicodeBidi = unicodeBidi; … … 509 509 510 510 StyledElement* element = static_cast<StyledElement*>(n); 511 int unicodeBidi = getIdentifierValue( CSSComputedStyleDeclaration::create(element).get(), CSSPropertyUnicodeBidi);511 int unicodeBidi = getIdentifierValue(element, CSSPropertyUnicodeBidi); 512 512 if (!unicodeBidi || unicodeBidi == CSSValueNormal) 513 513 continue; … … 535 535 { 536 536 for (Node* n = startNode; n && n != enclosingNode; n = n->parentNode()) { 537 if (n->isHTMLElement() && getIdentifierValue( CSSComputedStyleDeclaration::create(n).get(), CSSPropertyUnicodeBidi) == CSSValueEmbed)537 if (n->isHTMLElement() && getIdentifierValue(n, CSSPropertyUnicodeBidi) == CSSValueEmbed) 538 538 return n; 539 539 } … … 1508 1508 return 0; 1509 1509 1510 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(node); 1511 if (!style) 1512 return 0; 1513 1514 RefPtr<CSSPrimitiveValue> value = static_pointer_cast<CSSPrimitiveValue>(style->getPropertyCSSValue(CSSPropertyFontSize)); 1515 if (!value) 1516 return 0; 1517 1518 return value->getFloatValue(CSSPrimitiveValue::CSS_PX); 1510 RefPtr<CSSValue> value = ComputedStyleExtractor(node).propertyValue(CSSPropertyFontSize); 1511 ASSERT(value && value->isPrimitiveValue()); 1512 return static_cast<CSSPrimitiveValue*>(value.get())->getFloatValue(CSSPrimitiveValue::CSS_PX); 1519 1513 } 1520 1514 -
trunk/Source/WebCore/editing/EditingStyle.cpp
r150140 r150945 114 114 static int legacyFontSizeFromCSSValue(Document*, CSSPrimitiveValue*, bool shouldUseFixedFontDefaultSize, LegacyFontSizeMode); 115 115 static bool isTransparentColorValue(CSSValue*); 116 static bool hasTransparentBackgroundColor(CSSStyleDeclaration*);117 116 static bool hasTransparentBackgroundColor(StylePropertySet*); 118 117 static PassRefPtr<CSSValue> backgroundColorInEffect(Node*); … … 1106 1105 // For example: style="height: 1%; overflow: visible;" in quirksmode 1107 1106 // FIXME: There are others like this, see <rdar://problem/5195123> Slashdot copy/paste fidelity problem 1108 RefPtr<CSSComputedStyleDeclaration> computedStyleForElement = CSSComputedStyleDeclaration::create(element);1109 1107 RefPtr<MutableStylePropertySet> fromComputedStyle = MutableStylePropertySet::create(); 1108 ComputedStyleExtractor computedStyle(element); 1109 1110 1110 { 1111 1111 unsigned propertyCount = m_mutableStyle->propertyCount(); … … 1116 1116 continue; 1117 1117 if (static_cast<CSSPrimitiveValue*>(value)->isPercentage()) { 1118 if (RefPtr<CSSValue> computedPropertyValue = computedStyle ForElement->getPropertyCSSValue(property.id()))1119 fromComputedStyle->addParsedProperty(CSSProperty(property.id(), computedPropertyValue ));1118 if (RefPtr<CSSValue> computedPropertyValue = computedStyle.propertyValue(property.id())) 1119 fromComputedStyle->addParsedProperty(CSSProperty(property.id(), computedPropertyValue.release())); 1120 1120 } 1121 1121 } … … 1248 1248 continue; 1249 1249 1250 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(n); 1251 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi); 1250 RefPtr<CSSValue> unicodeBidi = ComputedStyleExtractor(n).propertyValue(CSSPropertyUnicodeBidi); 1252 1251 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1253 1252 continue; … … 1277 1276 continue; 1278 1277 1279 RefPtr<CSSComputedStyleDeclaration> style = CSSComputedStyleDeclaration::create(node);1280 RefPtr<CSSValue> unicodeBidi = style->getPropertyCSSValue(CSSPropertyUnicodeBidi);1278 ComputedStyleExtractor computedStyle(node); 1279 RefPtr<CSSValue> unicodeBidi = computedStyle.propertyValue(CSSPropertyUnicodeBidi); 1281 1280 if (!unicodeBidi || !unicodeBidi->isPrimitiveValue()) 1282 1281 continue; … … 1290 1289 1291 1290 ASSERT(unicodeBidiValue == CSSValueEmbed); 1292 RefPtr<CSSValue> direction = style->getPropertyCSSValue(CSSPropertyDirection);1291 RefPtr<CSSValue> direction = computedStyle.propertyValue(CSSPropertyDirection); 1293 1292 if (!direction || !direction->isPrimitiveValue()) 1294 1293 continue; … … 1543 1542 } 1544 1543 1544 int getIdentifierValue(Node* node, CSSPropertyID propertyID) 1545 { 1546 RefPtr<CSSValue> value = ComputedStyleExtractor(node).propertyValue(propertyID); 1547 if (!value || !value->isPrimitiveValue()) 1548 return 0; 1549 return static_cast<CSSPrimitiveValue*>(value.get())->getIdent(); 1550 } 1551 1545 1552 static bool isCSSValueLength(CSSPrimitiveValue* value) 1546 1553 { … … 1579 1586 } 1580 1587 1581 bool hasTransparentBackgroundColor(CSSStyleDeclaration* style)1582 {1583 RefPtr<CSSValue> cssValue = style->getPropertyCSSValueInternal(CSSPropertyBackgroundColor);1584 return isTransparentColorValue(cssValue.get());1585 }1586 1587 1588 bool hasTransparentBackgroundColor(StylePropertySet* style) 1588 1589 { … … 1594 1595 { 1595 1596 for (Node* ancestor = node; ancestor; ancestor = ancestor->parentNode()) { 1596 RefPtr<CSSComputedStyleDeclaration> ancestorStyle = CSSComputedStyleDeclaration::create(ancestor); 1597 if (!hasTransparentBackgroundColor(ancestorStyle.get())) 1598 return ancestorStyle->getPropertyCSSValue(CSSPropertyBackgroundColor); 1597 if (RefPtr<CSSValue> value = ComputedStyleExtractor(ancestor).propertyValue(CSSPropertyBackgroundColor)) { 1598 if (!isTransparentColorValue(value.get())) 1599 return value.release(); 1600 } 1599 1601 } 1600 1602 return 0; -
trunk/Source/WebCore/editing/EditingStyle.h
r148402 r150945 48 48 class CSSPrimitiveValue; 49 49 class CSSValue; 50 class ComputedStyleExtractor; 50 51 class Document; 51 52 class Element; … … 236 237 int getIdentifierValue(CSSStyleDeclaration*, CSSPropertyID); 237 238 int getIdentifierValue(StylePropertySet*, CSSPropertyID); 239 int getIdentifierValue(Node*, CSSPropertyID); 238 240 239 241 } // namespace WebCore -
trunk/Source/WebCore/svg/SVGAnimationElement.cpp
r145433 r150945 633 633 } 634 634 635 void SVGAnimationElement::computeCSSPropertyValue(SVGElement* element, CSSPropertyID id, String& value )635 void SVGAnimationElement::computeCSSPropertyValue(SVGElement* element, CSSPropertyID id, String& valueString) 636 636 { 637 637 ASSERT(element); … … 640 640 // Don't include any properties resulting from CSS Transitions/Animations or SMIL animations, as we want to retrieve the "base value". 641 641 element->setUseOverrideComputedStyle(true); 642 value = CSSComputedStyleDeclaration::create(element)->getPropertyValue(id); 642 RefPtr<CSSValue> value = ComputedStyleExtractor(element).propertyValue(id); 643 valueString = value ? value->cssText() : String(); 643 644 element->setUseOverrideComputedStyle(false); 644 645 }
Note: See TracChangeset
for help on using the changeset viewer.