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