| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 EditCommand::~EditCommand() {} | 43 EditCommand::~EditCommand() {} |
| 44 | 44 |
| 45 InputEvent::InputType EditCommand::inputType() const { | 45 InputEvent::InputType EditCommand::inputType() const { |
| 46 return InputEvent::InputType::None; | 46 return InputEvent::InputType::None; |
| 47 } | 47 } |
| 48 | 48 |
| 49 String EditCommand::textDataForInputEvent() const { | 49 String EditCommand::textDataForInputEvent() const { |
| 50 return nullAtom; | 50 return nullAtom; |
| 51 } | 51 } |
| 52 | 52 |
| 53 // TODO(xiaochengh): Move it to CompositeEditCommand.cpp | |
| 54 void CompositeEditCommand::setStartingSelection( | |
| 55 const VisibleSelection& selection) { | |
| 56 for (CompositeEditCommand* command = this;; command = command->parent()) { | |
| 57 if (UndoStep* undoStep = command->undoStep()) { | |
| 58 DCHECK(command->isTopLevelCommand()); | |
| 59 undoStep->setStartingSelection(selection); | |
| 60 } | |
| 61 command->m_startingSelection = selection; | |
| 62 if (!command->parent() || command->parent()->isFirstCommand(command)) | |
| 63 break; | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 // TODO(xiaochengh): Move it to CompositeEditCommand.cpp | |
| 68 // TODO(yosin): We will make |SelectionInDOMTree| version of | |
| 69 // |setEndingSelection()| as primary function instead of wrapper, once | |
| 70 // |EditCommand| holds other than |VisibleSelection|. | |
| 71 void CompositeEditCommand::setEndingSelection( | |
| 72 const SelectionInDOMTree& selection) { | |
| 73 // TODO(editing-dev): The use of | |
| 74 // updateStyleAndLayoutIgnorePendingStylesheets | |
| 75 // needs to be audited. See http://crbug.com/590369 for more details. | |
| 76 document().updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 77 setEndingVisibleSelection(createVisibleSelection(selection)); | |
| 78 } | |
| 79 | |
| 80 // TODO(xiaochengh): Move it to CompositeEditCommand.cpp | |
| 81 // TODO(yosin): We will make |SelectionInDOMTree| version of | |
| 82 // |setEndingSelection()| as primary function instead of wrapper. | |
| 83 void CompositeEditCommand::setEndingVisibleSelection( | |
| 84 const VisibleSelection& selection) { | |
| 85 for (CompositeEditCommand* command = this; command; | |
| 86 command = command->parent()) { | |
| 87 if (UndoStep* undoStep = command->undoStep()) { | |
| 88 DCHECK(command->isTopLevelCommand()); | |
| 89 undoStep->setEndingSelection(selection); | |
| 90 } | |
| 91 command->m_endingSelection = selection; | |
| 92 } | |
| 93 } | |
| 94 | |
| 95 bool EditCommand::isRenderedCharacter(const Position& position) { | 53 bool EditCommand::isRenderedCharacter(const Position& position) { |
| 96 if (position.isNull()) | 54 if (position.isNull()) |
| 97 return false; | 55 return false; |
| 98 DCHECK(position.isOffsetInAnchor()) << position; | 56 DCHECK(position.isOffsetInAnchor()) << position; |
| 99 if (!position.anchorNode()->isTextNode()) | 57 if (!position.anchorNode()->isTextNode()) |
| 100 return false; | 58 return false; |
| 101 | 59 |
| 102 LayoutObject* layoutObject = position.anchorNode()->layoutObject(); | 60 LayoutObject* layoutObject = position.anchorNode()->layoutObject(); |
| 103 if (!layoutObject) | 61 if (!layoutObject) |
| 104 return false; | 62 return false; |
| 105 | 63 |
| 106 return toLayoutText(layoutObject) | 64 return toLayoutText(layoutObject) |
| 107 ->isRenderedCharacter(position.offsetInContainerNode()); | 65 ->isRenderedCharacter(position.offsetInContainerNode()); |
| 108 } | 66 } |
| 109 | 67 |
| 110 void EditCommand::setParent(CompositeEditCommand* parent) { | 68 void EditCommand::setParent(CompositeEditCommand* parent) { |
| 111 DCHECK((parent && !m_parent) || (!parent && m_parent)); | 69 DCHECK((parent && !m_parent) || (!parent && m_parent)); |
| 112 DCHECK(!parent || !isCompositeEditCommand() || | 70 DCHECK(!parent || !isCompositeEditCommand() || |
| 113 !toCompositeEditCommand(this)->undoStep()); | 71 !toCompositeEditCommand(this)->undoStep()); |
| 114 m_parent = parent; | 72 m_parent = parent; |
| 115 } | 73 } |
| 116 | 74 |
| 117 // TODO(xiaochengh): Move it to CompositeEditCommand.cpp | |
| 118 void CompositeEditCommand::setParent(CompositeEditCommand* parent) { | |
| 119 EditCommand::setParent(parent); | |
| 120 if (parent) { | |
| 121 m_startingSelection = parent->m_endingSelection; | |
| 122 m_endingSelection = parent->m_endingSelection; | |
| 123 } | |
| 124 } | |
| 125 | |
| 126 void SimpleEditCommand::doReapply() { | 75 void SimpleEditCommand::doReapply() { |
| 127 EditingState editingState; | 76 EditingState editingState; |
| 128 doApply(&editingState); | 77 doApply(&editingState); |
| 129 } | 78 } |
| 130 | 79 |
| 131 DEFINE_TRACE(EditCommand) { | 80 DEFINE_TRACE(EditCommand) { |
| 132 visitor->trace(m_document); | 81 visitor->trace(m_document); |
| 133 visitor->trace(m_parent); | 82 visitor->trace(m_parent); |
| 134 } | 83 } |
| 135 | 84 |
| 136 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |