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

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

Issue 23822003: Have EditCommand classes deal with Document references, not pointers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 3 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/editing/WrapContentsInDummySpanCommand.cpp ('k') | no next file » | 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
500 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled(); 500 bool smartDelete = innerFrame->editor().smartInsertDeleteEnabled();
501 bool smartInsert = smartDelete && innerFrame->selection()->granulari ty() == WordGranularity && dragData->canSmartReplace(); 501 bool smartInsert = smartDelete && innerFrame->selection()->granulari ty() == WordGranularity && dragData->canSmartReplace();
502 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base() , smartInsert, smartDelete)); 502 applyCommand(MoveSelectionCommand::create(fragment, dragCaret.base() , smartInsert, smartDelete));
503 } else { 503 } else {
504 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, poin t)) { 504 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, poin t)) {
505 ReplaceSelectionCommand::CommandOptions options = ReplaceSelecti onCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting; 505 ReplaceSelectionCommand::CommandOptions options = ReplaceSelecti onCommand::SelectReplacement | ReplaceSelectionCommand::PreventNesting;
506 if (dragData->canSmartReplace()) 506 if (dragData->canSmartReplace())
507 options |= ReplaceSelectionCommand::SmartReplace; 507 options |= ReplaceSelectionCommand::SmartReplace;
508 if (chosePlainText) 508 if (chosePlainText)
509 options |= ReplaceSelectionCommand::MatchStyle; 509 options |= ReplaceSelectionCommand::MatchStyle;
510 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMous e.get(), fragment, options)); 510 ASSERT(m_documentUnderMouse);
511 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMou se.get(), fragment, options));
511 } 512 }
512 } 513 }
513 } else { 514 } else {
514 String text = dragData->asPlainText(innerFrame.get()); 515 String text = dragData->asPlainText(innerFrame.get());
515 if (text.isEmpty() || !innerFrame->editor().shouldInsertText(text, range .get(), EditorInsertActionDropped)) { 516 if (text.isEmpty() || !innerFrame->editor().shouldInsertText(text, range .get(), EditorInsertActionDropped)) {
516 return false; 517 return false;
517 } 518 }
518 519
519 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) 520 if (setSelectionToDragCaret(innerFrame.get(), dragCaret, range, point)) {
520 applyCommand(ReplaceSelectionCommand::create(m_documentUnderMouse.ge t(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::Select Replacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::Pre ventNesting)); 521 ASSERT(m_documentUnderMouse);
522 applyCommand(ReplaceSelectionCommand::create(*m_documentUnderMouse.g et(), createFragmentFromText(range.get(), text), ReplaceSelectionCommand::Selec tReplacement | ReplaceSelectionCommand::MatchStyle | ReplaceSelectionCommand::Pr eventNesting));
523 }
521 } 524 }
522 525
523 if (rootEditableElement) { 526 if (rootEditableElement) {
524 if (Frame* frame = rootEditableElement->document().frame()) 527 if (Frame* frame = rootEditableElement->document().frame())
525 frame->eventHandler()->updateDragStateAfterEditDragIfNeeded(rootEdit ableElement.get()); 528 frame->eventHandler()->updateDragStateAfterEditDragIfNeeded(rootEdit ableElement.get());
526 } 529 }
527 530
528 return true; 531 return true;
529 } 532 }
530 533
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 return false; 925 return false;
923 #endif 926 #endif
924 } 927 }
925 928
926 void DragController::cleanupAfterSystemDrag() 929 void DragController::cleanupAfterSystemDrag()
927 { 930 {
928 } 931 }
929 932
930 } // namespace WebCore 933 } // namespace WebCore
931 934
OLDNEW
« no previous file with comments | « Source/core/editing/WrapContentsInDummySpanCommand.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698