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

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

Issue 2414263002: Audit the use of updateStyleAndLayoutIgnorePendingStylesheets in toNormalizedEphemeralRange (Closed)
Patch Set: fix nit Created 4 years, 2 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) 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 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 310
311 template <typename Strategy> 311 template <typename Strategy>
312 EphemeralRangeTemplate<Strategy> 312 EphemeralRangeTemplate<Strategy>
313 VisibleSelectionTemplate<Strategy>::toNormalizedEphemeralRange() const { 313 VisibleSelectionTemplate<Strategy>::toNormalizedEphemeralRange() const {
314 if (isNone()) 314 if (isNone())
315 return EphemeralRangeTemplate<Strategy>(); 315 return EphemeralRangeTemplate<Strategy>();
316 316
317 // Make sure we have an updated layout since this function is called 317 // Make sure we have an updated layout since this function is called
318 // in the course of running edit commands which modify the DOM. 318 // in the course of running edit commands which modify the DOM.
319 // Failing to call this can result in equivalentXXXPosition calls returning 319 // Failing to ensure this can result in equivalentXXXPosition calls returning
320 // incorrect results. 320 // incorrect results.
321 m_start.document()->updateStyleAndLayout(); 321 DCHECK(!m_start.document()->needsLayoutTreeUpdate());
322
323 // Check again, because updating layout can clear the selection.
324 if (isNone())
325 return EphemeralRangeTemplate<Strategy>();
326 322
327 if (isCaret()) { 323 if (isCaret()) {
328 // If the selection is a caret, move the range start upstream. This 324 // If the selection is a caret, move the range start upstream. This
329 // helps us match the conventions of text editors tested, which make 325 // helps us match the conventions of text editors tested, which make
330 // style determinations based on the character before the caret, if any. 326 // style determinations based on the character before the caret, if any.
331 const PositionTemplate<Strategy> start = 327 const PositionTemplate<Strategy> start =
332 mostBackwardCaretPosition(m_start).parentAnchoredEquivalent(); 328 mostBackwardCaretPosition(m_start).parentAnchoredEquivalent();
333 return EphemeralRangeTemplate<Strategy>(start, start); 329 return EphemeralRangeTemplate<Strategy>(start, start);
334 } 330 }
335 // If the selection is a range, select the minimum range that encompasses 331 // If the selection is a range, select the minimum range that encompasses
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
986 982
987 void showTree(const blink::VisibleSelectionInFlatTree& sel) { 983 void showTree(const blink::VisibleSelectionInFlatTree& sel) {
988 sel.showTreeForThis(); 984 sel.showTreeForThis();
989 } 985 }
990 986
991 void showTree(const blink::VisibleSelectionInFlatTree* sel) { 987 void showTree(const blink::VisibleSelectionInFlatTree* sel) {
992 if (sel) 988 if (sel)
993 sel->showTreeForThis(); 989 sel->showTreeForThis();
994 } 990 }
995 #endif 991 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698