diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/core/page/drag_controller.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/core/page/drag_controller.cc | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/chromium/third_party/blink/renderer/core/page/drag_controller.cc b/chromium/third_party/blink/renderer/core/page/drag_controller.cc index 72a7420ce18..8d49321e25e 100644 --- a/chromium/third_party/blink/renderer/core/page/drag_controller.cc +++ b/chromium/third_party/blink/renderer/core/page/drag_controller.cc @@ -33,7 +33,6 @@ #include "third_party/blink/public/platform/web_common.h" #include "third_party/blink/public/platform/web_drag_data.h" #include "third_party/blink/public/platform/web_drag_operation.h" -#include "third_party/blink/public/platform/web_point.h" #include "third_party/blink/public/platform/web_screen_info.h" #include "third_party/blink/renderer/core/clipboard/data_object.h" #include "third_party/blink/renderer/core/clipboard/data_transfer.h" @@ -63,6 +62,7 @@ #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" @@ -139,7 +139,8 @@ static DataTransfer* CreateDraggingDataTransfer(DataTransferAccessPolicy policy, } DragController::DragController(Page* page) - : ContextLifecycleObserver(nullptr), + : ExecutionContextLifecycleObserver( + static_cast<ExecutionContext*>(nullptr)), page_(page), document_under_mouse_(nullptr), drag_initiator_(nullptr), @@ -259,9 +260,10 @@ void DragController::PerformDrag(DragData* drag_data, LocalFrame& local_root) { PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition()))); const HitTestResult result = event_handler.HitTestResultAtLocation(location); + auto* html_plugin_element = + DynamicTo<HTMLPlugInElement>(result.InnerNode()); prevented_default |= - IsHTMLPlugInElement(*result.InnerNode()) && - ToHTMLPlugInElement(result.InnerNode())->CanProcessDrag(); + html_plugin_element && html_plugin_element->CanProcessDrag(); } // Invalidate clipboard here for security. @@ -298,8 +300,8 @@ void DragController::PerformDrag(DragData* drag_data, LocalFrame& local_root) { // the drag as the initiator of the navigation below. resource_request.SetRequestorOrigin(SecurityOrigin::CreateUniqueOpaque()); - page_->MainFrame()->Navigate(FrameLoadRequest(nullptr, resource_request), - WebFrameLoadType::kStandard); + FrameLoadRequest request(nullptr, resource_request); + page_->MainFrame()->Navigate(request, WebFrameLoadType::kStandard); } // TODO(bokan): This case happens when we end a URL drag inside a guest @@ -466,8 +468,8 @@ DragOperation DragController::OperationForLoad(DragData* drag_data, Document* doc = local_root.DocumentAtPoint( PhysicalOffset::FromFloatPointRound(drag_data->ClientPosition())); - if (doc && - (did_initiate_drag_ || doc->IsPluginDocument() || HasEditableStyle(*doc))) + if (doc && (did_initiate_drag_ || IsA<PluginDocument>(doc) || + HasEditableStyle(*doc))) return kDragOperationNone; return GetDragOperation(drag_data); } @@ -483,7 +485,7 @@ static bool SetSelectionToDragCaret(LocalFrame* frame, // TODO(editing-dev): The use of // UpdateStyleAndLayout // needs to be audited. See http://crbug.com/590369 for more details. - frame->GetDocument()->UpdateStyleAndLayout(); + frame->GetDocument()->UpdateStyleAndLayout(DocumentUpdateReason::kEditing); if (!frame->Selection().ComputeVisibleSelectionInDOMTree().IsNone()) { return frame->Selection() .ComputeVisibleSelectionInDOMTree() @@ -499,7 +501,7 @@ static bool SetSelectionToDragCaret(LocalFrame* frame, // TODO(editing-dev): The use of // UpdateStyleAndLayout // needs to be audited. See http://crbug.com/590369 for more details. - frame->GetDocument()->UpdateStyleAndLayout(); + frame->GetDocument()->UpdateStyleAndLayout(DocumentUpdateReason::kEditing); const VisibleSelection& visible_selection = frame->Selection().ComputeVisibleSelectionInDOMTree(); range = CreateRange(visible_selection.ToNormalizedEphemeralRange()); @@ -576,7 +578,7 @@ bool DragController::ConcludeEditDrag(DragData* drag_data) { .CaretPosition() .GetPosition() .GetDocument() - ->UpdateStyleAndLayout(); + ->UpdateStyleAndLayout(DocumentUpdateReason::kEditing); } const PositionWithAffinity& caret_position = @@ -718,8 +720,7 @@ bool DragController::CanProcessDrag(DragData* drag_data, if (drag_data->ContainsFiles() && AsFileInput(result.InnerNode())) return true; - if (IsHTMLPlugInElement(*result.InnerNode())) { - HTMLPlugInElement* plugin = ToHTMLPlugInElement(result.InnerNode()); + if (auto* plugin = DynamicTo<HTMLPlugInElement>(result.InnerNode())) { if (!plugin->CanProcessDrag() && !HasEditableStyle(*result.InnerNode())) return false; } else if (!HasEditableStyle(*result.InnerNode())) { @@ -995,7 +996,7 @@ bool DragController::PopulateDragDataTransfer(LocalFrame* src, // Observe context related to source to allow dropping drag_state_ when the // Document goes away. - SetContext(src->GetDocument()); + SetExecutionContext(src->GetDocument()->ToExecutionContext()); return true; } @@ -1059,10 +1060,10 @@ static std::unique_ptr<DragImage> DragImageForImage( // Substitute an appropriately-sized SVGImageForContainer, to ensure dragged // SVG images scale seamlessly. scoped_refptr<SVGImageForContainer> svg_image; - if (image->IsSVGImage()) { + if (auto* svg_img = DynamicTo<SVGImage>(image)) { KURL url = element->GetDocument().CompleteURL(element->ImageSourceURL()); svg_image = SVGImageForContainer::Create( - ToSVGImage(image), FloatSize(image_element_size_in_pixels), 1, url); + svg_img, FloatSize(image_element_size_in_pixels), 1, url); image = svg_image.get(); } @@ -1072,25 +1073,17 @@ static std::unique_ptr<DragImage> DragImageForImage( interpolation_quality = kInterpolationNone; } - RespectImageOrientationEnum should_respect_image_orientation = + RespectImageOrientationEnum respect_image_orientation = LayoutObject::ShouldRespectImageOrientation(element->GetLayoutObject()); - ImageOrientation orientation; - - if (should_respect_image_orientation == kRespectImageOrientation && - image->IsBitmapImage()) - orientation = ToBitmapImage(image)->CurrentFrameOrientation(); - - IntSize image_size = orientation.UsesWidthAsHeight() - ? image->Size().TransposedSize() - : image->Size(); + IntSize image_size = image->Size(respect_image_orientation); FloatSize image_scale = DragImage::ClampedImageScale(image_size, image_element_size_in_pixels, MaxDragImageSize(device_scale_factor)); if (image_size.Area() <= kMaxOriginalImageArea && (drag_image = DragImage::Create( - image, should_respect_image_orientation, device_scale_factor, + image, respect_image_orientation, device_scale_factor, interpolation_quality, kDragImageAlpha, image_scale))) { IntSize original_size = image_element_size_in_pixels; origin = image_element_location; @@ -1149,12 +1142,13 @@ std::unique_ptr<DragImage> DragController::DragImageForSelection( if (!frame.Selection().ComputeVisibleSelectionInDOMTreeDeprecated().IsRange()) return nullptr; - frame.View()->UpdateAllLifecyclePhasesExceptPaint(); + frame.View()->UpdateAllLifecyclePhasesExceptPaint( + DocumentUpdateReason::kDragImage); DCHECK(frame.GetDocument()->IsActive()); FloatRect painting_rect = ClippedSelection(frame); GlobalPaintFlags paint_flags = - kGlobalPaintSelectionOnly | kGlobalPaintFlattenCompositingLayers; + kGlobalPaintSelectionDragImageOnly | kGlobalPaintFlattenCompositingLayers; PaintRecordBuilder builder; frame.View()->PaintContentsOutsideOfLifecycle( @@ -1164,7 +1158,7 @@ std::unique_ptr<DragImage> DragController::DragImageForSelection( PropertyTreeState property_tree_state = frame.View()->GetLayoutView()->FirstFragment().LocalBorderBoxProperties(); return DataTransfer::CreateDragImageForFrame( - frame, opacity, kDoNotRespectImageOrientation, painting_rect.Size(), + frame, opacity, kRespectImageOrientation, painting_rect.Size(), painting_rect.Location(), builder, property_tree_state); } @@ -1307,7 +1301,7 @@ void DragController::DoSystemDrag(DragImage* image, bool for_link) { did_initiate_drag_ = true; drag_initiator_ = frame->GetDocument(); - SetContext(drag_initiator_); + SetExecutionContext(drag_initiator_->ToExecutionContext()); // TODO(pdr): |drag_location| and |event_pos| should be passed in as // FloatPoints and we should calculate these adjusted values in floating @@ -1364,17 +1358,17 @@ DragState& DragController::GetDragState() { return *drag_state_; } -void DragController::ContextDestroyed(ExecutionContext*) { +void DragController::ContextDestroyed() { drag_state_ = nullptr; } -void DragController::Trace(blink::Visitor* visitor) { +void DragController::Trace(Visitor* visitor) { visitor->Trace(page_); visitor->Trace(document_under_mouse_); visitor->Trace(drag_initiator_); visitor->Trace(drag_state_); visitor->Trace(file_input_element_under_mouse_); - ContextLifecycleObserver::Trace(visitor); + ExecutionContextLifecycleObserver::Trace(visitor); } } // namespace blink |