| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 IndexSizeError, String::number(offset) + " is not a valid offset."); | 203 IndexSizeError, String::number(offset) + " is not a valid offset."); |
| 204 return; | 204 return; |
| 205 } | 205 } |
| 206 | 206 |
| 207 if (!isValidForPosition(node)) | 207 if (!isValidForPosition(node)) |
| 208 return; | 208 return; |
| 209 Range::checkNodeWOffset(node, offset, exceptionState); | 209 Range::checkNodeWOffset(node, offset, exceptionState); |
| 210 if (exceptionState.hadException()) | 210 if (exceptionState.hadException()) |
| 211 return; | 211 return; |
| 212 | 212 |
| 213 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 213 frame()->selection().setSelection( |
| 214 // needs to be audited. See http://crbug.com/590369 for more details. | 214 SelectionInDOMTree::Builder() |
| 215 // In the long term, we should change FrameSelection::setSelection to take a | 215 .collapse(Position(node, offset)) |
| 216 // parameter that does not require clean layout, so that modifying selection | 216 .setIsDirectional(frame()->selection().isDirectional()) |
| 217 // no longer performs synchronous layout by itself. | 217 .build()); |
| 218 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | |
| 219 | |
| 220 frame()->selection().setSelection(createVisibleSelection( | |
| 221 Position(node, offset), frame()->selection().isDirectional())); | |
| 222 } | 218 } |
| 223 | 219 |
| 224 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) { | 220 void DOMSelection::collapseToEnd(ExceptionState& exceptionState) { |
| 225 if (!isAvailable()) | 221 if (!isAvailable()) |
| 226 return; | 222 return; |
| 227 | 223 |
| 228 const VisibleSelection& selection = frame()->selection().selection(); | 224 const VisibleSelection& selection = frame()->selection().selection(); |
| 229 | 225 |
| 230 if (selection.isNone()) { | 226 if (selection.isNone()) { |
| 231 exceptionState.throwDOMException(InvalidStateError, | 227 exceptionState.throwDOMException(InvalidStateError, |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 m_treeScope->document().addConsoleMessage( | 673 m_treeScope->document().addConsoleMessage( |
| 678 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 674 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 679 } | 675 } |
| 680 | 676 |
| 681 DEFINE_TRACE(DOMSelection) { | 677 DEFINE_TRACE(DOMSelection) { |
| 682 visitor->trace(m_treeScope); | 678 visitor->trace(m_treeScope); |
| 683 DOMWindowProperty::trace(visitor); | 679 DOMWindowProperty::trace(visitor); |
| 684 } | 680 } |
| 685 | 681 |
| 686 } // namespace blink | 682 } // namespace blink |
| OLD | NEW |