[webkit-changes] [WebKit/WebKit] ca08a2: Use destroying delete for CSSValue

Darin Adler noreply at github.com
Sun Sep 25 16:42:42 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: ca08a222c8067db9d4795eb81f714274df666485
      https://github.com/WebKit/WebKit/commit/ca08a222c8067db9d4795eb81f714274df666485
  Author: Darin Adler <darin at apple.com>
  Date:   2022-09-25 (Sun, 25 Sep 2022)

  Changed paths:
    M Source/JavaScriptCore/runtime/TemporalPlainDate.cpp
    M Source/WebCore/WebCore.xcodeproj/project.pbxproj
    M Source/WebCore/css/CSSCrossfadeValue.cpp
    M Source/WebCore/css/CSSCrossfadeValue.h
    M Source/WebCore/css/CSSFilterImageValue.cpp
    M Source/WebCore/css/CSSFilterImageValue.h
    M Source/WebCore/css/CSSFontFaceSrcValue.cpp
    M Source/WebCore/css/CSSFontFaceSrcValue.h
    M Source/WebCore/css/CSSFunctionValue.cpp
    M Source/WebCore/css/CSSFunctionValue.h
    M Source/WebCore/css/CSSGridAutoRepeatValue.cpp
    M Source/WebCore/css/CSSGridIntegerRepeatValue.cpp
    M Source/WebCore/css/CSSGridLineNamesValue.cpp
    M Source/WebCore/css/CSSImageSetValue.cpp
    M Source/WebCore/css/CSSImageSetValue.h
    M Source/WebCore/css/CSSImageValue.cpp
    M Source/WebCore/css/CSSImageValue.h
    M Source/WebCore/css/CSSPrimitiveValue.cpp
    M Source/WebCore/css/CSSPrimitiveValue.h
    M Source/WebCore/css/CSSValue.cpp
    M Source/WebCore/css/CSSValue.h
    M Source/WebCore/css/CSSValueList.cpp
    M Source/WebCore/css/CSSValueList.h
    M Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.h
    M Source/WebCore/css/DeprecatedCSSOMValue.cpp
    M Source/WebCore/css/DeprecatedCSSOMValue.h
    M Source/WebCore/css/DeprecatedCSSOMValueList.cpp
    M Source/WebCore/css/DeprecatedCSSOMValueList.h
    M Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp
    M Source/WebCore/css/StyleProperties.cpp
    M Source/WebCore/css/StyleProperties.h
    M Source/WebCore/css/parser/CSSParserTokenRange.h
    M Source/WebCore/css/parser/CSSPropertyParser.h
    M Source/WebCore/css/typedom/CSSNumericValue.h
    M Source/WebCore/css/typedom/numeric/CSSMathMax.cpp
    M Source/WebCore/css/typedom/numeric/CSSMathProduct.cpp
    M Source/WebCore/css/typedom/numeric/CSSMathSum.cpp
    M Source/WebCore/rendering/style/StyleCustomPropertyData.h

  Log Message:
  -----------
  Use destroying delete for CSSValue
https://bugs.webkit.org/show_bug.cgi?id=244997
rdar://problem/99753615

Reviewed by Yusuke Suzuki and Sam Weinig.

* Source/JavaScriptCore/runtime/TemporalPlainDate.cpp: Fixed mistake in
copyright comment.

* Source/WebCore/WebCore.xcodeproj/project.pbxproj: Added CSSValuePair.h/cpp to
project file. Without this, the build didn't properly handle dependencies.

* Source/WebCore/css/CSSCrossfadeValue.cpp:
(WebCore::CSSCrossfadeValue::customTraverseSubresources const): Renamed
from traverseSubresources, wrote with logical operators instead of if statements.
* Source/WebCore/css/CSSCrossfadeValue.h: Updated for above.
* Source/WebCore/css/CSSFilterImageValue.cpp:
(WebCore::CSSFilterImageValue::customTraverseSubresources const): Ditto.
* Source/WebCore/css/CSSFilterImageValue.h: Ditto.
* Source/WebCore/css/CSSFontFaceSrcValue.cpp:
(WebCore::CSSFontFaceSrcValue::customTraverseSubresources const): Ditto.
* Source/WebCore/css/CSSFontFaceSrcValue.h: Ditto.

* Source/WebCore/css/CSSFunctionValue.cpp:
(WebCore::CSSFunctionValue::customCSSText const): Removed document argument
and moved to makeString instead of StringBuilder.
* Source/WebCore/css/CSSFunctionValue.h: Updated for above.
* Source/WebCore/css/CSSGridAutoRepeatValue.cpp:
(WebCore::CSSGridAutoRepeatValue::customCSSText const): Ditto.
* Source/WebCore/css/CSSGridIntegerRepeatValue.cpp:
(WebCore::CSSGridIntegerRepeatValue::customCSSText const): Ditto.
* Source/WebCore/css/CSSGridLineNamesValue.cpp:
(WebCore::CSSGridLineNamesValue::customCSSText const): Ditto.

