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 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 if (!baseNode || !extentNode) { |
| 276 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); | 276 UseCounter::count(frame(), UseCounter::SelectionSetBaseAndExtentNull); |
| 277 // TODO(editing-dev): Behavior on where base or extent is null is still | |
| 278 // under discussion: https://github.com/w3c/selection-api/issues/72 | |
| 279 if (!baseNode) { | |
|
yosin_UTC9
2016/12/02 04:38:02
It seems that dealing nullptr explicitly is more r
| |
| 280 frame()->selection().clear(); | |
| 281 return; | |
| 282 } | |
| 283 extentOffset = 0; | |
| 284 } | |
| 277 | 285 |
| 278 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) | 286 if (!isValidForPosition(baseNode) || !isValidForPosition(extentNode)) |
| 279 return; | 287 return; |
| 280 | 288 |
| 281 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets | 289 // TODO(editing-dev): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 282 // needs to be audited. See http://crbug.com/590369 for more details. | 290 // 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 | 291 // In the long term, we should change FrameSelection::setSelection to take a |
| 284 // parameter that does not require clean layout, so that modifying selection | 292 // parameter that does not require clean layout, so that modifying selection |
| 285 // no longer performs synchronous layout by itself. | 293 // no longer performs synchronous layout by itself. |
| 286 // TODO(editing-dev): Once SVG USE element doesn't modifies DOM tree, we | 294 // 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( | 665 m_treeScope->document().addConsoleMessage( |
| 658 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 666 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 659 } | 667 } |
| 660 | 668 |
| 661 DEFINE_TRACE(DOMSelection) { | 669 DEFINE_TRACE(DOMSelection) { |
| 662 visitor->trace(m_treeScope); | 670 visitor->trace(m_treeScope); |
| 663 DOMWindowProperty::trace(visitor); | 671 DOMWindowProperty::trace(visitor); |
| 664 } | 672 } |
| 665 | 673 |
| 666 } // namespace blink | 674 } // namespace blink |
| OLD | NEW |