[webkit-changes] [WebKit/WebKit] 954e3a: Cache resolved variable references

Antti Koivisto noreply at github.com
Thu Sep 7 11:50:57 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 954e3afcfb437134cbc829c3168496bb15f6aa42
      https://github.com/WebKit/WebKit/commit/954e3afcfb437134cbc829c3168496bb15f6aa42
  Author: Antti Koivisto <antti at apple.com>
  Date:   2023-09-07 (Thu, 07 Sep 2023)

  Changed paths:
    M Source/WebCore/css/CSSVariableReferenceValue.cpp
    M Source/WebCore/css/CSSVariableReferenceValue.h
    M Source/WebCore/style/StyleBuilder.cpp

  Log Message:
  -----------
  Cache resolved variable references
https://bugs.webkit.org/show_bug.cgi?id=261265
rdar://115104109

Reviewed by Alan Baradlay.

If the pointed-to variable doesn't change then the final result will be unchanged.
Also add a fast path for resolving simple var(--foo) reference. Currently the cache
is only used on this path.

* Source/WebCore/css/CSSVariableReferenceValue.cpp:
(WebCore::CSSVariableReferenceValue::CSSVariableReferenceValue):
(WebCore::propertyValueForVariableName):
(WebCore::CSSVariableReferenceValue::resolveVariableReference const):
(WebCore::CSSVariableReferenceValue::cacheSimpleReference):

Detect the simple reference case and cache it.

(WebCore::CSSVariableReferenceValue::tryResolveSimpleReference const):

In the simple case we just grab the underlying value and return it without doing any token manipulation.

(WebCore::CSSVariableReferenceValue::resolveVariableReferences const):

Use the fast path if possible.

(WebCore::CSSVariableReferenceValue::resolveAndCacheValue const):

In case we are depenent of only a single variable data object, check if it is equal to the cache entry
and if so, return the cached final value.

(WebCore::CSSVariableReferenceValue::resolveSingleValue const):
(WebCore::CSSVariableReferenceValue::resolveSubstitutionValue const):

Handle the normal and substitution (shorthand) case using a template.

* Source/WebCore/css/CSSVariableReferenceValue.h:
* Source/WebCore/style/StyleBuilder.cpp:
(WebCore::Style::Builder::resolveVariableReferences):

Canonical link: https://commits.webkit.org/267742@main




More information about the webkit-changes mailing list