* Source/WebCore/css/CSSImageSetValue.cpp:
(WebCore::CSSImageSetValue::customTraverseSubresources const): Renamed
from traverseSubresources, wrote with logical operators instead of if statements.
* Source/WebCore/css/CSSImageSetValue.h: Updated for above.
* Source/WebCore/css/CSSImageValue.cpp:
(WebCore::CSSImageValue::customTraverseSubresources const): Ditto.
* Source/WebCore/css/CSSImageValue.h: Ditto.

* Source/WebCore/css/CSSPrimitiveValue.cpp: Added global for the legacy
precision quirk. Since CSS serialization already depends on the CSS pool
global, this doesn't add any new problems, and side steps some complexity
where some customCSSText functions need document pointers and others do not.
(WebCore::CSSPrimitiveValue::customCSSText const): Removed document pointer
and use the global to figure out whether the legacy precison quirk is needed.
* Source/WebCore/css/CSSPrimitiveValue.h: Updated for above.

* Source/WebCore/css/CSSValue.cpp:
(WebCore::CSSValue::visitDerived): Added a function template that lets us
use the visitor pattern to implement many functions below.
(WebCore::CSSValue::visitDerived const): Ditto.
(WebCore::CSSValue::cssValueType const): Deleted. This can be done entirely
in the deprecated CSS value classes and need not be here.
(WebCore::CSSValue::traverseSubresources const): Use visitDerived and
customTraverseSubresources. In passing, "accidentally" fixed a bug where
CSSImageSetValue::traverseSubresources would never have been called, since
CSSImageSetValue derives from CSSValueList.
(WebCore::compareCSSValues): Deleted.
(WebCore::CSSValue::equals const): Use visitDerived. No longer need the
compareCSSValues helper.
(WebCore::CSSValue::cssText const): Removed the document argument. Use
visitDerived.
(WebCore::CSSValue::separatorCSSText): Changed to take a separator argument
so this can be shared with DeprecatedCSSOMValueList.
(WebCore::CSSValue::operator delete): Added, replacing the
destroy function. Use visitDerived, std::destroy_at and freeAfterDestruction.
(WebCore::CSSValue::destroy): Deleted.

* Source/WebCore/css/CSSValue.h: Removed Type and cssValueType. Moved the
body of the deref function out of the class definition, and made it use
delete instead of a destroy function. Removed the document argument to
cssText and made separatorCSSText protected since it's only for CSSValueList
and CSSValuePair. Replaced the destroy function with a destroying delete
implementation. Added a base version of customTraverseSubresources that
just returns false, made it private since it's only intended to be called
by the implementation of traverseSubresources.

* Source/WebCore/css/CSSValueList.cpp:
(WebCore::CSSValueList::customCSSText const): Removed document argument
and tweaked the implementation to use std::exchange instead of checking
StringBuilder::isEmpty.
(WebCore::CSSValueList::customTraverseSubresources const): Renamed
from traverseSubresources, use a modern for loop.

* Source/WebCore/css/CSSValueList.h: Updated for above changes. Also
made separator and separatorCSSText public here, leaving them protected
in the base class.

* Source/WebCore/css/DeprecatedCSSOMPrimitiveValue.h: Changed cssValueType
to return unsigned short to match the IDL file. Updated for ClassType changes.
Use Ref<const> instead of a const_cast.

* Source/WebCore/css/DeprecatedCSSOMValue.cpp:
(WebCore::DeprecatedCSSOMValue::operator delete): Added, replacing the
destroy function. Use std::destroy_at and freeAfterDestruction.
(WebCore::DeprecatedCSSOMValue::cssValueType const): Updated for changes
to ClassType.
(WebCore::DeprecatedCSSOMValue::cssText const): Ditto.
(WebCore::DeprecatedCSSOMComplexValue::cssValueType const): Added.
This has the code that was previously in CSSValue::cssValueType, and
it's better to have it here, since it's specific to the deprecated CSSOM.

* Source/WebCore/css/DeprecatedCSSOMValue.h: Use unsigned short instead
of unsigned for cssValueType to match the IDL. Changed ClassType to
an enum class and gave the values short names. Use destroying delete
instead of a destroy function, which allows us to use the default deref
from RefCounted instead of having to write our own. Use Ref<const> instead
of a const_cast.

* Source/WebCore/css/DeprecatedCSSOMValueList.cpp:
(WebCore::DeprecatedCSSOMValueList::cssText const): Use the
CSSValueList::separatorCSSText function instead of repeating the code here
and tweaked the implementation to use std::exchange instead of checking
StringBuilder::isEmpty.

* Source/WebCore/css/DeprecatedCSSOMValueList.h: Use WTF::map
instead of CSSValueList::itemWithoutBoundsCheck.

* Source/WebCore/css/PropertySetCSSStyleDeclaration.cpp:
(WebCore::PropertySetCSSStyleDeclaration::getPropertyValueInternal):
Call CSSPrimitiveValue::setUseLegacyPrecision here instead of passing
a document in.

* Source/WebCore/css/StyleProperties.cpp:
(WebCore::StyleProperties::getPropertyValue const): Removed the document
argument that was used only for the legacy precision quirk.
* Source/WebCore/css/StyleProperties.h: Ditto.

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




More information about the webkit-changes mailing list