#include "third_party/blink/renderer/core/css/resolver/style_resolver.h"
#include "base/containers/adapters.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom-blink.h"
#include "third_party/blink/public/web/web_print_page_description.h"
#include "third_party/blink/public/web/web_print_params.h"
#include "third_party/blink/renderer/core/animation/css/compositor_keyframe_value_factory.h"
#include "third_party/blink/renderer/core/animation/css/css_animations.h"
#include "third_party/blink/renderer/core/animation/document_animations.h"
#include "third_party/blink/renderer/core/animation/element_animations.h"
#include "third_party/blink/renderer/core/animation/invalidatable_interpolation.h"
#include "third_party/blink/renderer/core/css/anchor_evaluator.h"
#include "third_party/blink/renderer/core/css/cascade_layer_map.h"
#include "third_party/blink/renderer/core/css/container_query_evaluator.h"
#include "third_party/blink/renderer/core/css/css_custom_ident_value.h"
#include "third_party/blink/renderer/core/css/css_default_style_sheets.h"
#include "third_party/blink/renderer/core/css/css_font_selector.h"
#include "third_party/blink/renderer/core/css/css_identifier_value.h"
#include "third_party/blink/renderer/core/css/css_inherited_value.h"
#include "third_party/blink/renderer/core/css/css_initial_color_value.h"
#include "third_party/blink/renderer/core/css/css_keyframe_rule.h"
#include "third_party/blink/renderer/core/css/css_keyframes_rule.h"
#include "third_party/blink/renderer/core/css/css_position_try_rule.h"
#include "third_party/blink/renderer/core/css/css_property_names.h"
#include "third_party/blink/renderer/core/css/css_rule_list.h"
#include "third_party/blink/renderer/core/css/css_selector.h"
#include "third_party/blink/renderer/core/css/css_selector_watch.h"
#include "third_party/blink/renderer/core/css/css_style_declaration.h"
#include "third_party/blink/renderer/core/css/css_style_rule.h"
#include "third_party/blink/renderer/core/css/css_value_list.h"
#include "third_party/blink/renderer/core/css/element_rule_collector.h"
#include "third_party/blink/renderer/core/css/font_face.h"
#include "third_party/blink/renderer/core/css/out_of_flow_data.h"
#include "third_party/blink/renderer/core/css/page_margins_style.h"
#include "third_party/blink/renderer/core/css/page_rule_collector.h"
#include "third_party/blink/renderer/core/css/part_names.h"
#include "third_party/blink/renderer/core/css/post_style_update_scope.h"
#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/properties/css_property.h"
#include "third_party/blink/renderer/core/css/properties/css_property_ref.h"
#include "third_party/blink/renderer/core/css/properties/longhands.h"
#include "third_party/blink/renderer/core/css/resolver/cascade_filter.h"
#include "third_party/blink/renderer/core/css/resolver/match_result.h"
#include "third_party/blink/renderer/core/css/resolver/scoped_style_resolver.h"
#include "third_party/blink/renderer/core/css/resolver/selector_filter_parent_scope.h"
#include "third_party/blink/renderer/core/css/resolver/style_adjuster.h"
#include "third_party/blink/renderer/core/css/resolver/style_builder_converter.h"
#include "third_party/blink/renderer/core/css/resolver/style_cascade.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_state.h"
#include "third_party/blink/renderer/core/css/resolver/style_resolver_stats.h"
#include "third_party/blink/renderer/core/css/resolver/style_rule_usage_tracker.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css/style_rule_import.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/dom/element.h"
#include "third_party/blink/renderer/core/dom/first_letter_pseudo_element.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/shadow_root.h"
#include "third_party/blink/renderer/core/dom/space_split_string.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/local_frame_view.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/frame/web_feature.h"
#include "third_party/blink/renderer/core/fullscreen/fullscreen.h"
#include "third_party/blink/renderer/core/html/html_body_element.h"
#include "third_party/blink/renderer/core/html/html_html_element.h"
#include "third_party/blink/renderer/core/html/html_iframe_element.h"
#include "third_party/blink/renderer/core/html/html_image_element.h"
#include "third_party/blink/renderer/core/html/html_slot_element.h"
#include "third_party/blink/renderer/core/html/shadow/shadow_element_names.h"
#include "third_party/blink/renderer/core/html/track/text_track.h"
#include "third_party/blink/renderer/core/html/track/text_track_cue.h"
#include "third_party/blink/renderer/core/html/track/vtt/vtt_cue.h"
#include "third_party/blink/renderer/core/html/track/vtt/vtt_element.h"
#include "third_party/blink/renderer/core/html_names.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/mathml/mathml_fraction_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_operator_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_padded_element.h"
#include "third_party/blink/renderer/core/mathml/mathml_space_element.h"
#include "third_party/blink/renderer/core/mathml_names.h"
#include "third_party/blink/renderer/core/media_type_names.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/scrolling/snap_coordinator.h"
#include "third_party/blink/renderer/core/probe/core_probes.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/style/style_initial_data.h"
#include "third_party/blink/renderer/core/style_property_shorthand.h"
#include "third_party/blink/renderer/core/svg/svg_element.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/instrumentation/use_counter.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/wtf/hash_set.h"
#include "third_party/blink/renderer/platform/wtf/std_lib_extras.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string_hash.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
namespace {
bool ShouldStoreOldStyle(const StyleRecalcContext& style_recalc_context,
StyleResolverState& state) { … }
bool ShouldSetPendingUpdate(StyleResolverState& state, Element& element) { … }
void SetAnimationUpdateIfNeeded(const StyleRecalcContext& style_recalc_context,
StyleResolverState& state,
Element& element) { … }
ElementAnimations* GetElementAnimations(const StyleResolverState& state) { … }
bool HasAnimationsOrTransitions(const StyleResolverState& state) { … }
bool HasTimelines(const StyleResolverState& state) { … }
bool IsAnimationStyleChange(Element& element) { … }
#if DCHECK_IS_ON()
String ComputeBaseComputedStyleDiff(const ComputedStyle* base_computed_style,
const ComputedStyle& computed_style) { … }
#endif
void MaybeResetCascade(StyleCascade& cascade) { … }
bool TextAutosizingMultiplierChanged(const StyleResolverState& state,
const ComputedStyle& base_computed_style) { … }
PseudoId GetPseudoId(const Element& element, ElementRuleCollector* collector) { … }
void UseCountLegacyOverlapping(Document& document,
const ComputedStyle& a,
const ComputedStyleBuilder& b) { … }
void ApplyLengthConversionFlags(StyleResolverState& state) { … }
}
static CSSPropertyValueSet* LeftToRightDeclaration() { … }
static CSSPropertyValueSet* RightToLeftDeclaration() { … }
static CSSPropertyValueSet* DocumentElementUserAgentDeclarations() { … }
static CSSPropertyValueSet* ForcedColorsUserAgentDeclarations() { … }
static CSSPropertyValueSet* UniversalOverlayUserAgentDeclaration() { … }
static CSSPropertyValueSet* ScrollMarkerGroupUserAgentDeclaration() { … }
static void CollectScopedResolversForHostedShadowTrees(
const Element& element,
HeapVector<Member<ScopedStyleResolver>, 8>& resolvers) { … }
StyleResolver::StyleResolver(Document& document)
: … { … }
StyleResolver::~StyleResolver() = default;
void StyleResolver::Dispose() { … }
void StyleResolver::SetRuleUsageTracker(StyleRuleUsageTracker* tracker) { … }
static inline ScopedStyleResolver* ScopedResolverFor(const Element& element) { … }
static inline ScopedStyleResolver* ParentScopedResolverFor(
const Element& element,
bool* parent_scope_contains_style_attribute) { … }
static void MatchHostRules(const Element& element,
ElementRuleCollector& collector,
StyleRuleUsageTracker* tracker) { … }
static void MatchSlottedRules(const Element&,
ElementRuleCollector&,
StyleRuleUsageTracker* tracker);
static void MatchSlottedRulesForUAHost(const Element& element,
ElementRuleCollector& collector,
StyleRuleUsageTracker* tracker) { … }
static void MatchSlottedRules(const Element& element,
ElementRuleCollector& collector,
StyleRuleUsageTracker* tracker) { … }
const static TextTrack* GetTextTrackFromElement(const Element& element) { … }
static void MatchVTTRules(const Element& element,
ElementRuleCollector& collector,
StyleRuleUsageTracker* tracker) { … }
static void MatchElementScopeRules(const Element& element,
ElementRuleCollector& collector,
StyleRuleUsageTracker* tracker) { … }
void StyleResolver::MatchPseudoPartRulesForUAHost(
const Element& element,
ElementRuleCollector& collector) { … }
void StyleResolver::MatchPseudoPartRules(const Element& part_matching_element,
ElementRuleCollector& collector,
bool for_shadow_pseudo) { … }
void StyleResolver::MatchPositionTryRules(ElementRuleCollector& collector) { … }
void StyleResolver::MatchAuthorRules(const Element& element,
ElementRuleCollector& collector) { … }
void StyleResolver::MatchUserRules(ElementRuleCollector& collector) { … }
namespace {
bool IsInMediaUAShadow(const Element& element) { … }
}
template <typename Functor>
void StyleResolver::ForEachUARulesForElement(const Element& element,
ElementRuleCollector* collector,
Functor& func) const { … }
void StyleResolver::MatchUARules(const Element& element,
ElementRuleCollector& collector) { … }
void StyleResolver::MatchPresentationalHints(StyleResolverState& state,
ElementRuleCollector& collector) { … }
DISABLE_CFI_PERF
void StyleResolver::MatchAllRules(StyleResolverState& state,
ElementRuleCollector& collector,
bool include_smil_properties) { … }
const ComputedStyle* StyleResolver::StyleForViewport() { … }
static StyleBaseData* GetBaseData(const StyleResolverState& state) { … }
static const ComputedStyle* CachedAnimationBaseComputedStyle(
StyleResolverState& state) { … }
static void IncrementResolvedStyleCounters(const StyleRequest& style_request,
Document& document) { … }
const ComputedStyle* StyleResolver::ResolveStyle(
Element* element,
const StyleRecalcContext& style_recalc_context,
const StyleRequest& style_request) { … }
void StyleResolver::InitStyle(Element& element,
const StyleRequest& style_request,
const ComputedStyle& source_for_noninherited,
const ComputedStyle* parent_style,
StyleResolverState& state) { … }
void StyleResolver::ApplyMathMLCustomStyleProperties(
Element* element,
StyleResolverState& state) { … }
bool CanApplyInlineStyleIncrementally(Element* element,
const StyleResolverState& state,
const StyleRequest& style_request) { … }
void StyleResolver::ApplyBaseStyleNoCache(
Element* element,
const StyleRecalcContext& style_recalc_context,
const StyleRequest& style_request,
StyleResolverState& state,
StyleCascade& cascade) { … }
void StyleResolver::ApplyBaseStyle(
Element* element,
const StyleRecalcContext& style_recalc_context,
const StyleRequest& style_request,
StyleResolverState& state,
StyleCascade& cascade) { … }
CompositorKeyframeValue* StyleResolver::CreateCompositorKeyframeValueSnapshot(
Element& element,
const ComputedStyle& base_style,
const ComputedStyle* parent_style,
const PropertyHandle& property,
const CSSValue* value,
double offset) { … }
const ComputedStyle* StyleResolver::StyleForPage(uint32_t page_index,
const AtomicString& page_name,
float page_fitting_scale,
bool ignore_author_style) { … }
void StyleResolver::StyleForPageMargins(const ComputedStyle& page_style,
uint32_t page_index,
const AtomicString& page_name,
PageMarginsStyle* margins_style) { … }
void StyleResolver::LoadPaginationResources() { … }
const ComputedStyle& StyleResolver::InitialStyle() const { … }
ComputedStyleBuilder StyleResolver::CreateComputedStyleBuilder() const { … }
ComputedStyleBuilder StyleResolver::CreateComputedStyleBuilderInheritingFrom(
const ComputedStyle& parent_style) const { … }
float StyleResolver::InitialZoom() const { … }
ComputedStyleBuilder StyleResolver::InitialStyleBuilderForElement() const { … }
const ComputedStyle* StyleResolver::InitialStyleForElement() const { … }
const ComputedStyle* StyleResolver::StyleForText(Text* text_node) { … }
void StyleResolver::AddMatchedRulesToTracker(
const ElementRuleCollector& collector) { … }
StyleRuleList* StyleResolver::StyleRulesForElement(Element* element,
unsigned rules_to_include) { … }
HeapHashMap<CSSPropertyName, Member<const CSSValue>>
StyleResolver::CascadedValuesForElement(Element* element, PseudoId pseudo_id) { … }
Element* StyleResolver::FindContainerForElement(
Element* element,
const ContainerSelector& container_selector,
const TreeScope* selector_tree_scope) { … }
RuleIndexList* StyleResolver::PseudoCSSRulesForElement(
Element* element,
PseudoId pseudo_id,
const AtomicString& view_transition_name,
unsigned rules_to_include) { … }
RuleIndexList* StyleResolver::CssRulesForElement(Element* element,
unsigned rules_to_include) { … }
void StyleResolver::CollectPseudoRulesForElement(
const Element& element,
ElementRuleCollector& collector,
PseudoId pseudo_id,
const AtomicString& view_transition_name,
unsigned rules_to_include) { … }
bool StyleResolver::ApplyAnimatedStyle(StyleResolverState& state,
StyleCascade& cascade) { … }
void StyleResolver::ApplyAnchorData(StyleResolverState& state) { … }
StyleResolver::FindKeyframesRuleResult StyleResolver::FindKeyframesRule(
const Element* element,
const Element* animating_element,
const AtomicString& animation_name) { … }
void StyleResolver::InvalidateMatchedPropertiesCache() { … }
void StyleResolver::SetResizedForViewportUnits() { … }
void StyleResolver::ClearResizedForViewportUnits() { … }
bool StyleResolver::CacheSuccess::EffectiveZoomChanged(
const ComputedStyleBuilder& builder) const { … }
bool StyleResolver::CacheSuccess::FontChanged(
const ComputedStyleBuilder& builder) const { … }
bool StyleResolver::CacheSuccess::InheritedVariablesChanged(
const ComputedStyleBuilder& builder) const { … }
bool StyleResolver::CacheSuccess::LineHeightChanged(
const ComputedStyleBuilder& builder) const { … }
bool StyleResolver::CacheSuccess::IsUsableAfterApplyInheritedOnly(
const ComputedStyleBuilder& builder) const { … }
StyleResolver::CacheSuccess StyleResolver::ApplyMatchedCache(
StyleResolverState& state,
const StyleRequest& style_request,
const MatchResult& match_result) { … }
void StyleResolver::MaybeAddToMatchedPropertiesCache(
StyleResolverState& state,
const CacheSuccess& cache_success) { … }
bool StyleResolver::CanReuseBaseComputedStyle(const StyleResolverState& state) { … }
const CSSValue* StyleResolver::ComputeValue(
Element* element,
const CSSPropertyName& property_name,
const CSSValue& value) { … }
const CSSValue* StyleResolver::ResolveValue(
Element& element,
const ComputedStyle& style,
const CSSPropertyName& property_name,
const CSSValue& value) { … }
FilterOperations StyleResolver::ComputeFilterOperations(
Element* element,
const Font& font,
const CSSValue& filter_value) { … }
const ComputedStyle* StyleResolver::StyleForInterpolations(
Element& element,
ActiveInterpolationsMap& interpolations) { … }
void StyleResolver::ApplyInterpolations(
StyleResolverState& state,
StyleCascade& cascade,
ActiveInterpolationsMap& interpolations) { … }
const ComputedStyle* StyleResolver::BeforeChangeStyleForTransitionUpdate(
Element& element,
const ComputedStyle& base_style,
ActiveInterpolationsMap& transition_interpolations) { … }
void StyleResolver::ApplyPropertiesFromCascade(StyleResolverState& state,
StyleCascade& cascade,
CacheSuccess cache_success) { … }
void StyleResolver::ApplyCallbackSelectors(StyleResolverState& state) { … }
void StyleResolver::ApplyDocumentRulesSelectors(StyleResolverState& state,
ContainerNode* scope) { … }
StyleRuleList* StyleResolver::CollectMatchingRulesFromUnconnectedRuleSet(
StyleResolverState& state,
RuleSet* rule_set,
ContainerNode* scope) { … }
Font StyleResolver::ComputeFont(Element& element,
const ComputedStyle& style,
const CSSPropertyValueSet& property_set) { … }
void StyleResolver::UpdateMediaType() { … }
void StyleResolver::Trace(Visitor* visitor) const { … }
bool StyleResolver::IsForcedColorsModeEnabled() const { … }
ComputedStyleBuilder StyleResolver::CreateAnonymousStyleBuilderWithDisplay(
const ComputedStyle& parent_style,
EDisplay display) { … }
const ComputedStyle* StyleResolver::CreateAnonymousStyleWithDisplay(
const ComputedStyle& parent_style,
EDisplay display) { … }
const ComputedStyle* StyleResolver::CreateInheritedDisplayContentsStyleIfNeeded(
const ComputedStyle& parent_style,
const ComputedStyle& layout_parent_style) { … }
#define PROPAGATE_FROM …
#define PROPAGATE_VALUE …
namespace {
bool PropagateScrollSnapStyleToViewport(
Document& document,
const ComputedStyle* document_element_style,
ComputedStyleBuilder& new_viewport_style_builder) { … }
}
bool StyleResolver::ShouldStopBodyPropagation(const Element& body_or_html) { … }
void StyleResolver::PropagateStyleToViewport() { … }
#undef PROPAGATE_VALUE
#undef PROPAGATE_FROM
static Font ComputeInitialLetterFont(const ComputedStyle& style,
const ComputedStyle& paragraph_style) { … }
const ComputedStyle* StyleResolver::StyleForInitialLetterText(
const ComputedStyle& initial_letter_box_style,
const ComputedStyle& paragraph_style) { … }
StyleRulePositionTry* StyleResolver::ResolvePositionTryRule(
const TreeScope* tree_scope,
AtomicString position_try_name) { … }
}