⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 293278 in webkit


Ignore:
Timestamp:
Apr 22, 2022, 7:15:14 PM (4 years ago)
Author:
commit-queue@webkit.org
Message:

Reduce sizeof(CSSNumericType)
https://bugs.webkit.org/show_bug.cgi?id=239680

Patch by Alex Christensen <achristensen@webkit.org> on 2022-04-22
Reviewed by Yusuke Suzuki.

  • bindings/IDLTypes.h:

(WebCore::IDLType::nullValue):
(WebCore::IDLType::isNullType):
(WebCore::IDLType::extractValueFromNullable):

  • css/typedom/numeric/CSSMathProduct.cpp:

(WebCore::multiplyTypes):

  • css/typedom/numeric/CSSNumericType.h:

(WebCore::CSSNumericType::valueForType):
(WebCore::CSSNumericType::valueForType const):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r293264 r293278  
     12022-04-22  Alex Christensen  <achristensen@webkit.org>
     2
     3        Reduce sizeof(CSSNumericType)
     4        https://bugs.webkit.org/show_bug.cgi?id=239680
     5
     6        Reviewed by Yusuke Suzuki.
     7
     8        * bindings/IDLTypes.h:
     9        (WebCore::IDLType::nullValue):
     10        (WebCore::IDLType::isNullType):
     11        (WebCore::IDLType::extractValueFromNullable):
     12        * css/typedom/numeric/CSSMathProduct.cpp:
     13        (WebCore::multiplyTypes):
     14        * css/typedom/numeric/CSSNumericType.h:
     15        (WebCore::CSSNumericType::valueForType):
     16        (WebCore::CSSNumericType::valueForType const):
     17
    1182022-04-22  Patrick Angle  <pangle@apple.com>
    219
  • trunk/Source/WebCore/bindings/IDLTypes.h

    r289700 r293278  
    3131#include <variant>
    3232#include <wtf/Brigand.h>
     33#include <wtf/Markable.h>
    3334#include <wtf/StdLibExtras.h>
    3435#include <wtf/URL.h>
     
    7677    static bool isNullValue(const NullableType& value) { return !value; }
    7778    static ImplementationType extractValueFromNullable(const NullableType& value) { return value.value(); }
     79
     80    template<typename Traits> using NullableTypeWithLessPadding = Markable<ImplementationType, Traits>;
     81    template<typename Traits>
     82    static NullableTypeWithLessPadding<Traits> nullValue() { return std::nullopt; }
     83    template<typename Traits>
     84    static bool isNullType(const NullableTypeWithLessPadding<Traits>& value) { return !value; }
     85    template<typename Traits>
     86    static ImplementationType extractValueFromNullable(const NullableTypeWithLessPadding<Traits>& value) { return value.value(); }
    7887};
    7988
  • trunk/Source/WebCore/css/typedom/numeric/CSSMathProduct.cpp

    r293086 r293278  
    4444        return std::nullopt;
    4545
    46     auto add = [] (auto left, auto right) -> std::optional<unsigned> {
     46    auto add = [] (auto left, auto right) -> CSSNumericType::BaseTypeStorage {
    4747        if (!left)
    4848            return right;
  • trunk/Source/WebCore/css/typedom/numeric/CSSNumericType.h

    r293005 r293278  
    3030#include "CSSNumericBaseType.h"
    3131#include <optional>
     32#include <wtf/Markable.h>
    3233#include <wtf/text/StringConcatenateNumbers.h>
    3334
     
    3637// https://drafts.css-houdini.org/css-typed-om/#dom-cssnumericvalue-type
    3738struct CSSNumericType {
    38     std::optional<long> length;
    39     std::optional<long> angle;
    40     std::optional<long> time;
    41     std::optional<long> frequency;
    42     std::optional<long> resolution;
    43     std::optional<long> flex;
    44     std::optional<long> percent;
    45     std::optional<CSSNumericBaseType> percentHint;
     39    using BaseTypeStorage = Markable<int, IntegralMarkableTraits<int, std::numeric_limits<int>::min()>>;
     40    BaseTypeStorage length;
     41    BaseTypeStorage angle;
     42    BaseTypeStorage time;
     43    BaseTypeStorage frequency;
     44    BaseTypeStorage resolution;
     45    BaseTypeStorage flex;
     46    BaseTypeStorage percent;
     47    Markable<CSSNumericBaseType, EnumMarkableTraits<CSSNumericBaseType>> percentHint;
    4648
    4749    bool operator==(const CSSNumericType& other) const
     
    5759    }
    5860
    59     std::optional<long>& valueForType(CSSNumericBaseType type)
     61    BaseTypeStorage& valueForType(CSSNumericBaseType type)
    6062    {
    6163        switch (type) {
     
    7880    }
    7981
    80     const std::optional<long>& valueForType(CSSNumericBaseType type) const
     82    const BaseTypeStorage& valueForType(CSSNumericBaseType type) const
    8183    {
    8284        return const_cast<CSSNumericType*>(this)->valueForType(type);
Note: See TracChangeset for help on using the changeset viewer.