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

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

Issue 2729823002: Make FormatBlockCommand::elementForFormatBlockCommand() to take EphemeralRange (Closed)
Patch Set: 2017-03-09T13:09:11 Created 3 years, 9 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
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/FormatBlockCommand.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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 toHTMLElement(nodeAfterInsertionPosition)->getAttribute(styleAttr)); 132 toHTMLElement(nodeAfterInsertionPosition)->getAttribute(styleAttr));
133 133
134 document().updateStyleAndLayoutIgnorePendingStylesheets(); 134 document().updateStyleAndLayoutIgnorePendingStylesheets();
135 135
136 if (wasEndOfParagraph && 136 if (wasEndOfParagraph &&
137 !isEndOfParagraph(createVisiblePosition(lastParagraphInBlockNode)) && 137 !isEndOfParagraph(createVisiblePosition(lastParagraphInBlockNode)) &&
138 !isStartOfParagraph(createVisiblePosition(lastParagraphInBlockNode))) 138 !isStartOfParagraph(createVisiblePosition(lastParagraphInBlockNode)))
139 insertBlockPlaceholder(lastParagraphInBlockNode, editingState); 139 insertBlockPlaceholder(lastParagraphInBlockNode, editingState);
140 } 140 }
141 141
142 Element* FormatBlockCommand::elementForFormatBlockCommand(Range* range) { 142 Element* FormatBlockCommand::elementForFormatBlockCommand(
143 if (!range) 143 const EphemeralRange& range) {
144 return 0; 144 Node* commonAncestor = range.commonAncestorContainer();
145
146 Node* commonAncestor = range->commonAncestorContainer();
147 while (commonAncestor && !isElementForFormatBlock(commonAncestor)) 145 while (commonAncestor && !isElementForFormatBlock(commonAncestor))
148 commonAncestor = commonAncestor->parentNode(); 146 commonAncestor = commonAncestor->parentNode();
149 147
150 if (!commonAncestor) 148 if (!commonAncestor)
151 return 0; 149 return 0;
152 150
153 Element* element = rootEditableElement(*range->startContainer()); 151 Element* element =
152 rootEditableElement(*range.startPosition().computeContainerNode());
154 if (!element || commonAncestor->contains(element)) 153 if (!element || commonAncestor->contains(element))
155 return 0; 154 return 0;
156 155
157 return commonAncestor->isElementNode() ? toElement(commonAncestor) : 0; 156 return commonAncestor->isElementNode() ? toElement(commonAncestor) : 0;
158 } 157 }
159 158
160 bool isElementForFormatBlock(const QualifiedName& tagName) { 159 bool isElementForFormatBlock(const QualifiedName& tagName) {
161 DEFINE_STATIC_LOCAL( 160 DEFINE_STATIC_LOCAL(
162 HashSet<QualifiedName>, blockTags, 161 HashSet<QualifiedName>, blockTags,
163 ({ 162 ({
(...skipping 18 matching lines...) Expand all
182 if (isEnclosingBlock(&runner)) 181 if (isEnclosingBlock(&runner))
183 lastBlock = &runner; 182 lastBlock = &runner;
184 if (isHTMLListElement(&runner)) 183 if (isHTMLListElement(&runner))
185 return hasEditableStyle(*runner.parentNode()) ? runner.parentNode() 184 return hasEditableStyle(*runner.parentNode()) ? runner.parentNode()
186 : &runner; 185 : &runner;
187 } 186 }
188 return lastBlock; 187 return lastBlock;
189 } 188 }
190 189
191 } // namespace blink 190 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/editing/commands/FormatBlockCommand.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698