| 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 return; | 215 return; |
| 216 | 216 |
| 217 const VisibleSelection& selection = frame()->selection().selection(); | 217 const VisibleSelection& selection = frame()->selection().selection(); |
| 218 | 218 |
| 219 if (selection.isNone()) { | 219 if (selection.isNone()) { |
| 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 | |
| 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 | |
| 228 // parameter that does not require clean layout, so that modifying selection | |
| 229 // no longer performs synchronous layout by itself. | |
| 230 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 231 | |
| 232 SelectionInDOMTree::Builder builder; | 225 SelectionInDOMTree::Builder builder; |
| 233 builder.collapse(selection.end()); | 226 builder.collapse(selection.end()); |
| 234 frame()->selection().setSelection(createVisibleSelection(builder.build())); | 227 frame()->selection().setSelection(builder.build()); |
| 235 } | 228 } |
| 236 | 229 |
| 237 void DOMSelection::collapseToStart(ExceptionState& exceptionState) { | 230 void DOMSelection::collapseToStart(ExceptionState& exceptionState) { |
| 238 if (!isAvailable()) | 231 if (!isAvailable()) |
| 239 return; | 232 return; |
| 240 | 233 |
| 241 const VisibleSelection& selection = frame()->selection().selection(); | 234 const VisibleSelection& selection = frame()->selection().selection(); |
| 242 | 235 |
| 243 if (selection.isNone()) { | 236 if (selection.isNone()) { |
| 244 exceptionState.throwDOMException(InvalidStateError, | 237 exceptionState.throwDOMException(InvalidStateError, |
| 245 "there is no selection."); | 238 "there is no selection."); |
| 246 return; | 239 return; |
| 247 } | 240 } |
| 248 | 241 |
| 249 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | |
| 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 | |
| 252 // parameter that does not require clean layout, so that modifying selection | |
| 253 // no longer performs synchronous layout by itself. | |
| 254 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 255 | |
| 256 SelectionInDOMTree::Builder builder; | 242 SelectionInDOMTree::Builder builder; |
| 257 builder.collapse(selection.start()); | 243 builder.collapse(selection.start()); |
| 258 frame()->selection().setSelection(createVisibleSelection(builder.build())); | 244 frame()->selection().setSelection(builder.build()); |
| 259 } | 245 } |
| 260 | 246 |
| 261 void DOMSelection::empty() { | 247 void DOMSelection::empty() { |
| 262 if (!isAvailable()) | 248 if (!isAvailable()) |
| 263 return; | 249 return; |
| 264 frame()->selection().clear(); | 250 frame()->selection().clear(); |
| 265 } | 251 } |
| 266 | 252 |
| 267 void DOMSelection::setBaseAndExtent(Node* baseNode, | 253 void DOMSelection::setBaseAndExtent(Node* baseNode, |
| 268 int baseOffset, | 254 int baseOffset, |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 m_treeScope->document().addConsoleMessage( | 657 m_treeScope->document().addConsoleMessage( |
| 672 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 658 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 673 } | 659 } |
| 674 | 660 |
| 675 DEFINE_TRACE(DOMSelection) { | 661 DEFINE_TRACE(DOMSelection) { |
| 676 visitor->trace(m_treeScope); | 662 visitor->trace(m_treeScope); |
| 677 DOMWindowProperty::trace(visitor); | 663 DOMWindowProperty::trace(visitor); |
| 678 } | 664 } |
| 679 | 665 |
| 680 } // namespace blink | 666 } // namespace blink |
| OLD | NEW |