Commit 31f328e3 authored by Anders Hartvoll Ruud's avatar Anders Hartvoll Ruud Committed by Commit Bot

Increment MatchResult::current_tree_order_ by one for each tree scope

This is effectively what we're doing already, since the size of the
author_range_ends_ vector just increased by one (and the size of that
vector never decreases).

Setting the current_tree_order_ when finishing user rules is not
necessary. I don't know why we did this. Possibly it's a remnant of
a previous solution.

Overall, what matters is that current_tree_order_ is monotonically
increasing for each call to FinishAddingAuthorRulesForTreeScope.

This prepares the ua/user/author ranges for removal in a subsequent CL.

Change-Id: I99947e5bfdf727ba772d296ecab65b424625dd91
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2310495
Commit-Queue: Anders Hartvoll Ruud <andruud@chromium.org>
Reviewed-by: default avatarXiaocheng Hu <xiaochengh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#791167}
parent 75a1418f
......@@ -33,6 +33,7 @@
#include <memory>
#include <type_traits>
#include "base/numerics/clamped_math.h"
#include "third_party/blink/renderer/core/css/css_property_value_set.h"
#include "third_party/blink/renderer/core/css/style_rule.h"
#include "third_party/blink/renderer/platform/wtf/math_extras.h"
......@@ -79,11 +80,11 @@ void MatchResult::FinishAddingUserRules() {
user_range_ends_.back() == matched_properties_.size())
return;
user_range_ends_.push_back(matched_properties_.size());
current_tree_order_ = clampTo<uint16_t>(user_range_ends_.size());
}
void MatchResult::FinishAddingAuthorRulesForTreeScope() {
DCHECK_EQ(current_origin_, CascadeOrigin::kAuthor);
current_tree_order_ = base::ClampAdd(current_tree_order_, 1);
// Don't add empty ranges.
if (author_range_ends_.IsEmpty() && user_range_ends_.IsEmpty() &&
ua_range_end_ == matched_properties_.size())
......@@ -95,7 +96,6 @@ void MatchResult::FinishAddingAuthorRulesForTreeScope() {
author_range_ends_.back() == matched_properties_.size())
return;
author_range_ends_.push_back(matched_properties_.size());
current_tree_order_ = clampTo<uint16_t>(author_range_ends_.size());
}
MatchedExpansionsRange MatchResult::Expansions(const Document& document,
......
......@@ -59,10 +59,6 @@ struct CORE_EXPORT MatchedProperties {
// not used at all for the UA origin. Hence, it is not possible to compare
// tree_orders from two different origins.
//
// Note also that the tree_order will start at ~0u and then decrease.
// This is because we currently store the matched properties in reverse
// order.
//
// https://drafts.csswg.org/css-scoping/#shadow-cascading
uint16_t tree_order;
};
......
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