#include "third_party/blink/renderer/core/view_transition/view_transition_style_tracker.h"
#include <limits>
#include "base/containers/contains.h"
#include "base/not_fatal_until.h"
#include "components/viz/common/view_transition_element_resource_id.h"
#include "third_party/blink/public/resources/grit/blink_resources.h"
#include "third_party/blink/renderer/core/animation/element_animations.h"
#include "third_party/blink/renderer/core/css/css_default_style_sheets.h"
#include "third_party/blink/renderer/core/css/properties/computed_style_utils.h"
#include "third_party/blink/renderer/core/css/style_change_reason.h"
#include "third_party/blink/renderer/core/css/style_engine.h"
#include "third_party/blink/renderer/core/css/style_sheet_contents.h"
#include "third_party/blink/renderer/core/display_lock/display_lock_document_state.h"
#include "third_party/blink/renderer/core/dom/node.h"
#include "third_party/blink/renderer/core/dom/node_computed_style.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/frame/browser_controls.h"
#include "third_party/blink/renderer/core/frame/local_frame.h"
#include "third_party/blink/renderer/core/frame/page_scale_constraints_set.h"
#include "third_party/blink/renderer/core/frame/settings.h"
#include "third_party/blink/renderer/core/inspector/console_message.h"
#include "third_party/blink/renderer/core/layout/layout_text.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/layout/layout_view_transition_root.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/page/page_animator.h"
#include "third_party/blink/renderer/core/paint/clip_path_clipper.h"
#include "third_party/blink/renderer/core/paint/paint_layer.h"
#include "third_party/blink/renderer/core/paint/paint_layer_paint_order_iterator.h"
#include "third_party/blink/renderer/core/resize_observer/resize_observer_entry.h"
#include "third_party/blink/renderer/core/resize_observer/resize_observer_size.h"
#include "third_party/blink/renderer/core/scroll/scrollable_area.h"
#include "third_party/blink/renderer/core/style/computed_style_constants.h"
#include "third_party/blink/renderer/core/style/shape_clip_path_operation.h"
#include "third_party/blink/renderer/core/style/style_view_transition_group.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_content_element.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_pseudo_element_base.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_style_builder.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_supplement.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_transition_element.h"
#include "third_party/blink/renderer/core/view_transition/view_transition_utils.h"
#include "third_party/blink/renderer/platform/data_resource_helper.h"
#include "third_party/blink/renderer/platform/graphics/graphics_types.h"
#include "third_party/blink/renderer/platform/graphics/paint/geometry_mapper.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/widget/frame_widget.h"
#include "third_party/blink/renderer/platform/wtf/text/atomic_string.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
#include "ui/display/screen_info.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/transform.h"
namespace blink {
namespace {
const char* kDuplicateTagBaseError = …;
CSSPropertyID kPropertiesToCapture[] = …;
CSSPropertyID kPropertiesToAnimate[] = …;
template <typename K, typename V>
class FlatMapBuilder { … };
mojom::blink::ViewTransitionPropertyId ToTranstionPropertyId(CSSPropertyID id) { … }
CSSPropertyID FromTransitionPropertyId(
mojom::blink::ViewTransitionPropertyId id) { … }
const String& StaticUAStyles() { … }
const String& AnimationUAStyles() { … }
float ComputeStartForSide(float start,
float end,
int snapshot_root_dimension,
int max_capture_size) { … }
std::optional<gfx::RectF> ComputeCaptureRect(
const int max_capture_size,
const PhysicalRect& ink_overflow_rect_in_border_box_space,
const gfx::Transform& element_to_snapshot_root,
const gfx::Size& snapshot_root_size) { … }
int ComputeMaxCaptureSize(Document& document,
std::optional<int> max_texture_size,
const gfx::Size& snapshot_root_size) { … }
gfx::Transform ComputeViewportTransform(const LayoutObject& object) { … }
gfx::Transform ConvertFromTopLeftToCenter(
const gfx::Transform& transform_from_top_left,
const PhysicalSize& box_size) { … }
float DevicePixelRatioFromDocument(Document& document) { … }
Vector<AtomicString> GetDocumentScopedClassList(Element* element) { … }
}
class ViewTransitionStyleTracker::ImageWrapperPseudoElement
: public ViewTransitionPseudoElementBase { … };
ViewTransitionStyleTracker::ViewTransitionStyleTracker(
Document& document,
const blink::ViewTransitionToken& transition_token)
: … { … }
ViewTransitionStyleTracker::ViewTransitionStyleTracker(
Document& document,
ViewTransitionState transition_state)
: … { … }
ViewTransitionStyleTracker::~ViewTransitionStyleTracker() { … }
void ViewTransitionStyleTracker::AddConsoleError(
String message,
Vector<DOMNodeId> related_nodes) { … }
void ViewTransitionStyleTracker::AddTransitionElement(
Element* element,
const AtomicString& name,
const AtomicString& nearest_containing_group,
const AtomicString& nearest_group_with_contain) { … }
bool ViewTransitionStyleTracker::MatchForOnlyChild(
PseudoId pseudo_id,
const AtomicString& view_transition_name) const { … }
void ViewTransitionStyleTracker::AddTransitionElementsFromCSS() { … }
void ViewTransitionStyleTracker::AddTransitionElementsFromCSSRecursive(
PaintLayer* root,
const TreeScope* tree_scope,
Vector<AtomicString>& containing_group_stack,
const AtomicString& nearest_group_with_contain) { … }
bool ViewTransitionStyleTracker::FlattenAndVerifyElements(
VectorOf<Element>& elements,
VectorOf<AtomicString>& transition_names) { … }
AtomicString ViewTransitionStyleTracker::ComputeContainingGroupName(
const AtomicString& name,
const StyleViewTransitionGroup& group) const { … }
bool ViewTransitionStyleTracker::Capture(bool snap_browser_controls) { … }
void ViewTransitionStyleTracker::CaptureResolved() { … }
VectorOf<Element> ViewTransitionStyleTracker::GetTransitioningElements() const { … }
const Vector<AtomicString>&
ViewTransitionStyleTracker::GetViewTransitionClassList(
const AtomicString& name) const { … }
AtomicString ViewTransitionStyleTracker::GetContainingGroupName(
const AtomicString& name) const { … }
bool ViewTransitionStyleTracker::Start() { … }
void ViewTransitionStyleTracker::StartFinished() { … }
void ViewTransitionStyleTracker::Abort() { … }
void ViewTransitionStyleTracker::DidThrottleLocalSubframeRendering() { … }
void ViewTransitionStyleTracker::EndTransition() { … }
viz::ViewTransitionElementResourceId ViewTransitionStyleTracker::GetSnapshotId(
const Element& element) const { … }
const scoped_refptr<cc::ViewTransitionContentLayer>&
ViewTransitionStyleTracker::GetSubframeSnapshotLayer() const { … }
PseudoElement* ViewTransitionStyleTracker::CreatePseudoElement(
Element* parent,
PseudoId pseudo_id,
const AtomicString& view_transition_name) const { … }
bool ViewTransitionStyleTracker::RunPostPrePaintSteps() { … }
void ViewTransitionStyleTracker::ComputeLiveElementGeometry(
int max_capture_size,
LayoutObject& layout_object,
ContainerProperties& container_properties,
PhysicalRect& visual_overflow_rect_in_layout_space,
std::optional<gfx::RectF>& captured_rect_in_layout_space) const { … }
bool ViewTransitionStyleTracker::HasActiveAnimations() const { … }
PaintPropertyChangeType ViewTransitionStyleTracker::UpdateCaptureClip(
const Element& element,
const ClipPaintPropertyNodeOrAlias* current_clip,
const TransformPaintPropertyNodeOrAlias* current_transform) { … }
const ClipPaintPropertyNode* ViewTransitionStyleTracker::GetCaptureClip(
const Element& element) const { … }
bool ViewTransitionStyleTracker::IsTransitionElement(
const Element& element) const { … }
bool ViewTransitionStyleTracker::NeedsCaptureClipNode(
const Element& node) const { … }
StyleRequest::RulesToInclude ViewTransitionStyleTracker::StyleRulesToInclude()
const { … }
namespace {
gfx::Outsets GetFixedToSnapshotViewportOutsets(Document& document) { … }
}
gfx::Rect ViewTransitionStyleTracker::GetSnapshotRootInFixedViewport() const { … }
gfx::Size ViewTransitionStyleTracker::GetSnapshotRootSize() const { … }
gfx::Vector2d ViewTransitionStyleTracker::GetFixedToSnapshotRootOffset() const { … }
gfx::Vector2d ViewTransitionStyleTracker::GetFrameToSnapshotRootOffset() const { … }
ViewTransitionState ViewTransitionStyleTracker::GetViewTransitionState() const { … }
bool ViewTransitionStyleTracker::SnapshotRootDidChangeSize() const { … }
void ViewTransitionStyleTracker::InvalidateStyle() { … }
CSSStyleSheet& ViewTransitionStyleTracker::UAStyleSheet() { … }
bool ViewTransitionStyleTracker::HasLiveNewContent() const { … }
void ViewTransitionStyleTracker::Trace(Visitor* visitor) const { … }
void ViewTransitionStyleTracker::InvalidateHitTestingCache() { … }
void ViewTransitionStyleTracker::ElementData::Trace(Visitor* visitor) const { … }
gfx::RectF ViewTransitionStyleTracker::ElementData::GetInkOverflowRect(
bool use_cached_data) const { … }
gfx::RectF ViewTransitionStyleTracker::ElementData::GetCapturedSubrect(
bool use_cached_data) const { … }
gfx::RectF ViewTransitionStyleTracker::ElementData::GetBorderBoxRect(
bool use_cached_data,
float device_scale_factor) const { … }
void ViewTransitionStyleTracker::ElementData::CacheStateForOldSnapshot() { … }
PhysicalRect ViewTransitionStyleTracker::ComputeVisualOverflowRect(
LayoutBoxModelObject& box,
const LayoutBoxModelObject* ancestor) const { … }
const char* ViewTransitionStyleTracker::StateToString(State state) { … }
viz::ViewTransitionElementResourceId
ViewTransitionStyleTracker::GenerateResourceId() const { … }
void ViewTransitionStyleTracker::SnapBrowserControlsToFullyShown() { … }
}