Changeset 195465 in webkit


Ignore:
Timestamp:
Jan 22, 2016 12:00:34 PM (8 years ago)
Author:
Antti Koivisto
Message:

Style resolver initialization cleanups
https://bugs.webkit.org/show_bug.cgi?id=153356

Reviewed by Simon Fraser.

Simplify StyleResolver::State initialization.
Also use more references and other cleanups.

  • css/MediaQueryMatcher.cpp:

(WebCore::MediaQueryMatcher::prepareEvaluator):

  • css/StyleMedia.cpp:

(WebCore::StyleMedia::matchMedium):

  • css/StyleResolver.cpp:

(WebCore::StyleResolver::State::clear):
(WebCore::StyleResolver::StyleResolver):
(WebCore::StyleResolver::classNamesAffectedByRules):
(WebCore::StyleResolver::State::State):

Initialize State using a constructor instead of bunch of construction functions.
Remove m_styledElement field which is just a casted version of m_element.

(WebCore::StyleResolver::State::updateConversionData):
(WebCore::StyleResolver::State::setStyle):
(WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
(WebCore::StyleResolver::canShareStyleWithElement):
(WebCore::StyleResolver::locateSharedStyle):
(WebCore::isAtShadowBoundary):
(WebCore::StyleResolver::styleForElement):
(WebCore::StyleResolver::styleForKeyframe):
(WebCore::StyleResolver::keyframeStylesForAnimation):
(WebCore::StyleResolver::pseudoStyleForElement):
(WebCore::StyleResolver::styleForPage):
(WebCore::StyleResolver::pseudoStyleRulesForElement):
(WebCore::StyleResolver::clearCachedPropertiesAffectedByViewportUnits):
(WebCore::isCacheableInMatchedPropertiesCache):

Disallow caching of document element style entirely because the writing-mode and direction properties have special handling.
The existing check wasn't robust.

(WebCore::extractDirectionAndWritingMode):
(WebCore::StyleResolver::applyMatchedProperties):
(WebCore::StyleResolver::applyPropertyToStyle):
(WebCore::StyleResolver::State::initElement): Deleted.
(WebCore::StyleResolver::initElement): Deleted.
(WebCore::StyleResolver::State::initForStyleResolve): Deleted.

  • css/StyleResolver.h:

(WebCore::StyleResolver::mediaQueryEvaluator):
(WebCore::StyleResolver::State::State):
(WebCore::StyleResolver::State::document):
(WebCore::StyleResolver::State::element):
(WebCore::StyleResolver::State::style):
(WebCore::StyleResolver::State::takeStyle):
(WebCore::StyleResolver::State::styledElement): Deleted.

  • dom/Element.cpp:

(WebCore::Element::resolveStyle):

  • page/animation/KeyframeAnimation.cpp:

(WebCore::KeyframeAnimation::KeyframeAnimation):

  • rendering/RenderElement.cpp:

(WebCore::RenderElement::getUncachedPseudoStyle):
(WebCore::RenderElement::containingBlockForFixedPosition):

  • rendering/RenderNamedFlowFragment.cpp:

(WebCore::RenderNamedFlowFragment::computeStyleInRegion):

  • style/StyleTreeResolver.cpp:

(WebCore::Style::TreeResolver::styleForElement):

  • svg/SVGElement.cpp:

(WebCore::SVGElement::customStyleForRenderer):
(WebCore::SVGElement::computedStyle):
(WebCore::addQualifiedName):

  • svg/SVGElementRareData.h:

(WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
(WebCore::SVGElementRareData::overrideComputedStyle):

Location:
trunk/Source/WebCore
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r195463 r195465  
     12016-01-22  Antti Koivisto  <antti@apple.com>
     2
     3        Style resolver initialization cleanups
     4        https://bugs.webkit.org/show_bug.cgi?id=153356
     5
     6        Reviewed by Simon Fraser.
     7
     8            Simplify StyleResolver::State initialization.
     9            Also use more references and other cleanups.
     10
     11        * css/MediaQueryMatcher.cpp:
     12        (WebCore::MediaQueryMatcher::prepareEvaluator):
     13        * css/StyleMedia.cpp:
     14        (WebCore::StyleMedia::matchMedium):
     15        * css/StyleResolver.cpp:
     16        (WebCore::StyleResolver::State::clear):
     17        (WebCore::StyleResolver::StyleResolver):
     18        (WebCore::StyleResolver::classNamesAffectedByRules):
     19        (WebCore::StyleResolver::State::State):
     20
     21            Initialize State using a constructor instead of bunch of construction functions.
     22            Remove m_styledElement field which is just a casted version of m_element.
     23
     24        (WebCore::StyleResolver::State::updateConversionData):
     25        (WebCore::StyleResolver::State::setStyle):
     26        (WebCore::StyleResolver::sharingCandidateHasIdenticalStyleAffectingAttributes):
     27        (WebCore::StyleResolver::canShareStyleWithElement):
     28        (WebCore::StyleResolver::locateSharedStyle):
     29        (WebCore::isAtShadowBoundary):
     30        (WebCore::StyleResolver::styleForElement):
     31        (WebCore::StyleResolver::styleForKeyframe):
     32        (WebCore::StyleResolver::keyframeStylesForAnimation):
     33        (WebCore::StyleResolver::pseudoStyleForElement):
     34        (WebCore::StyleResolver::styleForPage):
     35        (WebCore::StyleResolver::pseudoStyleRulesForElement):
     36        (WebCore::StyleResolver::clearCachedPropertiesAffectedByViewportUnits):
     37        (WebCore::isCacheableInMatchedPropertiesCache):
     38
     39            Disallow caching of document element style entirely because the writing-mode and direction properties have special handling.
     40            The existing check wasn't robust.
     41
     42        (WebCore::extractDirectionAndWritingMode):
     43        (WebCore::StyleResolver::applyMatchedProperties):
     44        (WebCore::StyleResolver::applyPropertyToStyle):
     45        (WebCore::StyleResolver::State::initElement): Deleted.
     46        (WebCore::StyleResolver::initElement): Deleted.
     47        (WebCore::StyleResolver::State::initForStyleResolve): Deleted.
     48        * css/StyleResolver.h:
     49        (WebCore::StyleResolver::mediaQueryEvaluator):
     50        (WebCore::StyleResolver::State::State):
     51        (WebCore::StyleResolver::State::document):
     52        (WebCore::StyleResolver::State::element):
     53        (WebCore::StyleResolver::State::style):
     54        (WebCore::StyleResolver::State::takeStyle):
     55        (WebCore::StyleResolver::State::styledElement): Deleted.
     56        * dom/Element.cpp:
     57        (WebCore::Element::resolveStyle):
     58        * page/animation/KeyframeAnimation.cpp:
     59        (WebCore::KeyframeAnimation::KeyframeAnimation):
     60        * rendering/RenderElement.cpp:
     61        (WebCore::RenderElement::getUncachedPseudoStyle):
     62        (WebCore::RenderElement::containingBlockForFixedPosition):
     63        * rendering/RenderNamedFlowFragment.cpp:
     64        (WebCore::RenderNamedFlowFragment::computeStyleInRegion):
     65        * style/StyleTreeResolver.cpp:
     66        (WebCore::Style::TreeResolver::styleForElement):
     67        * svg/SVGElement.cpp:
     68        (WebCore::SVGElement::customStyleForRenderer):
     69        (WebCore::SVGElement::computedStyle):
     70        (WebCore::addQualifiedName):
     71        * svg/SVGElementRareData.h:
     72        (WebCore::SVGElementRareData::ensureAnimatedSMILStyleProperties):
     73        (WebCore::SVGElementRareData::overrideComputedStyle):
     74
    1752016-01-22  Chris Fleizach  <cfleizach@apple.com>
    276
  • trunk/Source/WebCore/css/MediaQueryMatcher.cpp

    r188315 r195465  
    8686        return nullptr;
    8787
    88     RefPtr<RenderStyle> rootStyle = m_document->ensureStyleResolver().styleForElement(documentElement, m_document->renderStyle(), DisallowStyleSharing, MatchOnlyUserAgentRules);
     88    RefPtr<RenderStyle> rootStyle = m_document->ensureStyleResolver().styleForElement(*documentElement, m_document->renderStyle(), DisallowStyleSharing, MatchOnlyUserAgentRules);
    8989
    9090    return std::make_unique<MediaQueryEvaluator>(mediaType(), m_document->frame(), rootStyle.get());
  • trunk/Source/WebCore/css/StyleMedia.cpp

    r165676 r195465  
    6262        return false;
    6363
    64     RefPtr<RenderStyle> rootStyle = document->ensureStyleResolver().styleForElement(documentElement, document->renderStyle(), DisallowStyleSharing, MatchOnlyUserAgentRules);
     64    RefPtr<RenderStyle> rootStyle = document->ensureStyleResolver().styleForElement(*documentElement, document->renderStyle(), DisallowStyleSharing, MatchOnlyUserAgentRules);
    6565
    6666    RefPtr<MediaQuerySet> media = MediaQuerySet::create();
  • trunk/Source/WebCore/css/StyleResolver.cpp

    r194854 r195465  
    192192{
    193193    m_element = nullptr;
    194     m_styledElement = nullptr;
    195194    m_parentStyle = nullptr;
    196195    m_regionForStyling = nullptr;
     
    266265
    267266    if (root)
    268         m_rootDefaultStyle = styleForElement(root, m_document.renderStyle(), DisallowStyleSharing, MatchOnlyUserAgentRules);
     267        m_rootDefaultStyle = styleForElement(*root, m_document.renderStyle(), DisallowStyleSharing, MatchOnlyUserAgentRules);
    269268
    270269    if (m_rootDefaultStyle && view)
     
    343342}
    344343
     344StyleResolver::State::State(Element& element, RenderStyle* parentStyle, const RenderRegion* regionForStyling, const SelectorFilter* selectorFilter)
     345    : m_element(&element)
     346    , m_parentStyle(parentStyle)
     347    , m_regionForStyling(regionForStyling)
     348    , m_elementLinkState(element.document().visitedLinkState().determineLinkState(element))
     349    , m_selectorFilter(selectorFilter)
     350{
     351    bool resetStyleInheritance = hasShadowRootParent(element) && downcast<ShadowRoot>(element.parentNode())->resetStyleInheritance();
     352    if (resetStyleInheritance)
     353        m_parentStyle = nullptr;
     354
     355    auto& document = element.document();
     356    auto* documentElement = document.documentElement();
     357    m_rootElementStyle = (!documentElement || documentElement == &element) ? document.renderStyle() : documentElement->renderStyle();
     358
     359    updateConversionData();
     360}
     361
    345362inline void StyleResolver::State::updateConversionData()
    346363{
    347364    m_cssToLengthConversionData = CSSToLengthConversionData(m_style.get(), m_rootElementStyle, m_element ? document().renderView() : nullptr);
    348 }
    349 
    350 inline void StyleResolver::State::initElement(Element* element)
    351 {
    352     m_element = element;
    353     m_styledElement = element && is<StyledElement>(*element) ? downcast<StyledElement>(element) : nullptr;
    354     m_elementLinkState = element ? element->document().visitedLinkState().determineLinkState(*element) : NotInsideLink;
    355     updateConversionData();
    356 }
    357 
    358 inline void StyleResolver::initElement(Element* e)
    359 {
    360     if (m_state.element() != e) {
    361         m_state.initElement(e);
    362         if (e && e == e->document().documentElement()) {
    363             e->document().setDirectionSetOnDocumentElement(false);
    364             e->document().setWritingModeSetOnDocumentElement(false);
    365         }
    366     }
    367 }
    368 
    369 inline void StyleResolver::State::initForStyleResolve(Document& document, Element* e, RenderStyle* parentStyle, const RenderRegion* regionForStyling, const SelectorFilter* selectorFilter)
    370 {
    371     m_regionForStyling = regionForStyling;
    372 
    373     if (e) {
    374         bool resetStyleInheritance = hasShadowRootParent(*e) && downcast<ShadowRoot>(*e->parentNode()).resetStyleInheritance();
    375         m_parentStyle = resetStyleInheritance ? nullptr : parentStyle;
    376     } else
    377         m_parentStyle = parentStyle;
    378 
    379     Node* docElement = e ? e->document().documentElement() : nullptr;
    380     RenderStyle* docStyle = document.renderStyle();
    381     m_rootElementStyle = docElement && e != docElement ? docElement->renderStyle() : docStyle;
    382 
    383     m_style = nullptr;
    384     m_pendingImageProperties.clear();
    385     m_fontDirty = false;
    386    
    387     m_authorRollback = nullptr;
    388     m_userRollback = nullptr;
    389 
    390     m_selectorFilter = selectorFilter;
    391 
    392     updateConversionData();
    393365}
    394366
     
    525497        return false;
    526498
    527     if (state.styledElement()->presentationAttributeStyle() != sharingCandidate.presentationAttributeStyle())
     499    if (downcast<StyledElement>(*state.element()).presentationAttributeStyle() != sharingCandidate.presentationAttributeStyle())
    528500        return false;
    529501
     
    569541    if (!sharingCandidateHasIdenticalStyleAffectingAttributes(element))
    570542        return false;
    571     if (element.additionalPresentationAttributeStyle() != state.styledElement()->additionalPresentationAttributeStyle())
     543    if (element.additionalPresentationAttributeStyle() != downcast<StyledElement>(*state.element()).additionalPresentationAttributeStyle())
    572544        return false;
    573545    if (element.affectsNextSiblingElementStyle() || element.styleIsAffectedByPreviousSibling())
     
    646618{
    647619    State& state = m_state;
    648     if (!state.styledElement() || !state.parentStyle())
     620    if (!is<StyledElement>(state.element()) || !state.parentStyle())
    649621        return nullptr;
     622    auto& styledElement = downcast<StyledElement>(*state.element());
    650623
    651624    // If the element has inline style it is probably unique.
    652     if (state.styledElement()->inlineStyle())
     625    if (styledElement.inlineStyle())
    653626        return nullptr;
    654     if (state.styledElement()->isSVGElement() && downcast<SVGElement>(*state.styledElement()).animatedSMILStyleProperties())
     627    if (styledElement.isSVGElement() && downcast<SVGElement>(styledElement).animatedSMILStyleProperties())
    655628        return nullptr;
    656629    // Ids stop style sharing if they show up in the stylesheets.
    657     if (state.styledElement()->hasID() && m_ruleSets.features().idsInRules.contains(state.styledElement()->idForStyleResolution().impl()))
     630    if (styledElement.hasID() && m_ruleSets.features().idsInRules.contains(styledElement.idForStyleResolution().impl()))
    658631        return nullptr;
    659     if (parentElementPreventsSharing(state.element()->parentElement()))
     632    if (parentElementPreventsSharing(styledElement.parentElement()))
    660633        return nullptr;
    661634    if (state.element() == state.document().cssTarget())
     
    672645    unsigned visitedNodeCount = 0;
    673646    StyledElement* shareElement = nullptr;
    674     Node* cousinList = state.styledElement()->previousSibling();
     647    Node* cousinList = styledElement.previousSibling();
    675648    while (cousinList) {
    676649        shareElement = findSiblingForStyleSharing(cousinList, count);
     
    691664        return nullptr;
    692665    // Tracking child index requires unique style for each node. This may get set by the sibling rule match above.
    693     if (parentElementPreventsSharing(state.element()->parentElement()))
     666    if (parentElementPreventsSharing(styledElement.parentElement()))
    694667        return nullptr;
    695668    return shareElement->renderStyle();
     
    704677}
    705678
    706 Ref<RenderStyle> StyleResolver::styleForElement(Element* element, RenderStyle* defaultParent,
     679Ref<RenderStyle> StyleResolver::styleForElement(Element& element, RenderStyle* parentStyle,
    707680    StyleSharingBehavior sharingBehavior, RuleMatchingBehavior matchingBehavior, const RenderRegion* regionForStyling, const SelectorFilter* selectorFilter)
    708681{
     
    711684    // Once an element has a renderer, we don't try to destroy it, since otherwise the renderer
    712685    // will vanish if a style recalc happens during loading.
    713     if (sharingBehavior == AllowStyleSharing && !element->document().haveStylesheetsLoaded() && !element->renderer()) {
     686    if (sharingBehavior == AllowStyleSharing && !m_document.haveStylesheetsLoaded() && !element.renderer()) {
    714687        if (!s_styleNotYetAvailable) {
    715688            s_styleNotYetAvailable = &RenderStyle::create().leakRef();
    716689            s_styleNotYetAvailable->setDisplay(NONE);
    717             s_styleNotYetAvailable->fontCascade().update(&document().fontSelector());
    718         }
    719         element->document().setHasNodesWithPlaceholderStyle();
     690            s_styleNotYetAvailable->fontCascade().update(&m_document.fontSelector());
     691        }
     692        m_document.setHasNodesWithPlaceholderStyle();
    720693        return *s_styleNotYetAvailable;
    721694    }
    722695
     696    m_state = State(element, parentStyle, regionForStyling, selectorFilter);
    723697    State& state = m_state;
    724     initElement(element);
    725     state.initForStyleResolve(document(), element, defaultParent, regionForStyling, selectorFilter);
     698
     699    if (&element == m_document.documentElement() && matchingBehavior == MatchAllRules) {
     700        // These bits may be set when resolving document element style.
     701        // FIXME: Style resolver shouldn't mutate document.
     702        m_document.setDirectionSetOnDocumentElement(false);
     703        m_document.setWritingModeSetOnDocumentElement(false);
     704    }
    726705
    727706    if (sharingBehavior == AllowStyleSharing) {
     
    734713    if (state.parentStyle()) {
    735714        state.setStyle(RenderStyle::create());
    736         state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
     715        state.style()->inheritFrom(state.parentStyle(), isAtShadowBoundary(&element) ? RenderStyle::AtShadowBoundary : RenderStyle::NotAtShadowBoundary);
    737716    } else {
    738717        state.setStyle(defaultStyleForElement());
     
    740719    }
    741720
    742     if (element->isLink()) {
     721    if (element.isLink()) {
    743722        state.style()->setIsLink(true);
    744723        EInsideLink linkState = state.elementLinkState();
    745724        if (linkState != NotInsideLink) {
    746             bool forceVisited = InspectorInstrumentation::forcePseudoState(*element, CSSSelector::PseudoClassVisited);
     725            bool forceVisited = InspectorInstrumentation::forcePseudoState(element, CSSSelector::PseudoClassVisited);
    747726            if (forceVisited)
    748727                linkState = InsideVisitedLink;
     
    752731
    753732    bool needsCollection = false;
    754     CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(*element, needsCollection);
     733    CSSDefaultStyleSheets::ensureDefaultStyleSheetsForElement(element, needsCollection);
    755734    if (needsCollection)
    756735        m_ruleSets.collectFeatures();
    757736
    758     ElementRuleCollector collector(*element, state.style(), m_ruleSets, m_state.selectorFilter());
     737    ElementRuleCollector collector(element, state.style(), m_ruleSets, m_state.selectorFilter());
    759738    collector.setRegionForStyling(regionForStyling);
    760739    collector.setMedium(m_medium.get());
     
    768747
    769748    // Clean up our style object's display and text decorations (among other fixups).
    770     adjustRenderStyle(*state.style(), *state.parentStyle(), element);
     749    adjustRenderStyle(*state.style(), *state.parentStyle(), &element);
    771750
    772751    if (state.style()->hasViewportUnits())
     
    837816}
    838817
    839 void StyleResolver::keyframeStylesForAnimation(Element* e, const RenderStyle* elementStyle, KeyframeList& list)
     818void StyleResolver::keyframeStylesForAnimation(Element& element, const RenderStyle* elementStyle, KeyframeList& list)
    840819{
    841820    list.clear();
    842821
    843822    // Get the keyframesRule for this name
    844     if (!e || list.animationName().isEmpty())
     823    if (list.animationName().isEmpty())
    845824        return;
    846825
     
    857836    for (unsigned i = 0; i < keyframes.size(); ++i) {
    858837        // Apply the declaration to the style. This is a simplified version of the logic in styleForElement
    859         initElement(e);
    860         m_state.initForStyleResolve(document(), e, nullptr);
     838        m_state = State(element, nullptr);
    861839
    862840        const StyleKeyframe* keyframe = keyframes[i].get();
     
    898876}
    899877
    900 PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element* element, const PseudoStyleRequest& pseudoStyleRequest, RenderStyle* parentStyle)
    901 {
    902     ASSERT(parentStyle);
    903     if (!element)
    904         return nullptr;
     878PassRefPtr<RenderStyle> StyleResolver::pseudoStyleForElement(Element& element, const PseudoStyleRequest& pseudoStyleRequest, RenderStyle& parentStyle)
     879{
     880    m_state = State(element, &parentStyle);
    905881
    906882    State& state = m_state;
    907 
    908     initElement(element);
    909 
    910     state.initForStyleResolve(document(), element, parentStyle);
    911883
    912884    if (m_state.parentStyle()) {
     
    922894
    923895    // Check UA, user and author rules.
    924     ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_state.selectorFilter());
     896    ElementRuleCollector collector(element, m_state.style(), m_ruleSets, m_state.selectorFilter());
    925897    collector.setPseudoStyleRequest(pseudoStyleRequest);
    926898    collector.setMedium(m_medium.get());
     
    956928    RELEASE_ASSERT(!m_inLoadPendingImages);
    957929
    958     m_state.initForStyleResolve(m_document, m_document.documentElement(), m_document.renderStyle());
     930    auto* documentElement = m_document.documentElement();
     931    if (!documentElement)
     932        return RenderStyle::create();
     933
     934    m_state = State(*documentElement, m_document.renderStyle());
    959935
    960936    m_state.setStyle(RenderStyle::create());
     
    13981374        return Vector<RefPtr<StyleRule>>();
    13991375
    1400     initElement(element);
    1401     m_state.initForStyleResolve(document(), element, nullptr);
    1402 
    1403     ElementRuleCollector collector(*element, m_state.style(), m_ruleSets, m_state.selectorFilter());
     1376    m_state = State(*element, nullptr);
     1377
     1378    ElementRuleCollector collector(*element, nullptr, m_ruleSets, m_state.selectorFilter());
    14041379    collector.setMode(SelectorChecker::Mode::CollectingRules);
    14051380    collector.setPseudoStyleRequest(PseudoStyleRequest(pseudoId));
     
    15561531}
    15571532
    1558 static bool isCacheableInMatchedPropertiesCache(const Element* element, const RenderStyle* style, const RenderStyle* parentStyle)
    1559 {
    1560     // FIXME: CSSPropertyWebkitWritingMode modifies state when applying to document element. We can't skip the applying by caching.
    1561     if (element == element->document().documentElement() && element->document().writingModeSetOnDocumentElement())
     1533static bool isCacheableInMatchedPropertiesCache(const Element& element, const RenderStyle* style, const RenderStyle* parentStyle)
     1534{
     1535    // FIXME: Writing mode and direction properties modify state when applying to document element by calling
     1536    // Document::setWritingMode/DirectionSetOnDocumentElement. We can't skip the applying by caching.
     1537    if (&element == element.document().documentElement())
    15621538        return false;
    15631539    if (style->unique() || (style->styleType() != NOPSEUDO && parentStyle->unique()))
     
    16081584}
    16091585
    1610 void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element* element, ShouldUseMatchedPropertiesCache shouldUseMatchedPropertiesCache)
    1611 {
    1612     ASSERT(element);
     1586void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element& element, ShouldUseMatchedPropertiesCache shouldUseMatchedPropertiesCache)
     1587{
    16131588    State& state = m_state;
    16141589    unsigned cacheHash = shouldUseMatchedPropertiesCache && matchResult.isCacheable ? computeMatchedPropertiesHash(matchResult.matchedProperties().data(), matchResult.matchedProperties().size()) : 0;
     
    16211596        // element context. This is fast and saves memory by reusing the style data structures.
    16221597        state.style()->copyNonInheritedFrom(cacheItem->renderStyle.get());
    1623         if (state.parentStyle()->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(element)) {
     1598        if (state.parentStyle()->inheritedDataShared(cacheItem->parentRenderStyle.get()) && !isAtShadowBoundary(&element)) {
    16241599            EInsideLink linkStatus = state.style()->insideLink();
    16251600            // If the cache item parent style has identical inherited properties to the current parent style then the
     
    17071682    if (cacheItem || !cacheHash)
    17081683        return;
    1709     if (!isCacheableInMatchedPropertiesCache(state.element(), state.style(), state.parentStyle()))
     1684    if (!isCacheableInMatchedPropertiesCache(*state.element(), state.style(), state.parentStyle()))
    17101685        return;
    17111686    addToMatchedPropertiesCache(state.style(), state.parentStyle(), cacheHash, matchResult);
     
    17141689void StyleResolver::applyPropertyToStyle(CSSPropertyID id, CSSValue* value, RenderStyle* style)
    17151690{
    1716     initElement(nullptr);
    1717     m_state.initForStyleResolve(document(), nullptr, style);
     1691    m_state = State();
     1692    m_state.setParentStyle(*style);
    17181693    m_state.setStyle(*style);
    17191694    applyPropertyToCurrentStyle(id, value);
  • trunk/Source/WebCore/css/StyleResolver.h

    r195293 r195465  
    136136    ~StyleResolver();
    137137
    138     Ref<RenderStyle> styleForElement(Element*, RenderStyle* parentStyle, StyleSharingBehavior = AllowStyleSharing,
     138    Ref<RenderStyle> styleForElement(Element&, RenderStyle* parentStyle, StyleSharingBehavior = AllowStyleSharing,
    139139        RuleMatchingBehavior = MatchAllRules, const RenderRegion* regionForStyling = nullptr, const SelectorFilter* = nullptr);
    140140
    141     void keyframeStylesForAnimation(Element*, const RenderStyle*, KeyframeList&);
    142 
    143     PassRefPtr<RenderStyle> pseudoStyleForElement(Element*, const PseudoStyleRequest&, RenderStyle* parentStyle);
     141    void keyframeStylesForAnimation(Element&, const RenderStyle*, KeyframeList&);
     142
     143    PassRefPtr<RenderStyle> pseudoStyleForElement(Element&, const PseudoStyleRequest&, RenderStyle& parentStyle);
    144144
    145145    Ref<RenderStyle> styleForPage(int pageIndex);
     
    161161
    162162private:
    163     void initElement(Element*);
    164163    RenderStyle* locateSharedStyle();
    165164    bool styleSharingCandidateMatchesRuleSet(RuleSet*);
     
    334333
    335334    enum ShouldUseMatchedPropertiesCache { DoNotUseMatchedPropertiesCache = 0, UseMatchedPropertiesCache };
    336     void applyMatchedProperties(const MatchResult&, const Element*, ShouldUseMatchedPropertiesCache = UseMatchedPropertiesCache);
     335    void applyMatchedProperties(const MatchResult&, const Element&, ShouldUseMatchedPropertiesCache = UseMatchedPropertiesCache);
    337336
    338337    void applyCascadedProperties(CascadedProperties&, int firstProperty, int lastProperty, const MatchResult*);
     
    360359
    361360    class State {
    362         WTF_MAKE_NONCOPYABLE(State);
    363361    public:
    364         State()
    365             : m_element(nullptr)
    366             , m_styledElement(nullptr)
    367             , m_parentStyle(nullptr)
    368             , m_rootElementStyle(nullptr)
    369             , m_regionForStyling(nullptr)
    370             , m_elementLinkState(NotInsideLink)
    371             , m_elementAffectedByClassRules(false)
    372             , m_applyPropertyToRegularStyle(true)
    373             , m_applyPropertyToVisitedLinkStyle(false)
    374             , m_fontDirty(false)
    375             , m_fontSizeHasViewportUnits(false)
    376             , m_hasUAAppearance(false)
    377             , m_backgroundData(BackgroundFillLayer)
    378         {
    379         }
     362        State() { }
     363        State(Element&, RenderStyle* parentStyle, const RenderRegion* regionForStyling = nullptr, const SelectorFilter* = nullptr);
    380364
    381365    public:
    382         void initElement(Element*);
    383         void initForStyleResolve(Document&, Element*, RenderStyle* parentStyle, const RenderRegion* regionForStyling = nullptr, const SelectorFilter* = nullptr);
    384366        void clear();
    385367
    386368        Document& document() const { return m_element->document(); }
    387369        Element* element() const { return m_element; }
    388         StyledElement* styledElement() const { return m_styledElement; }
     370
    389371        void setStyle(Ref<RenderStyle>&&);
    390372        RenderStyle* style() const { return m_style.get(); }
     
    445427        void updateConversionData();
    446428
    447         Element* m_element;
     429        Element* m_element { nullptr };
    448430        RefPtr<RenderStyle> m_style;
    449         StyledElement* m_styledElement;
    450431        RefPtr<RenderStyle> m_parentStyle;
    451         RenderStyle* m_rootElementStyle;
    452 
    453         // Required to ASSERT in applyProperties.
    454         const RenderRegion* m_regionForStyling;
    455        
    456         EInsideLink m_elementLinkState;
    457 
    458         bool m_elementAffectedByClassRules;
    459 
    460         bool m_applyPropertyToRegularStyle;
    461         bool m_applyPropertyToVisitedLinkStyle;
     432        RenderStyle* m_rootElementStyle { nullptr };
     433
     434        const RenderRegion* m_regionForStyling { nullptr };
     435       
     436        EInsideLink m_elementLinkState { NotInsideLink };
     437
     438        bool m_elementAffectedByClassRules { false };
     439        bool m_applyPropertyToRegularStyle { true };
     440        bool m_applyPropertyToVisitedLinkStyle { false };
     441        bool m_fontDirty { false };
     442        bool m_fontSizeHasViewportUnits { false };
     443        bool m_hasUAAppearance { false };
     444
     445        BorderData m_borderData;
     446        FillLayer m_backgroundData { BackgroundFillLayer };
     447        Color m_backgroundColor;
    462448
    463449        PendingImagePropertyMap m_pendingImageProperties;
    464 
    465450        Vector<RefPtr<ReferenceFilterOperation>> m_filtersWithPendingSVGDocuments;
    466 
    467         bool m_fontDirty;
    468         bool m_fontSizeHasViewportUnits;
    469 
    470         bool m_hasUAAppearance;
    471         BorderData m_borderData;
    472         FillLayer m_backgroundData;
    473         Color m_backgroundColor;
    474 
    475451        CSSToLengthConversionData m_cssToLengthConversionData;
    476452       
  • trunk/Source/WebCore/dom/Element.cpp

    r195452 r195465  
    14051405Ref<RenderStyle> Element::resolveStyle(RenderStyle* parentStyle)
    14061406{
    1407     return styleResolver().styleForElement(this, parentStyle);
     1407    return styleResolver().styleForElement(*this, parentStyle);
    14081408}
    14091409
  • trunk/Source/WebCore/page/animation/KeyframeAnimation.cpp

    r193610 r195465  
    5050    // Get the keyframe RenderStyles
    5151    if (m_object && m_object->element())
    52         m_object->element()->styleResolver().keyframeStylesForAnimation(m_object->element(), unanimatedStyle, m_keyframes);
     52        m_object->element()->styleResolver().keyframeStylesForAnimation(*m_object->element(), unanimatedStyle, m_keyframes);
    5353
    5454    // Update the m_transformFunctionListValid flag based on whether the function lists in the keyframes match.
  • trunk/Source/WebCore/rendering/RenderElement.cpp

    r195170 r195465  
    15911591
    15921592    if (pseudoStyleRequest.pseudoId == FIRST_LINE_INHERITED) {
    1593         RefPtr<RenderStyle> result = styleResolver.styleForElement(element(), parentStyle, DisallowStyleSharing);
     1593        RefPtr<RenderStyle> result = styleResolver.styleForElement(*element(), parentStyle, DisallowStyleSharing);
    15941594        result->setStyleType(FIRST_LINE_INHERITED);
    15951595        return result.release();
    15961596    }
    15971597
    1598     return styleResolver.pseudoStyleForElement(element(), pseudoStyleRequest, parentStyle);
     1598    return styleResolver.pseudoStyleForElement(*element(), pseudoStyleRequest, *parentStyle);
    15991599}
    16001600
  • trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp

    r194496 r195465  
    353353
    354354    // FIXME: Region styling fails for pseudo-elements because the renderers don't have a node.
    355     RefPtr<RenderStyle> renderObjectRegionStyle = renderer.element()->styleResolver().styleForElement(renderer.element(), &parentStyle, DisallowStyleSharing, MatchAllRules, this);
     355    RefPtr<RenderStyle> renderObjectRegionStyle = renderer.element()->styleResolver().styleForElement(*renderer.element(), &parentStyle, DisallowStyleSharing, MatchAllRules, this);
    356356
    357357    return renderObjectRegionStyle.release();
  • trunk/Source/WebCore/style/StyleTreeResolver.cpp

    r194762 r195465  
    128128            return style.releaseNonNull();
    129129    }
    130     return m_styleResolver.styleForElement(&element, &inheritedStyle, AllowStyleSharing, MatchAllRules, nullptr, &m_selectorFilter);
     130    return m_styleResolver.styleForElement(element, &inheritedStyle, AllowStyleSharing, MatchAllRules, nullptr, &m_selectorFilter);
    131131}
    132132
  • trunk/Source/WebCore/svg/SVGElement.cpp

    r190347 r195465  
    794794    // If the element is in a <use> tree we get the style from the definition tree.
    795795    if (auto* styleElement = this->correspondingElement())
    796         return styleElement->styleResolver().styleForElement(styleElement, &parentStyle, DisallowStyleSharing);
     796        return styleElement->styleResolver().styleForElement(*styleElement, &parentStyle, DisallowStyleSharing);
    797797
    798798    return resolveStyle(&parentStyle);
     
    828828    }
    829829
    830     return m_svgRareData->overrideComputedStyle(this, parentStyle);
     830    return m_svgRareData->overrideComputedStyle(*this, parentStyle);
    831831}
    832832
  • trunk/Source/WebCore/svg/SVGElementRareData.h

    r189987 r195465  
    6666    }
    6767
    68     RenderStyle* overrideComputedStyle(Element* element, RenderStyle* parentStyle)
     68    RenderStyle* overrideComputedStyle(Element& element, RenderStyle* parentStyle)
    6969    {
    70         ASSERT(element);
    7170        if (!m_useOverrideComputedStyle)
    7271            return 0;
    7372        if (!m_overrideComputedStyle || m_needsOverrideComputedStyleUpdate) {
    7473            // The style computed here contains no CSS Animations/Transitions or SMIL induced rules - this is needed to compute the "base value" for the SMIL animation sandwhich model.
    75             m_overrideComputedStyle = element->styleResolver().styleForElement(element, parentStyle, DisallowStyleSharing, MatchAllRulesExcludingSMIL);
     74            m_overrideComputedStyle = element.styleResolver().styleForElement(element, parentStyle, DisallowStyleSharing, MatchAllRulesExcludingSMIL);
    7675            m_needsOverrideComputedStyleUpdate = false;
    7776        }
Note: See TracChangeset for help on using the changeset viewer.