Commit d04688d1 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Remove CSSPropertyPriority

Change-Id: Ida10f6a7f6a4583dddc6e51bf6874d664cb138af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2372284
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804896}
parent a824f76e
......@@ -70,6 +70,7 @@ class CSSProperties(object):
# 1: CSSPropertyID::kVariable
self._first_enum_value = 2
self._last_used_enum_value = self._first_enum_value
self._last_high_priority_property = None
self._properties_by_id = {}
self._properties_by_name = {}
......@@ -141,7 +142,6 @@ class CSSProperties(object):
for property_ in self._longhands + self._shorthands:
self.expand_parameters(property_)
validate_property(property_)
# This order must match the order in CSSPropertyPriority.h.
priority_numbers = {'High': 0, 'Low': 1}
priority = priority_numbers[property_['priority']]
name_without_leading_dash = property_['name'].original
......@@ -170,6 +170,8 @@ class CSSProperties(object):
('property with ID {} appears more than once in the '
'properties list'.format(property_['property_id']))
self._properties_by_id[property_['property_id']] = property_
if property_['priority'] == 'High':
self._last_high_priority_property = property_
self.expand_aliases()
self._properties_including_aliases = self._longhands + \
......@@ -377,6 +379,10 @@ class CSSProperties(object):
def last_unresolved_property_id(self):
return self._last_unresolved_property_id
@property
def last_high_priority_property_id(self):
return self._last_high_priority_property['enum_key']
@property
def property_id_bit_length(self):
return int.bit_length(self._last_unresolved_property_id)
......
......@@ -47,6 +47,8 @@ class CSSPropertyNamesWriter(json5_generator.Writer):
self._css_properties.last_property_id,
'last_unresolved_property_id':
self._css_properties.last_unresolved_property_id,
'last_high_priority_property_id':
self._css_properties.last_high_priority_property_id,
'property_id_bit_length':
self._css_properties.property_id_bit_length,
'max_name_length':
......
......@@ -35,6 +35,8 @@ const int numCSSProperties = {{properties_count}};
const int kIntLastCSSProperty = {{last_property_id}};
const CSSPropertyID lastCSSProperty = static_cast<CSSPropertyID>(kIntLastCSSProperty);
const CSSPropertyID lastUnresolvedCSSProperty = static_cast<CSSPropertyID>({{last_unresolved_property_id}});
const CSSPropertyID kFirstHighPriorityCSSProperty = firstCSSProperty;
const CSSPropertyID kLastHighPriorityCSSProperty = CSSPropertyID::{{last_high_priority_property_id}};
const int numCSSPropertyIDs = static_cast<int>(lastUnresolvedCSSProperty) + 1;
const size_t maxCSSPropertyNameLength = {{max_name_length}};
constexpr size_t kCSSPropertyIDBitLength = {{property_id_bit_length}};
......@@ -43,12 +45,25 @@ static_assert((static_cast<size_t>(1) << kCSSPropertyIDBitLength) >
static_cast<size_t>(lastUnresolvedCSSProperty),
"kCSSPropertyIDBitLength has enough bits");
static_assert(CSSPropertyID::kColor == kFirstHighPriorityCSSProperty,
"CSSPropertyID::kColor is the first high-priority property");
static_assert(CSSPropertyID::kZoom == kLastHighPriorityCSSProperty,
"CSSPropertyID::kZoom is the last high-priority property");
static_assert((static_cast<int>(kLastHighPriorityCSSProperty) -
static_cast<int>(kFirstHighPriorityCSSProperty)) == 26,
"There should a low number of high-priority properties");
inline int GetCSSPropertyIDIndex(CSSPropertyID id) {
DCHECK_GE(id, firstCSSProperty);
DCHECK_LE(id, lastCSSProperty);
return static_cast<int>(id) - kIntFirstCSSProperty;
}
constexpr bool IsHighPriority(CSSPropertyID id) {
return id >= kFirstHighPriorityCSSProperty &&
id <= kLastHighPriorityCSSProperty;
}
inline bool isCSSPropertyIDWithName(CSSPropertyID id)
{
return id >= firstCSSProperty && id <= lastUnresolvedCSSProperty;
......
......@@ -483,7 +483,6 @@ blink_core_sources("css") {
"resolver/cascade_priority.h",
"resolver/cascade_resolver.cc",
"resolver/cascade_resolver.h",
"resolver/css_property_priority.h",
"resolver/css_to_style_map.cc",
"resolver/css_to_style_map.h",
"resolver/element_resolve_context.cc",
......
......@@ -4,7 +4,6 @@
#include "third_party/blink/renderer/core/css/resolver/cascade_map.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
namespace blink {
......@@ -125,10 +124,9 @@ void CascadeMap::Add(const CSSPropertyName& name, CascadePriority priority) {
DCHECK_LT(index, static_cast<size_t>(numCSSProperties));
// Set bit in high_priority_, if appropriate.
using HighPriority = CSSPropertyPriorityData<kHighPropertyPriority>;
static_assert(static_cast<int>(HighPriority::Last()) < 64,
static_assert(static_cast<int>(kLastHighPriorityCSSProperty) < 64,
"CascadeMap supports at most 63 high-priority properties");
if (HighPriority::PropertyHasPriority(id))
if (IsHighPriority(id))
high_priority_ |= (1ull << index);
has_important_ |= priority.IsImportant();
......
......@@ -8,7 +8,6 @@
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_priority.h"
#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
namespace blink {
......@@ -183,8 +182,7 @@ TEST(CascadeMapTest, AllHighPriorityBits) {
uint64_t expected = 0;
for (CSSPropertyID id : CSSPropertyIDList()) {
if (CSSPropertyPriorityData<kHighPropertyPriority>::PropertyHasPriority(
id)) {
if (IsHighPriority(id)) {
if (CSSProperty::Get(id).IsSurrogate())
continue;
map.Add(CSSPropertyName(id), CascadeOrigin::kAuthor);
......@@ -200,7 +198,7 @@ TEST(CascadeMapTest, LastHighPrio) {
EXPECT_FALSE(map.HighPriorityBits());
CSSPropertyID last = CSSPropertyPriorityData<kHighPropertyPriority>::Last();
CSSPropertyID last = kLastHighPriorityCSSProperty;
map.Add(CSSPropertyName(last), CascadeOrigin::kAuthor);
EXPECT_EQ(map.HighPriorityBits(), 1ull << static_cast<uint64_t>(last));
......
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CSS_PROPERTY_PRIORITY_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CSS_PROPERTY_PRIORITY_H_
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/platform/wtf/allocator/allocator.h"
namespace blink {
// The values of high priority properties affect the values of low priority
// properties. For example, the value of the high priority property 'font-size'
// decides the pixel value of low priority properties with 'em' units.
// TODO(sashab): Generate the methods in this file.
enum CSSPropertyPriority {
kHighPropertyPriority,
};
template <CSSPropertyPriority priority>
class CSSPropertyPriorityData {
STATIC_ONLY(CSSPropertyPriorityData);
public:
static constexpr CSSPropertyID First();
static constexpr CSSPropertyID Last();
static constexpr bool PropertyHasPriority(CSSPropertyID prop) {
return First() <= prop && prop <= Last();
}
};
template <>
constexpr CSSPropertyID
CSSPropertyPriorityData<kHighPropertyPriority>::First() {
static_assert(
CSSPropertyID::kColor == firstCSSProperty,
"CSSPropertyID::kColor should be the first high priority property");
return CSSPropertyID::kColor;
}
template <>
constexpr CSSPropertyID CSSPropertyPriorityData<kHighPropertyPriority>::Last() {
static_assert(static_cast<int>(CSSPropertyID::kZoom) ==
static_cast<int>(CSSPropertyID::kColor) + 26,
"CSSPropertyID::kZoom should be the end of the high priority "
"property range");
static_assert(static_cast<int>(CSSPropertyID::kWritingMode) ==
static_cast<int>(CSSPropertyID::kZoom) - 1,
"CSSPropertyID::kWritingMode should be immediately before "
"CSSPropertyID::kZoom");
return CSSPropertyID::kZoom;
}
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_CSS_RESOLVER_CSS_PROPERTY_PRIORITY_H_
......@@ -26,7 +26,6 @@
#include "third_party/blink/renderer/core/css/resolver/cascade_expansion.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_interpolations.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
......@@ -343,9 +342,8 @@ void StyleCascade::ApplyHighPriority(CascadeResolver& resolver) {
uint64_t bits = map_.HighPriorityBits();
if (bits) {
using HighPriority = CSSPropertyPriorityData<kHighPropertyPriority>;
int first = static_cast<int>(HighPriority::First());
int last = static_cast<int>(HighPriority::Last());
int first = static_cast<int>(kFirstHighPriorityCSSProperty);
int last = static_cast<int>(kLastHighPriorityCSSProperty);
for (int i = first; i <= last; ++i) {
if (bits & (static_cast<uint64_t>(1) << i))
LookupAndApply(CSSProperty::Get(convertToCSSPropertyID(i)), resolver);
......
......@@ -29,7 +29,6 @@
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/core/css/element_rule_collector.h"
#include "third_party/blink/renderer/core/css/pseudo_style_request.h"
#include "third_party/blink/renderer/core/css/resolver/css_property_priority.h"
#include "third_party/blink/renderer/core/css/resolver/matched_properties_cache.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder.h"
#include "third_party/blink/renderer/core/css/selector_checker.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment