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

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

Issue 2457613004: Utilize FrameSelection::setSelection() taking SelectionInDOMTree/SelectionInFlatTree (Closed)
Patch Set: 2016-10-28T15:45:56 Created 4 years, 1 month 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 | « no previous file | third_party/WebKit/Source/core/editing/FrameSelection.cpp » ('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) 2007, 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 exceptionState.throwDOMException(InvalidStateError, 220 exceptionState.throwDOMException(InvalidStateError,
221 "there is no selection."); 221 "there is no selection.");
222 return; 222 return;
223 } 223 }
224 224
225 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 225 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
226 // needs to be audited. See http://crbug.com/590369 for more details. 226 // needs to be audited. See http://crbug.com/590369 for more details.
227 // In the long term, we should change FrameSelection::setSelection to take a 227 // In the long term, we should change FrameSelection::setSelection to take a
228 // parameter that does not require clean layout, so that modifying selection 228 // parameter that does not require clean layout, so that modifying selection
229 // no longer performs synchronous layout by itself. 229 // no longer performs synchronous layout by itself.
230 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 230 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
Xiaocheng 2016/10/28 10:09:43 We can remove this call now.
yosin_UTC9 2016/10/31 06:13:08 Done.
231 231
232 SelectionInDOMTree::Builder builder; 232 SelectionInDOMTree::Builder builder;
233 builder.collapse(selection.end()); 233 builder.collapse(selection.end());
234 frame()->selection().setSelection(createVisibleSelection(builder.build())); 234 frame()->selection().setSelection(builder.build());
235 } 235 }
236 236
237 void DOMSelection::collapseToStart(ExceptionState& exceptionState) { 237 void DOMSelection::collapseToStart(ExceptionState& exceptionState) {
238 if (!isAvailable()) 238 if (!isAvailable())
239 return; 239 return;
240 240
241 const VisibleSelection& selection = frame()->selection().selection(); 241 const VisibleSelection& selection = frame()->selection().selection();
242 242
243 if (selection.isNone()) { 243 if (selection.isNone()) {
244 exceptionState.throwDOMException(InvalidStateError, 244 exceptionState.throwDOMException(InvalidStateError,
245 "there is no selection."); 245 "there is no selection.");
246 return; 246 return;
247 } 247 }
248 248
249 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets 249 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets
250 // needs to be audited. See http://crbug.com/590369 for more details. 250 // needs to be audited. See http://crbug.com/590369 for more details.
251 // In the long term, we should change FrameSelection::setSelection to take a 251 // In the long term, we should change FrameSelection::setSelection to take a
252 // parameter that does not require clean layout, so that modifying selection 252 // parameter that does not require clean layout, so that modifying selection
253 // no longer performs synchronous layout by itself. 253 // no longer performs synchronous layout by itself.
254 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); 254 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets();
Xiaocheng 2016/10/28 10:09:43 We can remove this call now.
yosin_UTC9 2016/10/31 06:13:08 Done
255 255
256 SelectionInDOMTree::Builder builder; 256 SelectionInDOMTree::Builder builder;
257 builder.collapse(selection.start()); 257 builder.collapse(selection.start());
258 frame()->selection().setSelection(createVisibleSelection(builder.build())); 258 frame()->selection().setSelection(builder.build());
259 } 259 }
260 260
261 void DOMSelection::empty() { 261 void DOMSelection::empty() {
262 if (!isAvailable()) 262 if (!isAvailable())
263 return; 263 return;
264 frame()->selection().clear(); 264 frame()->selection().clear();
265 } 265 }
266 266
267 void DOMSelection::setBaseAndExtent(Node* baseNode, 267 void DOMSelection::setBaseAndExtent(Node* baseNode,
268 int baseOffset, 268 int baseOffset,
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
671 m_treeScope->document().addConsoleMessage( 671 m_treeScope->document().addConsoleMessage(
672 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); 672 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message));
673 } 673 }
674 674
675 DEFINE_TRACE(DOMSelection) { 675 DEFINE_TRACE(DOMSelection) {
676 visitor->trace(m_treeScope); 676 visitor->trace(m_treeScope);
677 DOMWindowProperty::trace(visitor); 677 DOMWindowProperty::trace(visitor);
678 } 678 }
679 679
680 } // namespace blink 680 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/editing/FrameSelection.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698