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

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

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

Powered by Google App Engine
This is Rietveld 408576698