Chromium Code Reviews| 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |