Streamline CSSPropertyID set testing.
It turns out that CSSBitSet _can_ be made compile-time statically initialized without resorting to lots of precomputed uint64_t values, as long as we hold Clang just right. So change kKnownExposedProperties to using that (giving slightly less complex Jinja code), and convert the CSSParserFastPath tests from switches (which create jump tables, which are generally larger) to using bitsets. Change-Id: I2ddd18ca093611580adf4daeb99fdb5bcf066284 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4014121 Commit-Queue: Steinar H Gunderson <sesse@chromium.org> Reviewed-by: Anders Hartvoll Ruud <andruud@chromium.org> Cr-Commit-Position: refs/heads/main@{#1069137}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b7aabf1d0c
commit
603cb301d4
third_party/blink/renderer
build
scripts
core
css
properties
core
css
16
third_party/blink/renderer/build/scripts/core/css/properties/make_known_exposed_properties.py
vendored
16
third_party/blink/renderer/build/scripts/core/css/properties/make_known_exposed_properties.py
vendored
@@ -16,28 +16,24 @@ class KnownExposedPropertiesWriter(json5_generator.Writer):
|
|||||||
properties = (
|
properties = (
|
||||||
css_properties.CSSProperties(json5_file_paths)).properties_including_aliases
|
css_properties.CSSProperties(json5_file_paths)).properties_including_aliases
|
||||||
|
|
||||||
bitmask = []
|
known_exposed_properties = []
|
||||||
for property in properties:
|
for property in properties:
|
||||||
if not property['is_internal'] and \
|
if not property['is_internal'] and \
|
||||||
not property['runtime_flag'] and \
|
not property['runtime_flag'] and \
|
||||||
not property['in_origin_trial']:
|
not property['in_origin_trial']:
|
||||||
bit_idx = property['enum_value']
|
known_exposed_properties.append(property['enum_key'])
|
||||||
chunk = int(bit_idx / 64)
|
|
||||||
while chunk >= len(bitmask):
|
|
||||||
bitmask.append(0)
|
|
||||||
bitmask[chunk] = bitmask[chunk] | (1 << (bit_idx % 64))
|
|
||||||
|
|
||||||
self._known_exposed_properties_bitmask = bitmask
|
self._known_exposed_properties = known_exposed_properties
|
||||||
|
|
||||||
self._outputs = {
|
self._outputs = {
|
||||||
'known_exposed_properties.cc': self.generate_bitmap,
|
'known_exposed_properties.cc': self.generate_list,
|
||||||
}
|
}
|
||||||
|
|
||||||
@template_expander.use_jinja('core/css/properties/templates/known_exposed_properties.cc.tmpl')
|
@template_expander.use_jinja('core/css/properties/templates/known_exposed_properties.cc.tmpl')
|
||||||
def generate_bitmap(self):
|
def generate_list(self):
|
||||||
return {
|
return {
|
||||||
'input_files': self._input_files,
|
'input_files': self._input_files,
|
||||||
'known_exposed_properties_bitmask': self._known_exposed_properties_bitmask,
|
'known_exposed_properties': self._known_exposed_properties,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -12,10 +12,10 @@
|
|||||||
|
|
||||||
namespace blink {
|
namespace blink {
|
||||||
|
|
||||||
const CSSBitset kKnownExposedProperties{std::array<uint64_t, CSSBitset::kChunks>{
|
const CSSBitset kKnownExposedProperties{ {
|
||||||
{% for chunk in known_exposed_properties_bitmask %}
|
{% for property in known_exposed_properties %}
|
||||||
0x{{ '%016x' % chunk }}ULL,
|
CSSPropertyID::{{ property }},
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
}};
|
} };
|
||||||
|
|
||||||
} // namespace blink
|
} // namespace blink
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
#include "third_party/blink/renderer/core/css/css_value_clamping_utils.h"
|
#include "third_party/blink/renderer/core/css/css_value_clamping_utils.h"
|
||||||
#include "third_party/blink/renderer/core/css/parser/css_parser_idioms.h"
|
#include "third_party/blink/renderer/core/css/parser/css_parser_idioms.h"
|
||||||
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
|
#include "third_party/blink/renderer/core/css/parser/css_property_parser.h"
|
||||||
|
#include "third_party/blink/renderer/core/css/properties/css_bitset.h"
|
||||||
#include "third_party/blink/renderer/core/css/properties/css_property.h"
|
#include "third_party/blink/renderer/core/css/properties/css_property.h"
|
||||||
#include "third_party/blink/renderer/core/css/style_color.h"
|
#include "third_party/blink/renderer/core/css/style_color.h"
|
||||||
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
|
#include "third_party/blink/renderer/core/html/parser/html_parser_idioms.h"
|
||||||
@@ -31,60 +32,70 @@ namespace blink {
|
|||||||
|
|
||||||
static inline bool IsSimpleLengthPropertyID(CSSPropertyID property_id,
|
static inline bool IsSimpleLengthPropertyID(CSSPropertyID property_id,
|
||||||
bool& accepts_negative_numbers) {
|
bool& accepts_negative_numbers) {
|
||||||
switch (property_id) {
|
static CSSBitset properties{{
|
||||||
case CSSPropertyID::kBlockSize:
|
CSSPropertyID::kBlockSize,
|
||||||
case CSSPropertyID::kInlineSize:
|
CSSPropertyID::kInlineSize,
|
||||||
case CSSPropertyID::kMinBlockSize:
|
CSSPropertyID::kMinBlockSize,
|
||||||
case CSSPropertyID::kMinInlineSize:
|
CSSPropertyID::kMinInlineSize,
|
||||||
case CSSPropertyID::kFontSize:
|
CSSPropertyID::kFontSize,
|
||||||
case CSSPropertyID::kHeight:
|
CSSPropertyID::kHeight,
|
||||||
case CSSPropertyID::kWidth:
|
CSSPropertyID::kWidth,
|
||||||
case CSSPropertyID::kMinHeight:
|
CSSPropertyID::kMinHeight,
|
||||||
case CSSPropertyID::kMinWidth:
|
CSSPropertyID::kMinWidth,
|
||||||
case CSSPropertyID::kPaddingBottom:
|
CSSPropertyID::kPaddingBottom,
|
||||||
case CSSPropertyID::kPaddingLeft:
|
CSSPropertyID::kPaddingLeft,
|
||||||
case CSSPropertyID::kPaddingRight:
|
CSSPropertyID::kPaddingRight,
|
||||||
case CSSPropertyID::kPaddingTop:
|
CSSPropertyID::kPaddingTop,
|
||||||
case CSSPropertyID::kScrollPaddingBlockEnd:
|
CSSPropertyID::kScrollPaddingBlockEnd,
|
||||||
case CSSPropertyID::kScrollPaddingBlockStart:
|
CSSPropertyID::kScrollPaddingBlockStart,
|
||||||
case CSSPropertyID::kScrollPaddingBottom:
|
CSSPropertyID::kScrollPaddingBottom,
|
||||||
case CSSPropertyID::kScrollPaddingInlineEnd:
|
CSSPropertyID::kScrollPaddingInlineEnd,
|
||||||
case CSSPropertyID::kScrollPaddingInlineStart:
|
CSSPropertyID::kScrollPaddingInlineStart,
|
||||||
case CSSPropertyID::kScrollPaddingLeft:
|
CSSPropertyID::kScrollPaddingLeft,
|
||||||
case CSSPropertyID::kScrollPaddingRight:
|
CSSPropertyID::kScrollPaddingRight,
|
||||||
case CSSPropertyID::kScrollPaddingTop:
|
CSSPropertyID::kScrollPaddingTop,
|
||||||
case CSSPropertyID::kPaddingBlockEnd:
|
CSSPropertyID::kPaddingBlockEnd,
|
||||||
case CSSPropertyID::kPaddingBlockStart:
|
CSSPropertyID::kPaddingBlockStart,
|
||||||
case CSSPropertyID::kPaddingInlineEnd:
|
CSSPropertyID::kPaddingInlineEnd,
|
||||||
case CSSPropertyID::kPaddingInlineStart:
|
CSSPropertyID::kPaddingInlineStart,
|
||||||
case CSSPropertyID::kShapeMargin:
|
CSSPropertyID::kShapeMargin,
|
||||||
case CSSPropertyID::kR:
|
CSSPropertyID::kR,
|
||||||
case CSSPropertyID::kRx:
|
CSSPropertyID::kRx,
|
||||||
case CSSPropertyID::kRy:
|
CSSPropertyID::kRy,
|
||||||
accepts_negative_numbers = false;
|
CSSPropertyID::kBottom,
|
||||||
return true;
|
CSSPropertyID::kCx,
|
||||||
case CSSPropertyID::kBottom:
|
CSSPropertyID::kCy,
|
||||||
case CSSPropertyID::kCx:
|
CSSPropertyID::kLeft,
|
||||||
case CSSPropertyID::kCy:
|
CSSPropertyID::kMarginBottom,
|
||||||
case CSSPropertyID::kLeft:
|
CSSPropertyID::kMarginLeft,
|
||||||
case CSSPropertyID::kMarginBottom:
|
CSSPropertyID::kMarginRight,
|
||||||
case CSSPropertyID::kMarginLeft:
|
CSSPropertyID::kMarginTop,
|
||||||
case CSSPropertyID::kMarginRight:
|
CSSPropertyID::kOffsetDistance,
|
||||||
case CSSPropertyID::kMarginTop:
|
CSSPropertyID::kRight,
|
||||||
case CSSPropertyID::kOffsetDistance:
|
CSSPropertyID::kTop,
|
||||||
case CSSPropertyID::kRight:
|
CSSPropertyID::kMarginBlockEnd,
|
||||||
case CSSPropertyID::kTop:
|
CSSPropertyID::kMarginBlockStart,
|
||||||
case CSSPropertyID::kMarginBlockEnd:
|
CSSPropertyID::kMarginInlineEnd,
|
||||||
case CSSPropertyID::kMarginBlockStart:
|
CSSPropertyID::kMarginInlineStart,
|
||||||
case CSSPropertyID::kMarginInlineEnd:
|
CSSPropertyID::kX,
|
||||||
case CSSPropertyID::kMarginInlineStart:
|
CSSPropertyID::kY,
|
||||||
case CSSPropertyID::kX:
|
}};
|
||||||
case CSSPropertyID::kY:
|
// A subset of the above.
|
||||||
accepts_negative_numbers = true;
|
static CSSBitset accept_negative{
|
||||||
return true;
|
{CSSPropertyID::kBottom, CSSPropertyID::kCx, CSSPropertyID::kCy,
|
||||||
default:
|
CSSPropertyID::kLeft, CSSPropertyID::kMarginBottom,
|
||||||
return false;
|
CSSPropertyID::kMarginLeft, CSSPropertyID::kMarginRight,
|
||||||
|
CSSPropertyID::kMarginTop, CSSPropertyID::kOffsetDistance,
|
||||||
|
CSSPropertyID::kRight, CSSPropertyID::kTop,
|
||||||
|
CSSPropertyID::kMarginBlockEnd, CSSPropertyID::kMarginBlockStart,
|
||||||
|
CSSPropertyID::kMarginInlineEnd, CSSPropertyID::kMarginInlineStart,
|
||||||
|
CSSPropertyID::kX, CSSPropertyID::kY}};
|
||||||
|
|
||||||
|
accepts_negative_numbers = accept_negative.Has(property_id);
|
||||||
|
if (accepts_negative_numbers) {
|
||||||
|
DCHECK(properties.Has(property_id));
|
||||||
}
|
}
|
||||||
|
return properties.Has(property_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename CharacterType>
|
template <typename CharacterType>
|
||||||
@@ -194,49 +205,44 @@ static inline bool ParseSimpleAngle(const CharacterType* characters,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool IsColorPropertyID(CSSPropertyID property_id) {
|
static inline bool IsColorPropertyID(CSSPropertyID property_id) {
|
||||||
switch (property_id) {
|
static CSSBitset properties{{
|
||||||
case CSSPropertyID::kCaretColor:
|
CSSPropertyID::kCaretColor,
|
||||||
case CSSPropertyID::kColor:
|
CSSPropertyID::kColor,
|
||||||
case CSSPropertyID::kBackgroundColor:
|
CSSPropertyID::kBackgroundColor,
|
||||||
case CSSPropertyID::kBorderBottomColor:
|
CSSPropertyID::kBorderBottomColor,
|
||||||
case CSSPropertyID::kBorderLeftColor:
|
CSSPropertyID::kBorderLeftColor,
|
||||||
case CSSPropertyID::kBorderRightColor:
|
CSSPropertyID::kBorderRightColor,
|
||||||
case CSSPropertyID::kBorderTopColor:
|
CSSPropertyID::kBorderTopColor,
|
||||||
case CSSPropertyID::kFill:
|
CSSPropertyID::kFill,
|
||||||
case CSSPropertyID::kFloodColor:
|
CSSPropertyID::kFloodColor,
|
||||||
case CSSPropertyID::kLightingColor:
|
CSSPropertyID::kLightingColor,
|
||||||
case CSSPropertyID::kOutlineColor:
|
CSSPropertyID::kOutlineColor,
|
||||||
case CSSPropertyID::kStopColor:
|
CSSPropertyID::kStopColor,
|
||||||
case CSSPropertyID::kStroke:
|
CSSPropertyID::kStroke,
|
||||||
case CSSPropertyID::kBorderBlockEndColor:
|
CSSPropertyID::kBorderBlockEndColor,
|
||||||
case CSSPropertyID::kBorderBlockStartColor:
|
CSSPropertyID::kBorderBlockStartColor,
|
||||||
case CSSPropertyID::kBorderInlineEndColor:
|
CSSPropertyID::kBorderInlineEndColor,
|
||||||
case CSSPropertyID::kBorderInlineStartColor:
|
CSSPropertyID::kBorderInlineStartColor,
|
||||||
case CSSPropertyID::kColumnRuleColor:
|
CSSPropertyID::kColumnRuleColor,
|
||||||
case CSSPropertyID::kTextEmphasisColor:
|
CSSPropertyID::kTextEmphasisColor,
|
||||||
case CSSPropertyID::kWebkitTextFillColor:
|
CSSPropertyID::kWebkitTextFillColor,
|
||||||
case CSSPropertyID::kWebkitTextStrokeColor:
|
CSSPropertyID::kWebkitTextStrokeColor,
|
||||||
case CSSPropertyID::kTextDecorationColor:
|
CSSPropertyID::kTextDecorationColor,
|
||||||
return true;
|
}};
|
||||||
default:
|
return properties.Has(property_id);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
|
// https://quirks.spec.whatwg.org/#the-hashless-hex-color-quirk
|
||||||
static inline bool ColorPropertyAllowsQuirkyColor(CSSPropertyID property_id) {
|
static inline bool ColorPropertyAllowsQuirkyColor(CSSPropertyID property_id) {
|
||||||
switch (property_id) {
|
static CSSBitset properties{{
|
||||||
case CSSPropertyID::kColor:
|
CSSPropertyID::kColor,
|
||||||
case CSSPropertyID::kBackgroundColor:
|
CSSPropertyID::kBackgroundColor,
|
||||||
case CSSPropertyID::kBorderBottomColor:
|
CSSPropertyID::kBorderBottomColor,
|
||||||
case CSSPropertyID::kBorderLeftColor:
|
CSSPropertyID::kBorderLeftColor,
|
||||||
case CSSPropertyID::kBorderRightColor:
|
CSSPropertyID::kBorderRightColor,
|
||||||
case CSSPropertyID::kBorderTopColor:
|
CSSPropertyID::kBorderTopColor,
|
||||||
return true;
|
}};
|
||||||
default:
|
return properties.Has(property_id);
|
||||||
DCHECK(IsColorPropertyID(property_id));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the number of initial characters which form a valid double.
|
// Returns the number of initial characters which form a valid double.
|
||||||
@@ -1268,126 +1274,121 @@ bool CSSParserFastPaths::IsValidKeywordPropertyAndValue(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CSSParserFastPaths::IsHandledByKeywordFastPath(CSSPropertyID property_id) {
|
// NOTE: This list must match exactly those properties handled by
|
||||||
// NOTE: This list must match exactly those properties handled by
|
// IsValidKeywordPropertyAndValue().
|
||||||
// IsValidKeywordPropertyAndValue().
|
CSSBitset CSSParserFastPaths::handled_by_keyword_fast_paths_properties_{{
|
||||||
switch (property_id) {
|
CSSPropertyID::kAlignmentBaseline,
|
||||||
case CSSPropertyID::kAlignmentBaseline:
|
CSSPropertyID::kAll,
|
||||||
case CSSPropertyID::kAll:
|
CSSPropertyID::kMixBlendMode,
|
||||||
case CSSPropertyID::kMixBlendMode:
|
CSSPropertyID::kIsolation,
|
||||||
case CSSPropertyID::kIsolation:
|
CSSPropertyID::kBackgroundRepeatX,
|
||||||
case CSSPropertyID::kBackgroundRepeatX:
|
CSSPropertyID::kBackgroundRepeatY,
|
||||||
case CSSPropertyID::kBackgroundRepeatY:
|
CSSPropertyID::kBorderBottomStyle,
|
||||||
case CSSPropertyID::kBorderBottomStyle:
|
CSSPropertyID::kBorderCollapse,
|
||||||
case CSSPropertyID::kBorderCollapse:
|
CSSPropertyID::kBorderLeftStyle,
|
||||||
case CSSPropertyID::kBorderLeftStyle:
|
CSSPropertyID::kBorderRightStyle,
|
||||||
case CSSPropertyID::kBorderRightStyle:
|
CSSPropertyID::kBorderTopStyle,
|
||||||
case CSSPropertyID::kBorderTopStyle:
|
CSSPropertyID::kBoxSizing,
|
||||||
case CSSPropertyID::kBoxSizing:
|
CSSPropertyID::kBufferedRendering,
|
||||||
case CSSPropertyID::kBufferedRendering:
|
CSSPropertyID::kCaptionSide,
|
||||||
case CSSPropertyID::kCaptionSide:
|
CSSPropertyID::kClear,
|
||||||
case CSSPropertyID::kClear:
|
CSSPropertyID::kClipRule,
|
||||||
case CSSPropertyID::kClipRule:
|
CSSPropertyID::kColorInterpolation,
|
||||||
case CSSPropertyID::kColorInterpolation:
|
CSSPropertyID::kColorInterpolationFilters,
|
||||||
case CSSPropertyID::kColorInterpolationFilters:
|
CSSPropertyID::kColorRendering,
|
||||||
case CSSPropertyID::kColorRendering:
|
CSSPropertyID::kDirection,
|
||||||
case CSSPropertyID::kDirection:
|
CSSPropertyID::kDominantBaseline,
|
||||||
case CSSPropertyID::kDominantBaseline:
|
CSSPropertyID::kEmptyCells,
|
||||||
case CSSPropertyID::kEmptyCells:
|
CSSPropertyID::kFillRule,
|
||||||
case CSSPropertyID::kFillRule:
|
CSSPropertyID::kFloat,
|
||||||
case CSSPropertyID::kFloat:
|
CSSPropertyID::kForcedColorAdjust,
|
||||||
case CSSPropertyID::kForcedColorAdjust:
|
CSSPropertyID::kHyphens,
|
||||||
case CSSPropertyID::kHyphens:
|
CSSPropertyID::kImageRendering,
|
||||||
case CSSPropertyID::kImageRendering:
|
CSSPropertyID::kListStylePosition,
|
||||||
case CSSPropertyID::kListStylePosition:
|
CSSPropertyID::kMaskType,
|
||||||
case CSSPropertyID::kMaskType:
|
CSSPropertyID::kMathShift,
|
||||||
case CSSPropertyID::kMathShift:
|
CSSPropertyID::kMathStyle,
|
||||||
case CSSPropertyID::kMathStyle:
|
CSSPropertyID::kObjectFit,
|
||||||
case CSSPropertyID::kObjectFit:
|
CSSPropertyID::kOutlineStyle,
|
||||||
case CSSPropertyID::kOutlineStyle:
|
CSSPropertyID::kOverflowAnchor,
|
||||||
case CSSPropertyID::kOverflowAnchor:
|
CSSPropertyID::kOverflowBlock,
|
||||||
case CSSPropertyID::kOverflowBlock:
|
CSSPropertyID::kOverflowInline,
|
||||||
case CSSPropertyID::kOverflowInline:
|
CSSPropertyID::kOverflowWrap,
|
||||||
case CSSPropertyID::kOverflowWrap:
|
CSSPropertyID::kOverflowX,
|
||||||
case CSSPropertyID::kOverflowX:
|
CSSPropertyID::kOverflowY,
|
||||||
case CSSPropertyID::kOverflowY:
|
CSSPropertyID::kBreakAfter,
|
||||||
case CSSPropertyID::kBreakAfter:
|
CSSPropertyID::kBreakBefore,
|
||||||
case CSSPropertyID::kBreakBefore:
|
CSSPropertyID::kBreakInside,
|
||||||
case CSSPropertyID::kBreakInside:
|
CSSPropertyID::kPageOrientation,
|
||||||
case CSSPropertyID::kPageOrientation:
|
CSSPropertyID::kPointerEvents,
|
||||||
case CSSPropertyID::kPointerEvents:
|
CSSPropertyID::kPosition,
|
||||||
case CSSPropertyID::kPosition:
|
CSSPropertyID::kResize,
|
||||||
case CSSPropertyID::kResize:
|
CSSPropertyID::kScrollBehavior,
|
||||||
case CSSPropertyID::kScrollBehavior:
|
CSSPropertyID::kOverscrollBehaviorInline,
|
||||||
case CSSPropertyID::kOverscrollBehaviorInline:
|
CSSPropertyID::kOverscrollBehaviorBlock,
|
||||||
case CSSPropertyID::kOverscrollBehaviorBlock:
|
CSSPropertyID::kOverscrollBehaviorX,
|
||||||
case CSSPropertyID::kOverscrollBehaviorX:
|
CSSPropertyID::kOverscrollBehaviorY,
|
||||||
case CSSPropertyID::kOverscrollBehaviorY:
|
CSSPropertyID::kRubyPosition,
|
||||||
case CSSPropertyID::kRubyPosition:
|
CSSPropertyID::kShapeRendering,
|
||||||
case CSSPropertyID::kShapeRendering:
|
CSSPropertyID::kSpeak,
|
||||||
case CSSPropertyID::kSpeak:
|
CSSPropertyID::kStrokeLinecap,
|
||||||
case CSSPropertyID::kStrokeLinecap:
|
CSSPropertyID::kStrokeLinejoin,
|
||||||
case CSSPropertyID::kStrokeLinejoin:
|
CSSPropertyID::kTableLayout,
|
||||||
case CSSPropertyID::kTableLayout:
|
CSSPropertyID::kTextAlign,
|
||||||
case CSSPropertyID::kTextAlign:
|
CSSPropertyID::kTextAlignLast,
|
||||||
case CSSPropertyID::kTextAlignLast:
|
CSSPropertyID::kTextAnchor,
|
||||||
case CSSPropertyID::kTextAnchor:
|
CSSPropertyID::kTextCombineUpright,
|
||||||
case CSSPropertyID::kTextCombineUpright:
|
CSSPropertyID::kTextDecorationStyle,
|
||||||
case CSSPropertyID::kTextDecorationStyle:
|
CSSPropertyID::kTextDecorationSkipInk,
|
||||||
case CSSPropertyID::kTextDecorationSkipInk:
|
CSSPropertyID::kTextOrientation,
|
||||||
case CSSPropertyID::kTextOrientation:
|
CSSPropertyID::kWebkitTextOrientation,
|
||||||
case CSSPropertyID::kWebkitTextOrientation:
|
CSSPropertyID::kTextOverflow,
|
||||||
case CSSPropertyID::kTextOverflow:
|
CSSPropertyID::kTextRendering,
|
||||||
case CSSPropertyID::kTextRendering:
|
CSSPropertyID::kTextTransform,
|
||||||
case CSSPropertyID::kTextTransform:
|
CSSPropertyID::kUnicodeBidi,
|
||||||
case CSSPropertyID::kUnicodeBidi:
|
CSSPropertyID::kVectorEffect,
|
||||||
case CSSPropertyID::kVectorEffect:
|
CSSPropertyID::kVisibility,
|
||||||
case CSSPropertyID::kVisibility:
|
CSSPropertyID::kAppRegion,
|
||||||
case CSSPropertyID::kAppRegion:
|
CSSPropertyID::kBackfaceVisibility,
|
||||||
case CSSPropertyID::kBackfaceVisibility:
|
CSSPropertyID::kBorderBlockEndStyle,
|
||||||
case CSSPropertyID::kBorderBlockEndStyle:
|
CSSPropertyID::kBorderBlockStartStyle,
|
||||||
case CSSPropertyID::kBorderBlockStartStyle:
|
CSSPropertyID::kBorderInlineEndStyle,
|
||||||
case CSSPropertyID::kBorderInlineEndStyle:
|
CSSPropertyID::kBorderInlineStartStyle,
|
||||||
case CSSPropertyID::kBorderInlineStartStyle:
|
CSSPropertyID::kWebkitBoxAlign,
|
||||||
case CSSPropertyID::kWebkitBoxAlign:
|
CSSPropertyID::kWebkitBoxDecorationBreak,
|
||||||
case CSSPropertyID::kWebkitBoxDecorationBreak:
|
CSSPropertyID::kWebkitBoxDirection,
|
||||||
case CSSPropertyID::kWebkitBoxDirection:
|
CSSPropertyID::kWebkitBoxOrient,
|
||||||
case CSSPropertyID::kWebkitBoxOrient:
|
CSSPropertyID::kWebkitBoxPack,
|
||||||
case CSSPropertyID::kWebkitBoxPack:
|
CSSPropertyID::kColumnFill,
|
||||||
case CSSPropertyID::kColumnFill:
|
CSSPropertyID::kColumnRuleStyle,
|
||||||
case CSSPropertyID::kColumnRuleStyle:
|
CSSPropertyID::kFlexDirection,
|
||||||
case CSSPropertyID::kFlexDirection:
|
CSSPropertyID::kFlexWrap,
|
||||||
case CSSPropertyID::kFlexWrap:
|
CSSPropertyID::kFontKerning,
|
||||||
case CSSPropertyID::kFontKerning:
|
CSSPropertyID::kFontOpticalSizing,
|
||||||
case CSSPropertyID::kFontOpticalSizing:
|
CSSPropertyID::kFontSynthesisWeight,
|
||||||
case CSSPropertyID::kFontSynthesisWeight:
|
CSSPropertyID::kFontSynthesisStyle,
|
||||||
case CSSPropertyID::kFontSynthesisStyle:
|
CSSPropertyID::kFontSynthesisSmallCaps,
|
||||||
case CSSPropertyID::kFontSynthesisSmallCaps:
|
CSSPropertyID::kWebkitFontSmoothing,
|
||||||
case CSSPropertyID::kWebkitFontSmoothing:
|
CSSPropertyID::kLineBreak,
|
||||||
case CSSPropertyID::kLineBreak:
|
CSSPropertyID::kWebkitLineBreak,
|
||||||
case CSSPropertyID::kWebkitLineBreak:
|
CSSPropertyID::kWebkitPrintColorAdjust,
|
||||||
case CSSPropertyID::kWebkitPrintColorAdjust:
|
CSSPropertyID::kWebkitRtlOrdering,
|
||||||
case CSSPropertyID::kWebkitRtlOrdering:
|
CSSPropertyID::kWebkitRubyPosition,
|
||||||
case CSSPropertyID::kWebkitRubyPosition:
|
CSSPropertyID::kWebkitTextCombine,
|
||||||
case CSSPropertyID::kWebkitTextCombine:
|
CSSPropertyID::kWebkitTextSecurity,
|
||||||
case CSSPropertyID::kWebkitTextSecurity:
|
CSSPropertyID::kTransformBox,
|
||||||
case CSSPropertyID::kTransformBox:
|
CSSPropertyID::kTransformStyle,
|
||||||
case CSSPropertyID::kTransformStyle:
|
CSSPropertyID::kWebkitUserDrag,
|
||||||
case CSSPropertyID::kWebkitUserDrag:
|
CSSPropertyID::kWebkitUserModify,
|
||||||
case CSSPropertyID::kWebkitUserModify:
|
CSSPropertyID::kUserSelect,
|
||||||
case CSSPropertyID::kUserSelect:
|
CSSPropertyID::kWebkitWritingMode,
|
||||||
case CSSPropertyID::kWebkitWritingMode:
|
CSSPropertyID::kWhiteSpace,
|
||||||
case CSSPropertyID::kWhiteSpace:
|
CSSPropertyID::kWordBreak,
|
||||||
case CSSPropertyID::kWordBreak:
|
CSSPropertyID::kWritingMode,
|
||||||
case CSSPropertyID::kWritingMode:
|
CSSPropertyID::kScrollbarWidth,
|
||||||
case CSSPropertyID::kScrollbarWidth:
|
CSSPropertyID::kScrollSnapStop,
|
||||||
case CSSPropertyID::kScrollSnapStop:
|
CSSPropertyID::kOriginTrialTestProperty,
|
||||||
case CSSPropertyID::kOriginTrialTestProperty:
|
}};
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CSSParserFastPaths::IsValidSystemFont(CSSValueID value_id) {
|
bool CSSParserFastPaths::IsValidSystemFont(CSSValueID value_id) {
|
||||||
return value_id >= CSSValueID::kCaption && value_id <= CSSValueID::kStatusBar;
|
return value_id >= CSSValueID::kCaption && value_id <= CSSValueID::kStatusBar;
|
||||||
|
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "third_party/blink/renderer/core/core_export.h"
|
#include "third_party/blink/renderer/core/core_export.h"
|
||||||
#include "third_party/blink/renderer/core/css/css_property_names.h"
|
#include "third_party/blink/renderer/core/css/css_property_names.h"
|
||||||
|
#include "third_party/blink/renderer/core/css/properties/css_bitset.h"
|
||||||
#include "third_party/blink/renderer/core/css_value_keywords.h"
|
#include "third_party/blink/renderer/core/css_value_keywords.h"
|
||||||
#include "third_party/blink/renderer/platform/graphics/color.h"
|
#include "third_party/blink/renderer/platform/graphics/color.h"
|
||||||
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
|
||||||
@@ -26,7 +27,9 @@ class CORE_EXPORT CSSParserFastPaths {
|
|||||||
|
|
||||||
// NOTE: Properties handled here shouldn't be explicitly handled in
|
// NOTE: Properties handled here shouldn't be explicitly handled in
|
||||||
// CSSPropertyParser, so if this returns true, the fast path is the only path.
|
// CSSPropertyParser, so if this returns true, the fast path is the only path.
|
||||||
static bool IsHandledByKeywordFastPath(CSSPropertyID);
|
static bool IsHandledByKeywordFastPath(CSSPropertyID property_id) {
|
||||||
|
return handled_by_keyword_fast_paths_properties_.Has(property_id);
|
||||||
|
}
|
||||||
|
|
||||||
static bool IsValidKeywordPropertyAndValue(CSSPropertyID,
|
static bool IsValidKeywordPropertyAndValue(CSSPropertyID,
|
||||||
CSSValueID,
|
CSSValueID,
|
||||||
@@ -35,6 +38,9 @@ class CORE_EXPORT CSSParserFastPaths {
|
|||||||
static bool IsValidSystemFont(CSSValueID);
|
static bool IsValidSystemFont(CSSValueID);
|
||||||
|
|
||||||
static CSSValue* ParseColor(const String&, CSSParserMode);
|
static CSSValue* ParseColor(const String&, CSSParserMode);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static CSSBitset handled_by_keyword_fast_paths_properties_;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace blink
|
} // namespace blink
|
||||||
|
@@ -38,15 +38,12 @@ class CORE_EXPORT CSSBitsetBase {
|
|||||||
|
|
||||||
CSSBitsetBase() : chunks_() {}
|
CSSBitsetBase() : chunks_() {}
|
||||||
CSSBitsetBase(const CSSBitsetBase<kBits>& o) { *this = o; }
|
CSSBitsetBase(const CSSBitsetBase<kBits>& o) { *this = o; }
|
||||||
CSSBitsetBase(std::initializer_list<CSSPropertyID> list) : chunks_() {
|
|
||||||
for (CSSPropertyID id : list)
|
|
||||||
Set(id);
|
|
||||||
}
|
|
||||||
|
|
||||||
// This exists really only for generated code to be able to create global
|
// This slightly weird construction helps Clang make an actual
|
||||||
// (const) objects without requiring global constructors.
|
// compile-time static value, until we have constinit.
|
||||||
explicit constexpr CSSBitsetBase(const std::array<uint64_t, kChunks>& chunks)
|
template <int N>
|
||||||
: chunks_{chunks} {}
|
explicit constexpr CSSBitsetBase(const CSSPropertyID (&list)[N])
|
||||||
|
: chunks_(CreateChunks(list)) {}
|
||||||
|
|
||||||
CSSBitsetBase& operator=(const CSSBitsetBase& o) = default;
|
CSSBitsetBase& operator=(const CSSBitsetBase& o) = default;
|
||||||
|
|
||||||
@@ -54,21 +51,21 @@ class CORE_EXPORT CSSBitsetBase {
|
|||||||
bool operator!=(const CSSBitsetBase& o) const { return !(*this == o); }
|
bool operator!=(const CSSBitsetBase& o) const { return !(*this == o); }
|
||||||
|
|
||||||
inline void Set(CSSPropertyID id) {
|
inline void Set(CSSPropertyID id) {
|
||||||
size_t bit = static_cast<size_t>(id);
|
size_t bit = static_cast<size_t>(static_cast<unsigned>(id));
|
||||||
DCHECK_LT(bit, kBits);
|
DCHECK_LT(bit, kBits);
|
||||||
chunks_[bit / 64] |= (1ull << (bit % 64));
|
chunks_.data()[bit / 64] |= (1ull << (bit % 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Or(CSSPropertyID id, bool v) {
|
inline void Or(CSSPropertyID id, bool v) {
|
||||||
size_t bit = static_cast<size_t>(id);
|
size_t bit = static_cast<size_t>(static_cast<unsigned>(id));
|
||||||
DCHECK_LT(bit, kBits);
|
DCHECK_LT(bit, kBits);
|
||||||
chunks_[bit / 64] |= (static_cast<uint64_t>(v) << (bit % 64));
|
chunks_.data()[bit / 64] |= (static_cast<uint64_t>(v) << (bit % 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool Has(CSSPropertyID id) const {
|
inline bool Has(CSSPropertyID id) const {
|
||||||
size_t bit = static_cast<size_t>(id);
|
size_t bit = static_cast<size_t>(static_cast<unsigned>(id));
|
||||||
DCHECK_LT(bit, kBits);
|
DCHECK_LT(bit, kBits);
|
||||||
return chunks_[bit / 64] & (1ull << (bit % 64));
|
return chunks_.data()[bit / 64] & (1ull << (bit % 64));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool HasAny() const {
|
inline bool HasAny() const {
|
||||||
@@ -144,6 +141,17 @@ class CORE_EXPORT CSSBitsetBase {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::array<uint64_t, kChunks> chunks_;
|
std::array<uint64_t, kChunks> chunks_;
|
||||||
|
|
||||||
|
template <int N>
|
||||||
|
static constexpr std::array<uint64_t, kChunks> CreateChunks(
|
||||||
|
const CSSPropertyID (&list)[N]) {
|
||||||
|
std::array<uint64_t, kChunks> chunks{};
|
||||||
|
for (CSSPropertyID id : list) {
|
||||||
|
unsigned bit = static_cast<unsigned>(id);
|
||||||
|
chunks[bit / 64] |= uint64_t{1} << (bit % 64);
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
using CSSBitset = CSSBitsetBase<kNumCSSPropertyIDs>;
|
using CSSBitset = CSSBitsetBase<kNumCSSPropertyIDs>;
|
||||||
|
Reference in New Issue
Block a user