| 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 selectedRange->startContainer(), | 659 selectedRange->startContainer(), |
| 660 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); | 660 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); |
| 661 } | 661 } |
| 662 | 662 |
| 663 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { | 663 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { |
| 664 DCHECK(n); | 664 DCHECK(n); |
| 665 | 665 |
| 666 if (!isAvailable()) | 666 if (!isAvailable()) |
| 667 return false; | 667 return false; |
| 668 | 668 |
| 669 FrameSelection& selection = frame()->selection(); | 669 if (frame()->document() != n->document()) |
| 670 | |
| 671 if (frame()->document() != n->document() || selection.isNone()) | |
| 672 return false; | 670 return false; |
| 673 | 671 |
| 674 unsigned nodeIndex = n->nodeIndex(); | 672 unsigned nodeIndex = n->nodeIndex(); |
| 675 | 673 |
| 676 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 674 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 677 // needs to be audited. See http://crbug.com/590369 for more details. | 675 // needs to be audited. See http://crbug.com/590369 for more details. |
| 678 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. | 676 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. |
| 679 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 677 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 680 | 678 |
| 679 FrameSelection& selection = frame()->selection(); |
| 681 const EphemeralRange selectedRange = | 680 const EphemeralRange selectedRange = |
| 682 selection.selection().toNormalizedEphemeralRange(); | 681 selection.selection().toNormalizedEphemeralRange(); |
| 682 if (selectedRange.isNull()) |
| 683 return false; |
| 683 | 684 |
| 684 ContainerNode* parentNode = n->parentNode(); | 685 ContainerNode* parentNode = n->parentNode(); |
| 685 if (!parentNode) | 686 if (!parentNode) |
| 686 return false; | 687 return false; |
| 687 | 688 |
| 688 const Position startPosition = | 689 const Position startPosition = |
| 689 selectedRange.startPosition().toOffsetInAnchor(); | 690 selectedRange.startPosition().toOffsetInAnchor(); |
| 690 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); | 691 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); |
| 691 DummyExceptionStateForTesting exceptionState; | 692 DummyExceptionStateForTesting exceptionState; |
| 692 bool nodeFullySelected = | 693 bool nodeFullySelected = |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 m_treeScope->document().addConsoleMessage( | 790 m_treeScope->document().addConsoleMessage( |
| 790 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 791 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 791 } | 792 } |
| 792 | 793 |
| 793 DEFINE_TRACE(DOMSelection) { | 794 DEFINE_TRACE(DOMSelection) { |
| 794 visitor->trace(m_treeScope); | 795 visitor->trace(m_treeScope); |
| 795 ContextClient::trace(visitor); | 796 ContextClient::trace(visitor); |
| 796 } | 797 } |
| 797 | 798 |
| 798 } // namespace blink | 799 } // namespace blink |
| OLD | NEW |