Changeset 14169 in webkit
- Timestamp:
- May 2, 2006 8:17:55 PM (18 years ago)
- Location:
- trunk
- Files:
-
- 28 added
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r14155 r14169 1 2006-05-02 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by harrison 4 5 <http://bugzilla.opendarwin.org/show_bug.cgi?id=8704> 6 Fix a few end merge bugs 7 <rdar://problem/4424044> 8 REGRESSION: Extra line appears when typing 9 10 Added a function so that selection changes can participate in slow-motion-mode: 11 * editing/editing.js: 12 Extra newlines were added: 13 * editing/inserting/paragraph-separator-01-expected.checksum: Added. 14 * editing/inserting/paragraph-separator-01-expected.png: Added. 15 * editing/inserting/paragraph-separator-01-expected.txt: Added. 16 * editing/inserting/paragraph-separator-01.html: Added. 17 * editing/inserting/paragraph-separator-02-expected.checksum: Added. 18 * editing/inserting/paragraph-separator-02-expected.png: Added. 19 * editing/inserting/paragraph-separator-02-expected.txt: Added. 20 * editing/inserting/paragraph-separator-02.html: Added. 21 A preserved newline was turned into a nbsp: 22 * editing/inserting/paragraph-separator-03-expected.checksum: Added. 23 * editing/inserting/paragraph-separator-03-expected.png: Added. 24 * editing/inserting/paragraph-separator-03-expected.txt: Added. 25 * editing/inserting/paragraph-separator-03.html: Added. 26 End merge didn't happen: 27 * editing/pasteboard/merge-end-4-expected.checksum: Added. 28 * editing/pasteboard/merge-end-4-expected.png: Added. 29 * editing/pasteboard/merge-end-4-expected.txt: Added. 30 * editing/pasteboard/merge-end-4.html: Added. 31 Content was pulled out of these special elements: 32 * editing/pasteboard/merge-end-blockquote-expected.checksum: Added. 33 * editing/pasteboard/merge-end-blockquote-expected.png: Added. 34 * editing/pasteboard/merge-end-blockquote-expected.txt: Added. 35 * editing/pasteboard/merge-end-blockquote.html: Added. 36 * editing/pasteboard/merge-end-list-expected.checksum: Added. 37 * editing/pasteboard/merge-end-list-expected.png: Added. 38 * editing/pasteboard/merge-end-list-expected.txt: Added. 39 * editing/pasteboard/merge-end-list.html: Added. 40 * editing/pasteboard/merge-end-table-expected.checksum: Added. 41 * editing/pasteboard/merge-end-table-expected.png: Added. 42 * editing/pasteboard/merge-end-table-expected.txt: Added. 43 * editing/pasteboard/merge-end-table.html: Added. 44 1 45 2006-05-02 Anders Carlsson <andersca@mac.com> 2 46 -
trunk/LayoutTests/editing/editing.js
r13851 r14169 10 10 //------------------------------------------------------------------------------------------------------- 11 11 12 function execSetSelectionCommand(sn, so, en, eo) { 13 window.getSelection().setBaseAndExtent(sn, so, en, eo); 14 } 15 function setSelectionCommand(sn, so, en, eo) { 16 if (commandDelay > 0) { 17 window.setTimeout(execSetSelectionCommand, commandCount * commandDelay, sn, so, en, eo); 18 commandCount++; 19 } else 20 execSetSelectionCommand(sn, so, en, eo); 21 } 22 23 //------------------------------------------------------------------------------------------------------- 24 12 25 function execTransposeCharactersCommand() { 13 26 document.execCommand("Transpose"); -
trunk/WebCore/ChangeLog
r14167 r14169 1 2006-05-02 Justin Garcia <justin.garcia@apple.com> 2 3 Reviewed by harrison 4 5 <http://bugzilla.opendarwin.org/show_bug.cgi?id=8704> 6 Fix a few end merge bugs 7 <rdar://problem/4424044> 8 REGRESSION: Extra line appears when typing 9 10 * bridge/mac/WebCoreFrameBridge.mm: 11 (-[WebCoreFrameBridge smartInsertForString:replacingRange:beforeString:afterString:]): 12 Use renamed characterAfter. 13 * editing/InsertParagraphSeparatorCommand.cpp: 14 (WebCore::InsertParagraphSeparatorCommand::doApply): 15 Regenerate a VisiblePosition that became stale during a text node split. 16 Don't rebalance whitespace after the operation, 1) it has a bug that turns preserved 17 newlines into nbsps, 2) I think it should only be done during serialization, not after 18 every command (since editable regions now always have -webkit-nbsp-mode:space on them). 19 Use a regular br for the placeholder as I think we can move away from -webkit-block-placeholders. 20 21 * editing/RebalanceWhitespaceCommand.cpp: Added FIXMEs. 22 * editing/ReplaceSelectionCommand.cpp: 23 (WebCore::ReplaceSelectionCommand::shouldMergeStart): Removed FIXME. 24 (WebCore::ReplaceSelectionCommand::shouldMergeEnd): Can now use rendering information. 25 (WebCore::ReplaceSelectionCommand::doApply): 26 Call shouldMergeEnd after the insertion so that it can use rendering information. 27 Don't use positionAfterNode of the last node inserted to mark the position at the end 28 of inserted content because canonicalization can send it into content that was already 29 in the document. 30 31 * editing/ReplaceSelectionCommand.h: 32 * editing/VisiblePosition.cpp: 33 (WebCore::VisiblePosition::characterAfter): 34 Renamed. When two candidates are visually equivalent, the rightmost candidate will be 35 the one inside the text node where the character will be. 36 37 * editing/VisiblePosition.h: 38 * editing/htmlediting.cpp: 39 (WebCore::enclosingTableCell): Added. 40 (WebCore::enclosingList): 41 * editing/htmlediting.h: 42 1 43 2006-05-02 David Hyatt <hyatt@apple.com> 2 44 -
trunk/WebCore/bridge/mac/WebCoreFrameBridge.mm
r14110 r14169 1817 1817 bool addLeadingSpace = startPos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isStartOfParagraph(startVisiblePos); 1818 1818 if (addLeadingSpace) { 1819 QChar previousChar = startVisiblePos.previous().character ();1819 QChar previousChar = startVisiblePos.previous().characterAfter(); 1820 1820 if (!previousChar.isNull()) { 1821 1821 addLeadingSpace = !m_frame->isCharacterSmartReplaceExempt(previousChar, true); … … 1825 1825 bool addTrailingSpace = endPos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isEndOfParagraph(endVisiblePos); 1826 1826 if (addTrailingSpace) { 1827 QChar thisChar = endVisiblePos.character ();1827 QChar thisChar = endVisiblePos.characterAfter(); 1828 1828 if (!thisChar.isNull()) { 1829 1829 addTrailingSpace = !m_frame->isCharacterSmartReplaceExempt(thisChar, false); -
trunk/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r13821 r14169 266 266 // FIXME: We need the affinity for pos, but pos.downstream() does not give it 267 267 Position leadingWhitespace = pos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY); 268 // FIXME: leadingWhitespacePosition is returning the position before preserved newlines for positions 269 // after the preserved newline, causing the newline to be turned into a nbsp. 268 270 if (leadingWhitespace.isNotNull()) { 269 271 Text *textNode = static_cast<Text *>(leadingWhitespace.node()); … … 278 280 splitTextNode(textNode, pos.offset()); 279 281 pos = Position(startNode, 0); 282 visiblePos = VisiblePosition(pos); 280 283 splitText = true; 281 284 } … … 296 299 } 297 300 298 // I nsert a block placeholder if the next visible position is in a different paragraph,299 // because we know that there will be no content on the first line of the new block300 // before the first block child. So, we need the placeholder to "hold the first line open".301 VisiblePosition next = visiblePos.next();302 if (!next.isNull() && !inSameBlock(visiblePos, next))303 append BlockPlaceholder(blockToInsert.get());304 301 // If the paragraph separator was inserted at the end of a paragraph, an empty line must be 302 // created. All of the nodes, starting at visiblePos, are about to be added to the new paragraph 303 // element. If the first node to be inserted won't be one that will hold an empty line open, add a br. 304 if (isEndOfParagraph(visiblePos) && !startNode->hasTagName(brTag) && 305 !(startNode->renderer()->style()->preserveNewline() && visiblePos.characterAfter() == '\n')) 306 appendNode(createBreakElement(document()).get(), blockToInsert.get()); 307 305 308 // Move the start node and the siblings of the start node. 306 309 if (startNode != startBlock) { … … 344 347 345 348 setEndingSelection(Position(blockToInsert.get(), 0), DOWNSTREAM); 346 rebalanceWhitespace();347 349 applyStyleAfterInsertion(); 348 350 } -
trunk/WebCore/editing/RebalanceWhitespaceCommand.cpp
r13393 r14169 44 44 } 45 45 46 // FIXME: This doesn't go into adjacent text in siblings, cousins, etc. 47 // FIXME: This turns preserved newlines into nbsps. 46 48 void RebalanceWhitespaceCommand::doApply() 47 49 { -
trunk/WebCore/editing/ReplaceSelectionCommand.cpp
r14143 r14169 482 482 483 483 // Don't pull content out of a list item. 484 // FIXMEs: Do this check in shouldMergeEnd too. Don't pull content out of a table cell either.484 // FIXMEs: Don't pull content out of a table cell either. 485 485 if (enclosingList(incomingFragment.mergeStartNode())) 486 486 return false; … … 497 497 } 498 498 499 bool ReplaceSelectionCommand::shouldMergeEnd(const ReplacementFragment& incomingFragment, const Selection& destinationSelection) 500 { 501 return !incomingFragment.hasInterchangeNewlineAtEnd() && !isEndOfParagraph(destinationSelection.visibleEnd()); 499 bool ReplaceSelectionCommand::shouldMergeEnd(const ReplacementFragment& incomingFragment, const VisiblePosition& endOfInsertedContent, const VisiblePosition& destination) 500 { 501 Node* endNode = endOfInsertedContent.deepEquivalent().node(); 502 Node* destinationNode = destination.deepEquivalent().node(); 503 // FIXME: Unify the naming scheme for these enclosing element getters. 504 return !incomingFragment.hasInterchangeNewlineAtEnd() && 505 isEndOfParagraph(endOfInsertedContent) && 506 nearestMailBlockquote(endNode) == nearestMailBlockquote(destinationNode) && 507 enclosingListChild(endNode) == enclosingListChild(destinationNode) && 508 enclosingTableCell(endNode) == enclosingTableCell(destinationNode) && 509 !endNode->hasTagName(hrTag); 502 510 } 503 511 … … 531 539 bool mergeStart = shouldMergeStart(fragment, selection); 532 540 533 // Whether the last paragraph of the incoming fragment should be merged with content from visibleEnd to endOfParagraph(visibleEnd). 534 bool mergeEnd = shouldMergeEnd(fragment, selection); 541 bool endWasEndOfParagraph = isEndOfParagraph(visibleEnd); 535 542 536 543 Position startPos = selection.start(); … … 612 619 addLeadingSpace = startPos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isStartOfParagraph(visiblePos); 613 620 if (addLeadingSpace) { 614 QChar previousChar = visiblePos.previous().character ();621 QChar previousChar = visiblePos.previous().characterAfter(); 615 622 if (!previousChar.isNull()) { 616 623 addLeadingSpace = !frame->isCharacterSmartReplaceExempt(previousChar, true); … … 619 626 addTrailingSpace = startPos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isEndOfParagraph(visiblePos); 620 627 if (addTrailingSpace) { 621 QChar thisChar = visiblePos.character ();628 QChar thisChar = visiblePos.characterAfter(); 622 629 if (!thisChar.isNull()) { 623 630 addTrailingSpace = !frame->isCharacterSmartReplaceExempt(thisChar, false); … … 793 800 // Make sure that content after the end of the selection being pasted into is in the same paragraph as the 794 801 // last bit of content that was inserted. 795 if (mergeEnd) { 796 VisiblePosition afterInsertedContent(positionAfterNode(m_lastNodeInserted.get())); 797 if (isEndOfParagraph(afterInsertedContent)) { 798 VisiblePosition startOfParagraphToMove = startOfParagraph(afterInsertedContent); 799 VisiblePosition destination = afterInsertedContent.next(); 800 moveParagraph(startOfParagraphToMove, afterInsertedContent, destination); 801 } 802 VisiblePosition endOfInsertedContent(Position(m_lastNodeInserted.get(), maxDeepOffset(m_lastNodeInserted.get()))); 803 VisiblePosition destination = endOfInsertedContent.next(); 804 if (!endWasEndOfParagraph && shouldMergeEnd(fragment, endOfInsertedContent, destination)) { 805 VisiblePosition startOfParagraphToMove = startOfParagraph(endOfInsertedContent); 806 moveParagraph(startOfParagraphToMove, endOfInsertedContent, destination); 802 807 } 803 808 -
trunk/WebCore/editing/ReplaceSelectionCommand.h
r14086 r14169 132 132 133 133 bool shouldMergeStart(const ReplacementFragment&, const Selection&); 134 bool shouldMergeEnd(const ReplacementFragment&, const Selection&);134 bool shouldMergeEnd(const ReplacementFragment&, const VisiblePosition&, const VisiblePosition&); 135 135 136 136 RefPtr<Node> m_firstNodeInserted; -
trunk/WebCore/editing/VisiblePosition.cpp
r14086 r14169 214 214 } 215 215 216 QChar VisiblePosition::character() const 217 { 218 Position pos = m_deepPosition; 216 QChar VisiblePosition::characterAfter() const 217 { 218 // We canonicalize to the first of two equivalent candidates, but the second of the two candidates 219 // is the one that will be inside the text node containing the character after this visible position. 220 Position pos = m_deepPosition.downstream(); 219 221 Node *node = pos.node(); 220 222 if (!node || !node->isTextNode()) { -
trunk/WebCore/editing/VisiblePosition.h
r13896 r14169 67 67 bool isLastInBlock() const; 68 68 69 QChar character () const;69 QChar characterAfter() const; 70 70 71 71 void debugPosition(const char* msg = "") const; -
trunk/WebCore/editing/htmlediting.cpp
r14071 r14169 374 374 } 375 375 376 Node* enclosingTableCell(Node* node) 377 { 378 if (!node) 379 return 0; 380 381 for (Node* n = node->parentNode(); n; n = n->parentNode()) 382 if (n->renderer() && n->renderer()->isTableCell()) 383 return n; 384 385 return 0; 386 } 387 376 388 Node* enclosingList(Node* node) 377 389 { … … 382 394 if (n->hasTagName(ulTag) || n->hasTagName(olTag)) 383 395 return n; 396 384 397 return 0; 385 398 } -
trunk/WebCore/editing/htmlediting.h
r14071 r14169 82 82 Position positionOutsideContainingSpecialElement(const Position&, Node** containingSpecialElement=0); 83 83 84 bool isListElement(Node* n); 85 Node* enclosingList(Node* node); 86 Node *enclosingListChild(Node *n); 87 bool isTableElement(Node* n); 84 Node* enclosingTableCell(Node*); 85 bool isListElement(Node*); 86 Node* enclosingList(Node*); 87 Node* enclosingListChild(Node*); 88 bool isTableElement(Node*); 88 89 bool isFirstVisiblePositionAfterTableElement(const Position&); 89 90 Position positionBeforePrecedingTableElement(const Position&);
Note: See TracChangeset
for help on using the changeset viewer.