Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Side by Side Diff: Source/core/page/DragController.cpp

Issue 170603003: Use nullptr_t for RefPtr, PassRefPtr and RawPtr. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Final rebase Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/page/DOMSelection.cpp ('k') | Source/core/page/DragData.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Google Inc. 3 * Copyright (C) 2008 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 } 122 }
123 123
124 static PassRefPtr<Clipboard> createDraggingClipboard(ClipboardAccessPolicy polic y, DragData* dragData) 124 static PassRefPtr<Clipboard> createDraggingClipboard(ClipboardAccessPolicy polic y, DragData* dragData)
125 { 125 {
126 return Clipboard::create(Clipboard::DragAndDrop, policy, dragData->platformD ata()); 126 return Clipboard::create(Clipboard::DragAndDrop, policy, dragData->platformD ata());
127 } 127 }
128 128
129 DragController::DragController(Page* page, DragClient* client) 129 DragController::DragController(Page* page, DragClient* client)
130 : m_page(page) 130 : m_page(page)
131 , m_client(client) 131 , m_client(client)
132 , m_documentUnderMouse(0) 132 , m_documentUnderMouse(nullptr)
133 , m_dragInitiator(0) 133 , m_dragInitiator(nullptr)
134 , m_fileInputElementUnderMouse(0) 134 , m_fileInputElementUnderMouse(nullptr)
135 , m_documentIsHandlingDrag(false) 135 , m_documentIsHandlingDrag(false)
136 , m_dragDestinationAction(DragDestinationActionNone) 136 , m_dragDestinationAction(DragDestinationActionNone)
137 , m_didInitiateDrag(false) 137 , m_didInitiateDrag(false)
138 { 138 {
139 ASSERT(m_client); 139 ASSERT(m_client);
140 } 140 }
141 141
142 DragController::~DragController() 142 DragController::~DragController()
143 { 143 {
144 } 144 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 fragment->appendChild(anchor); 178 fragment->appendChild(anchor);
179 return fragment.release(); 179 return fragment.release();
180 } 180 }
181 } 181 }
182 } 182 }
183 if (allowPlainText && dragData->containsPlainText()) { 183 if (allowPlainText && dragData->containsPlainText()) {
184 chosePlainText = true; 184 chosePlainText = true;
185 return createFragmentFromText(context.get(), dragData->asPlainText()).ge t(); 185 return createFragmentFromText(context.get(), dragData->asPlainText()).ge t();
186 } 186 }
187 187
188 return 0; 188 return nullptr;
189 } 189 }
190 190
191 bool DragController::dragIsMove(FrameSelection& selection, DragData* dragData) 191 bool DragController::dragIsMove(FrameSelection& selection, DragData* dragData)
192 { 192 {
193 return m_documentUnderMouse == m_dragInitiator && selection.isContentEditabl e() && selection.isRange() && !isCopyKeyDown(dragData); 193 return m_documentUnderMouse == m_dragInitiator && selection.isContentEditabl e() && selection.isRange() && !isCopyKeyDown(dragData);
194 } 194 }
195 195
196 // FIXME: This method is poorly named. We're just clearing the selection from t he document this drag is exiting. 196 // FIXME: This method is poorly named. We're just clearing the selection from t he document this drag is exiting.
197 void DragController::cancelDrag() 197 void DragController::cancelDrag()
198 { 198 {
199 m_page->dragCaretController().clear(); 199 m_page->dragCaretController().clear();
200 } 200 }
201 201
202 void DragController::dragEnded() 202 void DragController::dragEnded()
203 { 203 {
204 m_dragInitiator = 0; 204 m_dragInitiator = nullptr;
205 m_didInitiateDrag = false; 205 m_didInitiateDrag = false;
206 m_page->dragCaretController().clear(); 206 m_page->dragCaretController().clear();
207 } 207 }
208 208
209 DragSession DragController::dragEntered(DragData* dragData) 209 DragSession DragController::dragEntered(DragData* dragData)
210 { 210 {
211 return dragEnteredOrUpdated(dragData); 211 return dragEnteredOrUpdated(dragData);
212 } 212 }
213 213
214 void DragController::dragExited(DragData* dragData) 214 void DragController::dragExited(DragData* dragData)
215 { 215 {
216 ASSERT(dragData); 216 ASSERT(dragData);
217 Frame* mainFrame = m_page->mainFrame(); 217 Frame* mainFrame = m_page->mainFrame();
218 218
219 if (RefPtr<FrameView> v = mainFrame->view()) { 219 if (RefPtr<FrameView> v = mainFrame->view()) {
220 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable ; 220 ClipboardAccessPolicy policy = (!m_documentUnderMouse || m_documentUnder Mouse->securityOrigin()->isLocal()) ? ClipboardReadable : ClipboardTypesReadable ;
221 RefPtr<Clipboard> clipboard = createDraggingClipboard(policy, dragData); 221 RefPtr<Clipboard> clipboard = createDraggingClipboard(policy, dragData);
222 clipboard->setSourceOperation(dragData->draggingSourceOperationMask()); 222 clipboard->setSourceOperation(dragData->draggingSourceOperationMask());
223 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData), clipboard.get()); 223 mainFrame->eventHandler().cancelDragAndDrop(createMouseEvent(dragData), clipboard.get());
224 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he re for security 224 clipboard->setAccessPolicy(ClipboardNumb); // invalidate clipboard he re for security
225 } 225 }
226 mouseMovedIntoDocument(0); 226 mouseMovedIntoDocument(0);
227 if (m_fileInputElementUnderMouse) 227 if (m_fileInputElementUnderMouse)
228 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 228 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
229 m_fileInputElementUnderMouse = 0; 229 m_fileInputElementUnderMouse = nullptr;
230 } 230 }
231 231
232 DragSession DragController::dragUpdated(DragData* dragData) 232 DragSession DragController::dragUpdated(DragData* dragData)
233 { 233 {
234 return dragEnteredOrUpdated(dragData); 234 return dragEnteredOrUpdated(dragData);
235 } 235 }
236 236
237 bool DragController::performDrag(DragData* dragData) 237 bool DragController::performDrag(DragData* dragData)
238 { 238 {
239 ASSERT(dragData); 239 ASSERT(dragData);
240 m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->client Position()); 240 m_documentUnderMouse = m_page->mainFrame()->documentAtPoint(dragData->client Position());
241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa ndlingDrag) { 241 if ((m_dragDestinationAction & DragDestinationActionDHTML) && m_documentIsHa ndlingDrag) {
242 RefPtr<Frame> mainFrame = m_page->mainFrame(); 242 RefPtr<Frame> mainFrame = m_page->mainFrame();
243 bool preventedDefault = false; 243 bool preventedDefault = false;
244 if (mainFrame->view()) { 244 if (mainFrame->view()) {
245 // Sending an event can result in the destruction of the view and pa rt. 245 // Sending an event can result in the destruction of the view and pa rt.
246 RefPtr<Clipboard> clipboard = createDraggingClipboard(ClipboardReada ble, dragData); 246 RefPtr<Clipboard> clipboard = createDraggingClipboard(ClipboardReada ble, dragData);
247 clipboard->setSourceOperation(dragData->draggingSourceOperationMask( )); 247 clipboard->setSourceOperation(dragData->draggingSourceOperationMask( ));
248 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea teMouseEvent(dragData), clipboard.get()); 248 preventedDefault = mainFrame->eventHandler().performDragAndDrop(crea teMouseEvent(dragData), clipboard.get());
249 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard h ere for security 249 clipboard->setAccessPolicy(ClipboardNumb); // Invalidate clipboard h ere for security
250 } 250 }
251 if (preventedDefault) { 251 if (preventedDefault) {
252 m_documentUnderMouse = 0; 252 m_documentUnderMouse = nullptr;
253 return true; 253 return true;
254 } 254 }
255 } 255 }
256 256
257 if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDra g(dragData)) { 257 if ((m_dragDestinationAction & DragDestinationActionEdit) && concludeEditDra g(dragData)) {
258 m_documentUnderMouse = 0; 258 m_documentUnderMouse = nullptr;
259 return true; 259 return true;
260 } 260 }
261 261
262 m_documentUnderMouse = 0; 262 m_documentUnderMouse = nullptr;
263 263
264 if (operationForLoad(dragData) == DragOperationNone) 264 if (operationForLoad(dragData) == DragOperationNone)
265 return false; 265 return false;
266 266
267 if (m_page->settings().navigateOnDragDrop()) 267 if (m_page->settings().navigateOnDragDrop())
268 m_page->mainFrame()->loader().load(FrameLoadRequest(0, ResourceRequest(d ragData->asURL()))); 268 m_page->mainFrame()->loader().load(FrameLoadRequest(0, ResourceRequest(d ragData->asURL())));
269 return true; 269 return true;
270 } 270 }
271 271
272 void DragController::mouseMovedIntoDocument(Document* newDocument) 272 void DragController::mouseMovedIntoDocument(Document* newDocument)
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1; 403 dragSession.numberOfItemsToBeAccepted = numberOfFiles != 1 ? 0 : 1;
404 } 404 }
405 405
406 return true; 406 return true;
407 } 407 }
408 408
409 // We are not over an editable region. Make sure we're clearing any prior dr ag cursor. 409 // We are not over an editable region. Make sure we're clearing any prior dr ag cursor.
410 m_page->dragCaretController().clear(); 410 m_page->dragCaretController().clear();
411 if (m_fileInputElementUnderMouse) 411 if (m_fileInputElementUnderMouse)
412 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 412 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
413 m_fileInputElementUnderMouse = 0; 413 m_fileInputElementUnderMouse = nullptr;
414 return false; 414 return false;
415 } 415 }
416 416
417 DragOperation DragController::operationForLoad(DragData* dragData) 417 DragOperation DragController::operationForLoad(DragData* dragData)
418 { 418 {
419 ASSERT(dragData); 419 ASSERT(dragData);
420 Document* doc = m_page->mainFrame()->documentAtPoint(dragData->clientPositio n()); 420 Document* doc = m_page->mainFrame()->documentAtPoint(dragData->clientPositio n());
421 421
422 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsE ditable())) 422 if (doc && (m_didInitiateDrag || doc->isPluginDocument() || doc->rendererIsE ditable()))
423 return DragOperationNone; 423 return DragOperationNone;
(...skipping 19 matching lines...) Expand all
443 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text), IGNORE_EXCEPTION); 443 return target->dispatchEvent(TextEvent::createForDrop(innerFrame->domWindow( ), text), IGNORE_EXCEPTION);
444 } 444 }
445 445
446 bool DragController::concludeEditDrag(DragData* dragData) 446 bool DragController::concludeEditDrag(DragData* dragData)
447 { 447 {
448 ASSERT(dragData); 448 ASSERT(dragData);
449 449
450 RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse; 450 RefPtr<HTMLInputElement> fileInput = m_fileInputElementUnderMouse;
451 if (m_fileInputElementUnderMouse) { 451 if (m_fileInputElementUnderMouse) {
452 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false); 452 m_fileInputElementUnderMouse->setCanReceiveDroppedFiles(false);
453 m_fileInputElementUnderMouse = 0; 453 m_fileInputElementUnderMouse = nullptr;
454 } 454 }
455 455
456 if (!m_documentUnderMouse) 456 if (!m_documentUnderMouse)
457 return false; 457 return false;
458 458
459 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition()); 459 IntPoint point = m_documentUnderMouse->view()->windowToContents(dragData->cl ientPosition());
460 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point); 460 Element* element = elementUnderMouse(m_documentUnderMouse.get(), point);
461 if (!element) 461 if (!element)
462 return false; 462 return false;
463 RefPtr<Frame> innerFrame = element->ownerDocument()->frame(); 463 RefPtr<Frame> innerFrame = element->ownerDocument()->frame();
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 return false; 958 return false;
959 #endif 959 #endif
960 } 960 }
961 961
962 void DragController::cleanupAfterSystemDrag() 962 void DragController::cleanupAfterSystemDrag()
963 { 963 {
964 } 964 }
965 965
966 } // namespace WebCore 966 } // namespace WebCore
967 967
OLDNEW
« no previous file with comments | « Source/core/page/DOMSelection.cpp ('k') | Source/core/page/DragData.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698