OLD | NEW |
---|---|
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 return; | 226 return; |
227 | 227 |
228 const VisibleSelection& selection = frame()->selection().selection(); | 228 const VisibleSelection& selection = frame()->selection().selection(); |
229 | 229 |
230 if (selection.isNone()) { | 230 if (selection.isNone()) { |
231 exceptionState.throwDOMException(InvalidStateError, | 231 exceptionState.throwDOMException(InvalidStateError, |
232 "there is no selection."); | 232 "there is no selection."); |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
237 // needs to be audited. See http://crbug.com/590369 for more details. | |
238 // In the long term, we should change FrameSelection::setSelection to take a | |
239 // parameter that does not require clean layout, so that modifying selection | |
240 // no longer performs synchronous layout by itself. | |
241 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
242 | |
236 frame()->selection().moveTo(selection.end(), SelDefaultAffinity); | 243 frame()->selection().moveTo(selection.end(), SelDefaultAffinity); |
237 } | 244 } |
238 | 245 |
239 void DOMSelection::collapseToStart(ExceptionState& exceptionState) { | 246 void DOMSelection::collapseToStart(ExceptionState& exceptionState) { |
240 if (!isAvailable()) | 247 if (!isAvailable()) |
241 return; | 248 return; |
242 | 249 |
243 const VisibleSelection& selection = frame()->selection().selection(); | 250 const VisibleSelection& selection = frame()->selection().selection(); |
244 | 251 |
245 if (selection.isNone()) { | 252 if (selection.isNone()) { |
246 exceptionState.throwDOMException(InvalidStateError, | 253 exceptionState.throwDOMException(InvalidStateError, |
247 "there is no selection."); | 254 "there is no selection."); |
248 return; | 255 return; |
249 } | 256 } |
250 | 257 |
258 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
259 // needs to be audited. See http://crbug.com/590369 for more details. | |
260 // In the long term, we should change FrameSelection::setSelection to take a | |
261 // parameter that does not require clean layout, so that modifying selection | |
262 // no longer performs synchronous layout by itself. | |
263 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
264 | |
251 frame()->selection().moveTo(selection.start(), SelDefaultAffinity); | 265 frame()->selection().moveTo(selection.start(), SelDefaultAffinity); |
252 } | 266 } |
253 | 267 |
254 void DOMSelection::empty() { | 268 void DOMSelection::empty() { |
255 if (!isAvailable()) | 269 if (!isAvailable()) |
256 return; | 270 return; |
257 frame()->selection().clear(); | 271 frame()->selection().clear(); |
258 } | 272 } |
259 | 273 |
260 void DOMSelection::setBaseAndExtent(Node* baseNode, | 274 void DOMSelection::setBaseAndExtent(Node* baseNode, |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
437 return; | 451 return; |
438 } | 452 } |
439 | 453 |
440 FrameSelection& selection = frame()->selection(); | 454 FrameSelection& selection = frame()->selection(); |
441 | 455 |
442 if (newRange->ownerDocument() != selection.document()) { | 456 if (newRange->ownerDocument() != selection.document()) { |
443 // "editing/selection/selection-in-iframe-removed-crash.html" goes here. | 457 // "editing/selection/selection-in-iframe-removed-crash.html" goes here. |
444 return; | 458 return; |
445 } | 459 } |
446 | 460 |
461 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
462 // needs to be audited. See http://crbug.com/590369 for more details. | |
463 // In the long term, we should change FrameSelection::setSelection to take a | |
464 // parameter that does not require clean layout, so that modifying selection | |
465 // no longer performs synchronous layout by itself. | |
466 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
Xiaocheng
2016/10/04 01:01:40
Originally, DOMSelection::addRange doesn't trigger
yosin_UTC9
2016/10/04 01:52:06
Upon failure, we don't grantee state. So, it shoul
| |
467 | |
447 if (selection.isNone()) { | 468 if (selection.isNone()) { |
448 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); | 469 selection.setSelectedRange(newRange, VP_DEFAULT_AFFINITY); |
449 return; | 470 return; |
450 } | 471 } |
451 | 472 |
452 Range* originalRange = selection.firstRange(); | 473 Range* originalRange = selection.firstRange(); |
453 | 474 |
454 if (originalRange->startContainer()->document() != | 475 if (originalRange->startContainer()->document() != |
455 newRange->startContainer()->document()) { | 476 newRange->startContainer()->document()) { |
456 addConsoleError( | 477 addConsoleError( |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
636 m_treeScope->document().addConsoleMessage( | 657 m_treeScope->document().addConsoleMessage( |
637 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 658 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
638 } | 659 } |
639 | 660 |
640 DEFINE_TRACE(DOMSelection) { | 661 DEFINE_TRACE(DOMSelection) { |
641 visitor->trace(m_treeScope); | 662 visitor->trace(m_treeScope); |
642 DOMWindowProperty::trace(visitor); | 663 DOMWindowProperty::trace(visitor); |
643 } | 664 } |
644 | 665 |
645 } // namespace blink | 666 } // namespace blink |
OLD | NEW |