OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) | 3 * (C) 2000 Gunnstein Lye (gunnstein@netcom.no) |
4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) | 4 * (C) 2000 Frederik Holljen (frederik.holljen@hig.no) |
5 * (C) 2001 Peter Kelly (pmk@post.com) | 5 * (C) 2001 Peter Kelly (pmk@post.com) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv
ed. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1527 if (n->isReadOnlyNode()) | 1527 if (n->isReadOnlyNode()) |
1528 return true; | 1528 return true; |
1529 } | 1529 } |
1530 for (Node* n = m_end.container(); n; n = n->parentNode()) { | 1530 for (Node* n = m_end.container(); n; n = n->parentNode()) { |
1531 if (n->isReadOnlyNode()) | 1531 if (n->isReadOnlyNode()) |
1532 return true; | 1532 return true; |
1533 } | 1533 } |
1534 return false; | 1534 return false; |
1535 } | 1535 } |
1536 | 1536 |
| 1537 bool Range::getLocationAndLength(unsigned& location, unsigned& length) |
| 1538 { |
| 1539 location = notFound; |
| 1540 length = 0; |
| 1541 |
| 1542 if (!startContainer()) |
| 1543 return false; |
| 1544 |
| 1545 Element* selectionRoot = ownerDocument()->frame()->selection()->rootEditable
Element(); |
| 1546 Element* scope = selectionRoot ? selectionRoot : ownerDocument()->documentEl
ement(); |
| 1547 |
| 1548 // Mouse events may cause TSM to attempt to create an NSRange for a portion
of the view |
| 1549 // that is not inside the current editable region. These checks ensure we d
on't produce |
| 1550 // potentially invalid data when responding to such requests. |
| 1551 if (startContainer() != scope && !startContainer()->isDescendantOf(scope)) |
| 1552 return false; |
| 1553 if (endContainer() != scope && !endContainer()->isDescendantOf(scope)) |
| 1554 return false; |
| 1555 |
| 1556 RefPtr<Range> testRange = Range::create(scope->document(), scope, 0, startCo
ntainer(), startOffset()); |
| 1557 ASSERT(testRange->startContainer() == scope); |
| 1558 location = TextIterator::rangeLength(testRange.get()); |
| 1559 |
| 1560 ExceptionCode ec; |
| 1561 testRange->setEnd(endContainer(), endOffset(), ec); |
| 1562 ASSERT(testRange->startContainer() == scope); |
| 1563 length = TextIterator::rangeLength(testRange.get()) - location; |
| 1564 return true; |
| 1565 } |
| 1566 |
1537 Node* Range::firstNode() const | 1567 Node* Range::firstNode() const |
1538 { | 1568 { |
1539 if (!m_start.container()) | 1569 if (!m_start.container()) |
1540 return 0; | 1570 return 0; |
1541 if (m_start.container()->offsetInCharacters()) | 1571 if (m_start.container()->offsetInCharacters()) |
1542 return m_start.container(); | 1572 return m_start.container(); |
1543 if (Node* child = m_start.container()->childNode(m_start.offset())) | 1573 if (Node* child = m_start.container()->childNode(m_start.offset())) |
1544 return child; | 1574 return child; |
1545 if (!m_start.offset()) | 1575 if (!m_start.offset()) |
1546 return m_start.container(); | 1576 return m_start.container(); |
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1971 | 2001 |
1972 void showTree(const WebCore::Range* range) | 2002 void showTree(const WebCore::Range* range) |
1973 { | 2003 { |
1974 if (range && range->boundaryPointsValid()) { | 2004 if (range && range->boundaryPointsValid()) { |
1975 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); | 2005 range->startContainer()->showTreeAndMark(range->startContainer(), "S", r
ange->endContainer(), "E"); |
1976 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); | 2006 fprintf(stderr, "start offset: %d, end offset: %d\n", range->startOffset
(), range->endOffset()); |
1977 } | 2007 } |
1978 } | 2008 } |
1979 | 2009 |
1980 #endif | 2010 #endif |
OLD | NEW |