#include "content/browser/renderer_host/render_widget_host_view_child_frame.h"
#include <algorithm>
#include <utility>
#include <vector>
#include "base/debug/dump_without_crashing.h"
#include "base/functional/bind.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/task/single_thread_task_runner.h"
#include "build/build_config.h"
#include "components/input/cursor_manager.h"
#include "components/input/render_widget_host_input_event_router.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_result.h"
#include "components/viz/common/surfaces/parent_local_surface_id_allocator.h"
#include "components/viz/host/host_frame_sink_manager.h"
#include "content/browser/compositor/surface_utils.h"
#include "content/browser/gpu/compositor_util.h"
#include "content/browser/renderer_host/cross_process_frame_connector.h"
#include "content/browser/renderer_host/input/touch_selection_controller_client_child_frame.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_delegate.h"
#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/renderer_host/render_widget_host_view_event_handler.h"
#include "content/browser/renderer_host/text_input_manager.h"
#include "content/common/features.h"
#include "content/common/input/synthetic_gesture_target.h"
#include "content/public/browser/render_process_host.h"
#include "third_party/blink/public/common/frame/frame_visual_properties.h"
#include "third_party/blink/public/common/input/web_touch_event.h"
#include "third_party/blink/public/mojom/frame/intrinsic_sizing_info.mojom.h"
#include "third_party/blink/public/mojom/frame/viewport_intersection_state.mojom.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/ime/mojom/text_input_state.mojom.h"
#include "ui/display/display_util.h"
#include "ui/gfx/geometry/dip_util.h"
#include "ui/gfx/geometry/size_conversions.h"
#include "ui/gfx/geometry/size_f.h"
#include "ui/touch_selection/touch_selection_controller.h"
namespace content {
RenderWidgetHostViewChildFrame* RenderWidgetHostViewChildFrame::Create(
RenderWidgetHost* widget,
const display::ScreenInfos& parent_screen_infos) { … }
RenderWidgetHostViewChildFrame::RenderWidgetHostViewChildFrame(
RenderWidgetHost* widget_host,
const display::ScreenInfos& parent_screen_infos)
: … { … }
RenderWidgetHostViewChildFrame::~RenderWidgetHostViewChildFrame() { … }
void RenderWidgetHostViewChildFrame::Init() { … }
void RenderWidgetHostViewChildFrame::
DetachFromTouchSelectionClientManagerIfNecessary() { … }
void RenderWidgetHostViewChildFrame::SetFrameConnector(
CrossProcessFrameConnector* frame_connector) { … }
void RenderWidgetHostViewChildFrame::UpdateIntrinsicSizingInfo(
blink::mojom::IntrinsicSizingInfoPtr sizing_info) { … }
std::unique_ptr<SyntheticGestureTarget>
RenderWidgetHostViewChildFrame::CreateSyntheticGestureTarget() { … }
void RenderWidgetHostViewChildFrame::OnManagerWillDestroy(
TouchSelectionControllerClientManager* manager) { … }
void RenderWidgetHostViewChildFrame::InitAsChild(gfx::NativeView parent_view) { … }
void RenderWidgetHostViewChildFrame::SetSize(const gfx::Size& size) { … }
void RenderWidgetHostViewChildFrame::SetBounds(const gfx::Rect& rect) { … }
void RenderWidgetHostViewChildFrame::Focus() { … }
bool RenderWidgetHostViewChildFrame::HasFocus() { … }
bool RenderWidgetHostViewChildFrame::IsSurfaceAvailableForCopy() { … }
void RenderWidgetHostViewChildFrame::EnsureSurfaceSynchronizedForWebTest() { … }
uint32_t RenderWidgetHostViewChildFrame::GetCaptureSequenceNumber() const { … }
void RenderWidgetHostViewChildFrame::ShowWithVisibility(
PageVisibilityState ) { … }
void RenderWidgetHostViewChildFrame::Hide() { … }
bool RenderWidgetHostViewChildFrame::IsShowing() { … }
void RenderWidgetHostViewChildFrame::WasOccluded() { … }
void RenderWidgetHostViewChildFrame::WasUnOccluded() { … }
gfx::Rect RenderWidgetHostViewChildFrame::GetViewBounds() { … }
gfx::Size RenderWidgetHostViewChildFrame::GetVisibleViewportSize() { … }
void RenderWidgetHostViewChildFrame::SetInsets(const gfx::Insets& insets) { … }
gfx::NativeView RenderWidgetHostViewChildFrame::GetNativeView() { … }
gfx::NativeViewAccessible
RenderWidgetHostViewChildFrame::GetNativeViewAccessible() { … }
void RenderWidgetHostViewChildFrame::UpdateFrameSinkIdRegistration() { … }
void RenderWidgetHostViewChildFrame::UpdateBackgroundColor() { … }
std::optional<DisplayFeature>
RenderWidgetHostViewChildFrame::GetDisplayFeature() { … }
void RenderWidgetHostViewChildFrame::SetDisplayFeatureForTesting(
const DisplayFeature*) { … }
void RenderWidgetHostViewChildFrame::NotifyHostAndDelegateOnWasShown(
blink::mojom::RecordContentToVisibleTimeRequestPtr) { … }
void RenderWidgetHostViewChildFrame::
RequestSuccessfulPresentationTimeFromHostOrDelegate(
blink::mojom::RecordContentToVisibleTimeRequestPtr) { … }
void RenderWidgetHostViewChildFrame::
CancelSuccessfulPresentationTimeRequestForHostAndDelegate() { … }
gfx::Size RenderWidgetHostViewChildFrame::GetCompositorViewportPixelSize() { … }
RenderWidgetHostViewBase* RenderWidgetHostViewChildFrame::GetRootView() { … }
void RenderWidgetHostViewChildFrame::InitAsPopup(
RenderWidgetHostView* parent_host_view,
const gfx::Rect& bounds,
const gfx::Rect& anchor_rect) { … }
void RenderWidgetHostViewChildFrame::UpdateCursor(const ui::Cursor& cursor) { … }
void RenderWidgetHostViewChildFrame::UpdateScreenInfo() { … }
void RenderWidgetHostViewChildFrame::SendInitialPropertiesIfNeeded() { … }
void RenderWidgetHostViewChildFrame::SetIsLoading(bool is_loading) { … }
void RenderWidgetHostViewChildFrame::RenderProcessGone() { … }
void RenderWidgetHostViewChildFrame::Destroy() { … }
void RenderWidgetHostViewChildFrame::UpdateTooltipUnderCursor(
const std::u16string& tooltip_text) { … }
void RenderWidgetHostViewChildFrame::UpdateTooltipFromKeyboard(
const std::u16string& tooltip_text,
const gfx::Rect& bounds) { … }
void RenderWidgetHostViewChildFrame::ClearKeyboardTriggeredTooltip() { … }
RenderWidgetHostViewBase* RenderWidgetHostViewChildFrame::GetParentViewInput() { … }
void RenderWidgetHostViewChildFrame::RegisterFrameSinkId() { … }
void RenderWidgetHostViewChildFrame::UnregisterFrameSinkId() { … }
void RenderWidgetHostViewChildFrame::UpdateViewportIntersection(
const blink::mojom::ViewportIntersectionState& intersection_state,
const std::optional<blink::VisualProperties>& visual_properties) { … }
void RenderWidgetHostViewChildFrame::SetIsInert() { … }
void RenderWidgetHostViewChildFrame::UpdateInheritedEffectiveTouchAction() { … }
void RenderWidgetHostViewChildFrame::UpdateRenderThrottlingStatus() { … }
void RenderWidgetHostViewChildFrame::StopFlingingIfNecessary(
const blink::WebGestureEvent& event,
blink::mojom::InputEventResultState ack_result) { … }
void RenderWidgetHostViewChildFrame::GestureEventAck(
const blink::WebGestureEvent& event,
blink::mojom::InputEventResultSource ack_source,
blink::mojom::InputEventResultState ack_result) { … }
void RenderWidgetHostViewChildFrame::ProcessTouchpadZoomEventAckInRoot(
const blink::WebGestureEvent& event,
blink::mojom::InputEventResultSource ack_source,
blink::mojom::InputEventResultState ack_result) { … }
void RenderWidgetHostViewChildFrame::ForwardTouchpadZoomEventIfNecessary(
const blink::WebGestureEvent& event,
blink::mojom::InputEventResultState ack_result) { … }
void RenderWidgetHostViewChildFrame::SetParentFrameSinkId(
const viz::FrameSinkId& parent_frame_sink_id) { … }
void RenderWidgetHostViewChildFrame::FirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) { … }
void RenderWidgetHostViewChildFrame::TransformPointToRootSurface(
gfx::PointF* point) { … }
gfx::Rect RenderWidgetHostViewChildFrame::GetBoundsInRootWindow() { … }
void RenderWidgetHostViewChildFrame::DidStopFlinging() { … }
blink::mojom::PointerLockResult RenderWidgetHostViewChildFrame::LockPointer(
bool request_unadjusted_movement) { … }
blink::mojom::PointerLockResult
RenderWidgetHostViewChildFrame::ChangePointerLock(
bool request_unadjusted_movement) { … }
void RenderWidgetHostViewChildFrame::UnlockPointer() { … }
bool RenderWidgetHostViewChildFrame::IsPointerLocked() { … }
const viz::FrameSinkId& RenderWidgetHostViewChildFrame::GetFrameSinkId() const { … }
const viz::LocalSurfaceId& RenderWidgetHostViewChildFrame::GetLocalSurfaceId()
const { … }
void RenderWidgetHostViewChildFrame::NotifyHitTestRegionUpdated(
const viz::AggregatedHitTestRegion& region) { … }
bool RenderWidgetHostViewChildFrame::ScreenRectIsUnstableFor(
const blink::WebInputEvent& event) { … }
bool RenderWidgetHostViewChildFrame::ScreenRectIsUnstableForIOv2For(
const blink::WebInputEvent& event) { … }
void RenderWidgetHostViewChildFrame::PreProcessTouchEvent(
const blink::WebTouchEvent& event) { … }
viz::FrameSinkId RenderWidgetHostViewChildFrame::GetRootFrameSinkId() { … }
viz::SurfaceId RenderWidgetHostViewChildFrame::GetCurrentSurfaceId() const { … }
bool RenderWidgetHostViewChildFrame::HasSize() const { … }
double RenderWidgetHostViewChildFrame::GetCSSZoomFactor() const { … }
gfx::PointF RenderWidgetHostViewChildFrame::TransformPointToRootCoordSpaceF(
const gfx::PointF& point) { … }
bool RenderWidgetHostViewChildFrame::TransformPointToCoordSpaceForView(
const gfx::PointF& point,
input::RenderWidgetHostViewInput* target_view,
gfx::PointF* transformed_point) { … }
gfx::PointF RenderWidgetHostViewChildFrame::TransformRootPointToViewCoordSpace(
const gfx::PointF& point) { … }
bool RenderWidgetHostViewChildFrame::IsRenderWidgetHostViewChildFrame() { … }
void RenderWidgetHostViewChildFrame::
InvalidateLocalSurfaceIdAndAllocationGroup() { … }
#if BUILDFLAG(IS_MAC)
void RenderWidgetHostViewChildFrame::SetActive(bool active) {}
void RenderWidgetHostViewChildFrame::ShowDefinitionForSelection() {
if (frame_connector_) {
frame_connector_->GetRootRenderWidgetHostView()
->ShowDefinitionForSelection();
}
}
void RenderWidgetHostViewChildFrame::SpeakSelection() {}
void RenderWidgetHostViewChildFrame::SetWindowFrameInScreen(
const gfx::Rect& rect) {}
void RenderWidgetHostViewChildFrame::ShowSharePicker(
const std::string& title,
const std::string& text,
const std::string& url,
const std::vector<std::string>& file_paths,
blink::mojom::ShareService::ShareCallback callback) {}
uint64_t RenderWidgetHostViewChildFrame::GetNSViewId() const {
return 0;
}
#endif
void RenderWidgetHostViewChildFrame::CopyFromSurface(
const gfx::Rect& src_subrect,
const gfx::Size& output_size,
base::OnceCallback<void(const SkBitmap&)> callback) { … }
void RenderWidgetHostViewChildFrame::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) { … }
void RenderWidgetHostViewChildFrame::OnFrameTokenChanged(
uint32_t frame_token,
base::TimeTicks activation_time) { … }
TouchSelectionControllerClientManager*
RenderWidgetHostViewChildFrame::GetTouchSelectionControllerClientManager() { … }
void RenderWidgetHostViewChildFrame::
OnRenderFrameMetadataChangedAfterActivation(
base::TimeTicks activation_time) { … }
void RenderWidgetHostViewChildFrame::TakeFallbackContentFrom(
RenderWidgetHostView* view) { … }
blink::mojom::InputEventResultState
RenderWidgetHostViewChildFrame::FilterInputEvent(
const blink::WebInputEvent& input_event) { … }
void RenderWidgetHostViewChildFrame::EnableAutoResize(
const gfx::Size& min_size,
const gfx::Size& max_size) { … }
void RenderWidgetHostViewChildFrame::DisableAutoResize(
const gfx::Size& new_size) { … }
viz::ScopedSurfaceIdAllocator
RenderWidgetHostViewChildFrame::DidUpdateVisualProperties(
const cc::RenderFrameMetadata& metadata) { … }
ui::TextInputType RenderWidgetHostViewChildFrame::GetTextInputType() const { … }
bool RenderWidgetHostViewChildFrame::GetTextRange(gfx::Range* range) const { … }
RenderWidgetHostViewBase*
RenderWidgetHostViewChildFrame::GetRootRenderWidgetHostView() const { … }
bool RenderWidgetHostViewChildFrame::CanBecomeVisible() { … }
void RenderWidgetHostViewChildFrame::OnDidUpdateVisualPropertiesComplete(
const cc::RenderFrameMetadata& metadata) { … }
void RenderWidgetHostViewChildFrame::DidNavigate() { … }
ui::Compositor* RenderWidgetHostViewChildFrame::GetCompositor() { … }
void RenderWidgetHostViewChildFrame::HandleSwipeToMoveCursorGestureAck(
const blink::WebGestureEvent& event) { … }
}