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

Side by Side Diff: third_party/WebKit/Source/core/editing/commands/EditCommand.cpp

Issue 2451093002: Get rid of EditCommand::setEndingSelection() taking one VisiblePosition (Closed)
Patch Set: 2016-10-26T16:39:39 Created 4 years, 1 month 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
OLDNEW
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 void EditCommand::setEndingSelection(const VisibleSelection& selection) { 87 void EditCommand::setEndingSelection(const VisibleSelection& selection) {
88 for (EditCommand* command = this; command; command = command->m_parent) { 88 for (EditCommand* command = this; command; command = command->m_parent) {
89 if (EditCommandComposition* composition = compositionIfPossible(command)) { 89 if (EditCommandComposition* composition = compositionIfPossible(command)) {
90 DCHECK(command->isTopLevelCommand()); 90 DCHECK(command->isTopLevelCommand());
91 composition->setEndingSelection(selection); 91 composition->setEndingSelection(selection);
92 } 92 }
93 command->m_endingSelection = selection; 93 command->m_endingSelection = selection;
94 } 94 }
95 } 95 }
96 96
97 // TODO(yosin): We will make |SelectionInDOMTree| version of
98 // |setEndingSelection()| as primary function instead of wrapper.
99 void EditCommand::setEndingSelection(const VisiblePosition& position) {
100 if (position.isNull()) {
101 setEndingSelection(SelectionInDOMTree());
102 return;
103 }
104 setEndingSelection(SelectionInDOMTree::Builder()
105 .collapse(position.toPositionWithAffinity())
106 .build());
107 }
108
109 bool EditCommand::isRenderedCharacter(const Position& position) { 97 bool EditCommand::isRenderedCharacter(const Position& position) {
110 if (position.isNull()) 98 if (position.isNull())
111 return false; 99 return false;
112 DCHECK(position.isOffsetInAnchor()) << position; 100 DCHECK(position.isOffsetInAnchor()) << position;
113 if (!position.anchorNode()->isTextNode()) 101 if (!position.anchorNode()->isTextNode())
114 return false; 102 return false;
115 103
116 LayoutObject* layoutObject = position.anchorNode()->layoutObject(); 104 LayoutObject* layoutObject = position.anchorNode()->layoutObject();
117 if (!layoutObject) 105 if (!layoutObject)
118 return false; 106 return false;
(...skipping 19 matching lines...) Expand all
138 } 126 }
139 127
140 DEFINE_TRACE(EditCommand) { 128 DEFINE_TRACE(EditCommand) {
141 visitor->trace(m_document); 129 visitor->trace(m_document);
142 visitor->trace(m_startingSelection); 130 visitor->trace(m_startingSelection);
143 visitor->trace(m_endingSelection); 131 visitor->trace(m_endingSelection);
144 visitor->trace(m_parent); 132 visitor->trace(m_parent);
145 } 133 }
146 134
147 } // namespace blink 135 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698