Changeset 207686 in webkit


Ignore:
Timestamp:
Oct 21, 2016 11:20:07 AM (8 years ago)
Author:
Antti Koivisto
Message:

Tighten ComputedStyleExtractor to use Element instead of Node
https://bugs.webkit.org/show_bug.cgi?id=163798

Reviewed by Andreas Kling.

Also make its functions non-const as they may compute style.

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::styleElementForNode):
(WebCore::ComputedStyleExtractor::ComputedStyleExtractor):

If we are called with a Node figure out the style Element in constructor.

(WebCore::ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword):
(WebCore::ComputedStyleExtractor::useFixedFontDefaultSize):
(WebCore::ComputedStyleExtractor::styledElement):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
(WebCore::CSSComputedStyleDeclaration::copyProperties):
(WebCore::elementOrItsAncestorNeedsStyleRecalc):

Use composed tree iterator for increased correctness in shadow trees.

(WebCore::updateStyleIfNeededForElement):
(WebCore::computeRenderStyleForProperty):
(WebCore::ComputedStyleExtractor::customPropertyValue):
(WebCore::ComputedStyleExtractor::customPropertyText):
(WebCore::ComputedStyleExtractor::propertyValue):
(WebCore::CSSComputedStyleDeclaration::length):
(WebCore::CSSComputedStyleDeclaration::item):
(WebCore::ComputedStyleExtractor::propertyMatches):
(WebCore::ComputedStyleExtractor::copyProperties):
(WebCore::ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties):
(WebCore::ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand):
(WebCore::ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand):
(WebCore::ComputedStyleExtractor::copyPropertiesInSet):
(WebCore::CSSComputedStyleDeclaration::getPropertyValue):
(WebCore::ComputedStyleExtractor::getBackgroundShorthandValue):
(WebCore::ComputedStyleExtractor::styledNode): Deleted.
(WebCore::nodeOrItsAncestorNeedsStyleRecalc): Deleted.
(WebCore::updateStyleIfNeededForNode): Deleted.

  • css/CSSComputedStyleDeclaration.h:
  • css/SVGCSSComputedStyleDeclaration.cpp:

(WebCore::ComputedStyleExtractor::svgPropertyValue):

  • editing/EditingStyle.cpp:

