chromium/third_party/blink/renderer/core/page/drag_controller.cc

/*
 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
 * Copyright (C) 2008 Google Inc.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#include "third_party/blink/renderer/core/page/drag_controller.h"

#include <memory>

#include "base/memory/scoped_refptr.h"
#include "build/build_config.h"
#include "third_party/blink/public/common/page/drag_operation.h"
#include "third_party/blink/public/mojom/frame/user_activation_notification_type.mojom-blink.h"
#include "third_party/blink/public/platform/web_common.h"
#include "third_party/blink/public/platform/web_drag_data.h"
#include "third_party/blink/renderer/core/clipboard/data_object.h"
#include "third_party/blink/renderer/core/clipboard/data_transfer.h"
#include "third_party/blink/renderer/core/clipboard/data_transfer_access_policy.h"
#include "third_party/blink/renderer/core/dom/document.h"
#include "third_party/blink/renderer/core/dom/document_fragment.h"
#include "third_party/blink/renderer/core/dom/element.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/shadow_root.h"
#include "third_party/blink/renderer/core/dom/text.h"
#include "third_party/blink/renderer/core/editing/commands/drag_and_drop_command.h"
#include "third_party/blink/renderer/core/editing/drag_caret.h"
#include "third_party/blink/renderer/core/editing/editing_utilities.h"
#include "third_party/blink/renderer/core/editing/editor.h"
#include "third_party/blink/renderer/core/editing/ephemeral_range.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/serializers/serialization.h"
#include "third_party/blink/renderer/core/events/text_event.h"
#include "third_party/blink/renderer/core/frame/local_dom_window.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/visual_viewport.h"
#include "third_party/blink/renderer/core/html/forms/html_form_element.h"
#include "third_party/blink/renderer/core/html/forms/html_input_element.h"
#include "third_party/blink/renderer/core/html/html_anchor_element.h"
#include "third_party/blink/renderer/core/html/html_plugin_element.h"
#include "third_party/blink/renderer/core/html/plugin_document.h"
#include "third_party/blink/renderer/core/input/event_handler.h"
#include "third_party/blink/renderer/core/input_type_names.h"
#include "third_party/blink/renderer/core/layout/hit_test_request.h"
#include "third_party/blink/renderer/core/layout/hit_test_result.h"
#include "third_party/blink/renderer/core/layout/layout_image.h"
#include "third_party/blink/renderer/core/layout/layout_theme.h"
#include "third_party/blink/renderer/core/layout/layout_view.h"
#include "third_party/blink/renderer/core/loader/frame_load_request.h"
#include "third_party/blink/renderer/core/loader/frame_loader.h"
#include "third_party/blink/renderer/core/loader/resource/image_resource_content.h"
#include "third_party/blink/renderer/core/page/chrome_client.h"
#include "third_party/blink/renderer/core/page/drag_data.h"
#include "third_party/blink/renderer/core/page/drag_image.h"
#include "third_party/blink/renderer/core/page/drag_state.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/platform/bindings/exception_state.h"
#include "third_party/blink/renderer/platform/graphics/image.h"
#include "third_party/blink/renderer/platform/graphics/image_orientation.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_record_builder.h"
#include "third_party/blink/renderer/platform/heap/garbage_collected.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_fetcher.h"
#include "third_party/blink/renderer/platform/loader/fetch/resource_request.h"
#include "third_party/blink/renderer/platform/weborigin/security_origin.h"
#include "third_party/blink/renderer/platform/wtf/shared_buffer.h"
#include "ui/base/dragdrop/mojom/drag_drop_types.mojom-blink.h"
#include "ui/display/screen_info.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/vector2d_conversions.h"

#if BUILDFLAG(IS_WIN)
#include <windows.h>
#endif

namespace blink {

FormControlType;
DragOperation;

static const int kMaxOriginalImageArea =;
static const int kLinkDragBorderInset =;
#if BUILDFLAG(IS_ANDROID)
// Android handles drag image transparency at the browser level
static const float kDragImageAlpha = 1.00f;
#else
static const float kDragImageAlpha =;
#endif

#if DCHECK_IS_ON()
static bool DragTypeIsValid(DragSourceAction action) {}
#endif  // DCHECK_IS_ON()

static WebMouseEvent CreateMouseEvent(DragData* drag_data) {}

static DataTransfer* CreateDraggingDataTransfer(DataTransferAccessPolicy policy,
                                                DragData* drag_data) {}

DragController::DragController(Page* page)
    :{}

static DocumentFragment* DocumentFragmentFromDragData(
    DragData* drag_data,
    LocalFrame* frame,
    Range* context,
    bool allow_plain_text,
    DragSourceType& drag_source_type,
    bool is_richly_editable_position) {}

bool DragController::DragIsMove(FrameSelection& selection,
                                DragData* drag_data) {}

void DragController::ClearDragCaret() {}

void DragController::DragEnded() {}

void DragController::DragExited(DragData* drag_data, LocalFrame& local_root) {}

void DragController::PerformDrag(DragData* drag_data, LocalFrame& local_root) {}

void DragController::MouseMovedIntoDocument(Document* new_document) {}

DragController::Operation DragController::DragEnteredOrUpdated(
    DragData* drag_data,
    LocalFrame& local_root) {}

static HTMLInputElement* AsFileInput(Node* node) {}

// This can return null if an empty document is loaded.
static Element* ElementUnderMouse(Document* document_under_mouse,
                                  const PhysicalOffset& point) {}

bool DragController::TryDocumentDrag(DragData* drag_data,
                                     DragDestinationAction action_mask,
                                     DragOperation& drag_operation,
                                     LocalFrame& local_root) {}

DragOperation DragController::OperationForLoad(DragData* drag_data,
                                               LocalFrame& local_root) {}

// Returns true if node at |point| is editable with populating |dragCaret| and
// |range|, otherwise returns false.
static bool SetSelectionToDragCaret(LocalFrame* frame,
                                    const SelectionInDOMTree& drag_caret,
                                    Range*& range,
                                    const PhysicalOffset& point) {}

DispatchEventResult DragController::DispatchTextInputEventFor(
    LocalFrame* inner_frame,
    DragData* drag_data) {}

bool DragController::ConcludeEditDrag(DragData* drag_data) {}

bool DragController::CanProcessDrag(DragData* drag_data,
                                    LocalFrame& local_root) {}

static DragOperation DefaultOperationForDrag(DragOperationsMask src_op_mask) {}

bool DragController::TryDHTMLDrag(DragData* drag_data,
                                  DragOperation& operation,
                                  LocalFrame& local_root) {}

bool SelectTextInsteadOfDrag(const Node& node) {}

Node* DragController::DraggableNode(const LocalFrame* src,
                                    Node* start_node,
                                    const gfx::Point& drag_origin,
                                    SelectionDragPolicy selection_drag_policy,
                                    DragSourceAction& drag_type) const {}

static void PrepareDataTransferForImageDrag(LocalFrame* source,
                                            DataTransfer* data_transfer,
                                            Element* node,
                                            const KURL& link_url,
                                            const KURL& image_url,
                                            const String& label) {}

bool DragController::PopulateDragDataTransfer(LocalFrame* src,
                                              const DragState& state,
                                              const gfx::Point& drag_origin) {}

namespace {

gfx::Point DragLocationForDHTMLDrag(const gfx::Point& mouse_dragged_point,
                                    const gfx::Point& drag_initiation_location,
                                    const gfx::Point& drag_image_offset,
                                    bool is_link_image) {}

gfx::Rect DragRectForSelectionDrag(const LocalFrame& frame) {}

const gfx::Size MaxDragImageSize(float device_scale_factor) {}

bool CanDragImage(const Element& element) {}

std::unique_ptr<DragImage> DragImageForImage(
    const Element& element,
    float device_scale_factor,
    const gfx::Size& image_element_size_in_pixels) {}

gfx::Rect DragRectForImage(const DragImage* drag_image,
                           const gfx::Point& drag_initiation_location,
                           const gfx::Point& image_element_location,
                           const gfx::Size& image_element_size_in_pixels) {}

std::unique_ptr<DragImage> DragImageForLink(const KURL& link_url,
                                            const String& link_text,
                                            float device_scale_factor) {}

gfx::Rect DragRectForLink(const DragImage* link_image,
                          const gfx::Point& origin,
                          float device_scale_factor,
                          float page_scale_factor) {}

}  // namespace

// static
gfx::RectF DragController::ClippedSelection(const LocalFrame& frame) {}

// static
std::unique_ptr<DragImage> DragController::DragImageForSelection(
    LocalFrame& frame,
    float opacity) {}

namespace {

void SelectEnclosingAnchorIfContentEditable(LocalFrame* frame) {}

std::unique_ptr<DragImage> DetermineDragImageAndRect(
    gfx::Rect& drag_obj_rect,
    gfx::Point& effective_drag_initiation_location,
    LocalFrame* frame,
    const DragState& state,
    const HitTestResult& hit_test_result,
    const gfx::Point& drag_initiation_location,
    const gfx::Point& mouse_dragged_point) {}

}  // namespace

bool DragController::StartDrag(LocalFrame* frame,
                               const DragState& state,
                               const WebMouseEvent& drag_event,
                               const gfx::Point& drag_initiation_location) {}

void DragController::DoSystemDrag(DragImage* image,
                                  const gfx::Rect& drag_obj_rect,
                                  const gfx::Point& drag_initiation_location,
                                  DataTransfer* data_transfer,
                                  LocalFrame* frame) {}

DragOperation DragController::GetDragOperation(DragData* drag_data) {}

bool DragController::IsCopyKeyDown(DragData* drag_data) {}

DragState& DragController::GetDragState() {}

void DragController::ContextDestroyed() {}

void DragController::Trace(Visitor* visitor) const {}

}  // namespace blink