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

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

Issue 2450603003: Introduce EditCommand::setEndingSelection() taking SelectionInDOMTree (Closed)
Patch Set: 2016-10-25T16:39:38 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/EditCommand.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/EditCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698