chromium/ui/views/widget/root_view.cc

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "ui/views/widget/root_view.h"

#include <algorithm>
#include <memory>
#include <string_view>

#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/raw_ptr_exclusion.h"
#include "base/memory/raw_ref.h"
#include "base/scoped_observation.h"
#include "build/build_config.h"
#include "ui/accessibility/ax_enums.mojom.h"
#include "ui/accessibility/ax_node_data.h"
#include "ui/accessibility/platform/ax_platform_node.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-shared.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/base/metadata/metadata_impl_macros.h"
#include "ui/base/ui_base_switches_util.h"
#include "ui/compositor/layer.h"
#include "ui/events/event.h"
#include "ui/events/event_utils.h"
#include "ui/events/gestures/gesture_recognizer.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/canvas.h"
#include "ui/views/accessibility/view_accessibility.h"
#include "ui/views/drag_controller.h"
#include "ui/views/view_class_properties.h"
#include "ui/views/view_targeter.h"
#include "ui/views/views_features.h"
#include "ui/views/widget/root_view_targeter.h"
#include "ui/views/widget/widget.h"
#include "ui/views/widget/widget_delegate.h"

DispatchDetails;

namespace views::internal {

namespace {

class MouseEnterExitEvent : public ui::MouseEvent {};

// TODO(crbug.com/40821061): This class is for debug purpose only.
// Remove it after resolving the issue.
class DanglingMouseMoveHandlerOnViewDestroyingChecker
    : public views::ViewObserver {};

}  // namespace

// Used by RootView to create a hidden child that can be used to make screen
// reader announcements on platforms that don't have a reliable system API call
// to do that.
//
// We use a separate view because the RootView itself supplies the widget's
// accessible name and cannot serve double-duty (the inability for views to make
// their own announcements without changing their accessible name or description
// is the reason this system exists at all).
class AnnounceTextView : public View {};

BEGIN_METADATA()

// This event handler receives events in the pre-target phase and takes care of
// the following:
//   - Shows keyboard-triggered context menus.
class PreEventDispatchHandler : public ui::EventHandler {};

// This event handler receives events in the post-target phase and takes care of
// the following:
//   - Generates context menu, or initiates drag-and-drop, from gesture events.
class PostEventDispatchHandler : public ui::EventHandler {};

////////////////////////////////////////////////////////////////////////////////
// RootView, public:

// Creation and lifetime -------------------------------------------------------

RootView::RootView(Widget* widget)
    :{}

RootView::~RootView() {}

// Tree operations -------------------------------------------------------------

void RootView::SetContentsView(View* contents_view) {}

View* RootView::GetContentsView() {}

void RootView::NotifyNativeViewHierarchyChanged() {}

// Focus -----------------------------------------------------------------------

void RootView::SetFocusTraversableParent(FocusTraversable* focus_traversable) {}

void RootView::SetFocusTraversableParentView(View* view) {}

// System events ---------------------------------------------------------------

void RootView::ThemeChanged() {}

void RootView::ResetEventHandlers() {}

void RootView::DeviceScaleFactorChanged(float old_device_scale_factor,
                                        float new_device_scale_factor) {}

// Accessibility ---------------------------------------------------------------

AnnounceTextView* RootView::GetOrCreateAnnounceView() {}

void RootView::AnnounceTextAs(
    const std::u16string& text,
    ui::AXPlatformNode::AnnouncementType announcement_type) {}

View* RootView::GetAnnounceViewForTesting() {}

////////////////////////////////////////////////////////////////////////////////
// RootView, FocusTraversable implementation:

FocusSearch* RootView::GetFocusSearch() {}

FocusTraversable* RootView::GetFocusTraversableParent() {}

View* RootView::GetFocusTraversableParentView() {}

////////////////////////////////////////////////////////////////////////////////
// RootView, ui::EventProcessor overrides:

ui::EventTarget* RootView::GetRootForEvent(ui::Event* event) {}

ui::EventTargeter* RootView::GetDefaultEventTargeter() {}

void RootView::OnEventProcessingStarted(ui::Event* event) {}

void RootView::OnEventProcessingFinished(ui::Event* event) {}

////////////////////////////////////////////////////////////////////////////////
// RootView, View overrides:

const Widget* RootView::GetWidget() const {}

Widget* RootView::GetWidget() {}

bool RootView::IsDrawn() const {}

bool RootView::OnMousePressed(const ui::MouseEvent& event) {}

bool RootView::OnMouseDragged(const ui::MouseEvent& event) {}

void RootView::OnMouseReleased(const ui::MouseEvent& event) {}

void RootView::OnMouseCaptureLost() {}

void RootView::OnMouseMoved(const ui::MouseEvent& event) {}

void RootView::OnMouseEntered(const ui::MouseEvent& event) {}

void RootView::OnMouseExited(const ui::MouseEvent& event) {}

bool RootView::OnMouseWheel(const ui::MouseWheelEvent& event) {}

void RootView::MaybeNotifyGestureHandlerBeforeReplacement() {}

void RootView::SetMouseAndGestureHandler(View* new_handler) {}

void RootView::SetMouseHandler(View* new_mouse_handler) {}

void RootView::GetAccessibleNodeData(ui::AXNodeData* node_data) {}

void RootView::UpdateParentLayer() {}

////////////////////////////////////////////////////////////////////////////////
// RootView, protected:

void RootView::ViewHierarchyChanged(
    const ViewHierarchyChangedDetails& details) {}

void RootView::VisibilityChanged(View* /*starting_from*/, bool is_visible) {}

void RootView::OnDidSchedulePaint(const gfx::Rect& rect) {}

void RootView::OnPaint(gfx::Canvas* canvas) {}

View::LayerOffsetData RootView::CalculateOffsetToAncestorWithLayer(
    ui::Layer** layer_parent) {}

View::DragInfo* RootView::GetDragInfo() {}

////////////////////////////////////////////////////////////////////////////////
// RootView, private:

void RootView::UpdateCursor(const ui::MouseEvent& event) {}

void RootView::SetMouseLocationAndFlags(const ui::MouseEvent& event) {}

void RootView::HandleMouseEnteredOrMoved(const ui::MouseEvent& event) {}

ui::EventDispatchDetails RootView::NotifyEnterExitOfDescendant(
    const ui::MouseEvent& event,
    ui::EventType type,
    View* view,
    View* sibling) {}

bool RootView::CanDispatchToTarget(ui::EventTarget* target) {}

ui::EventDispatchDetails RootView::PreDispatchEvent(ui::EventTarget* target,
                                                    ui::Event* event) {}

ui::EventDispatchDetails RootView::PostDispatchEvent(ui::EventTarget* target,
                                                     const ui::Event& event) {}

BEGIN_METADATA()
}  // namespace views::internal