OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2009 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 if (!renderer) | 72 if (!renderer) |
73 continue; | 73 continue; |
74 if (!node->rendererIsEditable()) | 74 if (!node->rendererIsEditable()) |
75 continue; | 75 continue; |
76 if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) ||
(renderer->isText() && toRenderText(renderer)->firstTextBox())) | 76 if ((renderer->isBox() && toRenderBox(renderer)->inlineBoxWrapper()) ||
(renderer->isText() && toRenderText(renderer)->firstTextBox())) |
77 return node; | 77 return node; |
78 } | 78 } |
79 return 0; | 79 return 0; |
80 } | 80 } |
81 | 81 |
82 Position::Position(PassRefPtr<Node> anchorNode, LegacyEditingOffset offset) | 82 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, LegacyEditingOffset
offset) |
83 : m_anchorNode(anchorNode) | 83 : m_anchorNode(anchorNode) |
84 , m_offset(offset.value()) | 84 , m_offset(offset.value()) |
85 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs
et)) | 85 , m_anchorType(anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_offs
et)) |
86 , m_isLegacyEditingPosition(true) | 86 , m_isLegacyEditingPosition(true) |
87 { | 87 { |
88 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); | 88 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); |
89 } | 89 } |
90 | 90 |
91 Position::Position(PassRefPtr<Node> anchorNode, AnchorType anchorType) | 91 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, AnchorType anchorTyp
e) |
92 : m_anchorNode(anchorNode) | 92 : m_anchorNode(anchorNode) |
93 , m_offset(0) | 93 , m_offset(0) |
94 , m_anchorType(anchorType) | 94 , m_anchorType(anchorType) |
95 , m_isLegacyEditingPosition(false) | 95 , m_isLegacyEditingPosition(false) |
96 { | 96 { |
97 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); | 97 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); |
98 | 98 |
99 ASSERT(anchorType != PositionIsOffsetInAnchor); | 99 ASSERT(anchorType != PositionIsOffsetInAnchor); |
100 ASSERT(!((anchorType == PositionIsBeforeChildren || anchorType == PositionIs
AfterChildren) | 100 ASSERT(!((anchorType == PositionIsBeforeChildren || anchorType == PositionIs
AfterChildren) |
101 && (m_anchorNode->isTextNode() || editingIgnoresContent(m_anchorNode.get
())))); | 101 && (m_anchorNode->isTextNode() || editingIgnoresContent(m_anchorNode.get
())))); |
102 } | 102 } |
103 | 103 |
104 Position::Position(PassRefPtr<Node> anchorNode, int offset, AnchorType anchorTyp
e) | 104 Position::Position(PassRefPtrWillBeRawPtr<Node> anchorNode, int offset, AnchorTy
pe anchorType) |
105 : m_anchorNode(anchorNode) | 105 : m_anchorNode(anchorNode) |
106 , m_offset(offset) | 106 , m_offset(offset) |
107 , m_anchorType(anchorType) | 107 , m_anchorType(anchorType) |
108 , m_isLegacyEditingPosition(false) | 108 , m_isLegacyEditingPosition(false) |
109 { | 109 { |
110 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); | 110 ASSERT(!m_anchorNode || !m_anchorNode->isPseudoElement()); |
111 | 111 |
112 ASSERT(anchorType == PositionIsOffsetInAnchor); | 112 ASSERT(anchorType == PositionIsOffsetInAnchor); |
113 } | 113 } |
114 | 114 |
115 Position::Position(PassRefPtrWillBeRawPtr<Text> textNode, unsigned offset) | 115 Position::Position(PassRefPtrWillBeRawPtr<Text> textNode, unsigned offset) |
116 : m_anchorNode(textNode) | 116 : m_anchorNode(textNode) |
117 , m_offset(static_cast<int>(offset)) | 117 , m_offset(static_cast<int>(offset)) |
118 , m_anchorType(PositionIsOffsetInAnchor) | 118 , m_anchorType(PositionIsOffsetInAnchor) |
119 , m_isLegacyEditingPosition(false) | 119 , m_isLegacyEditingPosition(false) |
120 { | 120 { |
121 ASSERT(m_anchorNode); | 121 ASSERT(m_anchorNode); |
122 } | 122 } |
123 | 123 |
124 void Position::moveToPosition(PassRefPtr<Node> node, int offset) | 124 void Position::moveToPosition(PassRefPtrWillBeRawPtr<Node> node, int offset) |
125 { | 125 { |
126 ASSERT(!editingIgnoresContent(node.get())); | 126 ASSERT(!editingIgnoresContent(node.get())); |
127 ASSERT(anchorType() == PositionIsOffsetInAnchor || m_isLegacyEditingPosition
); | 127 ASSERT(anchorType() == PositionIsOffsetInAnchor || m_isLegacyEditingPosition
); |
128 m_anchorNode = node; | 128 m_anchorNode = node; |
129 m_offset = offset; | 129 m_offset = offset; |
130 if (m_isLegacyEditingPosition) | 130 if (m_isLegacyEditingPosition) |
131 m_anchorType = anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_
offset); | 131 m_anchorType = anchorTypeForLegacyEditingPosition(m_anchorNode.get(), m_
offset); |
132 } | 132 } |
133 void Position::moveToOffset(int offset) | 133 void Position::moveToOffset(int offset) |
134 { | 134 { |
(...skipping 1144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 for (const RenderObject* r = m_anchorNode->renderer(); r; r = r->parent()) { | 1279 for (const RenderObject* r = m_anchorNode->renderer(); r; r = r->parent()) { |
1280 if (r->isRenderBlockFlow()) { | 1280 if (r->isRenderBlockFlow()) { |
1281 primaryDirection = r->style()->direction(); | 1281 primaryDirection = r->style()->direction(); |
1282 break; | 1282 break; |
1283 } | 1283 } |
1284 } | 1284 } |
1285 | 1285 |
1286 return primaryDirection; | 1286 return primaryDirection; |
1287 } | 1287 } |
1288 | 1288 |
| 1289 void Position::trace(Visitor* visitor) |
| 1290 { |
| 1291 visitor->trace(m_anchorNode); |
| 1292 } |
1289 | 1293 |
1290 void Position::debugPosition(const char* msg) const | 1294 void Position::debugPosition(const char* msg) const |
1291 { | 1295 { |
1292 if (isNull()) | 1296 if (isNull()) |
1293 fprintf(stderr, "Position [%s]: null\n", msg); | 1297 fprintf(stderr, "Position [%s]: null\n", msg); |
1294 else | 1298 else |
1295 fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, deprecatedNode()-
>nodeName().utf8().data(), deprecatedNode(), m_offset); | 1299 fprintf(stderr, "Position [%s]: %s [%p] at %d\n", msg, deprecatedNode()-
>nodeName().utf8().data(), deprecatedNode(), m_offset); |
1296 } | 1300 } |
1297 | 1301 |
1298 #ifndef NDEBUG | 1302 #ifndef NDEBUG |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 pos.showTreeForThis(); | 1364 pos.showTreeForThis(); |
1361 } | 1365 } |
1362 | 1366 |
1363 void showTree(const WebCore::Position* pos) | 1367 void showTree(const WebCore::Position* pos) |
1364 { | 1368 { |
1365 if (pos) | 1369 if (pos) |
1366 pos->showTreeForThis(); | 1370 pos->showTreeForThis(); |
1367 } | 1371 } |
1368 | 1372 |
1369 #endif | 1373 #endif |
OLD | NEW |