Commit 6d2c5b83 authored by timloh@chromium.org's avatar timloh@chromium.org

Add inherited flag to CSSProperties.in

This patch adds the flag 'inherited' to CSSProperties.in, replacing the
existing switch statement in CSSProperty.cpp. The primary use for
isInheritedProperty appears to be as part of the MatchedPropertiesCache
optimisation.

I've added the inherited flag to overflow-wrap and paint-order, which
are inherited in the code and specs[1][2] but were not returning true
in the switch. As far as I can tell, this has no difference aside from
making us still use the MatchedPropertiesCache if these are explicitly
set to inherit. I also added a fixme indicating that the property
resize shouldn't inherit by default.

[1] http://dev.w3.org/csswg/css-text/#overflow-wrap-property
[2] https://svgwg.org/svg2-draft/painting.html#PaintOrder

BUG=396992

Review URL: https://codereview.chromium.org/450103005

git-svn-id: svn://svn.chromium.org/blink/trunk@180051 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 71184aa8
......@@ -12,6 +12,7 @@ class CSSProperties(in_generator.Writer):
'alias_for': None,
'longhands': '',
'animatable': False,
'inherited': False,
'font': False,
'svg': False,
'name_for_methods': None,
......@@ -31,6 +32,7 @@ class CSSProperties(in_generator.Writer):
valid_values = {
'animatable': (True, False),
'inherited': (True, False),
'font': (True, False),
'svg': (True, False),
'custom_all': (True, False),
......
......@@ -19,6 +19,9 @@ class CSSPropertyMetadataWriter(css_properties.CSSProperties):
def generate_css_property_metadata_cpp(self):
return {
'properties': self._properties,
'switches': [('animatable', 'isAnimatableProperty'),
('inherited', 'isInheritedProperty'),
],
}
......
......@@ -5,14 +5,15 @@
#include "core/css/CSSPropertyMetadata.h"
namespace blink {
{% for flag, function_name in switches %}
bool CSSPropertyMetadata::isAnimatableProperty(CSSPropertyID property)
bool CSSPropertyMetadata::{{function_name}}(CSSPropertyID property)
{
switch(property) {
case CSSPropertyInvalid:
ASSERT_NOT_REACHED();
return false;
{% for property_id, property in properties.items() if property.animatable %}
{% for property_id, property in properties.items() if property[flag] %}
case {{property_id}}:
{% endfor %}
return true;
......@@ -20,5 +21,6 @@ bool CSSPropertyMetadata::isAnimatableProperty(CSSPropertyID property)
return false;
}
}
{% endfor %}
} // namespace blink
......@@ -22,6 +22,7 @@
#define CSSProperty_h
#include "core/CSSPropertyNames.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/CSSValue.h"
#include "platform/RuntimeEnabledFeatures.h"
#include "platform/text/TextDirection.h"
......@@ -56,7 +57,7 @@ class CSSProperty {
ALLOW_ONLY_INLINE_ALLOCATION();
public:
CSSProperty(CSSPropertyID propertyID, PassRefPtrWillBeRawPtr<CSSValue> value, bool important = false, bool isSetFromShorthand = false, int indexInShorthandsVector = 0, bool implicit = false)
: m_metadata(propertyID, isSetFromShorthand, indexInShorthandsVector, important, implicit, isInheritedProperty(propertyID))
: m_metadata(propertyID, isSetFromShorthand, indexInShorthandsVector, important, implicit, CSSPropertyMetadata::isInheritedProperty(propertyID))
, m_value(value)
{
}
......@@ -78,7 +79,6 @@ public:
void wrapValueInCommaSeparatedList();
static CSSPropertyID resolveDirectionAwareProperty(CSSPropertyID, TextDirection, WritingMode);
static bool isInheritedProperty(CSSPropertyID);
static bool isAffectedByAllProperty(CSSPropertyID);
const StylePropertyMetadata& metadata() const { return m_metadata; }
......
......@@ -12,6 +12,7 @@ namespace blink {
class CSSPropertyMetadata {
public:
static bool isAnimatableProperty(CSSPropertyID);
static bool isInheritedProperty(CSSPropertyID);
};
} // namespace blink
......
......@@ -229,7 +229,7 @@ String StylePropertySerializer::asText() const
} else
value = property.value()->cssText();
if (value == "initial" && !CSSProperty::isInheritedProperty(propertyID))
if (value == "initial" && !CSSPropertyMetadata::isInheritedProperty(propertyID))
continue;
result.append(getPropertyText(propertyID, value, property.isImportant(), numDecls++));
......
......@@ -53,7 +53,7 @@
#include "core/css/CSSLineBoxContainValue.h"
#include "core/css/parser/BisonCSSParser.h"
#include "core/css/CSSPrimitiveValueMappings.h"
#include "core/css/CSSProperty.h"
#include "core/css/CSSPropertyMetadata.h"
#include "core/css/Counter.h"
#include "core/css/Pair.h"
#include "core/css/Rect.h"
......@@ -125,7 +125,7 @@ void StyleBuilder::applyProperty(CSSPropertyID id, StyleResolverState& state, CS
if (primitiveValue && primitiveValue->getValueID() == CSSValueCurrentcolor)
state.style()->setHasCurrentColor();
if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSProperty::isInheritedProperty(id))
if (isInherit && !state.parentStyle()->hasExplicitlyInheritedProperties() && !CSSPropertyMetadata::isInheritedProperty(id))
state.parentStyle()->setHasExplicitlyInheritedProperties();
StyleBuilder::applyProperty(id, state, value, isInitial, isInherit);
......
......@@ -1336,7 +1336,7 @@ void StyleResolver::applyAllProperty(StyleResolverState& state, CSSValue* allVal
if (!isUnsetValue) {
value = allValue;
} else {
if (CSSProperty::isInheritedProperty(propertyId))
if (CSSPropertyMetadata::isInheritedProperty(propertyId))
value = cssValuePool().createInheritedValue().get();
else
value = cssValuePool().createExplicitInitialValue().get();
......
......@@ -116,7 +116,7 @@ static const Vector<CSSPropertyID>& inheritableEditingProperties()
if (properties.isEmpty()) {
RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingProperties, WTF_ARRAY_LENGTH(staticEditingProperties), properties);
for (size_t index = 0; index < properties.size();) {
if (!CSSProperty::isInheritedProperty(properties[index])) {
if (!CSSPropertyMetadata::isInheritedProperty(properties[index])) {
properties.remove(index);
continue;
}
......
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