#ifdef UNSAFE_BUFFERS_BUILD
#pragma allow_unsafe_buffers
#endif
#include "ui/aura/window.h"
#include <stddef.h>
#include <sstream>
#include <utility>
#include "base/containers/adapters.h"
#include "base/containers/contains.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/memory/raw_ptr.h"
#include "base/not_fatal_until.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
#include "cc/mojo_embedder/async_layer_tree_frame_sink.h"
#include "cc/trees/layer_tree_frame_sink.h"
#include "components/viz/common/features.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "mojo/public/cpp/bindings/pending_receiver.h"
#include "mojo/public/cpp/bindings/pending_remote.h"
#include "third_party/skia/include/core/SkPath.h"
#include "ui/aura/client/aura_constants.h"
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/cursor_client.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/client/focus_client.h"
#include "ui/aura/client/screen_position_client.h"
#include "ui/aura/client/visibility_client.h"
#include "ui/aura/client/window_stacking_client.h"
#include "ui/aura/env.h"
#include "ui/aura/layout_manager.h"
#include "ui/aura/scoped_keyboard_hook.h"
#include "ui/aura/window_delegate.h"
#include "ui/aura/window_event_dispatcher.h"
#include "ui/aura/window_observer.h"
#include "ui/aura/window_occlusion_tracker.h"
#include "ui/aura/window_targeter.h"
#include "ui/aura/window_tracker.h"
#include "ui/aura/window_tree_host.h"
#include "ui/base/layout.h"
#include "ui/base/metadata/base_type_conversion.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ui_base_features.h"
#include "ui/compositor/compositor.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animator.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
#include "ui/events/event_target_iterator.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/scoped_canvas.h"
DEFINE_ENUM_CONVERTERS(…)
DEFINE_ENUM_CONVERTERS(…)
namespace ui {
namespace metadata {
template <>
struct TypeConverter<viz::SurfaceId> : public BaseTypeConverter<true> { … };
std::u16string TypeConverter<viz::SurfaceId>::ToString(
const viz::SurfaceId& source_value) { … }
std::optional<viz::SurfaceId> TypeConverter<viz::SurfaceId>::FromString(
const std::u16string& source_value) { … }
ValidStrings TypeConverter<viz::SurfaceId>::GetValidStrings() { … }
}
}
namespace {
enum BoundsCallbackIndex : int { … };
}
namespace aura {
namespace {
class ScopedCursorHider { … };
}
Window::Window(WindowDelegate* delegate, client::WindowType type)
: … { … }
Window::~Window() { … }
void Window::Init(ui::LayerType layer_type) { … }
int Window::GetId() const { … }
void Window::SetId(int id) { … }
client::WindowType Window::GetType() const { … }
void Window::SetType(client::WindowType type) { … }
const std::string& Window::GetName() const { … }
void Window::SetName(const std::string& name) { … }
const std::u16string& Window::GetTitle() const { … }
void Window::SetTitle(const std::u16string& title) { … }
bool Window::GetTransparent() const { … }
void Window::SetTransparent(bool transparent) { … }
void Window::SetFillsBoundsCompletely(bool fills_bounds) { … }
Window* Window::GetRootWindow() { … }
const Window* Window::GetRootWindow() const { … }
WindowTreeHost* Window::GetHost() { … }
const WindowTreeHost* Window::GetHost() const { … }
void Window::Show() { … }
void Window::Hide() { … }
bool Window::IsVisible() const { … }
Window::OcclusionState Window::GetOcclusionState() const { … }
ScopedWindowCaptureRequest Window::MakeWindowCapturable() { … }
gfx::Rect Window::GetBoundsInRootWindow() const { … }
gfx::Rect Window::GetActualBoundsInRootWindow() const { … }
const gfx::Transform& Window::transform() const { … }
gfx::Rect Window::GetBoundsInScreen() const { … }
gfx::Rect Window::GetActualBoundsInScreen() const { … }
void Window::SetTransform(const gfx::Transform& transform) { … }
void Window::SetLayoutManager(std::nullptr_t) { … }
std::unique_ptr<WindowTargeter> Window::SetEventTargeter(
std::unique_ptr<WindowTargeter> targeter) { … }
void Window::SetBounds(const gfx::Rect& new_bounds) { … }
void Window::SetBoundsInScreen(const gfx::Rect& new_bounds_in_screen,
const display::Display& dst_display) { … }
gfx::Rect Window::GetTargetBounds() const { … }
void Window::ScheduleDraw() { … }
void Window::SchedulePaintInRect(const gfx::Rect& rect) { … }
void Window::StackChildAtTop(Window* child) { … }
void Window::StackChildAbove(Window* child, Window* target) { … }
void Window::StackChildAtBottom(Window* child) { … }
void Window::StackChildBelow(Window* child, Window* target) { … }
void Window::AddChild(Window* child) { … }
void Window::RemoveChild(Window* child) { … }
bool Window::Contains(const Window* other) const { … }
Window* Window::GetChildById(int id) { … }
const Window* Window::GetChildById(int id) const { … }
void Window::ConvertPointToTarget(const Window* source,
const Window* target,
gfx::PointF* point) { … }
void Window::ConvertPointToTarget(const Window* source,
const Window* target,
gfx::Point* point) { … }
void Window::ConvertRectToTarget(const Window* source,
const Window* target,
gfx::Rect* rect) { … }
void Window::ConvertNativePointToTargetHost(const Window* source,
const Window* target,
gfx::PointF* point) { … }
void Window::ConvertNativePointToTargetHost(const Window* source,
const Window* target,
gfx::Point* point) { … }
void Window::MoveCursorTo(const gfx::Point& point_in_window) { … }
gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const { … }
void Window::AddObserver(WindowObserver* observer) { … }
void Window::RemoveObserver(WindowObserver* observer) { … }
bool Window::HasObserver(const WindowObserver* observer) const { … }
void Window::SetEventTargetingPolicy(EventTargetingPolicy policy) { … }
bool Window::ContainsPointInRoot(const gfx::Point& point_in_root) const { … }
bool Window::ContainsPoint(const gfx::Point& local_point) const { … }
Window* Window::GetEventHandlerForPoint(const gfx::Point& local_point) { … }
Window* Window::GetToplevelWindow() { … }
void Window::Focus() { … }
bool Window::HasFocus() const { … }
bool Window::CanFocus() const { … }
void Window::SetCapture() { … }
void Window::ReleaseCapture() { … }
bool Window::HasCapture() { … }
std::unique_ptr<ScopedKeyboardHook> Window::CaptureSystemKeyEvents(
std::optional<base::flat_set<ui::DomCode>> dom_codes) { … }
void Window::SetNativeWindowProperty(const char* key, void* value) { … }
void* Window::GetNativeWindowProperty(const char* key) const { … }
void Window::OnDeviceScaleFactorChanged(float old_device_scale_factor,
float new_device_scale_factor) { … }
void Window::UpdateVisualState() { … }
void Window::GetDebugInfo(const aura::Window* active_window,
const aura::Window* focused_window,
const aura::Window* capture_window,
std::ostringstream* out) const { … }
#if DCHECK_IS_ON()
std::string Window::GetWindowHierarchy(int depth) const { … }
void Window::PrintWindowHierarchy(int depth) const { … }
#endif
void Window::RemoveOrDestroyChildren() { … }
void Window::AfterPropertyChange(const void* key, int64_t old_value) { … }
void Window::SetEmbedFrameSinkIdImpl(const viz::FrameSinkId& frame_sink_id) { … }
bool Window::HitTest(const gfx::Point& local_point) { … }
void Window::SetBoundsInternal(const gfx::Rect& new_bounds) { … }
void Window::SetVisibleInternal(bool visible) { … }
void Window::SetOcclusionInfo(OcclusionState occlusion_state,
const SkRegion& occluded_region) { … }
void Window::SchedulePaint() { … }
void Window::Paint(const ui::PaintContext& context) { … }
void Window::RemoveChildImpl(Window* child, Window* new_parent) { … }
void Window::OnParentChanged() { … }
void Window::StackChildRelativeTo(Window* child,
Window* target,
StackDirection direction) { … }
void Window::StackChildLayerRelativeTo(Window* child,
Window* target,
StackDirection direction) { … }
void Window::OnStackingChanged() { … }
void Window::NotifyRemovingFromRootWindow(Window* new_root) { … }
void Window::NotifyAddedToRootWindow() { … }
void Window::NotifyWindowHierarchyChange(
const WindowObserver::HierarchyChangeParams& params) { … }
void Window::NotifyWindowHierarchyChangeDown(
const WindowObserver::HierarchyChangeParams& params) { … }
void Window::NotifyWindowHierarchyChangeUp(
const WindowObserver::HierarchyChangeParams& params) { … }
void Window::NotifyWindowHierarchyChangeAtReceiver(
const WindowObserver::HierarchyChangeParams& params) { … }
void Window::NotifyWindowVisibilityChanged(aura::Window* target,
bool visible) { … }
bool Window::NotifyWindowVisibilityChangedAtReceiver(aura::Window* target,
bool visible) { … }
bool Window::NotifyWindowVisibilityChangedDown(aura::Window* target,
bool visible) { … }
void Window::NotifyWindowVisibilityChangedUp(aura::Window* target,
bool visible) { … }
bool Window::CleanupGestureState() { … }
std::unique_ptr<cc::LayerTreeFrameSink> Window::CreateLayerTreeFrameSink() { … }
viz::SurfaceId Window::GetSurfaceId() { … }
viz::SurfaceId Window::GetSurfaceId() const { … }
void Window::AllocateLocalSurfaceId() { … }
viz::ScopedSurfaceIdAllocator Window::GetSurfaceIdAllocator(
base::OnceCallback<void()> allocation_task) { … }
const viz::LocalSurfaceId& Window::GetLocalSurfaceId() { … }
void Window::InvalidateLocalSurfaceId(bool also_invalidate_allocation_group) { … }
void Window::UpdateLocalSurfaceIdFromEmbeddedClient(
const std::optional<viz::LocalSurfaceId>&
embedded_client_local_surface_id) { … }
const viz::FrameSinkId& Window::GetFrameSinkId() const { … }
void Window::SetEmbedFrameSinkId(const viz::FrameSinkId& frame_sink_id) { … }
void Window::TrackOcclusionState() { … }
bool Window::RequiresDoubleTapGestureEvents() const { … }
const std::u16string Window::OcclusionStateToString(OcclusionState state) { … }
std::string_view Window::WindowTypeToString(client::WindowType type) { … }
void Window::SetOpaqueRegionsForOcclusion(
const std::vector<gfx::Rect>& opaque_regions_for_occlusion) { … }
void Window::NotifyResizeLoopStarted() { … }
void Window::NotifyResizeLoopEnded() { … }
void Window::OnPaintLayer(const ui::PaintContext& context) { … }
void Window::OnLayerBoundsChanged(const gfx::Rect& old_bounds,
ui::PropertyChangeReason reason) { … }
void Window::OnLayerOpacityChanged(ui::PropertyChangeReason reason) { … }
void Window::OnLayerAlphaShapeChanged() { … }
void Window::OnLayerFillsBoundsOpaquelyChanged(
ui::PropertyChangeReason reason) { … }
void Window::OnLayerTransformed(const gfx::Transform& old_transform,
ui::PropertyChangeReason reason) { … }
bool Window::CanAcceptEvent(const ui::Event& event) { … }
ui::EventTarget* Window::GetParentTarget() { … }
std::unique_ptr<ui::EventTargetIterator> Window::GetChildIterator() const { … }
ui::EventTargeter* Window::GetEventTargeter() { … }
void Window::ConvertEventToTarget(const ui::EventTarget* target,
ui::LocatedEvent* event) const { … }
gfx::PointF Window::GetScreenLocationF(const ui::LocatedEvent& event) const { … }
std::unique_ptr<ui::Layer> Window::ReleaseLayer() { … }
std::unique_ptr<ui::Layer> Window::RecreateLayer() { … }
void Window::SetLayer(std::unique_ptr<ui::Layer> alayer) { … }
void Window::OnFirstSurfaceActivation(const viz::SurfaceInfo& surface_info) { … }
void Window::OnFrameTokenChanged(uint32_t frame_token,
base::TimeTicks activation_time) { … }
void Window::UpdateLayerName() { … }
void Window::RegisterFrameSinkId() { … }
void Window::UnregisterFrameSinkId() { … }
void Window::UpdateLocalSurfaceId() { … }
const viz::LocalSurfaceId& Window::GetCurrentLocalSurfaceId() const { … }
bool Window::IsEmbeddingExternalContent() const { … }
void Window::OnScopedWindowCaptureRequestAdded() { … }
void Window::OnScopedWindowCaptureRequestRemoved() { … }
int Window::GetHeight() const { … }
int Window::GetWidth() const { … }
int Window::GetX() const { … }
int Window::GetY() const { … }
void Window::SetHeight(int height) { … }
void Window::SetWidth(int width) { … }
void Window::SetX(int x) { … }
void Window::SetY(int y) { … }
void Window::SetLayoutManagerImpl(
std::unique_ptr<LayoutManager> layout_manager) { … }
bool Window::GetCapture() const { … }
bool Window::GetVisible() const { … }
void Window::SetVisible(bool visible) { … }
BEGIN_METADATA_BASE(…)
}