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

Side by Side Diff: Source/core/editing/VisibleSelection.cpp

Issue 541633004: Avoid temporary range allocation in FrameSelection::respondToNodeModification. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address review comments. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/editing/VisibleSelection.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) 2004, 2005, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2005, 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 185
186 PassRefPtrWillBeRawPtr<Range> VisibleSelection::firstRange() const 186 PassRefPtrWillBeRawPtr<Range> VisibleSelection::firstRange() const
187 { 187 {
188 if (isNone()) 188 if (isNone())
189 return nullptr; 189 return nullptr;
190 Position start = m_start.parentAnchoredEquivalent(); 190 Position start = m_start.parentAnchoredEquivalent();
191 Position end = m_end.parentAnchoredEquivalent(); 191 Position end = m_end.parentAnchoredEquivalent();
192 return Range::create(*start.document(), start, end); 192 return Range::create(*start.document(), start, end);
193 } 193 }
194 194
195 bool VisibleSelection::intersectsNode(Node* node) const
196 {
197 if (isNone())
198 return false;
199 Position start = m_start.parentAnchoredEquivalent();
200 Position end = m_end.parentAnchoredEquivalent();
201 TrackExceptionState exceptionState;
202 return Range::intersectsNode(node, start, end, exceptionState) && !exception State.hadException();
203 }
204
195 PassRefPtrWillBeRawPtr<Range> VisibleSelection::toNormalizedRange() const 205 PassRefPtrWillBeRawPtr<Range> VisibleSelection::toNormalizedRange() const
196 { 206 {
197 if (isNone()) 207 if (isNone())
198 return nullptr; 208 return nullptr;
199 209
200 // Make sure we have an updated layout since this function is called 210 // Make sure we have an updated layout since this function is called
201 // in the course of running edit commands which modify the DOM. 211 // in the course of running edit commands which modify the DOM.
202 // Failing to call this can result in equivalentXXXPosition calls returning 212 // Failing to call this can result in equivalentXXXPosition calls returning
203 // incorrect results. 213 // incorrect results.
204 m_start.document()->updateLayout(); 214 m_start.document()->updateLayout();
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 sel.showTreeForThis(); 866 sel.showTreeForThis();
857 } 867 }
858 868
859 void showTree(const blink::VisibleSelection* sel) 869 void showTree(const blink::VisibleSelection* sel)
860 { 870 {
861 if (sel) 871 if (sel)
862 sel->showTreeForThis(); 872 sel->showTreeForThis();
863 } 873 }
864 874
865 #endif 875 #endif
OLDNEW
« no previous file with comments | « Source/core/editing/VisibleSelection.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698