Diff
Modified: trunk/Source/WTF/ChangeLog (253843 => 253844)
--- trunk/Source/WTF/ChangeLog 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WTF/ChangeLog 2019-12-20 21:51:48 UTC (rev 253844)
@@ -1,3 +1,16 @@
+2019-12-20 Truitt Savell <tsav...@apple.com>
+
+ Unreviewed, rolling out r253820.
+
+ Broke Mac testing
+
+ Reverted changeset:
+
+ "Invalidate only affected elements after media query
+ evaluation changes"
+ https://bugs.webkit.org/show_bug.cgi?id=205392
+ https://trac.webkit.org/changeset/253820
+
2019-12-20 Antti Koivisto <an...@apple.com>
Invalidate only affected elements after media query evaluation changes
Modified: trunk/Source/WTF/wtf/HashTraits.h (253843 => 253844)
--- trunk/Source/WTF/wtf/HashTraits.h 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WTF/wtf/HashTraits.h 2019-12-20 21:51:48 UTC (rev 253844)
@@ -389,14 +389,6 @@
}
};
-template<typename T, size_t inlineCapacity>
-struct HashTraits<Vector<T, inlineCapacity>> : GenericHashTraits<Vector<T, inlineCapacity>> {
- static constexpr bool emptyValueIsZero = !inlineCapacity;
-
- static void constructDeletedValue(Vector<T, inlineCapacity>& slot) { new (NotNull, std::addressof(slot)) Vector<T, inlineCapacity>(WTF::HashTableDeletedValue); }
- static bool isDeletedValue(const Vector<T, inlineCapacity>& value) { return value.isHashTableDeletedValue(); }
-};
-
} // namespace WTF
using WTF::HashTraits;
Modified: trunk/Source/WTF/wtf/VectorHash.h (253843 => 253844)
--- trunk/Source/WTF/wtf/VectorHash.h 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WTF/wtf/VectorHash.h 2019-12-20 21:51:48 UTC (rev 253844)
@@ -28,7 +28,6 @@
#include "HashFunctions.h"
#include "HashTraits.h"
#include "Hasher.h"
-#include "Vector.h"
namespace WTF {
@@ -49,6 +48,14 @@
};
template<typename T, size_t inlineCapacity>
+struct HashTraits<Vector<T, inlineCapacity>> : GenericHashTraits<Vector<T, inlineCapacity>> {
+ static constexpr bool emptyValueIsZero = !inlineCapacity;
+
+ static void constructDeletedValue(Vector<T, inlineCapacity>& slot) { new (NotNull, std::addressof(slot)) Vector<T, inlineCapacity>(WTF::HashTableDeletedValue); }
+ static bool isDeletedValue(const Vector<T, inlineCapacity>& value) { return value.isHashTableDeletedValue(); }
+};
+
+template<typename T, size_t inlineCapacity>
struct DefaultHash<Vector<T, inlineCapacity>> {
using Hash = VectorHash<T, inlineCapacity>;
};
Modified: trunk/Source/WebCore/ChangeLog (253843 => 253844)
--- trunk/Source/WebCore/ChangeLog 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/ChangeLog 2019-12-20 21:51:48 UTC (rev 253844)
@@ -1,3 +1,16 @@
+2019-12-20 Truitt Savell <tsav...@apple.com>
+
+ Unreviewed, rolling out r253820.
+
+ Broke Mac testing
+
+ Reverted changeset:
+
+ "Invalidate only affected elements after media query
+ evaluation changes"
+ https://bugs.webkit.org/show_bug.cgi?id=205392
+ https://trac.webkit.org/changeset/253820
+
2019-12-20 youenn fablet <you...@apple.com>
SWServer can be created without any path to store registrations in non ephemeral sessions
Modified: trunk/Source/WebCore/style/RuleSet.cpp (253843 => 253844)
--- trunk/Source/WebCore/style/RuleSet.cpp 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/RuleSet.cpp 2019-12-20 21:51:48 UTC (rev 253844)
@@ -95,7 +95,7 @@
m_features.collectFeatures(ruleData);
if (mediaQueryCollector)
- mediaQueryCollector->addRuleIfNeeded(ruleData);
+ mediaQueryCollector->addRulePositionIfNeeded(ruleData.position());
unsigned classBucketSize = 0;
const CSSSelector* idSelector = nullptr;
@@ -405,12 +405,9 @@
traverseVector(m_universalRules);
}
-Optional<DynamicMediaQueryEvaluationChanges> RuleSet::evaluteDynamicMediaQueryRules(const MediaQueryEvaluator& evaluator)
+RuleSet::MediaQueryStyleUpdateType RuleSet::evaluteDynamicMediaQueryRules(const MediaQueryEvaluator& evaluator)
{
- Vector<size_t> changedQueryIndexes;
- Vector<const Vector<RuleFeature>*> ruleFeatures;
-
- size_t mediaQueryIndex = 0;
+ bool changes = false;
for (auto& dynamicRules : m_dynamicMediaQueryRules) {
bool result = true;
for (auto& set : dynamicRules.mediaQuerySets) {
@@ -423,34 +420,18 @@
if (result != dynamicRules.result) {
dynamicRules.result = result;
if (dynamicRules.requiresFullReset)
- return { { DynamicMediaQueryEvaluationChanges::Type::ResetStyle } };
+ return MediaQueryStyleUpdateType::Reset;
traverseRuleDatas([&](RuleData& ruleData) {
if (!dynamicRules.affectedRulePositions.contains(ruleData.position()))
return;
ruleData.setEnabled(result);
+ changes = true;
});
-
- changedQueryIndexes.append(mediaQueryIndex);
- ruleFeatures.append(&dynamicRules.ruleFeatures);
}
-
- ++mediaQueryIndex;
}
- if (changedQueryIndexes.isEmpty())
- return { };
-
- auto& ruleSet = m_mediaQueryInvalidationRuleSetCache.ensure(changedQueryIndexes, [&] {
- auto ruleSet = makeUnique<RuleSet>();
- for (auto* featureVector : ruleFeatures) {
- for (auto& feature : *featureVector)
- ruleSet->addRule(*feature.rule, feature.selectorIndex, feature.selectorListIndex);
- }
- return ruleSet;
- }).iterator->value;
-
- return { { DynamicMediaQueryEvaluationChanges::Type::InvalidateStyle, { ruleSet.get() } } };
+ return changes ? MediaQueryStyleUpdateType::Resolve : MediaQueryStyleUpdateType::None;
}
bool RuleSet::hasShadowPseudoElementRules() const
@@ -491,7 +472,7 @@
RuleSet::MediaQueryCollector::~MediaQueryCollector() = default;
-bool RuleSet::MediaQueryCollector::pushAndEvaluate(const MediaQuerySet* set)
+bool RuleSet::MediaQueryCollector::pushAndEvaluate(MediaQuerySet* set)
{
if (!set)
return true;
@@ -514,7 +495,7 @@
return true;
}
-void RuleSet::MediaQueryCollector::pop(const MediaQuerySet* set)
+void RuleSet::MediaQueryCollector::pop(MediaQuerySet* set)
{
if (!set || dynamicContextStack.isEmpty() || set != &dynamicContextStack.last().set.get())
return;
@@ -527,9 +508,6 @@
if (collectDynamic) {
auto& toAdd = dynamicContextStack.last().affectedRulePositions;
rules.affectedRulePositions.add(toAdd.begin(), toAdd.end());
-
- rules.ruleFeatures = WTFMove(dynamicContextStack.last().ruleFeatures);
- rules.ruleFeatures.shrinkToFit();
} else
rules.requiresFullReset = true;
@@ -546,14 +524,11 @@
didMutateResolverWithinDynamicMediaQuery = true;
}
-void RuleSet::MediaQueryCollector::addRuleIfNeeded(const RuleData& ruleData)
+void RuleSet::MediaQueryCollector::addRulePositionIfNeeded(size_t index)
{
if (dynamicContextStack.isEmpty())
return;
-
- auto& context = dynamicContextStack.last();
- context.affectedRulePositions.append(ruleData.position());
- context.ruleFeatures.append({ ruleData.rule(), ruleData.selectorIndex(), ruleData.selectorListIndex() });
+ dynamicContextStack.last().affectedRulePositions.append(index);
}
Modified: trunk/Source/WebCore/style/RuleSet.h (253843 => 253844)
--- trunk/Source/WebCore/style/RuleSet.h 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/RuleSet.h 2019-12-20 21:51:48 UTC (rev 253844)
@@ -28,7 +28,6 @@
#include "StyleRule.h"
#include <wtf/Forward.h>
#include <wtf/HashMap.h>
-#include <wtf/VectorHash.h>
#include <wtf/text/AtomString.h>
#include <wtf/text/AtomStringHash.h>
@@ -41,23 +40,7 @@
namespace Style {
class Resolver;
-class RuleSet;
-struct DynamicMediaQueryEvaluationChanges {
- enum class Type { InvalidateStyle, ResetStyle };
- Type type;
- Vector<const RuleSet*, 1> invalidationRuleSets { };
-
- void append(DynamicMediaQueryEvaluationChanges&& other)
- {
- type = std::max(type, other.type);
- if (type == Type::ResetStyle)
- invalidationRuleSets.clear();
- else
- invalidationRuleSets.appendVector(WTFMove(other.invalidationRuleSets));
- };
-};
-
class RuleSet {
WTF_MAKE_NONCOPYABLE(RuleSet); WTF_MAKE_FAST_ALLOCATED;
public:
@@ -80,9 +63,8 @@
typedef HashMap<AtomString, std::unique_ptr<RuleDataVector>> AtomRuleMap;
struct DynamicMediaQueryRules {
- Vector<Ref<const MediaQuerySet>> mediaQuerySets;
+ Vector<Ref<MediaQuerySet>> mediaQuerySets;
HashSet<size_t, DefaultHash<size_t>::Hash, WTF::UnsignedWithZeroKeyHashTraits<size_t>> affectedRulePositions;
- Vector<RuleFeature> ruleFeatures;
bool requiresFullReset { false };
bool result { true };
};
@@ -94,9 +76,8 @@
const bool collectDynamic { false };
struct DynamicContext {
- Ref<const MediaQuerySet> set;
+ Ref<MediaQuerySet> set;
Vector<size_t> affectedRulePositions { };
- Vector<RuleFeature> ruleFeatures { };
};
Vector<DynamicContext> dynamicContextStack { };
@@ -104,10 +85,10 @@
bool didMutateResolverWithinDynamicMediaQuery { false };
bool hasViewportDependentMediaQueries { false };
- bool pushAndEvaluate(const MediaQuerySet*);
- void pop(const MediaQuerySet*);
+ bool pushAndEvaluate(MediaQuerySet*);
+ void pop(MediaQuerySet*);
void didMutateResolver();
- void addRuleIfNeeded(const RuleData&);
+ void addRulePositionIfNeeded(size_t);
};
void addRulesFromSheet(StyleSheetContents&, const MediaQueryEvaluator&);
@@ -122,7 +103,8 @@
bool hasViewportDependentMediaQueries() const { return m_hasViewportDependentMediaQueries; }
- Optional<DynamicMediaQueryEvaluationChanges> evaluteDynamicMediaQueryRules(const MediaQueryEvaluator&);
+ enum class MediaQueryStyleUpdateType { None, Resolve, Reset };
+ MediaQueryStyleUpdateType evaluteDynamicMediaQueryRules(const MediaQueryEvaluator&);
const RuleFeatureSet& features() const { return m_features; }
@@ -175,7 +157,6 @@
RuleFeatureSet m_features;
bool m_hasViewportDependentMediaQueries { false };
Vector<DynamicMediaQueryRules> m_dynamicMediaQueryRules;
- HashMap<Vector<size_t>, std::unique_ptr<const RuleSet>> m_mediaQueryInvalidationRuleSetCache;
};
inline const RuleSet::RuleDataVector* RuleSet::tagRules(const AtomString& key, bool isHTMLName) const
Modified: trunk/Source/WebCore/style/StyleResolver.cpp (253843 => 253844)
--- trunk/Source/WebCore/style/StyleResolver.cpp 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/StyleResolver.cpp 2019-12-20 21:51:48 UTC (rev 253844)
@@ -607,7 +607,7 @@
return m_ruleSets.hasViewportDependentMediaQueries();
}
-Optional<DynamicMediaQueryEvaluationChanges> Resolver::evaluateDynamicMediaQueries()
+RuleSet::MediaQueryStyleUpdateType Resolver::evaluateDynamicMediaQueries()
{
return m_ruleSets.evaluteDynamicMediaQueryRules(m_mediaQueryEvaluator);
}
Modified: trunk/Source/WebCore/style/StyleResolver.h (253843 => 253844)
--- trunk/Source/WebCore/style/StyleResolver.h 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/StyleResolver.h 2019-12-20 21:51:48 UTC (rev 253844)
@@ -132,7 +132,7 @@
#endif
bool hasViewportDependentMediaQueries() const;
- Optional<DynamicMediaQueryEvaluationChanges> evaluateDynamicMediaQueries();
+ RuleSet::MediaQueryStyleUpdateType evaluateDynamicMediaQueries();
void addKeyframeStyle(Ref<StyleRuleKeyframes>&&);
Modified: trunk/Source/WebCore/style/StyleScope.cpp (253843 => 253844)
--- trunk/Source/WebCore/style/StyleScope.cpp 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/StyleScope.cpp 2019-12-20 21:51:48 UTC (rev 253844)
@@ -651,20 +651,17 @@
if (!resolver)
return;
- auto evaluationChanges = testFunction(*resolver);
- if (!evaluationChanges)
+ auto updateType = testFunction(*resolver);
+
+ switch (updateType) {
+ case RuleSet::MediaQueryStyleUpdateType::None:
return;
-
- switch (evaluationChanges->type) {
- case DynamicMediaQueryEvaluationChanges::Type::InvalidateStyle: {
- Invalidator invalidator(evaluationChanges->invalidationRuleSets);
- if (m_shadowRoot)
- invalidator.invalidateStyle(*m_shadowRoot);
- else
- invalidator.invalidateStyle(m_document);
+ case RuleSet::MediaQueryStyleUpdateType::Resolve:
+ // FIXME: We could have an invalidation ruleset for rules inside dynamic media queries.
+ if (auto* documentElement = m_document.documentElement())
+ documentElement->invalidateStyleForSubtree();
break;
- }
- case DynamicMediaQueryEvaluationChanges::Type::ResetStyle:
+ case RuleSet::MediaQueryStyleUpdateType::Reset:
scheduleUpdate(UpdateType::ContentsOrInterpretation);
break;
}
Modified: trunk/Source/WebCore/style/StyleScopeRuleSets.cpp (253843 => 253844)
--- trunk/Source/WebCore/style/StyleScopeRuleSets.cpp 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/StyleScopeRuleSets.cpp 2019-12-20 21:51:48 UTC (rev 253844)
@@ -141,26 +141,27 @@
return false;
}
-Optional<DynamicMediaQueryEvaluationChanges> ScopeRuleSets::evaluteDynamicMediaQueryRules(const MediaQueryEvaluator& evaluator)
+RuleSet::MediaQueryStyleUpdateType ScopeRuleSets::evaluteDynamicMediaQueryRules(const MediaQueryEvaluator& evaluator)
{
- Optional<DynamicMediaQueryEvaluationChanges> evaluationChanges;
+ auto updateType = RuleSet::MediaQueryStyleUpdateType::None;
- auto evaluate = [&](auto* ruleSet) {
+ auto evaluate = [&](auto& ruleSet) {
if (!ruleSet)
- return;
- if (auto changes = ruleSet->evaluteDynamicMediaQueryRules(evaluator)) {
- if (evaluationChanges)
- evaluationChanges->append(WTFMove(*changes));
- else
- evaluationChanges = changes;
- }
+ return false;
+ auto newUpdateType = ruleSet->evaluteDynamicMediaQueryRules(evaluator);
+ if (newUpdateType > updateType)
+ updateType = newUpdateType;
+ return updateType == RuleSet::MediaQueryStyleUpdateType::Reset;
};
- evaluate(&authorStyle());
- evaluate(userStyle());
- evaluate(userAgentMediaQueryStyle());
+ if (evaluate(m_authorStyle))
+ return updateType;
- return evaluationChanges;
+ if (evaluate(m_userStyle))
+ return updateType;
+
+ evaluate(m_userAgentMediaQueryStyle);
+ return updateType;
}
void ScopeRuleSets::appendAuthorStyleSheets(const Vector<RefPtr<CSSStyleSheet>>& styleSheets, MediaQueryEvaluator* medium, InspectorCSSOMWrappers& inspectorCSSOMWrappers)
Modified: trunk/Source/WebCore/style/StyleScopeRuleSets.h (253843 => 253844)
--- trunk/Source/WebCore/style/StyleScopeRuleSets.h 2019-12-20 21:44:22 UTC (rev 253843)
+++ trunk/Source/WebCore/style/StyleScopeRuleSets.h 2019-12-20 21:51:48 UTC (rev 253844)
@@ -79,9 +79,8 @@
void resetUserAgentMediaQueryStyle();
bool hasViewportDependentMediaQueries() const;
+ RuleSet::MediaQueryStyleUpdateType evaluteDynamicMediaQueryRules(const MediaQueryEvaluator&);
- Optional<DynamicMediaQueryEvaluationChanges> evaluteDynamicMediaQueryRules(const MediaQueryEvaluator&);
-
RuleFeatureSet& mutableFeatures();
bool& isInvalidatingStyleWithRuleSets() { return m_isInvalidatingStyleWithRuleSets; }