| 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 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const | 447 bool DOMSelection::containsNode(const Node* n, bool allowPartial) const |
| 448 { | 448 { |
| 449 if (!m_frame) | 449 if (!m_frame) |
| 450 return false; | 450 return false; |
| 451 | 451 |
| 452 FrameSelection* selection = m_frame->selection(); | 452 FrameSelection* selection = m_frame->selection(); |
| 453 | 453 |
| 454 if (!n || m_frame->document() != n->document() || selection->isNone()) | 454 if (!n || m_frame->document() != n->document() || selection->isNone()) |
| 455 return false; | 455 return false; |
| 456 | 456 |
| 457 ContainerNode* parentNode = n->parentNode(); | |
| 458 unsigned nodeIndex = n->nodeIndex(); | 457 unsigned nodeIndex = n->nodeIndex(); |
| 459 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); | 458 RefPtr<Range> selectedRange = selection->selection().toNormalizedRange(); |
| 460 | 459 |
| 460 ContainerNode* parentNode = n->parentNode(); |
| 461 if (!parentNode) | 461 if (!parentNode) |
| 462 return false; | 462 return false; |
| 463 | 463 |
| 464 ExceptionCode ec = 0; | 464 ExceptionCode ec = 0; |
| 465 bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex,
selectedRange->startContainer(), selectedRange->startOffset(), ec) >= 0 && !ec | 465 bool nodeFullySelected = Range::compareBoundaryPoints(parentNode, nodeIndex,
selectedRange->startContainer(), selectedRange->startOffset(), ec) >= 0 && !ec |
| 466 && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange
->endContainer(), selectedRange->endOffset(), ec) <= 0 && !ec; | 466 && Range::compareBoundaryPoints(parentNode, nodeIndex + 1, selectedRange
->endContainer(), selectedRange->endOffset(), ec) <= 0 && !ec; |
| 467 ASSERT(!ec); | 467 ASSERT(!ec); |
| 468 if (nodeFullySelected) | 468 if (nodeFullySelected) |
| 469 return true; | 469 return true; |
| 470 | 470 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 530 | 530 |
| 531 bool DOMSelection::isValidForPosition(Node* node) const | 531 bool DOMSelection::isValidForPosition(Node* node) const |
| 532 { | 532 { |
| 533 ASSERT(m_frame); | 533 ASSERT(m_frame); |
| 534 if (!node) | 534 if (!node) |
| 535 return true; | 535 return true; |
| 536 return node->document() == m_frame->document(); | 536 return node->document() == m_frame->document(); |
| 537 } | 537 } |
| 538 | 538 |
| 539 } // namespace WebCore | 539 } // namespace WebCore |
| OLD | NEW |