| OLD | NEW |
| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 dragSourceType = DragSourceType::PlainTextSource; | 192 dragSourceType = DragSourceType::PlainTextSource; |
| 193 return createFragmentFromText(EphemeralRange(context), | 193 return createFragmentFromText(EphemeralRange(context), |
| 194 dragData->asPlainText()); | 194 dragData->asPlainText()); |
| 195 } | 195 } |
| 196 | 196 |
| 197 return nullptr; | 197 return nullptr; |
| 198 } | 198 } |
| 199 | 199 |
| 200 bool DragController::dragIsMove(FrameSelection& selection, DragData* dragData) { | 200 bool DragController::dragIsMove(FrameSelection& selection, DragData* dragData) { |
| 201 return m_documentUnderMouse == m_dragInitiator && | 201 return m_documentUnderMouse == m_dragInitiator && |
| 202 selection.isContentEditable() && | 202 selection.computeVisibleSelectionInDOMTreeDeprecated() |
| 203 .isContentEditable() && |
| 203 selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && | 204 selection.computeVisibleSelectionInDOMTreeDeprecated().isRange() && |
| 204 !isCopyKeyDown(dragData); | 205 !isCopyKeyDown(dragData); |
| 205 } | 206 } |
| 206 | 207 |
| 207 // FIXME: This method is poorly named. We're just clearing the selection from | 208 // FIXME: This method is poorly named. We're just clearing the selection from |
| 208 // the document this drag is exiting. | 209 // the document this drag is exiting. |
| 209 void DragController::cancelDrag() { | 210 void DragController::cancelDrag() { |
| 210 m_page->dragCaret().clear(); | 211 m_page->dragCaret().clear(); |
| 211 } | 212 } |
| 212 | 213 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 473 frame->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 473 const PositionWithAffinity& position = frame->positionForPoint(point); | 474 const PositionWithAffinity& position = frame->positionForPoint(point); |
| 474 if (!position.isConnected()) | 475 if (!position.isConnected()) |
| 475 return false; | 476 return false; |
| 476 | 477 |
| 477 frame->selection().setSelection( | 478 frame->selection().setSelection( |
| 478 SelectionInDOMTree::Builder().collapse(position).build()); | 479 SelectionInDOMTree::Builder().collapse(position).build()); |
| 479 dragCaret = frame->selection().computeVisibleSelectionInDOMTreeDeprecated(); | 480 dragCaret = frame->selection().computeVisibleSelectionInDOMTreeDeprecated(); |
| 480 range = createRange(dragCaret.toNormalizedEphemeralRange()); | 481 range = createRange(dragCaret.toNormalizedEphemeralRange()); |
| 481 } | 482 } |
| 482 return !frame->selection().isNone() && frame->selection().isContentEditable(); | 483 return !frame->selection().isNone() && |
| 484 frame->selection() |
| 485 .computeVisibleSelectionInDOMTreeDeprecated() |
| 486 .isContentEditable(); |
| 483 } | 487 } |
| 484 | 488 |
| 485 DispatchEventResult DragController::dispatchTextInputEventFor( | 489 DispatchEventResult DragController::dispatchTextInputEventFor( |
| 486 LocalFrame* innerFrame, | 490 LocalFrame* innerFrame, |
| 487 DragData* dragData) { | 491 DragData* dragData) { |
| 488 // Layout should be clean due to a hit test performed in |elementUnderMouse|. | 492 // Layout should be clean due to a hit test performed in |elementUnderMouse|. |
| 489 DCHECK(!innerFrame->document()->needsLayoutTreeUpdate()); | 493 DCHECK(!innerFrame->document()->needsLayoutTreeUpdate()); |
| 490 DCHECK(m_page->dragCaret().hasCaret()); | 494 DCHECK(m_page->dragCaret().hasCaret()); |
| 491 String text = m_page->dragCaret().isContentRichlyEditable() | 495 String text = m_page->dragCaret().isContentRichlyEditable() |
| 492 ? "" | 496 ? "" |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1139 imageSizeInPixels, dragLocation); | 1143 imageSizeInPixels, dragLocation); |
| 1140 } | 1144 } |
| 1141 doSystemDrag(dragImage.get(), dragLocation, dragOrigin, dataTransfer, src, | 1145 doSystemDrag(dragImage.get(), dragLocation, dragOrigin, dataTransfer, src, |
| 1142 false); | 1146 false); |
| 1143 } else if (state.m_dragType == DragSourceActionLink) { | 1147 } else if (state.m_dragType == DragSourceActionLink) { |
| 1144 if (linkURL.isEmpty()) | 1148 if (linkURL.isEmpty()) |
| 1145 return false; | 1149 return false; |
| 1146 if (src->selection() | 1150 if (src->selection() |
| 1147 .computeVisibleSelectionInDOMTreeDeprecated() | 1151 .computeVisibleSelectionInDOMTreeDeprecated() |
| 1148 .isCaret() && | 1152 .isCaret() && |
| 1149 src->selection().isContentEditable()) { | 1153 src->selection() |
| 1154 .computeVisibleSelectionInDOMTreeDeprecated() |
| 1155 .isContentEditable()) { |
| 1150 // a user can initiate a drag on a link without having any text | 1156 // a user can initiate a drag on a link without having any text |
| 1151 // selected. In this case, we should expand the selection to | 1157 // selected. In this case, we should expand the selection to |
| 1152 // the enclosing anchor element | 1158 // the enclosing anchor element |
| 1153 if (Node* node = enclosingAnchorElement(src->selection().base())) { | 1159 if (Node* node = enclosingAnchorElement(src->selection().base())) { |
| 1154 src->selection().setSelection( | 1160 src->selection().setSelection( |
| 1155 SelectionInDOMTree::Builder().selectAllChildren(*node).build()); | 1161 SelectionInDOMTree::Builder().selectAllChildren(*node).build()); |
| 1156 } | 1162 } |
| 1157 } | 1163 } |
| 1158 | 1164 |
| 1159 if (!dragImage) { | 1165 if (!dragImage) { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 | 1250 |
| 1245 DEFINE_TRACE(DragController) { | 1251 DEFINE_TRACE(DragController) { |
| 1246 visitor->trace(m_page); | 1252 visitor->trace(m_page); |
| 1247 visitor->trace(m_documentUnderMouse); | 1253 visitor->trace(m_documentUnderMouse); |
| 1248 visitor->trace(m_dragInitiator); | 1254 visitor->trace(m_dragInitiator); |
| 1249 visitor->trace(m_dragState); | 1255 visitor->trace(m_dragState); |
| 1250 visitor->trace(m_fileInputElementUnderMouse); | 1256 visitor->trace(m_fileInputElementUnderMouse); |
| 1251 } | 1257 } |
| 1252 | 1258 |
| 1253 } // namespace blink | 1259 } // namespace blink |
| OLD | NEW |