OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2007, 2008 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 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 RefPtrWillBeRawPtr<Text> node(prpNode); | 486 RefPtrWillBeRawPtr<Text> node(prpNode); |
487 applyCommandToComposite(DeleteFromTextNodeCommand::create(node, offset, coun
t)); | 487 applyCommandToComposite(DeleteFromTextNodeCommand::create(node, offset, coun
t)); |
488 if (!replacementText.isEmpty()) | 488 if (!replacementText.isEmpty()) |
489 applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset,
replacementText)); | 489 applyCommandToComposite(InsertIntoTextNodeCommand::create(node, offset,
replacementText)); |
490 } | 490 } |
491 | 491 |
492 Position CompositeEditCommand::replaceSelectedTextInNode(const String& text) | 492 Position CompositeEditCommand::replaceSelectedTextInNode(const String& text) |
493 { | 493 { |
494 Position start = endingSelection().start(); | 494 Position start = endingSelection().start(); |
495 Position end = endingSelection().end(); | 495 Position end = endingSelection().end(); |
496 if (start.containerNode() != end.containerNode() || !start.containerNode()->
isTextNode() || isTabSpanTextNode(start.containerNode())) | 496 if (start.containerNode() != end.containerNode() || !start.containerNode()->
isTextNode() || isTabHTMLSpanElementTextNode(start.containerNode())) |
497 return Position(); | 497 return Position(); |
498 | 498 |
499 RefPtrWillBeRawPtr<Text> textNode = start.containerText(); | 499 RefPtrWillBeRawPtr<Text> textNode = start.containerText(); |
500 replaceTextInNode(textNode, start.offsetInContainerNode(), end.offsetInConta
inerNode() - start.offsetInContainerNode(), text); | 500 replaceTextInNode(textNode, start.offsetInContainerNode(), end.offsetInConta
inerNode() - start.offsetInContainerNode(), text); |
501 | 501 |
502 return Position(textNode.release(), start.offsetInContainerNode() + text.len
gth()); | 502 return Position(textNode.release(), start.offsetInContainerNode() + text.len
gth()); |
503 } | 503 } |
504 | 504 |
505 static void copyMarkerTypesAndDescriptions(const DocumentMarkerVector& markerPoi
nters, Vector<DocumentMarker::MarkerType>& types, Vector<String>& descriptions) | 505 static void copyMarkerTypesAndDescriptions(const DocumentMarkerVector& markerPoi
nters, Vector<DocumentMarker::MarkerType>& types, Vector<String>& descriptions) |
506 { | 506 { |
(...skipping 15 matching lines...) Expand all Loading... |
522 copyMarkerTypesAndDescriptions(markerController.markersInRange(Range::create
(document(), node.get(), offset, node.get(), offset + count).get(), DocumentMark
er::AllMarkers()), types, descriptions); | 522 copyMarkerTypesAndDescriptions(markerController.markersInRange(Range::create
(document(), node.get(), offset, node.get(), offset + count).get(), DocumentMark
er::AllMarkers()), types, descriptions); |
523 replaceTextInNode(node, offset, count, replacementText); | 523 replaceTextInNode(node, offset, count, replacementText); |
524 RefPtrWillBeRawPtr<Range> newRange = Range::create(document(), node.get(), o
ffset, node.get(), offset + replacementText.length()); | 524 RefPtrWillBeRawPtr<Range> newRange = Range::create(document(), node.get(), o
ffset, node.get(), offset + replacementText.length()); |
525 ASSERT(types.size() == descriptions.size()); | 525 ASSERT(types.size() == descriptions.size()); |
526 for (size_t i = 0; i < types.size(); ++i) | 526 for (size_t i = 0; i < types.size(); ++i) |
527 markerController.addMarker(newRange.get(), types[i], descriptions[i]); | 527 markerController.addMarker(newRange.get(), types[i], descriptions[i]); |
528 } | 528 } |
529 | 529 |
530 Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos) | 530 Position CompositeEditCommand::positionOutsideTabSpan(const Position& pos) |
531 { | 531 { |
532 if (!isTabSpanTextNode(pos.anchorNode())) | 532 if (!isTabHTMLSpanElementTextNode(pos.anchorNode())) |
533 return pos; | 533 return pos; |
534 | 534 |
535 switch (pos.anchorType()) { | 535 switch (pos.anchorType()) { |
536 case Position::PositionIsBeforeChildren: | 536 case Position::PositionIsBeforeChildren: |
537 case Position::PositionIsAfterChildren: | 537 case Position::PositionIsAfterChildren: |
538 ASSERT_NOT_REACHED(); | 538 ASSERT_NOT_REACHED(); |
539 return pos; | 539 return pos; |
540 case Position::PositionIsOffsetInAnchor: | 540 case Position::PositionIsOffsetInAnchor: |
541 break; | 541 break; |
542 case Position::PositionIsBeforeAnchor: | 542 case Position::PositionIsBeforeAnchor: |
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 // If listNode does NOT appear at the end of the outer list item, th
en behave as if in a regular paragraph. | 1319 // If listNode does NOT appear at the end of the outer list item, th
en behave as if in a regular paragraph. |
1320 } else if (isHTMLOListElement(*blockEnclosingList) || isHTMLUListElement
(*blockEnclosingList)) { | 1320 } else if (isHTMLOListElement(*blockEnclosingList) || isHTMLUListElement
(*blockEnclosingList)) { |
1321 newBlock = createListItemElement(document()); | 1321 newBlock = createListItemElement(document()); |
1322 } | 1322 } |
1323 } | 1323 } |
1324 if (!newBlock) | 1324 if (!newBlock) |
1325 newBlock = createDefaultParagraphElement(document()); | 1325 newBlock = createDefaultParagraphElement(document()); |
1326 | 1326 |
1327 RefPtrWillBeRawPtr<Node> previousListNode = emptyListItem->isElementNode() ?
ElementTraversal::previousSibling(*emptyListItem): emptyListItem->previousSibli
ng(); | 1327 RefPtrWillBeRawPtr<Node> previousListNode = emptyListItem->isElementNode() ?
ElementTraversal::previousSibling(*emptyListItem): emptyListItem->previousSibli
ng(); |
1328 RefPtrWillBeRawPtr<Node> nextListNode = emptyListItem->isElementNode() ? Ele
mentTraversal::nextSibling(*emptyListItem): emptyListItem->nextSibling(); | 1328 RefPtrWillBeRawPtr<Node> nextListNode = emptyListItem->isElementNode() ? Ele
mentTraversal::nextSibling(*emptyListItem): emptyListItem->nextSibling(); |
1329 if (isListItem(nextListNode.get()) || isListElement(nextListNode.get())) { | 1329 if (isListItem(nextListNode.get()) || isHTMLListElement(nextListNode.get()))
{ |
1330 // If emptyListItem follows another list item or nested list, split the
list node. | 1330 // If emptyListItem follows another list item or nested list, split the
list node. |
1331 if (isListItem(previousListNode.get()) || isListElement(previousListNode
.get())) | 1331 if (isListItem(previousListNode.get()) || isHTMLListElement(previousList
Node.get())) |
1332 splitElement(toElement(listNode), emptyListItem); | 1332 splitElement(toElement(listNode), emptyListItem); |
1333 | 1333 |
1334 // If emptyListItem is followed by other list item or nested list, then
insert newBlock before the list node. | 1334 // If emptyListItem is followed by other list item or nested list, then
insert newBlock before the list node. |
1335 // Because we have splitted the element, emptyListItem is the first elem
ent in the list node. | 1335 // Because we have splitted the element, emptyListItem is the first elem
ent in the list node. |
1336 // i.e. insert newBlock before ul or ol whose first element is emptyList
Item | 1336 // i.e. insert newBlock before ul or ol whose first element is emptyList
Item |
1337 insertNodeBefore(newBlock, listNode); | 1337 insertNodeBefore(newBlock, listNode); |
1338 removeNode(emptyListItem); | 1338 removeNode(emptyListItem); |
1339 } else { | 1339 } else { |
1340 // When emptyListItem does not follow any list item or nested list, inse
rt newBlock after the enclosing list node. | 1340 // When emptyListItem does not follow any list item or nested list, inse
rt newBlock after the enclosing list node. |
1341 // Remove the enclosing node if emptyListItem is the only child; otherwi
se just remove emptyListItem. | 1341 // Remove the enclosing node if emptyListItem is the only child; otherwi
se just remove emptyListItem. |
1342 insertNodeAfter(newBlock, listNode); | 1342 insertNodeAfter(newBlock, listNode); |
1343 removeNode(isListItem(previousListNode.get()) || isListElement(previousL
istNode.get()) ? emptyListItem.get() : listNode.get()); | 1343 removeNode(isListItem(previousListNode.get()) || isHTMLListElement(previ
ousListNode.get()) ? emptyListItem.get() : listNode.get()); |
1344 } | 1344 } |
1345 | 1345 |
1346 appendBlockPlaceholder(newBlock); | 1346 appendBlockPlaceholder(newBlock); |
1347 setEndingSelection(VisibleSelection(firstPositionInNode(newBlock.get()), DOW
NSTREAM, endingSelection().isDirectional())); | 1347 setEndingSelection(VisibleSelection(firstPositionInNode(newBlock.get()), DOW
NSTREAM, endingSelection().isDirectional())); |
1348 | 1348 |
1349 style->prepareToApplyAt(endingSelection().start()); | 1349 style->prepareToApplyAt(endingSelection().start()); |
1350 if (!style->isEmpty()) | 1350 if (!style->isEmpty()) |
1351 applyStyle(style.get()); | 1351 applyStyle(style.get()); |
1352 | 1352 |
1353 return true; | 1353 return true; |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 } | 1498 } |
1499 | 1499 |
1500 void CompositeEditCommand::trace(Visitor* visitor) | 1500 void CompositeEditCommand::trace(Visitor* visitor) |
1501 { | 1501 { |
1502 visitor->trace(m_commands); | 1502 visitor->trace(m_commands); |
1503 visitor->trace(m_composition); | 1503 visitor->trace(m_composition); |
1504 EditCommand::trace(visitor); | 1504 EditCommand::trace(visitor); |
1505 } | 1505 } |
1506 | 1506 |
1507 } // namespace blink | 1507 } // namespace blink |
OLD | NEW |