| 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 selectedRange->startContainer(), | 623 selectedRange->startContainer(), |
| 624 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); | 624 selectedRange->startOffset(), ASSERT_NO_EXCEPTION); |
| 625 } | 625 } |
| 626 | 626 |
| 627 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { | 627 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const { |
| 628 DCHECK(n); | 628 DCHECK(n); |
| 629 | 629 |
| 630 if (!isAvailable()) | 630 if (!isAvailable()) |
| 631 return false; | 631 return false; |
| 632 | 632 |
| 633 FrameSelection& selection = frame()->selection(); | 633 if (frame()->document() != n->document()) |
| 634 | |
| 635 if (frame()->document() != n->document() || selection.isNone()) | |
| 636 return false; | 634 return false; |
| 637 | 635 |
| 638 unsigned nodeIndex = n->nodeIndex(); | 636 unsigned nodeIndex = n->nodeIndex(); |
| 639 | 637 |
| 640 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets | 638 // TODO(xiaochengh): The use of updateStyleAndLayoutIgnorePendingStylesheets |
| 641 // needs to be audited. See http://crbug.com/590369 for more details. | 639 // needs to be audited. See http://crbug.com/590369 for more details. |
| 642 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. | 640 // |VisibleSelection::toNormalizedEphemeralRange| requires clean layout. |
| 643 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); | 641 frame()->document()->updateStyleAndLayoutIgnorePendingStylesheets(); |
| 644 | 642 |
| 643 FrameSelection& selection = frame()->selection(); |
| 645 const EphemeralRange selectedRange = | 644 const EphemeralRange selectedRange = |
| 646 selection.selection().toNormalizedEphemeralRange(); | 645 selection.selection().toNormalizedEphemeralRange(); |
| 646 if (selectedRange.isNull()) |
| 647 return false; |
| 647 | 648 |
| 648 ContainerNode* parentNode = n->parentNode(); | 649 ContainerNode* parentNode = n->parentNode(); |
| 649 if (!parentNode) | 650 if (!parentNode) |
| 650 return false; | 651 return false; |
| 651 | 652 |
| 652 const Position startPosition = | 653 const Position startPosition = |
| 653 selectedRange.startPosition().toOffsetInAnchor(); | 654 selectedRange.startPosition().toOffsetInAnchor(); |
| 654 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); | 655 const Position endPosition = selectedRange.endPosition().toOffsetInAnchor(); |
| 655 DummyExceptionStateForTesting exceptionState; | 656 DummyExceptionStateForTesting exceptionState; |
| 656 bool nodeFullySelected = | 657 bool nodeFullySelected = |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 m_treeScope->document().addConsoleMessage( | 754 m_treeScope->document().addConsoleMessage( |
| 754 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); | 755 ConsoleMessage::create(JSMessageSource, ErrorMessageLevel, message)); |
| 755 } | 756 } |
| 756 | 757 |
| 757 DEFINE_TRACE(DOMSelection) { | 758 DEFINE_TRACE(DOMSelection) { |
| 758 visitor->trace(m_treeScope); | 759 visitor->trace(m_treeScope); |
| 759 ContextClient::trace(visitor); | 760 ContextClient::trace(visitor); |
| 760 } | 761 } |
| 761 | 762 |
| 762 } // namespace blink | 763 } // namespace blink |
| OLD | NEW |