Changeset 207686 in webkit
- Timestamp:
- Oct 21, 2016, 11:20:07 AM (8 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207685 r207686 1 2016-10-21 Antti Koivisto <antti@apple.com> 2 3 Tighten ComputedStyleExtractor to use Element instead of Node 4 https://bugs.webkit.org/show_bug.cgi?id=163798 5 6 Reviewed by Andreas Kling. 7 8 Also make its functions non-const as they may compute style. 9 10 * css/CSSComputedStyleDeclaration.cpp: 11 (WebCore::styleElementForNode): 12 (WebCore::ComputedStyleExtractor::ComputedStyleExtractor): 13 14 If we are called with a Node figure out the style Element in constructor. 15 16 (WebCore::ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword): 17 (WebCore::ComputedStyleExtractor::useFixedFontDefaultSize): 18 (WebCore::ComputedStyleExtractor::styledElement): 19 (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): 20 (WebCore::CSSComputedStyleDeclaration::copyProperties): 21 (WebCore::elementOrItsAncestorNeedsStyleRecalc): 22 23 Use composed tree iterator for increased correctness in shadow trees. 24 25 (WebCore::updateStyleIfNeededForElement): 26 (WebCore::computeRenderStyleForProperty): 27 (WebCore::ComputedStyleExtractor::customPropertyValue): 28 (WebCore::ComputedStyleExtractor::customPropertyText): 29 (WebCore::ComputedStyleExtractor::propertyValue): 30 (WebCore::CSSComputedStyleDeclaration::length): 31 (WebCore::CSSComputedStyleDeclaration::item): 32 (WebCore::ComputedStyleExtractor::propertyMatches): 33 (WebCore::ComputedStyleExtractor::copyProperties): 34 (WebCore::ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties): 35 (WebCore::ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand): 36 (WebCore::ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand): 37 (WebCore::ComputedStyleExtractor::copyPropertiesInSet): 38 (WebCore::CSSComputedStyleDeclaration::getPropertyValue): 39 (WebCore::ComputedStyleExtractor::getBackgroundShorthandValue): 40 (WebCore::ComputedStyleExtractor::styledNode): Deleted. 41 (WebCore::nodeOrItsAncestorNeedsStyleRecalc): Deleted. 42 (WebCore::updateStyleIfNeededForNode): Deleted. 43 * css/CSSComputedStyleDeclaration.h: 44 * css/SVGCSSComputedStyleDeclaration.cpp: 45 (WebCore::ComputedStyleExtractor::svgPropertyValue): 46 * editing/EditingStyle.cpp: 47 (WebCore::EditingStyle::removeEquivalentProperties): 48 * editing/EditingStyle.h: 49 1 50 2016-10-21 Chris Dumez <cdumez@apple.com> 2 51 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r207669 r207686 50 50 #include "CSSValueList.h" 51 51 #include "CSSValuePool.h" 52 #include "ComposedTreeAncestorIterator.h" 52 53 #include "ContentData.h" 53 54 #include "CounterContent.h" … … 73 74 #include "StyleResolver.h" 74 75 #include "StyleScope.h" 76 #include "Text.h" 75 77 #include "WebKitCSSFilterValue.h" 76 78 #include "WebKitCSSTransformValue.h" … … 1584 1586 } 1585 1587 1586 ComputedStyleExtractor::ComputedStyleExtractor(RefPtr<Node>&& node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier) 1587 : m_node(WTFMove(node)) 1588 static Element* styleElementForNode(Node* node) 1589 { 1590 if (!node) 1591 return nullptr; 1592 if (is<Element>(*node)) 1593 return downcast<Element>(node); 1594 return composedTreeAncestors(*node).first(); 1595 } 1596 1597 ComputedStyleExtractor::ComputedStyleExtractor(Node* node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier) 1598 : m_element(styleElementForNode(node)) 1588 1599 , m_pseudoElementSpecifier(pseudoElementSpecifier) 1589 1600 , m_allowVisitedStyle(allowVisitedStyle) … … 1591 1602 } 1592 1603 1604 ComputedStyleExtractor::ComputedStyleExtractor(Element* element, bool allowVisitedStyle, PseudoId pseudoElementSpecifier) 1605 : m_element(element) 1606 , m_pseudoElementSpecifier(pseudoElementSpecifier) 1607 , m_allowVisitedStyle(allowVisitedStyle) 1608 { 1609 } 1593 1610 1594 1611 CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(Element& element, bool allowVisitedStyle, const String& pseudoElementName) … … 1639 1656 } 1640 1657 1641 RefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const1642 { 1643 if (!m_ node)1658 RefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() 1659 { 1660 if (!m_element) 1644 1661 return nullptr; 1645 1662 1646 m_ node->document().updateLayoutIgnorePendingStylesheets();1647 1648 auto* style = m_ node->computedStyle(m_pseudoElementSpecifier);1663 m_element->document().updateLayoutIgnorePendingStylesheets(); 1664 1665 auto* style = m_element->computedStyle(m_pseudoElementSpecifier); 1649 1666 if (!style) 1650 1667 return nullptr; … … 1656 1673 } 1657 1674 1658 bool ComputedStyleExtractor::useFixedFontDefaultSize() const1659 { 1660 if (!m_ node)1675 bool ComputedStyleExtractor::useFixedFontDefaultSize() 1676 { 1677 if (!m_element) 1661 1678 return false; 1662 1663 auto* style = m_node->computedStyle(m_pseudoElementSpecifier); 1679 auto* style = m_element->computedStyle(m_pseudoElementSpecifier); 1664 1680 if (!style) 1665 1681 return false; … … 2265 2281 } 2266 2282 2267 Node* ComputedStyleExtractor::styledNode() const 2268 { 2269 if (!m_ node)2283 Element* ComputedStyleExtractor::styledElement() 2284 { 2285 if (!m_element) 2270 2286 return nullptr; 2271 if (!is<Element>(*m_node))2272 return m_node.get();2273 Element& element = downcast<Element>(*m_node);2274 2287 PseudoElement* pseudoElement; 2275 if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element.beforePseudoElement()))2288 if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = m_element->beforePseudoElement())) 2276 2289 return pseudoElement; 2277 if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element.afterPseudoElement()))2290 if (m_pseudoElementSpecifier == AFTER && (pseudoElement = m_element->afterPseudoElement())) 2278 2291 return pseudoElement; 2279 return &element;2292 return m_element.get(); 2280 2293 } 2281 2294 … … 2327 2340 RefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const 2328 2341 { 2329 return ComputedStyleExtractor(m_element. copyRef(), m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout);2342 return ComputedStyleExtractor(m_element.ptr(), m_allowVisitedStyle, m_pseudoElementSpecifier).propertyValue(propertyID, updateLayout); 2330 2343 } 2331 2344 2332 2345 Ref<MutableStyleProperties> CSSComputedStyleDeclaration::copyProperties() const 2333 2346 { 2334 return ComputedStyleExtractor(m_element. copyRef(), m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties();2335 } 2336 2337 static inline bool nodeOrItsAncestorNeedsStyleRecalc(const Node& node)2338 { 2339 if ( node.needsStyleRecalc())2347 return ComputedStyleExtractor(m_element.ptr(), m_allowVisitedStyle, m_pseudoElementSpecifier).copyProperties(); 2348 } 2349 2350 static inline bool elementOrItsAncestorNeedsStyleRecalc(Element& element) 2351 { 2352 if (element.needsStyleRecalc()) 2340 2353 return true; 2341 2342 const Node* currentNode = &node; 2343 const Element* ancestor = currentNode->parentOrShadowHostElement(); 2344 while (ancestor) { 2345 if (ancestor->needsStyleRecalc()) 2354 if (element.document().hasPendingForcedStyleRecalc()) 2355 return true; 2356 if (!element.document().childNeedsStyleRecalc()) 2357 return false; 2358 2359 const auto* currentElement = &element; 2360 for (auto& ancestor : composedTreeAncestors(element)) { 2361 if (ancestor.needsStyleRecalc()) 2346 2362 return true; 2347 2363 2348 if (ancestor ->directChildNeedsStyleRecalc() && currentNode->styleIsAffectedByPreviousSibling())2364 if (ancestor.directChildNeedsStyleRecalc() && currentElement->styleIsAffectedByPreviousSibling()) 2349 2365 return true; 2350 2366 2351 currentNode = ancestor; 2352 ancestor = currentNode->parentOrShadowHostElement(); 2367 currentElement = &ancestor; 2353 2368 } 2354 2369 return false; 2355 2370 } 2356 2371 2357 static bool updateStyleIfNeededFor Node(const Node& node)2358 { 2359 Document& document = node.document();2372 static bool updateStyleIfNeededForElement(Element& element) 2373 { 2374 auto& document = element.document(); 2360 2375 2361 2376 document.styleScope().flushPendingUpdate(); 2362 2377 2363 if (! document.hasPendingForcedStyleRecalc() && !(document.childNeedsStyleRecalc() && nodeOrItsAncestorNeedsStyleRecalc(node)))2378 if (!elementOrItsAncestorNeedsStyleRecalc(element)) 2364 2379 return false; 2380 2365 2381 document.updateStyleIfNeeded(); 2366 2382 return true; 2367 2383 } 2368 2384 2369 static inline const RenderStyle* computeRenderStyleForProperty( Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID, std::unique_ptr<RenderStyle>& ownedStyle)2370 { 2371 RenderObject* renderer = styledNode->renderer();2385 static inline const RenderStyle* computeRenderStyleForProperty(Element& element, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID, std::unique_ptr<RenderStyle>& ownedStyle) 2386 { 2387 auto* renderer = element.renderer(); 2372 2388 2373 2389 if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) { 2374 ownedStyle = renderer->animation().getAnimatedStyleForRenderer( downcast<RenderElement>(*renderer));2375 if (pseudoElementSpecifier && ! styledNode->isPseudoElement()) {2390 ownedStyle = renderer->animation().getAnimatedStyleForRenderer(*renderer); 2391 if (pseudoElementSpecifier && !element.isPseudoElement()) { 2376 2392 // FIXME: This cached pseudo style will only exist if the animation has been run at least once. 2377 2393 return ownedStyle->getCachedPseudoStyle(pseudoElementSpecifier); … … 2380 2396 } 2381 2397 2382 return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);2398 return element.computedStyle(element.isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier); 2383 2399 } 2384 2400 … … 2447 2463 } 2448 2464 2449 RefPtr<CSSValue> ComputedStyleExtractor::customPropertyValue(const String& propertyName) const2450 { 2451 Node* styledNode = this->styledNode();2452 if (!styled Node)2465 RefPtr<CSSValue> ComputedStyleExtractor::customPropertyValue(const String& propertyName) 2466 { 2467 Element* styledElement = this->styledElement(); 2468 if (!styledElement) 2453 2469 return nullptr; 2454 2470 2455 if (updateStyleIfNeededForNode(*styledNode)) { 2456 // The style recalc could have caused the styled node to be discarded or replaced 2457 // if it was a PseudoElement so we need to update it. 2458 styledNode = this->styledNode(); 2471 if (updateStyleIfNeededForElement(*styledElement)) { 2472 // Style update may change styledElement() to PseudoElement or back. 2473 styledElement = this->styledElement(); 2459 2474 } 2460 2475 2461 2476 std::unique_ptr<RenderStyle> ownedStyle; 2462 auto* style = computeRenderStyleForProperty( styledNode, m_pseudoElementSpecifier, CSSPropertyCustom, ownedStyle);2477 auto* style = computeRenderStyleForProperty(*styledElement, m_pseudoElementSpecifier, CSSPropertyCustom, ownedStyle); 2463 2478 if (!style || !style->hasCustomProperty(propertyName)) 2464 2479 return nullptr; … … 2467 2482 } 2468 2483 2469 String ComputedStyleExtractor::customPropertyText(const String& propertyName) const2470 { 2471 RefPtr<CSSValue> propertyValue = this->customPropertyValue(propertyName);2484 String ComputedStyleExtractor::customPropertyText(const String& propertyName) 2485 { 2486 RefPtr<CSSValue> propertyValue = customPropertyValue(propertyName); 2472 2487 return propertyValue ? propertyValue->cssText() : emptyString(); 2473 2488 } 2474 2489 2475 RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const2476 { 2477 Node* styledNode = this->styledNode();2478 if (!styled Node)2490 RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) 2491 { 2492 auto* styledElement = this->styledElement(); 2493 if (!styledElement) 2479 2494 return nullptr; 2480 2495 … … 2484 2499 bool forceFullLayout = false; 2485 2500 if (updateLayout) { 2486 Document& document = styledNode->document(); 2487 2488 if (updateStyleIfNeededForNode(*styledNode)) { 2489 // The style recalc could have caused the styled node to be discarded or replaced 2490 // if it was a PseudoElement so we need to update it. 2491 styledNode = this->styledNode(); 2492 } 2493 2494 renderer = styledNode->renderer(); 2495 2496 if (propertyID == CSSPropertyDisplay && !renderer && is<SVGElement>(*styledNode) && !downcast<SVGElement>(*styledNode).isValid()) 2501 Document& document = m_element->document(); 2502 2503 if (updateStyleIfNeededForElement(*styledElement)) { 2504 // Style update may change styledElement() to PseudoElement or back. 2505 styledElement = this->styledElement(); 2506 } 2507 renderer = styledElement->renderer(); 2508 2509 if (propertyID == CSSPropertyDisplay && !renderer && is<SVGElement>(*styledElement) && !downcast<SVGElement>(*styledElement).isValid()) 2497 2510 return nullptr; 2498 2511 2499 style = computeRenderStyleForProperty( styledNode, m_pseudoElementSpecifier, propertyID, ownedStyle);2512 style = computeRenderStyleForProperty(*styledElement, m_pseudoElementSpecifier, propertyID, ownedStyle); 2500 2513 2501 2514 // FIXME: Some of these cases could be narrowed down or optimized better. 2502 2515 forceFullLayout = isLayoutDependent(propertyID, style, renderer) 2503 || styled Node->isInShadowTree()2516 || styledElement->isInShadowTree() 2504 2517 || (document.styleScope().resolverIfExists() && document.styleScope().resolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement()); 2505 2518 2506 2519 if (forceFullLayout) { 2507 2520 document.updateLayoutIgnorePendingStylesheets(); 2508 styled Node = this->styledNode();2521 styledElement = this->styledElement(); 2509 2522 } 2510 2523 } 2511 2524 2512 2525 if (!updateLayout || forceFullLayout) { 2513 style = computeRenderStyleForProperty( styledNode, m_pseudoElementSpecifier, propertyID, ownedStyle);2514 renderer = styled Node->renderer();2526 style = computeRenderStyleForProperty(*styledElement, m_pseudoElementSpecifier, propertyID, ownedStyle); 2527 renderer = styledElement->renderer(); 2515 2528 } 2516 2529 … … 2820 2833 return valueForItemPositionWithOverflowAlignment(style->alignItems()); 2821 2834 case CSSPropertyAlignSelf: 2822 return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(style->alignSelf(), styled Node->parentNode()));2835 return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(style->alignSelf(), styledElement->parentNode())); 2823 2836 case CSSPropertyFlex: 2824 2837 return getCSSPropertyValuesForShorthandProperties(flexShorthand()); … … 2839 2852 #if ENABLE(CSS_GRID_LAYOUT) 2840 2853 case CSSPropertyJustifyItems: 2841 return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto(style->justifyItems(), styled Node->parentNode()));2854 return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto(style->justifyItems(), styledElement->parentNode())); 2842 2855 case CSSPropertyJustifySelf: 2843 return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style->justifySelf(), styled Node->parentNode()));2856 return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style->justifySelf(), styledElement->parentNode())); 2844 2857 #endif 2845 2858 case CSSPropertyOrder: … … 2891 2904 #if ENABLE(VARIATION_FONTS) 2892 2905 case CSSPropertyFontVariationSettings: { 2893 if (styled Node->document().settings() && styledNode->document().settings()->variationFontsEnabled()) {2906 if (styledElement->document().settings() && styledElement->document().settings()->variationFontsEnabled()) { 2894 2907 const FontVariationSettings& variationSettings = style->fontDescription().variationSettings(); 2895 2908 if (variationSettings.isEmpty()) … … 3077 3090 case CSSPropertyMinHeight: 3078 3091 if (style->minHeight().isAuto()) { 3079 if (isFlexOrGrid(styled Node->parentNode()))3092 if (isFlexOrGrid(styledElement->parentNode())) 3080 3093 return cssValuePool.createIdentifierValue(CSSValueAuto); 3081 3094 return zoomAdjustedPixelValue(0, *style); … … 3084 3097 case CSSPropertyMinWidth: 3085 3098 if (style->minWidth().isAuto()) { 3086 if (isFlexOrGrid(styled Node->parentNode()))3099 if (isFlexOrGrid(styledElement->parentNode())) 3087 3100 return cssValuePool.createIdentifierValue(CSSValueAuto); 3088 3101 return zoomAdjustedPixelValue(0, *style); … … 3965 3978 unsigned CSSComputedStyleDeclaration::length() const 3966 3979 { 3967 auto& element = m_element.get(); 3968 updateStyleIfNeededForNode(element); 3969 3970 auto* style = const_cast<Element&>(element).computedStyle(m_pseudoElementSpecifier); 3980 updateStyleIfNeededForElement(m_element.get()); 3981 3982 auto* style = m_element->computedStyle(m_pseudoElementSpecifier); 3971 3983 if (!style) 3972 3984 return 0; … … 3983 3995 return getPropertyNameString(computedProperties[i]); 3984 3996 3985 auto& element = m_element.get(); 3986 auto* style = const_cast<Element&>(element).computedStyle(m_pseudoElementSpecifier); 3997 auto* style = m_element->computedStyle(m_pseudoElementSpecifier); 3987 3998 if (!style) 3988 3999 return String(); … … 3999 4010 } 4000 4011 4001 bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) const 4002 { 4003 if (propertyID == CSSPropertyFontSize && is<CSSPrimitiveValue>(*value) && m_node) { 4004 m_node->document().updateLayoutIgnorePendingStylesheets(); 4005 if (auto* style = m_node->computedStyle(m_pseudoElementSpecifier)) { 4012 bool ComputedStyleExtractor::propertyMatches(CSSPropertyID propertyID, const CSSValue* value) 4013 { 4014 if (!m_element) 4015 return false; 4016 if (propertyID == CSSPropertyFontSize && is<CSSPrimitiveValue>(*value)) { 4017 m_element->document().updateLayoutIgnorePendingStylesheets(); 4018 if (auto* style = m_element->computedStyle(m_pseudoElementSpecifier)) { 4006 4019 if (CSSValueID sizeIdentifier = style->fontDescription().keywordSizeAsIdentifier()) { 4007 4020 auto& primitiveValue = downcast<CSSPrimitiveValue>(*value); … … 4015 4028 } 4016 4029 4017 Ref<MutableStyleProperties> ComputedStyleExtractor::copyProperties() const4030 Ref<MutableStyleProperties> ComputedStyleExtractor::copyProperties() 4018 4031 { 4019 4032 return copyPropertiesInSet(computedProperties, numComputedProperties); 4020 4033 } 4021 4034 4022 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const4035 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) 4023 4036 { 4024 4037 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); … … 4030 4043 } 4031 4044 4032 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const4045 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) 4033 4046 { 4034 4047 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); … … 4058 4071 } 4059 4072 4060 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const4073 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) 4061 4074 { 4062 4075 RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated(); … … 4068 4081 } 4069 4082 4070 Ref<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const4083 Ref<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) 4071 4084 { 4072 4085 Vector<CSSProperty, 256> list; … … 4088 4101 { 4089 4102 if (isCustomPropertyName(propertyName)) 4090 return ComputedStyleExtractor(m_element. copyRef(), m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyValue(propertyName);4103 return ComputedStyleExtractor(m_element.ptr(), m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyValue(propertyName); 4091 4104 4092 4105 CSSPropertyID propertyID = cssPropertyID(propertyName); … … 4100 4113 { 4101 4114 if (isCustomPropertyName(propertyName)) 4102 return ComputedStyleExtractor(m_element. copyRef(), m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyText(propertyName);4115 return ComputedStyleExtractor(m_element.ptr(), m_allowVisitedStyle, m_pseudoElementSpecifier).customPropertyText(propertyName); 4103 4116 4104 4117 CSSPropertyID propertyID = cssPropertyID(propertyName); … … 4149 4162 } 4150 4163 4151 Ref<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const4164 Ref<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() 4152 4165 { 4153 4166 static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition }; -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h
r207396 r207686 48 48 class ComputedStyleExtractor { 49 49 public: 50 ComputedStyleExtractor(RefPtr<Node>&&, bool allowVisitedStyle = false, PseudoId = NOPSEUDO); 50 ComputedStyleExtractor(Node*, bool allowVisitedStyle = false, PseudoId = NOPSEUDO); 51 ComputedStyleExtractor(Element*, bool allowVisitedStyle = false, PseudoId = NOPSEUDO); 51 52 52 RefPtr<CSSValue> propertyValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const;53 String customPropertyText(const String& propertyName) const;54 RefPtr<CSSValue> customPropertyValue(const String& propertyName) const;53 RefPtr<CSSValue> propertyValue(CSSPropertyID, EUpdateLayout = UpdateLayout); 54 String customPropertyText(const String& propertyName); 55 RefPtr<CSSValue> customPropertyValue(const String& propertyName); 55 56 56 57 // Helper methods for HTML editing. 57 Ref<MutableStyleProperties> copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const;58 Ref<MutableStyleProperties> copyProperties() const;59 RefPtr<CSSPrimitiveValue> getFontSizeCSSValuePreferringKeyword() const;60 bool useFixedFontDefaultSize() const;61 bool propertyMatches(CSSPropertyID, const CSSValue*) const;58 Ref<MutableStyleProperties> copyPropertiesInSet(const CSSPropertyID* set, unsigned length); 59 Ref<MutableStyleProperties> copyProperties(); 60 RefPtr<CSSPrimitiveValue> getFontSizeCSSValuePreferringKeyword(); 61 bool useFixedFontDefaultSize(); 62 bool propertyMatches(CSSPropertyID, const CSSValue*); 62 63 63 64 static Ref<CSSValue> valueForFilter(const RenderStyle&, const FilterOperations&, AdjustPixelValuesForComputedStyle = AdjustPixelValues); 64 65 65 66 private: 66 // The styled node is either the nodepassed into computedPropertyValue, or the67 // The styled element is either the element passed into computedPropertyValue, or the 67 68 // PseudoElement for :before and :after if they exist. 68 // FIXME: This should be styledElement since in JS getComputedStyle only works 69 // on Elements, but right now editing creates these for text nodes. We should fix that. 70 Node* styledNode() const; 69 Element* styledElement(); 71 70 72 RefPtr<CSSValue> svgPropertyValue(CSSPropertyID, EUpdateLayout) const;71 RefPtr<CSSValue> svgPropertyValue(CSSPropertyID, EUpdateLayout); 73 72 RefPtr<SVGPaint> adjustSVGPaintForCurrentColor(RefPtr<SVGPaint>&&, const RenderStyle*) const; 74 73 … … 76 75 RefPtr<CSSPrimitiveValue> currentColorOrValidColor(const RenderStyle*, const Color&) const; 77 76 78 RefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand&) const;79 RefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand&) const;80 Ref<CSSValueList> getBackgroundShorthandValue() const;81 RefPtr<CSSValueList> getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand&) const;77 RefPtr<CSSValueList> getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand&); 78 RefPtr<CSSValueList> getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand&); 79 Ref<CSSValueList> getBackgroundShorthandValue(); 80 RefPtr<CSSValueList> getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand&); 82 81 83 RefPtr< Node> m_node;82 RefPtr<Element> m_element; 84 83 PseudoId m_pseudoElementSpecifier; 85 84 bool m_allowVisitedStyle; … … 122 121 RefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const; 123 122 124 Ref<Element> m_element;123 mutable Ref<Element> m_element; 125 124 PseudoId m_pseudoElementSpecifier; 126 125 bool m_allowVisitedStyle; -
trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp
r201113 r207686 25 25 #include "CSSPropertyNames.h" 26 26 #include "Document.h" 27 #include "Element.h" 27 28 #include "RenderStyle.h" 28 29 #include "SVGPaint.h" … … 101 102 } 102 103 103 RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const 104 { 105 Node* node = m_node.get(); 106 if (!node) 104 RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) 105 { 106 if (!m_element) 107 107 return nullptr; 108 108 109 109 // Make sure our layout is up to date before we allow a query on these attributes. 110 110 if (updateLayout) 111 node->document().updateLayout();112 113 auto* style = node->computedStyle();111 m_element->document().updateLayout(); 112 113 auto* style = m_element->computedStyle(); 114 114 if (!style) 115 115 return nullptr; -
trunk/Source/WebCore/editing/EditingStyle.cpp
r207396 r207686 1365 1365 1366 1366 template<typename T> 1367 void EditingStyle::removeEquivalentProperties( constT& style)1367 void EditingStyle::removeEquivalentProperties(T& style) 1368 1368 { 1369 1369 Vector<CSSPropertyID> propertiesToRemove; -
trunk/Source/WebCore/editing/EditingStyle.h
r204717 r207686 124 124 void removeStyleAddedByNode(Node*); 125 125 void removeStyleConflictingWithStyleOfNode(Node*); 126 template<typename T> void removeEquivalentProperties( constT&);126 template<typename T> void removeEquivalentProperties(T&); 127 127 void collapseTextDecorationProperties(); 128 128 enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreTextOnlyProperties };
Note:
See TracChangeset
for help on using the changeset viewer.