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

Side by Side Diff: Source/core/editing/MoveSelectionCommand.cpp

Issue 23450030: Introduce Position::inDocument() (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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if (selectionStart.anchorType() == Position::PositionIsOffsetInAnchor && selectionStart.containerNode() == pos.containerNode()) 55 if (selectionStart.anchorType() == Position::PositionIsOffsetInAnchor && selectionStart.containerNode() == pos.containerNode())
56 pos.moveToOffset(pos.offsetInContainerNode() + selectionStart.offset InContainerNode()); 56 pos.moveToOffset(pos.offsetInContainerNode() + selectionStart.offset InContainerNode());
57 } 57 }
58 58
59 deleteSelection(m_smartDelete); 59 deleteSelection(m_smartDelete);
60 60
61 // If the node for the destination has been removed as a result of the delet ion, 61 // If the node for the destination has been removed as a result of the delet ion,
62 // set the destination to the ending point after the deletion. 62 // set the destination to the ending point after the deletion.
63 // Fixes: <rdar://problem/3910425> REGRESSION (Mail): Crash in ReplaceSelect ionCommand; 63 // Fixes: <rdar://problem/3910425> REGRESSION (Mail): Crash in ReplaceSelect ionCommand;
64 // selection is empty, leading to null deref 64 // selection is empty, leading to null deref
65 if (!pos.anchorNode()->inDocument()) 65 if (!pos.inDocument())
66 pos = endingSelection().start(); 66 pos = endingSelection().start();
67 67
68 cleanupAfterDeletion(pos); 68 cleanupAfterDeletion(pos);
69 69
70 setEndingSelection(VisibleSelection(pos, endingSelection().affinity(), endin gSelection().isDirectional())); 70 setEndingSelection(VisibleSelection(pos, endingSelection().affinity(), endin gSelection().isDirectional()));
71 if (!pos.anchorNode()->inDocument()) { 71 if (!pos.inDocument()) {
72 // Document was modified out from under us. 72 // Document was modified out from under us.
73 return; 73 return;
74 } 74 }
75 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::PreventNesting; 75 ReplaceSelectionCommand::CommandOptions options = ReplaceSelectionCommand::S electReplacement | ReplaceSelectionCommand::PreventNesting;
76 if (m_smartInsert) 76 if (m_smartInsert)
77 options |= ReplaceSelectionCommand::SmartReplace; 77 options |= ReplaceSelectionCommand::SmartReplace;
78 applyCommandToComposite(ReplaceSelectionCommand::create(document(), m_fragme nt, options)); 78 applyCommandToComposite(ReplaceSelectionCommand::create(document(), m_fragme nt, options));
79 } 79 }
80 80
81 EditAction MoveSelectionCommand::editingAction() const 81 EditAction MoveSelectionCommand::editingAction() const
82 { 82 {
83 return EditActionDrag; 83 return EditActionDrag;
84 } 84 }
85 85
86 } // namespace WebCore 86 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/editing/InsertTextCommand.cpp ('k') | Source/core/editing/ReplaceSelectionCommand.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698