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

Side by Side Diff: Source/core/editing/FrameSelection.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/dom/Range.cpp ('k') | Source/core/editing/VisibleSelection.h » ('j') | 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, 2008, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2004, 2008, 2009, 2010 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 clearRenderTreeSelection = true; 351 clearRenderTreeSelection = true;
352 } else if (baseRemoved || extentRemoved) { 352 } else if (baseRemoved || extentRemoved) {
353 // The base and/or extent are about to be removed, but the start and end aren't. 353 // The base and/or extent are about to be removed, but the start and end aren't.
354 // Change the base and extent to the start and end, but don't re-validat e the 354 // Change the base and extent to the start and end, but don't re-validat e the
355 // selection, since doing so could move the start and end into the node 355 // selection, since doing so could move the start and end into the node
356 // that is about to be removed. 356 // that is about to be removed.
357 if (m_selection.isBaseFirst()) 357 if (m_selection.isBaseFirst())
358 m_selection.setWithoutValidation(m_selection.start(), m_selection.en d()); 358 m_selection.setWithoutValidation(m_selection.start(), m_selection.en d());
359 else 359 else
360 m_selection.setWithoutValidation(m_selection.end(), m_selection.star t()); 360 m_selection.setWithoutValidation(m_selection.end(), m_selection.star t());
361 } else if (RefPtrWillBeRawPtr<Range> range = m_selection.firstRange()) { 361 } else if (m_selection.intersectsNode(&node)) {
362 TrackExceptionState exceptionState; 362 // If we did nothing here, when this node's renderer was destroyed, the rect that it
363 Range::CompareResults compareResult = range->compareNode(&node, exceptio nState); 363 // occupied would be invalidated, but, selection gaps that change as a r esult of
364 if (!exceptionState.hadException() && (compareResult == Range::NODE_BEFO RE_AND_AFTER || compareResult == Range::NODE_INSIDE)) { 364 // the removal wouldn't be invalidated.
365 // If we did nothing here, when this node's renderer was destroyed, the rect that it 365 // FIXME: Don't do so much unnecessary invalidation.
366 // occupied would be invalidated, but, selection gaps that change as a result of 366 clearRenderTreeSelection = true;
367 // the removal wouldn't be invalidated.
368 // FIXME: Don't do so much unnecessary invalidation.
369 clearRenderTreeSelection = true;
370 }
371 } 367 }
372 368
373 if (clearRenderTreeSelection) 369 if (clearRenderTreeSelection)
374 m_selection.start().document()->renderView()->clearSelection(); 370 m_selection.start().document()->renderView()->clearSelection();
375 371
376 if (clearDOMTreeSelection) 372 if (clearDOMTreeSelection)
377 setSelection(VisibleSelection(), DoNotSetFocus); 373 setSelection(VisibleSelection(), DoNotSetFocus);
378 } 374 }
379 375
380 static Position updatePositionAfterAdoptingTextReplacement(const Position& posit ion, CharacterData* node, unsigned offset, unsigned oldLength, unsigned newLengt h) 376 static Position updatePositionAfterAdoptingTextReplacement(const Position& posit ion, CharacterData* node, unsigned offset, unsigned oldLength, unsigned newLengt h)
(...skipping 1547 matching lines...) Expand 10 before | Expand all | Expand 10 after
1928 sel.showTreeForThis(); 1924 sel.showTreeForThis();
1929 } 1925 }
1930 1926
1931 void showTree(const blink::FrameSelection* sel) 1927 void showTree(const blink::FrameSelection* sel)
1932 { 1928 {
1933 if (sel) 1929 if (sel)
1934 sel->showTreeForThis(); 1930 sel->showTreeForThis();
1935 } 1931 }
1936 1932
1937 #endif 1933 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/Range.cpp ('k') | Source/core/editing/VisibleSelection.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698