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

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

Issue 2788473003: Use EphmeralRange insteadof Range in CompositeEditCommands::isNodeVisiblyContainedWithin()
Patch Set: update Created 3 years, 8 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) 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 Element* root = rootEditableElementOf(start); 77 Element* root = rootEditableElementOf(start);
78 // Root is null for elements with contenteditable=false. 78 // Root is null for elements with contenteditable=false.
79 if (!root || !refElement) 79 if (!root || !refElement)
80 return; 80 return;
81 81
82 Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.anchorNode()); 82 Node* nodeToSplitTo = enclosingBlockToSplitTreeTo(start.anchorNode());
83 Node* outerBlock = (start.anchorNode() == nodeToSplitTo) 83 Node* outerBlock = (start.anchorNode() == nodeToSplitTo)
84 ? start.anchorNode() 84 ? start.anchorNode()
85 : splitTreeToNode(start.anchorNode(), nodeToSplitTo); 85 : splitTreeToNode(start.anchorNode(), nodeToSplitTo);
86 Node* nodeAfterInsertionPosition = outerBlock; 86 Node* nodeAfterInsertionPosition = outerBlock;
87 Range* range = Range::create(document(), start, endOfSelection); 87 const EphemeralRange range = EphemeralRange(start, endOfSelection);
88 88
89 document().updateStyleAndLayoutIgnorePendingStylesheets(); 89 document().updateStyleAndLayoutIgnorePendingStylesheets();
90 if (isElementForFormatBlock(refElement->tagQName()) && 90 if (isElementForFormatBlock(refElement->tagQName()) &&
91 createVisiblePosition(start).deepEquivalent() == 91 createVisiblePosition(start).deepEquivalent() ==
92 startOfBlock(createVisiblePosition(start)).deepEquivalent() && 92 startOfBlock(createVisiblePosition(start)).deepEquivalent() &&
93 (createVisiblePosition(end).deepEquivalent() == 93 (createVisiblePosition(end).deepEquivalent() ==
94 endOfBlock(createVisiblePosition(end)).deepEquivalent() || 94 endOfBlock(createVisiblePosition(end)).deepEquivalent() ||
95 isNodeVisiblyContainedWithin(*refElement, *range)) && 95 isNodeVisiblyContainedWithin(*refElement, range)) &&
96 refElement != root && !root->isDescendantOf(refElement)) { 96 refElement != root && !root->isDescendantOf(refElement)) {
97 // Already in a block element that only contains the current paragraph 97 // Already in a block element that only contains the current paragraph
98 if (refElement->hasTagName(tagName())) 98 if (refElement->hasTagName(tagName()))
99 return; 99 return;
100 nodeAfterInsertionPosition = refElement; 100 nodeAfterInsertionPosition = refElement;
101 } 101 }
102 102
103 if (!blockElement) { 103 if (!blockElement) {
104 // Create a new blockquote and insert it as a child of the root editable 104 // Create a new blockquote and insert it as a child of the root editable
105 // element. We accomplish this by splitting all parents of the current 105 // element. We accomplish this by splitting all parents of the current
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 if (isEnclosingBlock(&runner)) 181 if (isEnclosingBlock(&runner))
182 lastBlock = &runner; 182 lastBlock = &runner;
183 if (isHTMLListElement(&runner)) 183 if (isHTMLListElement(&runner))
184 return hasEditableStyle(*runner.parentNode()) ? runner.parentNode() 184 return hasEditableStyle(*runner.parentNode()) ? runner.parentNode()
185 : &runner; 185 : &runner;
186 } 186 }
187 return lastBlock; 187 return lastBlock;
188 } 188 }
189 189
190 } // namespace blink 190 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698