Changeset 48235 in webkit
- Timestamp:
- Sep 9, 2009, 4:25:53 PM (16 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r48234 r48235 1 1 2009-07-30 Eric Seidel <eric@webkit.org> 2 3 Reviewed by Adam Barth. 4 5 Add more position constructors 6 positionBeforeNode, positionAfterNode 7 firstPositionInNode, lastPositionInNode 8 https://bugs.webkit.org/show_bug.cgi?id=25494 9 10 I also added a lastOffsetInNode and deployed it to a couple places. 11 12 There are no callers to these new constructors yet, but those 13 will be coming in future patches. 14 15 * dom/Position.cpp: 16 (WebCore::Position::computeOffsetInContainerNode): 17 * dom/Position.h: 18 (WebCore::positionBeforeNode): 19 (WebCore::positionAfterNode): 20 (WebCore::lastOffsetInNode): 21 (WebCore::firstPositionInNode): 22 (WebCore::lastPositionInNode): 23 * editing/ApplyStyleCommand.cpp: 24 * editing/TextIterator.cpp: 25 (WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator): 26 * editing/htmlediting.cpp: 27 (WebCore::lastOffsetForEditing): 28 29 2009-04-30 Eric Seidel <eric@webkit.org> 2 30 3 31 Reviewed by Adam Barth. -
trunk/WebCore/dom/Position.cpp
r48233 r48235 139 139 switch (anchorType()) { 140 140 case PositionIsOffsetInAnchor: 141 { 142 int maximumValidOffset = m_anchorNode->offsetInCharacters() ? m_anchorNode->maxCharacterOffset() : m_anchorNode->childNodeCount(); 143 return std::min(maximumValidOffset, m_offset); 144 } 141 return std::min(lastOffsetInNode(m_anchorNode.get()), m_offset); 145 142 case PositionIsBeforeAnchor: 146 143 return m_anchorNode->nodeIndex(); -
trunk/WebCore/dom/Position.h
r48234 r48235 209 209 } 210 210 211 // positionBeforeNode and positionAfterNode return neighbor-anchored positions, construction is O(1) 212 inline Position positionBeforeNode(Node* anchorNode) 213 { 214 ASSERT(anchorNode); 215 return Position(anchorNode, Position::PositionIsBeforeAnchor); 216 } 217 218 inline Position positionAfterNode(Node* anchorNode) 219 { 220 ASSERT(anchorNode); 221 return Position(anchorNode, Position::PositionIsAfterAnchor); 222 } 223 224 inline int lastOffsetInNode(Node* node) 225 { 226 return node->offsetInCharacters() ? node->maxCharacterOffset() : node->childNodeCount(); 227 } 228 229 // firstPositionInNode and lastPositionInNode return parent-anchored positions, lastPositionInNode construction is O(n) due to childNodeCount() 230 inline Position firstPositionInNode(Node* anchorNode) 231 { 232 return Position(anchorNode, 0, Position::PositionIsOffsetInAnchor); 233 } 234 235 inline Position lastPositionInNode(Node* anchorNode) 236 { 237 return Position(anchorNode, lastOffsetInNode(anchorNode), Position::PositionIsOffsetInAnchor); 238 } 239 211 240 } // namespace WebCore 212 241 -
trunk/WebCore/editing/ApplyStyleCommand.cpp
r48234 r48235 1380 1380 } 1381 1381 1382 // FIXME: Why does this exist? Callers should either use lastOffsetForEditing or lastOffsetInNode 1382 1383 static int maxRangeOffset(Node *n) 1383 1384 { -
trunk/WebCore/editing/TextIterator.cpp
r46647 r48235 34 34 #include "htmlediting.h" 35 35 #include "InlineTextBox.h" 36 #include "Position.h"37 36 #include "Range.h" 38 37 #include "RenderTableCell.h" … … 942 941 if (endOffset > 0 && endOffset <= static_cast<int>(endNode->childNodeCount())) { 943 942 endNode = endNode->childNode(endOffset - 1); 944 endOffset = endNode->offsetInCharacters() ? endNode->maxCharacterOffset() : endNode->childNodeCount();943 endOffset = lastOffsetInNode(endNode); 945 944 } 946 945 } -
trunk/WebCore/editing/htmlediting.cpp
r48234 r48235 385 385 if (node->offsetInCharacters()) 386 386 return node->maxCharacterOffset(); 387 387 388 388 if (node->hasChildNodes()) 389 389 return node->childNodeCount(); 390 390 391 391 // NOTE: This should preempt the childNodeCount for, e.g., select nodes 392 392 if (editingIgnoresContent(node))
Note:
See TracChangeset
for help on using the changeset viewer.