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 Position anchor = anchorPosition(visibleSelection()); |
| 373 ASSERT(!shadowAncestor->isShadowRoot()); | 373 if (!anchor.anchorNode()->isInShadowTree()) |
| 374 ContainerNode* container = shadowAncestor->parentOrShadowHostNode(); | 374 return m_frame->selection().firstRange(); |
| 375 int offset = shadowAncestor->nodeIndex(); | |
| 376 return Range::create(shadowAncestor->document(), container, offset, cont ainer, offset); | |
| 377 } | |
| 378 | 375 |
| 379 return m_frame->selection().firstRange(); | 376 if (!visibleSelection().isBaseFirst()) |
| 377 return Range::create(*anchor.document(), focusNode(), focusOffset(), sha dowAdjustedNode(anchor), anchorOffset()); | |
|
Yuta Kitamura
2015/01/07 07:50:57
Does anchorOffset() work for shadowAdjustedNode(an
kojii
2015/01/07 08:20:43
Yes, this |anchorOffset()| is |DOMSelection::ancho
Yuta Kitamura
2015/01/07 08:47:54
Okay, then the PS5 looks fine to me.
I don't have
| |
| 378 return Range::create(*anchor.document(), shadowAdjustedNode(anchor), anchorO ffset(), focusNode(), focusOffset()); | |
| 380 } | 379 } |
| 381 | 380 |
| 382 void DOMSelection::removeAllRanges() | 381 void DOMSelection::removeAllRanges() |
| 383 { | 382 { |
| 384 if (!m_frame) | 383 if (!m_frame) |
| 385 return; | 384 return; |
| 386 m_frame->selection().clear(); | 385 m_frame->selection().clear(); |
| 387 } | 386 } |
| 388 | 387 |
| 389 void DOMSelection::addRange(Range* newRange) | 388 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)); | 558 m_treeScope->document().addConsoleMessage(ConsoleMessage::create(JSMessa geSource, ErrorMessageLevel, message)); |
| 560 } | 559 } |
| 561 | 560 |
| 562 void DOMSelection::trace(Visitor* visitor) | 561 void DOMSelection::trace(Visitor* visitor) |
| 563 { | 562 { |
| 564 visitor->trace(m_treeScope); | 563 visitor->trace(m_treeScope); |
| 565 DOMWindowProperty::trace(visitor); | 564 DOMWindowProperty::trace(visitor); |
| 566 } | 565 } |
| 567 | 566 |
| 568 } // namespace blink | 567 } // namespace blink |
| OLD | NEW |