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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 if (!node) | 53 if (!node) |
54 return 0; | 54 return 0; |
55 | 55 |
56 if (!node->isInShadowTree()) | 56 if (!node->isInShadowTree()) |
57 return 0; | 57 return 0; |
58 | 58 |
59 return frame->document()->ancestorInThisScope(node); | 59 return frame->document()->ancestorInThisScope(node); |
60 } | 60 } |
61 | 61 |
62 DOMSelection::DOMSelection(const TreeScope* treeScope) | 62 DOMSelection::DOMSelection(const TreeScope* treeScope) |
63 : DOMWindowProperty(treeScope->rootNode()->document()->frame()) | 63 : DOMWindowProperty(treeScope->rootNode()->document().frame()) |
64 , m_treeScope(treeScope) | 64 , m_treeScope(treeScope) |
65 { | 65 { |
66 ScriptWrappable::init(this); | 66 ScriptWrappable::init(this); |
67 } | 67 } |
68 | 68 |
69 void DOMSelection::clearTreeScope() | 69 void DOMSelection::clearTreeScope() |
70 { | 70 { |
71 m_treeScope = 0; | 71 m_treeScope = 0; |
72 } | 72 } |
73 | 73 |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"getRangeAt", "Selection", String::number(index) + " is not a valid index.")); | 374 es.throwDOMException(IndexSizeError, ExceptionMessages::failedToExecute(
"getRangeAt", "Selection", String::number(index) + " is not a valid index.")); |
375 return 0; | 375 return 0; |
376 } | 376 } |
377 | 377 |
378 // If you're hitting this, you've added broken multi-range selection support | 378 // If you're hitting this, you've added broken multi-range selection support |
379 ASSERT(rangeCount() == 1); | 379 ASSERT(rangeCount() == 1); |
380 | 380 |
381 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { | 381 if (Node* shadowAncestor = selectionShadowAncestor(m_frame)) { |
382 ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(
); | 382 ContainerNode* container = shadowAncestor->parentNodeGuaranteedHostFree(
); |
383 int offset = shadowAncestor->nodeIndex(); | 383 int offset = shadowAncestor->nodeIndex(); |
384 return Range::create(shadowAncestor->document(), container, offset, cont
ainer, offset); | 384 return Range::create(&shadowAncestor->document(), container, offset, con
tainer, offset); |
385 } | 385 } |
386 | 386 |
387 const VisibleSelection& selection = m_frame->selection()->selection(); | 387 const VisibleSelection& selection = m_frame->selection()->selection(); |
388 return selection.firstRange(); | 388 return selection.firstRange(); |
389 } | 389 } |
390 | 390 |
391 void DOMSelection::removeAllRanges() | 391 void DOMSelection::removeAllRanges() |
392 { | 392 { |
393 if (!m_frame) | 393 if (!m_frame) |
394 return; | 394 return; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selecte
dRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffs
et(), ASSERT_NO_EXCEPTION); | 456 setBaseAndExtent(selectedRange->startContainer(ASSERT_NO_EXCEPTION), selecte
dRange->startOffset(), selectedRange->startContainer(), selectedRange->startOffs
et(), ASSERT_NO_EXCEPTION); |
457 } | 457 } |
458 | 458 |
459 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const | 459 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const |
460 { | 460 { |
461 if (!m_frame) | 461 if (!m_frame) |
462 return false; | 462 return false; |
463 | 463 |
464 FrameSelection* selection = m_frame->selection(); | 464 FrameSelection* selection = m_frame->selection(); |
465 | 465 |
466 if (!n || m_frame->document() != n->document() || selection->isNone()) | 466 if (!n || m_frame->document() != &n->document() || selection->isNone()) |
467 return false; | 467 return false; |
468 | 468 |
469 unsigned nodeIndex = n->nodeIndex(); | 469 unsigned nodeIndex = n->nodeIndex(); |
470 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); | 470 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); |
471 | 471 |
472 ContainerNode* parentNode = n->parentNode(); | 472 ContainerNode* parentNode = n->parentNode(); |
473 if (!parentNode) | 473 if (!parentNode) |
474 return false; | 474 return false; |
475 | 475 |
476 TrackExceptionState es; | 476 TrackExceptionState es; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
538 return position.computeOffsetInContainerNode(); | 538 return position.computeOffsetInContainerNode(); |
539 | 539 |
540 return adjustedNode->nodeIndex(); | 540 return adjustedNode->nodeIndex(); |
541 } | 541 } |
542 | 542 |
543 bool DOMSelection::isValidForPosition(Node* node) const | 543 bool DOMSelection::isValidForPosition(Node* node) const |
544 { | 544 { |
545 ASSERT(m_frame); | 545 ASSERT(m_frame); |
546 if (!node) | 546 if (!node) |
547 return true; | 547 return true; |
548 return node->document() == m_frame->document(); | 548 return &node->document() == m_frame->document(); |
549 } | 549 } |
550 | 550 |
551 } // namespace WebCore | 551 } // namespace WebCore |
OLD | NEW |