From 59e6bd55fdc39e363878150c71ff15141028c885 Mon Sep 17 00:00:00 2001 From: "rniwa@webkit.org" Date: Wed, 6 Apr 2011 12:59:24 +0000 Subject: [PATCH] 2011-04-06 Ryosuke Niwa Reviewed by Eric Seidel. REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words https://bugs.webkit.org/show_bug.cgi?id=57872 r46914 initially introduced a regression by replacing calls to styleAtPosition by editingStyleAtPosition because editingStyleAtPosition did not avoid tab span to obtain the computed style unlike styleAtPosition. r46914 also introduced a regression by cloning hierarchy under new block at the insertion position without avoiding the tab span. Fixed the both regressions by avoiding tab spans when computing the editing style and when cloning hierarchy. Test: editing/inserting/insert-paragraph-separator-tab-span.html * editing/EditingStyle.cpp: (WebCore::EditingStyle::init): Always avoid a tab span when computing the editing style. * editing/InsertParagraphSeparatorCommand.cpp: (WebCore::InsertParagraphSeparatorCommand::doApply): Avoid cloning tab spans and inserting a paragraph separator into a paragraph separator. 2011-04-06 Ryosuke Niwa Reviewed by Eric Seidel. REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words https://bugs.webkit.org/show_bug.cgi?id=57872 Added a test insert a paragraph separator and text around tab spans. WebKit should not apply the tab span's style to the paragraph separator or the text. * editing/inserting/insert-paragraph-separator-tab-span-expected.txt: Added. * editing/inserting/insert-paragraph-separator-tab-span.html: Added. git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83039 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 13 ++++++++ ...nsert-paragraph-separator-tab-span-expected.txt | 38 ++++++++++++++++++++++ .../insert-paragraph-separator-tab-span.html | 32 ++++++++++++++++++ Source/WebCore/ChangeLog | 23 +++++++++++++ Source/WebCore/editing/EditingStyle.cpp | 5 +++ .../editing/InsertParagraphSeparatorCommand.cpp | 9 +++-- 6 files changed, 117 insertions(+), 3 deletions(-) create mode 100644 LayoutTests/editing/inserting/insert-paragraph-separator-tab-span-expected.txt create mode 100644 LayoutTests/editing/inserting/insert-paragraph-separator-tab-span.html diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 64dae57..506cb70 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,16 @@ +2011-04-06 Ryosuke Niwa + + Reviewed by Eric Seidel. + + REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words + https://bugs.webkit.org/show_bug.cgi?id=57872 + + Added a test insert a paragraph separator and text around tab spans. WebKit should not apply the tab span's + style to the paragraph separator or the text. + + * editing/inserting/insert-paragraph-separator-tab-span-expected.txt: Added. + * editing/inserting/insert-paragraph-separator-tab-span.html: Added. + 2011-04-05 Alexander Pavlov Reviewed by Pavel Feldman. diff --git a/LayoutTests/editing/inserting/insert-paragraph-separator-tab-span-expected.txt b/LayoutTests/editing/inserting/insert-paragraph-separator-tab-span-expected.txt new file mode 100644 index 0000000..49e1376 --- /dev/null +++ b/LayoutTests/editing/inserting/insert-paragraph-separator-tab-span-expected.txt @@ -0,0 +1,38 @@ +This test ensures WebKit avoids cloning Apple tab span when inserting a paragraph separator. +Only tab should be inside a Apple tab span in the following tests. + +last visible position: +| +| class="Apple-tab-span" +| style="white-space:pre" +| " " +|
+| "hello world WebKit <#selection-caret>" + +first visible position: +|
+|
+| "hello world WebKit <#selection-caret>" +| +| class="Apple-tab-span" +| style="white-space:pre" +| " " + +before tab span: +| "hi, " +|
+| "hello world WebKit <#selection-caret>" +| +| class="Apple-tab-span" +| style="white-space:pre" +| " " +| " rocks" + +after tab span: +| "hi, " +| +| class="Apple-tab-span" +| style="white-space:pre" +| " " +| " rockshello world WebKit <#selection-caret>" +|
diff --git a/LayoutTests/editing/inserting/insert-paragraph-separator-tab-span.html b/LayoutTests/editing/inserting/insert-paragraph-separator-tab-span.html new file mode 100644 index 0000000..406ddb7 --- /dev/null +++ b/LayoutTests/editing/inserting/insert-paragraph-separator-tab-span.html @@ -0,0 +1,32 @@ + + + +
+
+
hi, rocks
+
hi, rocks
+ + + + diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 0d6c381..93d6946 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,26 @@ +2011-04-06 Ryosuke Niwa + + Reviewed by Eric Seidel. + + REGRESSION (r46914, r48764): When typing in Mail, line wrapping frequently occurs in the middle of words + https://bugs.webkit.org/show_bug.cgi?id=57872 + + r46914 initially introduced a regression by replacing calls to styleAtPosition by editingStyleAtPosition + because editingStyleAtPosition did not avoid tab span to obtain the computed style unlike styleAtPosition. + + r46914 also introduced a regression by cloning hierarchy under new block at the insertion position without + avoiding the tab span. + + Fixed the both regressions by avoiding tab spans when computing the editing style and when cloning hierarchy. + + Test: editing/inserting/insert-paragraph-separator-tab-span.html + + * editing/EditingStyle.cpp: + (WebCore::EditingStyle::init): Always avoid a tab span when computing the editing style. + * editing/InsertParagraphSeparatorCommand.cpp: + (WebCore::InsertParagraphSeparatorCommand::doApply): Avoid cloning tab spans and inserting a paragraph + separator into a paragraph separator. + 2011-04-06 Levi Weintraub Reviewed by Ryosuke Niwa. diff --git a/Source/WebCore/editing/EditingStyle.cpp b/Source/WebCore/editing/EditingStyle.cpp index 668c943..b2195a9 100644 --- a/Source/WebCore/editing/EditingStyle.cpp +++ b/Source/WebCore/editing/EditingStyle.cpp @@ -300,6 +300,11 @@ EditingStyle::~EditingStyle() void EditingStyle::init(Node* node, PropertiesToInclude propertiesToInclude) { + if (isTabSpanTextNode(node)) + node = tabSpanNode(node)->parentNode(); + else if (isTabSpanNode(node)) + node = node->parentNode(); + RefPtr computedStyleAtPosition = computedStyle(node); m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copy() : editingStyleFromComputedStyle(computedStyleAtPosition); diff --git a/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp b/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp index 771c56a..5af08ad 100644 --- a/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp +++ b/Source/WebCore/editing/InsertParagraphSeparatorCommand.cpp @@ -239,7 +239,7 @@ void InsertParagraphSeparatorCommand::doApply() // Recreate the same structure in the new paragraph. Vector ancestors; - getAncestorsInsideBlock(insertionPosition.deprecatedNode(), startBlock, ancestors); + getAncestorsInsideBlock(positionBeforeTabSpan(insertionPosition).deprecatedNode(), startBlock, ancestors); RefPtr parent = cloneHierarchyUnderNewBlock(ancestors, blockToInsert); appendBlockPlaceholder(parent); @@ -254,6 +254,9 @@ void InsertParagraphSeparatorCommand::doApply() // similar case where previous position is in another, presumeably nested, block. if (isFirstInBlock || !inSameBlock(visiblePos, visiblePos.previous())) { Node *refNode; + + insertionPosition = positionBeforeTabSpan(insertionPosition); + if (isFirstInBlock && !nestNewBlock) refNode = startBlock; else if (insertionPosition.deprecatedNode() == startBlock && nestNewBlock) { @@ -270,7 +273,7 @@ void InsertParagraphSeparatorCommand::doApply() // Recreate the same structure in the new paragraph. Vector ancestors; - getAncestorsInsideBlock(positionAvoidingSpecialElementBoundary(insertionPosition).deprecatedNode(), startBlock, ancestors); + getAncestorsInsideBlock(positionAvoidingSpecialElementBoundary(positionBeforeTabSpan(insertionPosition)).deprecatedNode(), startBlock, ancestors); appendBlockPlaceholder(cloneHierarchyUnderNewBlock(ancestors, blockToInsert)); @@ -303,7 +306,7 @@ void InsertParagraphSeparatorCommand::doApply() // Build up list of ancestors in between the start node and the start block. Vector ancestors; - getAncestorsInsideBlock(insertionPosition.deprecatedNode(), startBlock, ancestors); + getAncestorsInsideBlock(positionBeforeTabSpan(insertionPosition).deprecatedNode(), startBlock, ancestors); // Make sure we do not cause a rendered space to become unrendered. // FIXME: We need the affinity for pos, but pos.downstream() does not give it -- 1.8.3.1