Diff
Modified: trunk/Source/WebCore/ChangeLog (251643 => 251644)
--- trunk/Source/WebCore/ChangeLog 2019-10-27 20:24:29 UTC (rev 251643)
+++ trunk/Source/WebCore/ChangeLog 2019-10-27 22:12:20 UTC (rev 251644)
@@ -1,3 +1,33 @@
+2019-10-27 Antti Koivisto <[email protected]>
+
+ Move resolving direction and writing mode to PropertyCascade
+ https://bugs.webkit.org/show_bug.cgi?id=203471
+ Reviewed by Zalan Bujtas.
+
+ Simplify PropertyCascade call sites.
+
+ * css/StyleResolver.cpp:
+ (WebCore::StyleResolver::styleForKeyframe):
+ (WebCore::StyleResolver::styleForPage):
+ (WebCore::StyleResolver::applyMatchedProperties):
+ (WebCore::StyleResolver::applyPropertyToCurrentStyle):
+ (WebCore::extractDirectionAndWritingMode): Deleted.
+ * style/PropertyCascade.cpp:
+ (WebCore::Style::PropertyCascade::PropertyCascade):
+
+ Add copying constructor that avoids re-resolving directions.
+
+ (WebCore::Style::PropertyCascade::buildCascade):
+
+ Factor into a function.
+
+ (WebCore::Style::PropertyCascade::propertyCascadeForRollback):
+ (WebCore::Style::PropertyCascade::resolveDirectionAndWritingMode):
+
+ The code moves here.
+
+ * style/PropertyCascade.h:
+
2019-10-27 Claudio Saavedra <[email protected]>
[GTK][WPE] Test PublicSuffix.TopPrivatelyControlledDomain is failing since r250589
Modified: trunk/Source/WebCore/css/StyleResolver.cpp (251643 => 251644)
--- trunk/Source/WebCore/css/StyleResolver.cpp 2019-10-27 20:24:29 UTC (rev 251643)
+++ trunk/Source/WebCore/css/StyleResolver.cpp 2019-10-27 22:12:20 UTC (rev 251644)
@@ -118,8 +118,6 @@
static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1);
-static void extractDirectionAndWritingMode(const RenderStyle&, const MatchResult&, TextDirection&, WritingMode&);
-
inline void StyleResolver::State::cacheBorderAndBackground()
{
m_hasUAAppearance = m_style->hasAppearance();
@@ -366,12 +364,8 @@
state.setStyle(RenderStyle::clonePtr(*elementStyle));
state.setParentStyle(RenderStyle::clonePtr(*elementStyle));
- TextDirection direction;
- WritingMode writingMode;
- extractDirectionAndWritingMode(*state.style(), result, direction, writingMode);
+ Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author });
- Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author }, direction, writingMode);
-
cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty);
// If our font got dirtied, update it now.
@@ -570,12 +564,8 @@
auto& result = collector.matchResult();
- TextDirection direction;
- WritingMode writingMode;
- extractDirectionAndWritingMode(*m_state.style(), result, direction, writingMode);
+ Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author });
- Style::PropertyCascade cascade(*this, result, { Style::CascadeLevel::Author }, direction, writingMode);
-
cascade.applyProperties(firstCSSProperty, lastHighPriorityProperty);
// If our font got dirtied, update it now.
@@ -1304,41 +1294,6 @@
return true;
}
-void extractDirectionAndWritingMode(const RenderStyle& style, const MatchResult& matchResult, TextDirection& direction, WritingMode& writingMode)
-{
- direction = style.direction();
- writingMode = style.writingMode();
-
- bool hadImportantWritingMode = false;
- bool hadImportantDirection = false;
-
- for (auto* matchedDeclarations : { &matchResult.userAgentDeclarations, &matchResult.userDeclarations, &matchResult.authorDeclarations }) {
- for (const auto& matchedProperties : *matchedDeclarations) {
- for (unsigned i = 0, count = matchedProperties.properties->propertyCount(); i < count; ++i) {
- auto property = matchedProperties.properties->propertyAt(i);
- if (!property.value()->isPrimitiveValue())
- continue;
- switch (property.id()) {
- case CSSPropertyWritingMode:
- if (!hadImportantWritingMode || property.isImportant()) {
- writingMode = downcast<CSSPrimitiveValue>(*property.value());
- hadImportantWritingMode = property.isImportant();
- }
- break;
- case CSSPropertyDirection:
- if (!hadImportantDirection || property.isImportant()) {
- direction = downcast<CSSPrimitiveValue>(*property.value());
- hadImportantDirection = property.isImportant();
- }
- break;
- default:
- break;
- }
- }
- }
- }
-}
-
void StyleResolver::applyMatchedProperties(const MatchResult& matchResult, const Element& element, ShouldUseMatchedPropertiesCache shouldUseMatchedPropertiesCache)
{
State& state = m_state;
@@ -1365,18 +1320,12 @@
includedProperties = Style::PropertyCascade::IncludedProperties::InheritedOnly;
}
- // Directional properties (*-before/after) are aliases that depend on the TextDirection and WritingMode.
- // These must be resolved before we can begin the property cascade.
- TextDirection direction;
- WritingMode writingMode;
- extractDirectionAndWritingMode(*state.style(), matchResult, direction, writingMode);
-
if (elementTypeHasAppearanceFromUAStyle(*state.element())) {
// FIXME: This is such a hack.
// Find out if there's a -webkit-appearance property in effect from the UA sheet.
// If so, we cache the border and background styles so that RenderTheme::adjustStyle()
// can look at them later to figure out if this is a styled form control or not.
- Style::PropertyCascade cascade(*this, matchResult, { Style::CascadeLevel::UserAgent }, direction, writingMode, includedProperties);
+ Style::PropertyCascade cascade(*this, matchResult, { Style::CascadeLevel::UserAgent }, includedProperties);
cascade.applyProperties(CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition);
adjustStyleForInterCharacterRuby();
@@ -1399,7 +1348,7 @@
state.cacheBorderAndBackground();
}
- Style::PropertyCascade cascade(*this, matchResult, Style::allCascadeLevels(), direction, writingMode, includedProperties);
+ Style::PropertyCascade cascade(*this, matchResult, Style::allCascadeLevels(), includedProperties);
cascade.applyProperties(CSSPropertyWebkitRubyPosition, CSSPropertyWebkitRubyPosition);
adjustStyleForInterCharacterRuby();
@@ -1454,7 +1403,7 @@
if (!value)
return;
MatchResult matchResult;
- Style::PropertyCascade cascade(*this, matchResult, { }, { }, { });
+ Style::PropertyCascade cascade(*this, matchResult, { });
if (value)
cascade.applyProperty(id, *value);
}
Modified: trunk/Source/WebCore/style/PropertyCascade.cpp (251643 => 251644)
--- trunk/Source/WebCore/style/PropertyCascade.cpp 2019-10-27 20:24:29 UTC (rev 251643)
+++ trunk/Source/WebCore/style/PropertyCascade.cpp 2019-10-27 22:12:20 UTC (rev 251644)
@@ -27,6 +27,7 @@
#include "PropertyCascade.h"
#include "CSSPaintImageValue.h"
+#include "CSSPrimitiveValueMappings.h"
#include "CSSValuePool.h"
#include "PaintWorkletGlobalScope.h"
#include "StyleBuilder.h"
@@ -172,13 +173,32 @@
}
#endif
-PropertyCascade::PropertyCascade(StyleResolver& styleResolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, TextDirection direction, WritingMode writingMode, IncludedProperties includedProperties)
+PropertyCascade::PropertyCascade(StyleResolver& styleResolver, const MatchResult& matchResult, OptionSet<CascadeLevel> cascadeLevels, IncludedProperties includedProperties)
: m_styleResolver(styleResolver)
, m_matchResult(matchResult)
, m_includedProperties(includedProperties)
- , m_direction(direction)
- , m_writingMode(writingMode)
{
+ // Directional properties (*-before/after) are aliases that depend on the TextDirection and WritingMode.
+ // These must be resolved before we can begin building the property cascade.
+ resolveDirectionAndWritingMode();
+
+ buildCascade(cascadeLevels);
+}
+
+PropertyCascade::PropertyCascade(const PropertyCascade& parent, OptionSet<CascadeLevel> cascadeLevels)
+ : m_styleResolver(parent.m_styleResolver)
+ , m_matchResult(parent.m_matchResult)
+ , m_includedProperties(parent.m_includedProperties)
+ , m_direction(parent.m_direction)
+ , m_writingMode(parent.m_writingMode)
+{
+ buildCascade(cascadeLevels);
+}
+
+PropertyCascade::~PropertyCascade() = default;
+
+void PropertyCascade::buildCascade(OptionSet<CascadeLevel> cascadeLevels)
+{
OptionSet<CascadeLevel> cascadeLevelsWithImportant;
for (auto cascadeLevel : cascadeLevels) {
@@ -194,8 +214,6 @@
}
}
-PropertyCascade::~PropertyCascade() = default;
-
void PropertyCascade::setPropertyInternal(Property& property, CSSPropertyID id, CSSValue& cssValue, unsigned linkMatchType, CascadeLevel cascadeLevel, ScopeOrdinal styleScopeOrdinal)
{
ASSERT(linkMatchType <= SelectorChecker::MatchAll);
@@ -490,7 +508,7 @@
case CascadeLevel::Author:
if (!m_authorRollbackCascade) {
auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent, CascadeLevel::User };
- m_authorRollbackCascade = makeUnique<const PropertyCascade>(m_styleResolver, m_matchResult, cascadeLevels, m_direction, m_writingMode, m_includedProperties);
+ m_authorRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels);
}
return m_authorRollbackCascade.get();
@@ -497,7 +515,7 @@
case CascadeLevel::User:
if (!m_userRollbackCascade) {
auto cascadeLevels = OptionSet<CascadeLevel> { CascadeLevel::UserAgent };
- m_userRollbackCascade = makeUnique<const PropertyCascade>(m_styleResolver, m_matchResult, cascadeLevels, m_direction, m_writingMode, m_includedProperties);
+ m_userRollbackCascade = makeUnique<const PropertyCascade>(*this, cascadeLevels);
}
return m_userRollbackCascade.get();
@@ -650,5 +668,42 @@
return parser.parseValueWithVariableReferences(propID, value, *this);
}
+void PropertyCascade::resolveDirectionAndWritingMode()
+{
+ auto& style = *m_styleResolver.style();
+
+ m_direction = style.direction();
+ m_writingMode = style.writingMode();
+
+ bool hadImportantWritingMode = false;
+ bool hadImportantDirection = false;
+
+ for (auto cascadeLevel : { CascadeLevel::UserAgent, CascadeLevel::User, CascadeLevel::Author }) {
+ for (const auto& matchedProperties : declarationsForCascadeLevel(m_matchResult, cascadeLevel)) {
+ for (unsigned i = 0, count = matchedProperties.properties->propertyCount(); i < count; ++i) {
+ auto property = matchedProperties.properties->propertyAt(i);
+ if (!property.value()->isPrimitiveValue())
+ continue;
+ switch (property.id()) {
+ case CSSPropertyWritingMode:
+ if (!hadImportantWritingMode || property.isImportant()) {
+ m_writingMode = downcast<CSSPrimitiveValue>(*property.value());
+ hadImportantWritingMode = property.isImportant();
+ }
+ break;
+ case CSSPropertyDirection:
+ if (!hadImportantDirection || property.isImportant()) {
+ m_direction = downcast<CSSPrimitiveValue>(*property.value());
+ hadImportantDirection = property.isImportant();
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ }
}
+
}
+}
Modified: trunk/Source/WebCore/style/PropertyCascade.h (251643 => 251644)
--- trunk/Source/WebCore/style/PropertyCascade.h 2019-10-27 20:24:29 UTC (rev 251643)
+++ trunk/Source/WebCore/style/PropertyCascade.h 2019-10-27 22:12:20 UTC (rev 251644)
@@ -47,7 +47,9 @@
WTF_MAKE_FAST_ALLOCATED;
public:
enum IncludedProperties { All, InheritedOnly };
- PropertyCascade(StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, TextDirection, WritingMode, IncludedProperties = IncludedProperties::All);
+ PropertyCascade(StyleResolver&, const MatchResult&, OptionSet<CascadeLevel>, IncludedProperties = IncludedProperties::All);
+ PropertyCascade(const PropertyCascade&, OptionSet<CascadeLevel>);
+
~PropertyCascade();
StyleResolver& styleResolver() { return m_styleResolver; }
@@ -74,6 +76,7 @@
void applyProperty(CSSPropertyID, CSSValue&, SelectorChecker::LinkMatchMask = SelectorChecker::MatchDefault);
private:
+ void buildCascade(OptionSet<CascadeLevel>);
bool addNormalMatches(CascadeLevel);
void addImportantMatches(CascadeLevel);
bool addMatch(const MatchedProperties&, CascadeLevel, bool important);
@@ -92,12 +95,15 @@
Ref<CSSValue> resolveValue(CSSPropertyID, CSSValue&);
RefPtr<CSSValue> resolvedVariableValue(CSSPropertyID, const CSSValue&);
+ void resolveDirectionAndWritingMode();
+
StyleResolver& m_styleResolver;
const MatchResult& m_matchResult;
const IncludedProperties m_includedProperties;
- const TextDirection m_direction;
- const WritingMode m_writingMode;
+
+ TextDirection m_direction;
+ WritingMode m_writingMode;
Property m_properties[numCSSProperties + 2];
std::bitset<numCSSProperties + 2> m_propertyIsPresent;