| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007 Apple, Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007 Apple, 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 26 matching lines...) Expand all Loading... |
| 37 EditCommand::EditCommand(Document& document) | 37 EditCommand::EditCommand(Document& document) |
| 38 : m_document(&document) | 38 : m_document(&document) |
| 39 , m_parent(nullptr) | 39 , m_parent(nullptr) |
| 40 { | 40 { |
| 41 ASSERT(m_document); | 41 ASSERT(m_document); |
| 42 ASSERT(m_document->frame()); | 42 ASSERT(m_document->frame()); |
| 43 setStartingSelection(m_document->frame()->selection().selection()); | 43 setStartingSelection(m_document->frame()->selection().selection()); |
| 44 setEndingSelection(m_startingSelection); | 44 setEndingSelection(m_startingSelection); |
| 45 } | 45 } |
| 46 | 46 |
| 47 EditCommand::EditCommand(Document* document, const VisibleSelection& startingSel
ection, const VisibleSelection& endingSelection) | |
| 48 : m_document(document) | |
| 49 , m_parent(nullptr) | |
| 50 { | |
| 51 ASSERT(m_document); | |
| 52 ASSERT(m_document->frame()); | |
| 53 setStartingSelection(startingSelection); | |
| 54 setEndingSelection(endingSelection); | |
| 55 } | |
| 56 | |
| 57 EditCommand::~EditCommand() | 47 EditCommand::~EditCommand() |
| 58 { | 48 { |
| 59 } | 49 } |
| 60 | 50 |
| 61 EditAction EditCommand::editingAction() const | 51 EditAction EditCommand::editingAction() const |
| 62 { | 52 { |
| 63 return EditActionUnspecified; | 53 return EditActionUnspecified; |
| 64 } | 54 } |
| 65 | 55 |
| 66 static inline EditCommandComposition* compositionIfPossible(EditCommand* command
) | 56 static inline EditCommandComposition* compositionIfPossible(EditCommand* command
) |
| 67 { | 57 { |
| 68 if (!command->isCompositeEditCommand()) | 58 if (!command->isCompositeEditCommand()) |
| 69 return 0; | 59 return 0; |
| 70 return toCompositeEditCommand(command)->composition(); | 60 return toCompositeEditCommand(command)->composition(); |
| 71 } | 61 } |
| 72 | 62 |
| 73 void EditCommand::setStartingSelection(const VisibleSelection& selection) | 63 void EditCommand::setStartingSelection(const VisibleSelection& selection) |
| 74 { | 64 { |
| 75 for (EditCommand* command = this; ; command = command->m_parent) { | 65 for (EditCommand* command = this; ; command = command->m_parent) { |
| 76 if (EditCommandComposition* composition = compositionIfPossible(command)
) { | 66 if (EditCommandComposition* composition = compositionIfPossible(command)
) { |
| 77 ASSERT(command->isTopLevelCommand()); | 67 ASSERT(command->isTopLevelCommand()); |
| 78 composition->setStartingSelection(selection); | 68 composition->setStartingSelection(selection); |
| 79 } | 69 } |
| 80 command->m_startingSelection = selection; | 70 command->m_startingSelection = selection; |
| 81 if (!command->m_parent || command->m_parent->isFirstCommand(command)) | 71 if (!command->m_parent || command->m_parent->isFirstCommand(command)) |
| 82 break; | 72 break; |
| 83 } | 73 } |
| 84 } | 74 } |
| 85 | 75 |
| 86 void EditCommand::setStartingSelection(const VisiblePosition& position) | |
| 87 { | |
| 88 setStartingSelection(VisibleSelection(position)); | |
| 89 } | |
| 90 | |
| 91 void EditCommand::setEndingSelection(const VisibleSelection& selection) | 76 void EditCommand::setEndingSelection(const VisibleSelection& selection) |
| 92 { | 77 { |
| 93 for (EditCommand* command = this; command; command = command->m_parent) { | 78 for (EditCommand* command = this; command; command = command->m_parent) { |
| 94 if (EditCommandComposition* composition = compositionIfPossible(command)
) { | 79 if (EditCommandComposition* composition = compositionIfPossible(command)
) { |
| 95 ASSERT(command->isTopLevelCommand()); | 80 ASSERT(command->isTopLevelCommand()); |
| 96 composition->setEndingSelection(selection); | 81 composition->setEndingSelection(selection); |
| 97 } | 82 } |
| 98 command->m_endingSelection = selection; | 83 command->m_endingSelection = selection; |
| 99 } | 84 } |
| 100 } | 85 } |
| (...skipping 21 matching lines...) Expand all Loading... |
| 122 | 107 |
| 123 void EditCommand::trace(Visitor* visitor) | 108 void EditCommand::trace(Visitor* visitor) |
| 124 { | 109 { |
| 125 visitor->trace(m_document); | 110 visitor->trace(m_document); |
| 126 visitor->trace(m_startingSelection); | 111 visitor->trace(m_startingSelection); |
| 127 visitor->trace(m_endingSelection); | 112 visitor->trace(m_endingSelection); |
| 128 visitor->trace(m_parent); | 113 visitor->trace(m_parent); |
| 129 } | 114 } |
| 130 | 115 |
| 131 } // namespace blink | 116 } // namespace blink |
| OLD | NEW |