| 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 if (EditCommandComposition* composition = compositionIfPossible(command)) { | 64 if (EditCommandComposition* composition = compositionIfPossible(command)) { |
| 65 DCHECK(command->isTopLevelCommand()); | 65 DCHECK(command->isTopLevelCommand()); |
| 66 composition->setStartingSelection(selection); | 66 composition->setStartingSelection(selection); |
| 67 } | 67 } |
| 68 command->m_startingSelection = selection; | 68 command->m_startingSelection = selection; |
| 69 if (!command->m_parent || command->m_parent->isFirstCommand(command)) | 69 if (!command->m_parent || command->m_parent->isFirstCommand(command)) |
| 70 break; | 70 break; |
| 71 } | 71 } |
| 72 } | 72 } |
| 73 | 73 |
| 74 // TODO(yosin): We will make |SelectionInDOMTree| version of |
| 75 // |setEndingSelection()| as primary function instead of wrapper, once |
| 76 // |EditCommand| holds other than |VisibleSelection|. |
| 77 void EditCommand::setEndingSelection(const SelectionInDOMTree& selection) { |
| 78 // TODO(editing-dev): The use of |
| 79 // updateStyleAndLayoutIgnorePendingStylesheets |
| 80 // needs to be audited. See http://crbug.com/590369 for more details. |
| 81 document().updateStyleAndLayoutIgnorePendingStylesheets(); |
| 82 setEndingSelection(createVisibleSelection(selection)); |
| 83 } |
| 84 |
| 85 // TODO(yosin): We will make |SelectionInDOMTree| version of |
| 86 // |setEndingSelection()| as primary function instead of wrapper. |
| 74 void EditCommand::setEndingSelection(const VisibleSelection& selection) { | 87 void EditCommand::setEndingSelection(const VisibleSelection& selection) { |
| 75 for (EditCommand* command = this; command; command = command->m_parent) { | 88 for (EditCommand* command = this; command; command = command->m_parent) { |
| 76 if (EditCommandComposition* composition = compositionIfPossible(command)) { | 89 if (EditCommandComposition* composition = compositionIfPossible(command)) { |
| 77 DCHECK(command->isTopLevelCommand()); | 90 DCHECK(command->isTopLevelCommand()); |
| 78 composition->setEndingSelection(selection); | 91 composition->setEndingSelection(selection); |
| 79 } | 92 } |
| 80 command->m_endingSelection = selection; | 93 command->m_endingSelection = selection; |
| 81 } | 94 } |
| 82 } | 95 } |
| 83 | 96 |
| 97 // TODO(yosin): We will make |SelectionInDOMTree| version of |
| 98 // |setEndingSelection()| as primary function instead of wrapper. |
| 84 void EditCommand::setEndingSelection(const VisiblePosition& position) { | 99 void EditCommand::setEndingSelection(const VisiblePosition& position) { |
| 85 if (position.isNull()) { | 100 if (position.isNull()) { |
| 86 setEndingSelection(VisibleSelection()); | 101 setEndingSelection(SelectionInDOMTree()); |
| 87 return; | 102 return; |
| 88 } | 103 } |
| 89 setEndingSelection( | 104 setEndingSelection(SelectionInDOMTree::Builder() |
| 90 createVisibleSelection(SelectionInDOMTree::Builder() | 105 .collapse(position.toPositionWithAffinity()) |
| 91 .collapse(position.toPositionWithAffinity()) | 106 .build()); |
| 92 .build())); | |
| 93 } | 107 } |
| 94 | 108 |
| 95 bool EditCommand::isRenderedCharacter(const Position& position) { | 109 bool EditCommand::isRenderedCharacter(const Position& position) { |
| 96 if (position.isNull()) | 110 if (position.isNull()) |
| 97 return false; | 111 return false; |
| 98 DCHECK(position.isOffsetInAnchor()) << position; | 112 DCHECK(position.isOffsetInAnchor()) << position; |
| 99 if (!position.anchorNode()->isTextNode()) | 113 if (!position.anchorNode()->isTextNode()) |
| 100 return false; | 114 return false; |
| 101 | 115 |
| 102 LayoutObject* layoutObject = position.anchorNode()->layoutObject(); | 116 LayoutObject* layoutObject = position.anchorNode()->layoutObject(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 124 } | 138 } |
| 125 | 139 |
| 126 DEFINE_TRACE(EditCommand) { | 140 DEFINE_TRACE(EditCommand) { |
| 127 visitor->trace(m_document); | 141 visitor->trace(m_document); |
| 128 visitor->trace(m_startingSelection); | 142 visitor->trace(m_startingSelection); |
| 129 visitor->trace(m_endingSelection); | 143 visitor->trace(m_endingSelection); |
| 130 visitor->trace(m_parent); | 144 visitor->trace(m_parent); |
| 131 } | 145 } |
| 132 | 146 |
| 133 } // namespace blink | 147 } // namespace blink |
| OLD | NEW |