Changeset 83247 in webkit
- Timestamp:
- Apr 7, 2011 9:11:13 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r83246 r83247 1 2011-04-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Darin Adler. 4 5 REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words 6 https://bugs.webkit.org/show_bug.cgi?id=57872 7 8 Added tests to ensure WebKit inserts a paragraph separator properly around tab span. 9 10 * editing/inserting/insert-div-021-expected.txt: No longer duplicates span[id="test"] incorrectly. 11 * editing/inserting/insert-paragraph-after-tab-span-and-text-expected.txt: Added. 12 * editing/inserting/insert-paragraph-after-tab-span-and-text.html: Added. 13 * editing/inserting/insert-paragraph-separator-tab-span-expected.txt: Added. 14 * editing/inserting/insert-paragraph-separator-tab-span.html: Added. 15 * editing/inserting/insert-paragraph-at-end-of-line-expected.txt: No longer duplicates a[id="anchor"] incorrectly. 16 1 17 2011-04-07 Ryosuke Niwa <rniwa@webkit.org> 2 18 … … 408 424 * platform/chromium-mac-leopard/fast/speech/input-appearance-searchandspeech-expected.png: Added. 409 425 * platform/chromium-mac/fast/speech/input-appearance-numberandspeech-expected.txt: 426 427 2011-04-07 Ryosuke Niwa <rniwa@webkit.org> 428 429 Reviewed by Eric Seidel. 430 431 REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words 432 https://bugs.webkit.org/show_bug.cgi?id=57872 433 434 Added a test insert a paragraph separator and text around tab spans. WebKit should not apply the tab span's 435 style to the paragraph separator or the text. 436 437 * editing/inserting/insert-paragraph-separator-tab-span-expected.txt: Added. 438 * editing/inserting/insert-paragraph-separator-tab-span.html: Added. 410 439 411 440 2011-04-07 Ryosuke Niwa <rniwa@webkit.org> -
trunk/LayoutTests/editing/inserting/insert-div-021-expected.txt
r83161 r83247 33 33 | <br> 34 34 | <div> 35 | <span>36 | id="test"37 35 | "<#selection-caret>bar 38 36 " -
trunk/LayoutTests/editing/inserting/insert-paragraph-at-end-of-line-expected.txt
r83181 r83247 19 19 | "1" 20 20 | <div> 21 | <a>22 | href="#"23 | id="anchor"24 21 | "2<#selection-caret>" 25 22 | <br> -
trunk/Source/WebCore/ChangeLog
r83245 r83247 1 2011-04-07 Ryosuke Niwa <rniwa@webkit.org> 2 3 Reviewed by Eric Seidel. 4 5 REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words 6 https://bugs.webkit.org/show_bug.cgi?id=57872 7 8 r46914 initially introduced a regression by replacing calls to styleAtPosition by editingStyleAtPosition 9 because editingStyleAtPosition did not avoid tab span to obtain the computed style unlike styleAtPosition. 10 11 r46914 also introduced a regression by cloning hierarchy under new block at the insertion position without 12 avoiding the tab span. 13 14 Fixed the both regressions by avoiding tab spans when computing the editing style and when cloning hierarchy. 15 Also reverted r46914 for the general code path because re-creating node hierarchy duplicates nodes when 16 we're moving nodes after the paragraph separator. Instead, we now split the tree up until the start block 17 before moving the nodes. 18 19 Tests: editing/inserting/insert-paragraph-after-tab-span-and-text.html 20 editing/inserting/insert-paragraph-separator-tab-span.html 21 22 * editing/DeleteSelectionCommand.cpp: 23 (WebCore::DeleteSelectionCommand::saveTypingStyleState): Since EditingStyle's constructor avoids a tab span, 24 no longer calls positionBeforeTabSpan on the position passed to EditingStyle's constructor. 25 * editing/EditingStyle.cpp: 26 (WebCore::EditingStyle::init): Always avoid a tab span when computing the editing style. 27 * editing/InsertParagraphSeparatorCommand.cpp: 28 (WebCore::InsertParagraphSeparatorCommand::doApply): Avoid cloning tab spans and inserting a paragraph 29 separator into a paragraph separator. 30 * editing/htmlediting.cpp: 31 (WebCore::positionOutsideTabSpan): Renamed from positionBeforeTabSpan. Also returns the position in the parent 32 node after the tab span if the position was at the end of the tab span. 33 * editing/htmlediting.h: 34 1 35 2011-04-07 Jia Pu <jpu@apple.com> 2 36 -
trunk/Source/WebCore/editing/DeleteSelectionCommand.cpp
r82550 r83247 282 282 283 283 // Figure out the typing style in effect before the delete is done. 284 m_typingStyle = EditingStyle::create( positionBeforeTabSpan(m_selectionToDelete.start()));284 m_typingStyle = EditingStyle::create(m_selectionToDelete.start()); 285 285 m_typingStyle->removeStyleAddedByNode(enclosingAnchorElement(m_selectionToDelete.start())); 286 286 -
trunk/Source/WebCore/editing/EditingStyle.cpp
r83097 r83247 301 301 void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) 302 302 { 303 if (isTabSpanTextNode(node)) 304 node = tabSpanNode(node)->parentNode(); 305 else if (isTabSpanNode(node)) 306 node = node->parentNode(); 307 303 308 RefPtr<CSSComputedStyleDeclaration> computedStyleAtPosition = computedStyle(node); 304 309 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copy() : editingStyleFromComputedStyle(computedStyleAtPosition); -
trunk/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp
r83097 r83247 240 240 241 241 Vector<Element*> ancestors; 242 getAncestorsInsideBlock( insertionPosition.deprecatedNode(), startBlock, ancestors);242 getAncestorsInsideBlock(positionOutsideTabSpan(insertionPosition).deprecatedNode(), startBlock, ancestors); 243 243 RefPtr<Element> parent = cloneHierarchyUnderNewBlock(ancestors, blockToInsert); 244 244 … … 255 255 if (isFirstInBlock || !inSameBlock(visiblePos, visiblePos.previous())) { 256 256 Node *refNode; 257 258 insertionPosition = positionOutsideTabSpan(insertionPosition); 259 257 260 if (isFirstInBlock && !nestNewBlock) 258 261 refNode = startBlock; … … 271 274 272 275 Vector<Element*> ancestors; 273 getAncestorsInsideBlock(positionAvoidingSpecialElementBoundary( insertionPosition).deprecatedNode(), startBlock, ancestors);276 getAncestorsInsideBlock(positionAvoidingSpecialElementBoundary(positionOutsideTabSpan(insertionPosition)).deprecatedNode(), startBlock, ancestors); 274 277 275 278 appendBlockPlaceholder(cloneHierarchyUnderNewBlock(ancestors, blockToInsert)); … … 300 303 // all of the correct nodes when building the ancestor list. So this needs to be the deepest representation of the position 301 304 // before we walk the DOM tree. 302 insertionPosition = VisiblePosition(insertionPosition).deepEquivalent(); 303 304 // Build up list of ancestors in between the start node and the start block. 305 Vector<Element*> ancestors; 306 getAncestorsInsideBlock(insertionPosition.deprecatedNode(), startBlock, ancestors); 305 insertionPosition = positionOutsideTabSpan(VisiblePosition(insertionPosition).deepEquivalent()); 307 306 308 307 // Make sure we do not cause a rendered space to become unrendered. … … 336 335 337 336 updateLayout(); 338 339 // Make clones of ancestors in between the start node and the outer block.340 RefPtr<Element> parent = cloneHierarchyUnderNewBlock(ancestors, blockToInsert);341 337 342 338 // If the paragraph separator was inserted at the end of a paragraph, an empty line must be … … 345 341 if (isEndOfParagraph(visiblePos) && !lineBreakExistsAtVisiblePosition(visiblePos)) 346 342 appendNode(createBreakElement(document()).get(), blockToInsert.get()); 347 343 348 344 // Move the start node and the siblings of the start node. 349 if (insertionPosition.deprecatedNode() != startBlock) { 350 Node* n = insertionPosition.deprecatedNode(); 351 if (insertionPosition.deprecatedEditingOffset() >= caretMaxOffset(n)) 352 n = n->nextSibling(); 345 if (VisiblePosition(insertionPosition) != VisiblePosition(positionBeforeNode(blockToInsert.get()))) { 346 Node* n; 347 if (insertionPosition.containerNode() == startBlock) 348 n = insertionPosition.computeNodeAfterPosition(); 349 else { 350 splitTreeToNode(insertionPosition.containerNode(), startBlock); 351 352 for (n = startBlock->firstChild(); n; n = n->nextSibling()) { 353 if (comparePositions(VisiblePosition(insertionPosition), positionBeforeNode(n)) <= 0) 354 break; 355 } 356 } 353 357 354 358 while (n && n != blockToInsert) { 355 359 Node *next = n->nextSibling(); 356 360 removeNode(n); 357 appendNode(n, parent.get());361 appendNode(n, blockToInsert); 358 362 n = next; 359 363 } 360 364 } 361 362 // Move everything after the start node.363 if (!ancestors.isEmpty()) {364 Element* leftParent = ancestors.first();365 while (leftParent && leftParent != startBlock) {366 parent = parent->parentElement();367 if (!parent)368 break;369 Node* n = leftParent->nextSibling();370 while (n && n != blockToInsert) {371 Node* next = n->nextSibling();372 removeNode(n);373 appendNode(n, parent.get());374 n = next;375 }376 leftParent = leftParent->parentElement();377 }378 }379 365 380 366 // Handle whitespace that occurs after the split -
trunk/Source/WebCore/editing/htmlediting.cpp
r82121 r83247 895 895 } 896 896 897 Position position BeforeTabSpan(const Position& pos)898 { 899 Node* node = pos. deprecatedNode();897 Position positionOutsideTabSpan(const Position& pos) 898 { 899 Node* node = pos.containerNode(); 900 900 if (isTabSpanTextNode(node)) 901 901 node = tabSpanNode(node); 902 902 else if (!isTabSpanNode(node)) 903 903 return pos; 904 904 905 if (node && VisiblePosition(pos) == lastPositionInNode(node)) 906 return positionInParentAfterNode(node); 907 905 908 return positionInParentBeforeNode(node); 906 909 } -
trunk/Source/WebCore/editing/htmlediting.h
r82121 r83247 112 112 Position previousVisuallyDistinctCandidate(const Position&); 113 113 114 Position position BeforeTabSpan(const Position&);114 Position positionOutsideTabSpan(const Position&); 115 115 Position positionBeforeContainingSpecialElement(const Position&, Node** containingSpecialElement=0); 116 116 Position positionAfterContainingSpecialElement(const Position&, Node** containingSpecialElement=0);
Note: See TracChangeset
for help on using the changeset viewer.