| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #include "config.h" | 26 #include "config.h" |
| 27 #include "core/editing/commands/EditCommand.h" | 27 #include "core/editing/commands/EditCommand.h" |
| 28 | 28 |
| 29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
| 30 #include "core/dom/NodeTraversal.h" | 30 #include "core/dom/NodeTraversal.h" |
| 31 #include "core/editing/FrameSelection.h" | 31 #include "core/editing/FrameSelection.h" |
| 32 #include "core/editing/commands/CompositeEditCommand.h" | 32 #include "core/editing/commands/CompositeEditCommand.h" |
| 33 #include "core/frame/LocalFrame.h" | 33 #include "core/frame/LocalFrame.h" |
| 34 #include "core/layout/LayoutText.h" |
| 34 | 35 |
| 35 namespace blink { | 36 namespace blink { |
| 36 | 37 |
| 37 EditCommand::EditCommand(Document& document) | 38 EditCommand::EditCommand(Document& document) |
| 38 : m_document(&document) | 39 : m_document(&document) |
| 39 , m_parent(nullptr) | 40 , m_parent(nullptr) |
| 40 { | 41 { |
| 41 ASSERT(m_document); | 42 ASSERT(m_document); |
| 42 ASSERT(m_document->frame()); | 43 ASSERT(m_document->frame()); |
| 43 setStartingSelection(m_document->frame()->selection().selection()); | 44 setStartingSelection(m_document->frame()->selection().selection()); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 83 } |
| 83 command->m_endingSelection = selection; | 84 command->m_endingSelection = selection; |
| 84 } | 85 } |
| 85 } | 86 } |
| 86 | 87 |
| 87 void EditCommand::setEndingSelection(const VisiblePosition& position) | 88 void EditCommand::setEndingSelection(const VisiblePosition& position) |
| 88 { | 89 { |
| 89 setEndingSelection(VisibleSelection(position)); | 90 setEndingSelection(VisibleSelection(position)); |
| 90 } | 91 } |
| 91 | 92 |
| 93 bool EditCommand::isRenderedCharacter(const Position& position) |
| 94 { |
| 95 if (position.isNull()) |
| 96 return false; |
| 97 ASSERT(position.isOffsetInAnchor()); |
| 98 if (!position.anchorNode()->isTextNode()) |
| 99 return false; |
| 100 |
| 101 LayoutObject* layoutObject = position.anchorNode()->layoutObject(); |
| 102 if (!layoutObject) |
| 103 return false; |
| 104 |
| 105 return toLayoutText(layoutObject)->isRenderedCharacter(position.offsetInCont
ainerNode()); |
| 106 } |
| 107 |
| 92 void EditCommand::setParent(CompositeEditCommand* parent) | 108 void EditCommand::setParent(CompositeEditCommand* parent) |
| 93 { | 109 { |
| 94 ASSERT((parent && !m_parent) || (!parent && m_parent)); | 110 ASSERT((parent && !m_parent) || (!parent && m_parent)); |
| 95 ASSERT(!parent || !isCompositeEditCommand() || !toCompositeEditCommand(this)
->composition()); | 111 ASSERT(!parent || !isCompositeEditCommand() || !toCompositeEditCommand(this)
->composition()); |
| 96 m_parent = parent; | 112 m_parent = parent; |
| 97 if (parent) { | 113 if (parent) { |
| 98 m_startingSelection = parent->m_endingSelection; | 114 m_startingSelection = parent->m_endingSelection; |
| 99 m_endingSelection = parent->m_endingSelection; | 115 m_endingSelection = parent->m_endingSelection; |
| 100 } | 116 } |
| 101 } | 117 } |
| 102 | 118 |
| 103 void SimpleEditCommand::doReapply() | 119 void SimpleEditCommand::doReapply() |
| 104 { | 120 { |
| 105 doApply(); | 121 doApply(); |
| 106 } | 122 } |
| 107 | 123 |
| 108 DEFINE_TRACE(EditCommand) | 124 DEFINE_TRACE(EditCommand) |
| 109 { | 125 { |
| 110 visitor->trace(m_document); | 126 visitor->trace(m_document); |
| 111 visitor->trace(m_startingSelection); | 127 visitor->trace(m_startingSelection); |
| 112 visitor->trace(m_endingSelection); | 128 visitor->trace(m_endingSelection); |
| 113 visitor->trace(m_parent); | 129 visitor->trace(m_parent); |
| 114 } | 130 } |
| 115 | 131 |
| 116 } // namespace blink | 132 } // namespace blink |
| OLD | NEW |