| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 int offsetB = hasDescendentB ? 0 : b.computeOffsetInContainerNode(); | 90 int offsetB = hasDescendentB ? 0 : b.computeOffsetInContainerNode(); |
| 91 | 91 |
| 92 int bias = 0; | 92 int bias = 0; |
| 93 if (nodeA == nodeB) { | 93 if (nodeA == nodeB) { |
| 94 if (hasDescendentA) | 94 if (hasDescendentA) |
| 95 bias = -1; | 95 bias = -1; |
| 96 else if (hasDescendentB) | 96 else if (hasDescendentB) |
| 97 bias = 1; | 97 bias = 1; |
| 98 } | 98 } |
| 99 | 99 |
| 100 int result = Range::compareBoundaryPoints(nodeA, offsetA, nodeB, offsetB, IG
NORE_EXCEPTION_STATE); | 100 int result = Range::compareBoundaryPoints(nodeA, offsetA, nodeB, offsetB, IG
NORE_EXCEPTION); |
| 101 return result ? result : bias; | 101 return result ? result : bias; |
| 102 } | 102 } |
| 103 | 103 |
| 104 int comparePositions(const VisiblePosition& a, const VisiblePosition& b) | 104 int comparePositions(const VisiblePosition& a, const VisiblePosition& b) |
| 105 { | 105 { |
| 106 return comparePositions(a.deepEquivalent(), b.deepEquivalent()); | 106 return comparePositions(a.deepEquivalent(), b.deepEquivalent()); |
| 107 } | 107 } |
| 108 | 108 |
| 109 Node* highestEditableRoot(const Position& position, EditableType editableType) | 109 Node* highestEditableRoot(const Position& position, EditableType editableType) |
| 110 { | 110 { |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 | 890 |
| 891 // Make the span to hold the tab. | 891 // Make the span to hold the tab. |
| 892 RefPtr<Element> spanElement = document->createElement(spanTag, false); | 892 RefPtr<Element> spanElement = document->createElement(spanTag, false); |
| 893 spanElement->setAttribute(classAttr, AppleTabSpanClass); | 893 spanElement->setAttribute(classAttr, AppleTabSpanClass); |
| 894 spanElement->setAttribute(styleAttr, "white-space:pre"); | 894 spanElement->setAttribute(styleAttr, "white-space:pre"); |
| 895 | 895 |
| 896 // Add tab text to that span. | 896 // Add tab text to that span. |
| 897 if (!tabTextNode) | 897 if (!tabTextNode) |
| 898 tabTextNode = document->createEditingTextNode("\t"); | 898 tabTextNode = document->createEditingTextNode("\t"); |
| 899 | 899 |
| 900 spanElement->appendChild(tabTextNode.release(), ASSERT_NO_EXCEPTION_STATE); | 900 spanElement->appendChild(tabTextNode.release(), ASSERT_NO_EXCEPTION); |
| 901 | 901 |
| 902 return spanElement.release(); | 902 return spanElement.release(); |
| 903 } | 903 } |
| 904 | 904 |
| 905 PassRefPtr<Element> createTabSpanElement(Document* document, const String& tabTe
xt) | 905 PassRefPtr<Element> createTabSpanElement(Document* document, const String& tabTe
xt) |
| 906 { | 906 { |
| 907 return createTabSpanElement(document, document->createTextNode(tabText)); | 907 return createTabSpanElement(document, document->createTextNode(tabText)); |
| 908 } | 908 } |
| 909 | 909 |
| 910 PassRefPtr<Element> createTabSpanElement(Document* document) | 910 PassRefPtr<Element> createTabSpanElement(Document* document) |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1084 return VisiblePosition(first) == VisiblePosition(second.upstream()); | 1084 return VisiblePosition(first) == VisiblePosition(second.upstream()); |
| 1085 } | 1085 } |
| 1086 | 1086 |
| 1087 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. | 1087 // Determines whether a node is inside a range or visibly starts and ends at the
boundaries of the range. |
| 1088 // Call this function to determine whether a node is visibly fit inside selected
Range | 1088 // Call this function to determine whether a node is visibly fit inside selected
Range |
| 1089 bool isNodeVisiblyContainedWithin(Node* node, const Range* selectedRange) | 1089 bool isNodeVisiblyContainedWithin(Node* node, const Range* selectedRange) |
| 1090 { | 1090 { |
| 1091 ASSERT(node); | 1091 ASSERT(node); |
| 1092 ASSERT(selectedRange); | 1092 ASSERT(selectedRange); |
| 1093 // If the node is inside the range, then it surely is contained within | 1093 // If the node is inside the range, then it surely is contained within |
| 1094 if (selectedRange->compareNode(node, IGNORE_EXCEPTION_STATE) == Range::NODE_
INSIDE) | 1094 if (selectedRange->compareNode(node, IGNORE_EXCEPTION) == Range::NODE_INSIDE
) |
| 1095 return true; | 1095 return true; |
| 1096 | 1096 |
| 1097 bool startIsVisuallySame = visiblePositionBeforeNode(node) == selectedRange-
>startPosition(); | 1097 bool startIsVisuallySame = visiblePositionBeforeNode(node) == selectedRange-
>startPosition(); |
| 1098 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange->endPosition()) < 0) | 1098 if (startIsVisuallySame && comparePositions(positionInParentAfterNode(node),
selectedRange->endPosition()) < 0) |
| 1099 return true; | 1099 return true; |
| 1100 | 1100 |
| 1101 bool endIsVisuallySame = visiblePositionAfterNode(node) == selectedRange->en
dPosition(); | 1101 bool endIsVisuallySame = visiblePositionAfterNode(node) == selectedRange->en
dPosition(); |
| 1102 if (endIsVisuallySame && comparePositions(selectedRange->startPosition(), po
sitionInParentBeforeNode(node)) < 0) | 1102 if (endIsVisuallySame && comparePositions(selectedRange->startPosition(), po
sitionInParentBeforeNode(node)) < 0) |
| 1103 return true; | 1103 return true; |
| 1104 | 1104 |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 // if the selection starts just before a paragraph break, skip over it | 1160 // if the selection starts just before a paragraph break, skip over it |
| 1161 if (isEndOfParagraph(visiblePosition)) | 1161 if (isEndOfParagraph(visiblePosition)) |
| 1162 return visiblePosition.next().deepEquivalent().downstream(); | 1162 return visiblePosition.next().deepEquivalent().downstream(); |
| 1163 | 1163 |
| 1164 // otherwise, make sure to be at the start of the first selected node, | 1164 // otherwise, make sure to be at the start of the first selected node, |
| 1165 // instead of possibly at the end of the last node before the selection | 1165 // instead of possibly at the end of the last node before the selection |
| 1166 return visiblePosition.deepEquivalent().downstream(); | 1166 return visiblePosition.deepEquivalent().downstream(); |
| 1167 } | 1167 } |
| 1168 | 1168 |
| 1169 } // namespace WebCore | 1169 } // namespace WebCore |
| OLD | NEW |