| 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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 return; | 265 return; |
| 266 } | 266 } |
| 267 | 267 |
| 268 if (extentOffset < 0) { | 268 if (extentOffset < 0) { |
| 269 exceptionState.throwDOMException( | 269 exceptionState.throwDOMException( |
| 270 IndexSizeError, | 270 IndexSizeError, |
| 271 String::number(extentOffset) + " is not a valid extent offset."); | 271 String::number(extentOffset) + " is not a valid extent offset."); |
| 272 return; | 272 return; |
| 273 } | 273 } |
| 274 | 274 |
| 275 if (!baseNode || !extentNode) | 275 // TODO(editing-dev): Behavior on where base or extent is null is still |
| 276 // under discussion: https://github.com/w3c/selection-api/issues/72 |
| 277 if (!baseNode) { |
| 276 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); | 278 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); |
| 279 frame()->selection().clear(); |
| 280 return; |
| 281 } |
| 282 if (!extentNode) { |
| 283 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); |
| 284 extentOffset = 0; |
| 285 } |
| 277 | 286 |
| 278 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) | 287 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) |
| 279 return; | 288 return; |
| 280 | 289 |
| 281 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 290 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 282 // needs to be audited. See http://crbug.com/590369 for more details. | 291 // needs to be audited. See http://crbug.com/590369 for more details. |
| 283 // In the long term, we should change FrameSelection::setSelection to take a | 292 // In the long term, we should change FrameSelection::setSelection to take a |
| 284 // parameter that does not require clean layout, so that modifying selection | 293 // parameter that does not require clean layout, so that modifying selection |
| 285 // no longer performs synchronous layout by itself. | 294 // no longer performs synchronous layout by itself. |
| 286 // TODO(editing-dev): Once SVG USE element doesn't modifies DOM tree, we | 295 // TODO(editing-dev): Once SVG USE element doesn't modifies DOM tree, we |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 m_treeScope->document().addConsoleMessage( | 666 m_treeScope->document().addConsoleMessage( |
| 658 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 667 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 659 } | 668 } |
| 660 | 669 |
| 661 DEFINE_TRACE(DOMSelection) { | 670 DEFINE_TRACE(DOMSelection) { |
| 662 visitor->trace(m_treeScope); | 671 visitor->trace(m_treeScope); |
| 663 DOMWindowProperty::trace(visitor); | 672 DOMWindowProperty::trace(visitor); |
| 664 } | 673 } |
| 665 | 674 |
| 666 } // namespace blink | 675 } // namespace blink |
| OLD | NEW |