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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 362 return nullptr; | 362 return nullptr; |
| 363 | 363 |
| 364 if (index < 0 || index >= rangeCount()) { | 364 if (index < 0 || index >= rangeCount()) { |
| 365 exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); | 365 exceptionState.throwDOMException(IndexSizeError, String::number(index) + " is not a valid index."); |
| 366 return nullptr; | 366 return nullptr; |
| 367 } | 367 } |
| 368 | 368 |
| 369 // If you're hitting this, you've added broken multi-range selection support | 369 // If you're hitting this, you've added broken multi-range selection support |
| 370 ASSERT(rangeCount() == 1); | 370 ASSERT(rangeCount() == 1); |
| 371 | 371 |
| 372 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { | 372 if (!m_treeScope->rootNode().isShadowRoot()) |
| 373 ASSERT(!shadowAncestor->isShadowRoot()); | 373 return m_frame->selection().firstRange(); |
| 374 ContainerNode* container = shadowAncestor->parentOrShadowHostNode(); | |
| 375 int offset = shadowAncestor->nodeIndex(); | |
| 376 return Range::create(shadowAncestor->document(), container, offset, cont ainer, offset); | |
| 377 } | |
| 378 | 374 |
| 379 return m_frame->selection().firstRange(); | 375 Node* anchor = anchorNode(); |
| 376 ASSERT(anchor); | |
|
yosin_UTC9
2015/01/07 01:06:29
I think we don't need to |ASSERT(anchor)| here. We
kojii
2015/01/07 06:53:52
Done.
| |
| 377 return Range::create(anchor->document(), anchor, anchorOffset(), focusNode() , focusOffset()); | |
| 380 } | 378 } |
| 381 | 379 |
| 382 void DOMSelection::removeAllRanges() | 380 void DOMSelection::removeAllRanges() |
| 383 { | 381 { |
| 384 if (!m_frame) | 382 if (!m_frame) |
| 385 return; | 383 return; |
| 386 m_frame->selection().clear(); | 384 m_frame->selection().clear(); |
| 387 } | 385 } |
| 388 | 386 |
| 389 void DOMSelection::addRange(Range* newRange) | 387 void DOMSelection::addRange(Range* newRange) |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 559 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); | 557 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); |
| 560 } | 558 } |
| 561 | 559 |
| 562 void DOMSelection::trace(Visitor* visitor) | 560 void DOMSelection::trace(Visitor* visitor) |
| 563 { | 561 { |
| 564 visitor->trace(m_treeScope); | 562 visitor->trace(m_treeScope); |
| 565 DOMWindowProperty::trace(visitor); | 563 DOMWindowProperty::trace(visitor); |
| 566 } | 564 } |
| 567 | 565 |
| 568 } // namespace blink | 566 } // namespace blink |
| OLD | NEW |