(WebCore::EditingStyle::removeEquivalentProperties):

  • editing/EditingStyle.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r207685 r207686  
     12016-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
    1502016-10-21  Chris Dumez  <cdumez@apple.com>
    251
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r207669 r207686  
    5050#include "CSSValueList.h"
    5151#include "CSSValuePool.h"
     52#include "ComposedTreeAncestorIterator.h"
    5253#include "ContentData.h"
    5354#include "CounterContent.h"
     
    7374#include "StyleResolver.h"
    7475#include "StyleScope.h"
     76#include "Text.h"
    7577#include "WebKitCSSFilterValue.h"
    7678#include "WebKitCSSTransformValue.h"
     
    15841586}
    15851587
    1586 ComputedStyleExtractor::ComputedStyleExtractor(RefPtr<Node>&& node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
    1587     : m_node(WTFMove(node))
     1588static 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
     1597ComputedStyleExtractor::ComputedStyleExtractor(Node* node, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
     1598    : m_element(styleElementForNode(node))
    15881599    , m_pseudoElementSpecifier(pseudoElementSpecifier)
    15891600    , m_allowVisitedStyle(allowVisitedStyle)
     
    15911602}
    15921603
     1604ComputedStyleExtractor::ComputedStyleExtractor(Element* element, bool allowVisitedStyle, PseudoId pseudoElementSpecifier)
     1605    : m_element(element)
     1606    , m_pseudoElementSpecifier(pseudoElementSpecifier)
     1607    , m_allowVisitedStyle(allowVisitedStyle)
     1608{
     1609}
    15931610
    15941611CSSComputedStyleDeclaration::CSSComputedStyleDeclaration(Element& element, bool allowVisitedStyle, const String& pseudoElementName)
     
    16391656}
    16401657
    1641 RefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword() const
    1642 {
    1643     if (!m_node)
     1658RefPtr<CSSPrimitiveValue> ComputedStyleExtractor::getFontSizeCSSValuePreferringKeyword()
     1659{
     1660    if (!m_element)
    16441661        return nullptr;
    16451662
    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);
    16491666    if (!style)
    16501667        return nullptr;
     
    16561673}
    16571674
    1658 bool ComputedStyleExtractor::useFixedFontDefaultSize() const
    1659 {
    1660     if (!m_node)
     1675bool ComputedStyleExtractor::useFixedFontDefaultSize()
     1676{
     1677    if (!m_element)
    16611678        return false;
    1662 
    1663     auto* style = m_node->computedStyle(m_pseudoElementSpecifier);
     1679    auto* style = m_element->computedStyle(m_pseudoElementSpecifier);
    16641680    if (!style)
    16651681        return false;
     
    22652281}
    22662282
    2267 Node* ComputedStyleExtractor::styledNode() const
    2268 {
    2269     if (!m_node)
     2283Element* ComputedStyleExtractor::styledElement()
     2284{
     2285    if (!m_element)
    22702286        return nullptr;
    2271     if (!is<Element>(*m_node))
    2272         return m_node.get();
    2273     Element& element = downcast<Element>(*m_node);
    22742287    PseudoElement* pseudoElement;
    2275     if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = element.beforePseudoElement()))
     2288    if (m_pseudoElementSpecifier == BEFORE && (pseudoElement = m_element->beforePseudoElement()))
    22762289        return pseudoElement;
    2277     if (m_pseudoElementSpecifier == AFTER && (pseudoElement = element.afterPseudoElement()))
     2290    if (m_pseudoElementSpecifier == AFTER && (pseudoElement = m_element->afterPseudoElement()))
    22782291        return pseudoElement;
    2279     return &element;
     2292    return m_element.get();
    22802293}
    22812294
     
    23272340RefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
    23282341{
    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);
    23302343}
    23312344
    23322345Ref<MutableStyleProperties> CSSComputedStyleDeclaration::copyProperties() const
    23332346{
    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
     2350static inline bool elementOrItsAncestorNeedsStyleRecalc(Element& element)
     2351{
     2352    if (element.needsStyleRecalc())
    23402353        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())
    23462362            return true;
    23472363
    2348         if (ancestor->directChildNeedsStyleRecalc() && currentNode->styleIsAffectedByPreviousSibling())
     2364        if (ancestor.directChildNeedsStyleRecalc() && currentElement->styleIsAffectedByPreviousSibling())
    23492365            return true;
    23502366
    2351         currentNode = ancestor;
    2352         ancestor = currentNode->parentOrShadowHostElement();
     2367        currentElement = &ancestor;
    23532368    }
    23542369    return false;
    23552370}
    23562371
    2357 static bool updateStyleIfNeededForNode(const Node& node)
    2358 {
    2359     Document& document = node.document();
     2372static bool updateStyleIfNeededForElement(Element& element)
     2373{
     2374    auto& document = element.document();
    23602375
    23612376    document.styleScope().flushPendingUpdate();
    23622377
    2363     if (!document.hasPendingForcedStyleRecalc() && !(document.childNeedsStyleRecalc() && nodeOrItsAncestorNeedsStyleRecalc(node)))
     2378    if (!elementOrItsAncestorNeedsStyleRecalc(element))
    23642379        return false;
     2380
    23652381    document.updateStyleIfNeeded();
    23662382    return true;
    23672383}
    23682384
    2369 static inline const RenderStyle* computeRenderStyleForProperty(Node* styledNode, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID, std::unique_ptr<RenderStyle>& ownedStyle)
    2370 {
    2371     RenderObject* renderer = styledNode->renderer();
     2385static inline const RenderStyle* computeRenderStyleForProperty(Element& element, PseudoId pseudoElementSpecifier, CSSPropertyID propertyID, std::unique_ptr<RenderStyle>& ownedStyle)
     2386{
     2387    auto* renderer = element.renderer();
    23722388
    23732389    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()) {
    23762392            // FIXME: This cached pseudo style will only exist if the animation has been run at least once.
    23772393            return ownedStyle->getCachedPseudoStyle(pseudoElementSpecifier);
     
    23802396    }
    23812397
    2382     return styledNode->computedStyle(styledNode->isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
     2398    return element.computedStyle(element.isPseudoElement() ? NOPSEUDO : pseudoElementSpecifier);
    23832399}
    23842400
     
    24472463}
    24482464
    2449 RefPtr<CSSValue> ComputedStyleExtractor::customPropertyValue(const String& propertyName) const
    2450 {
    2451     Node* styledNode = this->styledNode();
    2452     if (!styledNode)
     2465RefPtr<CSSValue> ComputedStyleExtractor::customPropertyValue(const String& propertyName)
     2466{
     2467    Element* styledElement = this->styledElement();
     2468    if (!styledElement)
    24532469        return nullptr;
    24542470   
    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();
    24592474    }
    24602475
    24612476    std::unique_ptr<RenderStyle> ownedStyle;
    2462     auto* style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, CSSPropertyCustom, ownedStyle);
     2477    auto* style = computeRenderStyleForProperty(*styledElement, m_pseudoElementSpecifier, CSSPropertyCustom, ownedStyle);
    24632478    if (!style || !style->hasCustomProperty(propertyName))
    24642479        return nullptr;
     
    24672482}
    24682483
    2469 String ComputedStyleExtractor::customPropertyText(const String& propertyName) const
    2470 {
    2471     RefPtr<CSSValue> propertyValue = this->customPropertyValue(propertyName);
     2484String ComputedStyleExtractor::customPropertyText(const String& propertyName)
     2485{
     2486    RefPtr<CSSValue> propertyValue = customPropertyValue(propertyName);
    24722487    return propertyValue ? propertyValue->cssText() : emptyString();
    24732488}
    24742489
    2475 RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
    2476 {
    2477     Node* styledNode = this->styledNode();
    2478     if (!styledNode)
     2490RefPtr<CSSValue> ComputedStyleExtractor::propertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout)
     2491{
     2492    auto* styledElement = this->styledElement();
     2493    if (!styledElement)
    24792494        return nullptr;
    24802495
     
    24842499    bool forceFullLayout = false;
    24852500    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())
    24972510            return nullptr;
    24982511
    2499         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID, ownedStyle);
     2512        style = computeRenderStyleForProperty(*styledElement, m_pseudoElementSpecifier, propertyID, ownedStyle);
    25002513
    25012514        // FIXME: Some of these cases could be narrowed down or optimized better.
    25022515        forceFullLayout = isLayoutDependent(propertyID, style, renderer)
    2503             || styledNode->isInShadowTree()
     2516            || styledElement->isInShadowTree()
    25042517            || (document.styleScope().resolverIfExists() && document.styleScope().resolverIfExists()->hasViewportDependentMediaQueries() && document.ownerElement());
    25052518
    25062519        if (forceFullLayout) {
    25072520            document.updateLayoutIgnorePendingStylesheets();
    2508             styledNode = this->styledNode();
     2521            styledElement = this->styledElement();
    25092522        }
    25102523    }
    25112524
    25122525    if (!updateLayout || forceFullLayout) {
    2513         style = computeRenderStyleForProperty(styledNode, m_pseudoElementSpecifier, propertyID, ownedStyle);
    2514         renderer = styledNode->renderer();
     2526        style = computeRenderStyleForProperty(*styledElement, m_pseudoElementSpecifier, propertyID, ownedStyle);
     2527        renderer = styledElement->renderer();
    25152528    }
    25162529
     
    28202833            return valueForItemPositionWithOverflowAlignment(style->alignItems());
    28212834        case CSSPropertyAlignSelf:
    2822             return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(style->alignSelf(), styledNode->parentNode()));
     2835            return valueForItemPositionWithOverflowAlignment(resolveAlignSelfAuto(style->alignSelf(), styledElement->parentNode()));
    28232836        case CSSPropertyFlex:
    28242837            return getCSSPropertyValuesForShorthandProperties(flexShorthand());
     
    28392852#if ENABLE(CSS_GRID_LAYOUT)
    28402853        case CSSPropertyJustifyItems:
    2841             return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto(style->justifyItems(), styledNode->parentNode()));
     2854            return valueForItemPositionWithOverflowAlignment(resolveJustifyItemsAuto(style->justifyItems(), styledElement->parentNode()));
    28422855        case CSSPropertyJustifySelf:
    2843             return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style->justifySelf(), styledNode->parentNode()));
     2856            return valueForItemPositionWithOverflowAlignment(resolveJustifySelfAuto(style->justifySelf(), styledElement->parentNode()));
    28442857#endif
    28452858        case CSSPropertyOrder:
     
    28912904#if ENABLE(VARIATION_FONTS)
    28922905        case CSSPropertyFontVariationSettings: {
    2893             if (styledNode->document().settings() && styledNode->document().settings()->variationFontsEnabled()) {
     2906            if (styledElement->document().settings() && styledElement->document().settings()->variationFontsEnabled()) {
    28942907                const FontVariationSettings& variationSettings = style->fontDescription().variationSettings();
    28952908                if (variationSettings.isEmpty())
     
    30773090        case CSSPropertyMinHeight:
    30783091            if (style->minHeight().isAuto()) {
    3079                 if (isFlexOrGrid(styledNode->parentNode()))
     3092                if (isFlexOrGrid(styledElement->parentNode()))
    30803093                    return cssValuePool.createIdentifierValue(CSSValueAuto);
    30813094                return zoomAdjustedPixelValue(0, *style);
     
    30843097        case CSSPropertyMinWidth:
    30853098            if (style->minWidth().isAuto()) {
    3086                 if (isFlexOrGrid(styledNode->parentNode()))
     3099                if (isFlexOrGrid(styledElement->parentNode()))
    30873100                    return cssValuePool.createIdentifierValue(CSSValueAuto);
    30883101                return zoomAdjustedPixelValue(0, *style);
     
    39653978unsigned CSSComputedStyleDeclaration::length() const
    39663979{
    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);
    39713983    if (!style)
    39723984        return 0;
     
    39833995        return getPropertyNameString(computedProperties[i]);
    39843996   
    3985     auto& element = m_element.get();
    3986     auto* style = const_cast<Element&>(element).computedStyle(m_pseudoElementSpecifier);
     3997    auto* style = m_element->computedStyle(m_pseudoElementSpecifier);
    39873998    if (!style)
    39883999        return String();
     
    39994010}
    40004011
    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)) {
     4012bool 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)) {
    40064019            if (CSSValueID sizeIdentifier = style->fontDescription().keywordSizeAsIdentifier()) {
    40074020                auto& primitiveValue = downcast<CSSPrimitiveValue>(*value);
     
    40154028}
    40164029
    4017 Ref<MutableStyleProperties> ComputedStyleExtractor::copyProperties() const
     4030Ref<MutableStyleProperties> ComputedStyleExtractor::copyProperties()
    40184031{
    40194032    return copyPropertiesInSet(computedProperties, numComputedProperties);
    40204033}
    40214034
    4022 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand) const
     4035RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForShorthandProperties(const StylePropertyShorthand& shorthand)
    40234036{
    40244037    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     
    40304043}
    40314044
    4032 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand) const
     4045RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForSidesShorthand(const StylePropertyShorthand& shorthand)
    40334046{
    40344047    RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
     
    40584071}
    40594072
    4060 RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand) const
     4073RefPtr<CSSValueList> ComputedStyleExtractor::getCSSPropertyValuesForGridShorthand(const StylePropertyShorthand& shorthand)
    40614074{
    40624075    RefPtr<CSSValueList> list = CSSValueList::createSlashSeparated();
     
    40684081}
    40694082
    4070 Ref<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
     4083Ref<MutableStyleProperties> ComputedStyleExtractor::copyPropertiesInSet(const CSSPropertyID* set, unsigned length)
    40714084{
    40724085    Vector<CSSProperty, 256> list;
     
    40884101{
    40894102    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);
    40914104
    40924105    CSSPropertyID propertyID = cssPropertyID(propertyName);
     
    41004113{
    41014114    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);
    41034116
    41044117    CSSPropertyID propertyID = cssPropertyID(propertyName);
     
    41494162}
    41504163
    4151 Ref<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue() const
     4164Ref<CSSValueList> ComputedStyleExtractor::getBackgroundShorthandValue()
    41524165{
    41534166    static const CSSPropertyID propertiesBeforeSlashSeperator[5] = { CSSPropertyBackgroundColor, CSSPropertyBackgroundImage, CSSPropertyBackgroundRepeat, CSSPropertyBackgroundAttachment, CSSPropertyBackgroundPosition };
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h

    r207396 r207686  
    4848class ComputedStyleExtractor {
    4949public:
    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);
    5152
    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);
    5556
    5657    // 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*);
    6263
    6364    static Ref<CSSValue> valueForFilter(const RenderStyle&, const FilterOperations&, AdjustPixelValuesForComputedStyle = AdjustPixelValues);
    6465
    6566private:
    66     // The styled node is either the node passed into computedPropertyValue, or the
     67    // The styled element is either the element passed into computedPropertyValue, or the
    6768    // 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();
    7170
    72     RefPtr<CSSValue> svgPropertyValue(CSSPropertyID, EUpdateLayout) const;
     71    RefPtr<CSSValue> svgPropertyValue(CSSPropertyID, EUpdateLayout);
    7372    RefPtr<SVGPaint> adjustSVGPaintForCurrentColor(RefPtr<SVGPaint>&&, const RenderStyle*) const;
    7473
     
    7675    RefPtr<CSSPrimitiveValue> currentColorOrValidColor(const RenderStyle*, const Color&) const;
    7776
    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&);
    8281
    83     RefPtr<Node> m_node;
     82    RefPtr<Element> m_element;
    8483    PseudoId m_pseudoElementSpecifier;
    8584    bool m_allowVisitedStyle;
     
    122121    RefPtr<CSSValue> getPropertyCSSValue(CSSPropertyID, EUpdateLayout = UpdateLayout) const;
    123122
    124     Ref<Element> m_element;
     123    mutable Ref<Element> m_element;
    125124    PseudoId m_pseudoElementSpecifier;
    126125    bool m_allowVisitedStyle;
  • trunk/Source/WebCore/css/SVGCSSComputedStyleDeclaration.cpp

    r201113 r207686  
    2525#include "CSSPropertyNames.h"
    2626#include "Document.h"
     27#include "Element.h"
    2728#include "RenderStyle.h"
    2829#include "SVGPaint.h"
     
    101102}
    102103
    103 RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout) const
    104 {
    105     Node* node = m_node.get();
    106     if (!node)
     104RefPtr<CSSValue> ComputedStyleExtractor::svgPropertyValue(CSSPropertyID propertyID, EUpdateLayout updateLayout)
     105{
     106    if (!m_element)
    107107        return nullptr;
    108108
    109109    // Make sure our layout is up to date before we allow a query on these attributes.
    110110    if (updateLayout)
    111         node->document().updateLayout();
    112 
    113     auto* style = node->computedStyle();
     111        m_element->document().updateLayout();
     112
     113    auto* style = m_element->computedStyle();
    114114    if (!style)
    115115        return nullptr;
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r207396 r207686  
    13651365
    13661366template<typename T>
    1367 void EditingStyle::removeEquivalentProperties(const T& style)
     1367void EditingStyle::removeEquivalentProperties(T& style)
    13681368{
    13691369    Vector<CSSPropertyID> propertiesToRemove;
  • trunk/Source/WebCore/editing/EditingStyle.h

    r204717 r207686  
    124124    void removeStyleAddedByNode(Node*);
    125125    void removeStyleConflictingWithStyleOfNode(Node*);
    126     template<typename T> void removeEquivalentProperties(const T&);
     126    template<typename T> void removeEquivalentProperties(T&);
    127127    void collapseTextDecorationProperties();
    128128    enum ShouldIgnoreTextOnlyProperties { IgnoreTextOnlyProperties, DoNotIgnoreTextOnlyProperties };
Note: See TracChangeset for help on using the changeset viewer.