Changeset 98794 in webkit
- Timestamp:
- Oct 28, 2011, 10:27:07 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/LayoutTests/ChangeLog ¶
r98791 r98794 1 2011-10-28 Ryosuke Niwa <rniwa@webkit.org> 2 3 The copy and paste result in nested scrollbars on http://dojotoolkit.org/widgets 4 https://bugs.webkit.org/show_bug.cgi?id=70799 5 6 Reviewed by Enrica Casucci. 7 8 Added a test to copy contents inside a body with background and text-decoration properties. 9 10 WebKit should not copy body element. 11 12 * editing/deleting/delete-line-break-before-underlined-content-expected.txt: an erroneous inline div 13 is replaced by a span. 14 * editing/deleting/deleting-line-break-preserves-underline-color-expected.txt: two style spans are 15 merged into one. 16 * editing/pasteboard/19644-2-expected.txt: div is replaced by span. This is okay because it's the only 17 content in the body. Even though we now only put the gray background under text as inline style as 18 opposed to apply at the block level, that's what execCommand('BackColor'...) does and what user expects. 19 * editing/pasteboard/avoid-copying-body-with-background-expected.txt: Added. 20 * editing/pasteboard/avoid-copying-body-with-background.html: Added. 21 * editing/pasteboard/preserve-underline-color-expected.txt: 22 * platform/mac/editing/pasteboard/5134759-expected.txt: 23 1 24 2011-10-28 Adam Klein <adamk@chromium.org> 2 25 -
TabularUnified trunk/LayoutTests/editing/deleting/delete-line-break-before-underlined-content-expected.txt ¶
r86605 r98794 1 1 This tests for a bug where underlined content would lose its underliningwhen deleting the line break before the paragraph that contained it. 2 2 | "This shouldn't be underlined.<#selection-caret>" 3 | <div> 4 | id="div" 5 | style="text-decoration: underline; display: inline !important; " 3 | <span> 4 | style="text-decoration: underline; " 6 5 | "This should be underlined." -
TabularUnified trunk/LayoutTests/editing/deleting/deleting-line-break-preserves-underline-color-expected.txt ¶
r96870 r98794 14 14 | "This should not be underlined.<#selection-caret>" 15 15 | <span> 16 | style="text-decoration: underline; color: blue;" 17 | <span> 18 | style="color:red;" 19 | "This should be underlined." 16 | style="color: red; text-decoration: underline; " 17 | "This should be underlined." -
TabularUnified trunk/LayoutTests/editing/pasteboard/19644-2-expected.txt ¶
r42722 r98794 1 < div style="background-color: rgb(187, 187, 187); ">This tests to make sure that we wrap copied markup in a div to hold a fully selected body's attributes and style when the that body has a background-color. If you copy and paste this text into Mail, it should have a grey background.</div>1 <span style="background-color: rgb(187, 187, 187); ">This tests to make sure that we wrap copied markup in a div to hold a fully selected body's attributes and style when the that body has a background-color. If you copy and paste this text into Mail, it should have a grey background.</span> -
TabularUnified trunk/LayoutTests/editing/pasteboard/preserve-underline-color-expected.txt ¶
r86619 r98794 1 1 This test for a bug copy/pasting underlined text. The color of the underline should be the color of the element that has the text-decoration property. 2 2 | <span> 3 | style="text-decoration: underline; color: blue; " 4 | <span> 5 | style="color: red; " 6 | "This should be underlined.<#selection-caret>" 3 | style="color: rgb(255, 0, 0); text-decoration: underline; " 4 | "This should be underlined.<#selection-caret>" 7 5 | <br> -
TabularUnified trunk/LayoutTests/platform/mac/editing/pasteboard/5134759-expected.txt ¶
r63291 r98794 18 18 text run at (0,0) width 39: "Hello " 19 19 RenderInline {SPAN} at (0,0) size 45x18 20 RenderInline {DIV} at (0,0) size 45x18 21 RenderText {#text} at (39,0) size 45x18 22 text run at (39,0) width 45: "World!" 20 RenderText {#text} at (39,0) size 45x18 21 text run at (39,0) width 45: "World!" 23 22 RenderBlock (anonymous) at (0,18) size 784x0 24 caret: position 6 of child 0 {#text} of child 0 {DIV} of child1 {SPAN} of child 0 {DIV} of child 2 {DIV} of body23 caret: position 6 of child 0 {#text} of child 1 {SPAN} of child 0 {DIV} of child 2 {DIV} of body -
TabularUnified trunk/Source/WebCore/ChangeLog ¶
r98793 r98794 1 2011-10-28 Ryosuke Niwa <rniwa@webkit.org> 2 3 The copy and paste result in nested scrollbars on http://dojotoolkit.org/widgets 4 https://bugs.webkit.org/show_bug.cgi?id=70799 5 6 Reviewed by Enrica Casucci. 7 8 The bug was caused by WebKit's treating a fully selected root with background property as a special common ancestor. 9 A variant of this bug was caused by treating any element with text-decoration property as a presentational element. 10 11 Fixed the above two bugs by not serializing the said nodes. The effective background color was already serialized 12 by wrappingStyleForSerialization, there was nothing to be done besides stop including it in highestAncestorToWrapMarkup. 13 14 For text-decoration property, added the logic to compute the effective value in EditingStyle::init. Also treat it 15 as a non-inheritable editing property so that the rest of EditingStyle just works. 16 17 Test: editing/pasteboard/avoid-copying-body-with-background.html 18 19 * editing/EditingStyle.cpp: Added CSSPropertyTextDecoration to the list of editing properties. 20 (WebCore::copyEditingProperties): 21 (WebCore::EditingStyle::init): Compute the effective text decoration when propertiesToInclude is 22 EditingPropertiesInEffect. 23 (WebCore::EditingStyle::prepareToApplyAt): 24 (WebCore::EditingStyle::mergeInlineStyleOfElement): 25 (WebCore::EditingStyle::wrappingStyleForSerialization): 26 (WebCore::EditingStyle::removeStyleFromRulesAndContext): 27 * editing/EditingStyle.h: Renamed EditingInheritablePropertiesAndBackgroundColorInEffect to 28 EditingPropertiesInEffect. 29 * editing/markup.cpp: 30 (WebCore::StyledMarkupAccumulator::appendStyleNodeOpenTag): Removed an assertion that's no longer valid. 31 (WebCore::isElementPresentational): Don't consider an element with text-decoration as a presentational element. 32 (WebCore::highestAncestorToWrapMarkup): Don't consider fully selected root as a special common ancestor ever. 33 Background color is computed property when we compute the wrapping style. 34 (WebCore::createMarkup): 35 1 36 2011-10-28 Adam Barth <abarth@webkit.org> 2 37 -
TabularUnified trunk/Source/WebCore/editing/EditingStyle.cpp ¶
r97480 r98794 56 56 static const int editingProperties[] = { 57 57 CSSPropertyBackgroundColor, 58 CSSPropertyTextDecoration, 58 59 59 60 // CSS inheritable properties … … 80 81 }; 81 82 82 static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, bool include BackgroundColor= false)83 { 84 if (include BackgroundColor)83 static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, bool includeNonInheritableProperties = false) 84 { 85 if (includeNonInheritableProperties) 85 86 return style->copyPropertiesInSet(editingProperties, WTF_ARRAY_LENGTH(editingProperties)); 86 return style->copyPropertiesInSet(editingProperties + 1, WTF_ARRAY_LENGTH(editingProperties) - 1);87 return style->copyPropertiesInSet(editingProperties + 2, WTF_ARRAY_LENGTH(editingProperties) - 2); 87 88 } 88 89 … … 363 364 m_mutableStyle = propertiesToInclude == AllProperties && computedStyleAtPosition ? computedStyleAtPosition->copy() : editingStyleFromComputedStyle(computedStyleAtPosition); 364 365 365 if (propertiesToInclude == Editing InheritablePropertiesAndBackgroundColorInEffect) {366 if (propertiesToInclude == EditingPropertiesInEffect) { 366 367 if (RefPtr<CSSValue> value = backgroundColorInEffect(node)) 367 368 m_mutableStyle->setProperty(CSSPropertyBackgroundColor, value->cssText()); 369 if (RefPtr<CSSValue> value = computedStyleAtPosition->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect)) 370 m_mutableStyle->setProperty(CSSPropertyTextDecoration, value->cssText()); 368 371 } 369 372 … … 855 858 // If this function was modified in the future to delete all redundant properties, then add a boolean value to indicate 856 859 // which one of editingStyleAtPosition or computedStyle is called. 857 RefPtr<EditingStyle> style = EditingStyle::create(position, Editing InheritablePropertiesAndBackgroundColorInEffect);860 RefPtr<EditingStyle> style = EditingStyle::create(position, EditingPropertiesInEffect); 858 861 859 862 RefPtr<CSSValue> unicodeBidi; … … 901 904 return; 902 905 case OnlyEditingInheritableProperties: 903 case Editing InheritablePropertiesAndBackgroundColorInEffect:904 mergeStyle(copyEditingProperties(element->inlineStyleDecl(), propertiesToInclude == Editing InheritablePropertiesAndBackgroundColorInEffect).get(), mode);906 case EditingPropertiesInEffect: 907 mergeStyle(copyEditingProperties(element->inlineStyleDecl(), propertiesToInclude == EditingPropertiesInEffect).get(), mode); 905 908 return; 906 909 } … … 937 940 RefPtr<EditingStyle> wrappingStyle; 938 941 if (shouldAnnotate) { 939 wrappingStyle = EditingStyle::create(context, EditingStyle::Editing InheritablePropertiesAndBackgroundColorInEffect);942 wrappingStyle = EditingStyle::create(context, EditingStyle::EditingPropertiesInEffect); 940 943 941 944 // Styles that Mail blockquotes contribute should only be placed on the Mail blockquote, … … 956 959 if (node->isStyledElement()) { 957 960 wrappingStyle->mergeInlineAndImplicitStyleOfElement(static_cast<StyledElement*>(node), EditingStyle::DoNotOverrideValues, 958 EditingStyle::Editing InheritablePropertiesAndBackgroundColorInEffect);961 EditingStyle::EditingPropertiesInEffect); 959 962 } 960 963 } … … 1069 1072 1070 1073 // 2. Remove style present in context and not overriden by matched rules. 1071 RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, Editing InheritablePropertiesAndBackgroundColorInEffect);1074 RefPtr<EditingStyle> computedStyle = EditingStyle::create(context, EditingPropertiesInEffect); 1072 1075 if (computedStyle->m_mutableStyle) { 1073 1076 computedStyle->removePropertiesInElementDefaultStyle(element); -
TabularUnified trunk/Source/WebCore/editing/EditingStyle.h ¶
r97480 r98794 62 62 public: 63 63 64 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties, Editing InheritablePropertiesAndBackgroundColorInEffect };64 enum PropertiesToInclude { AllProperties, OnlyEditingInheritableProperties, EditingPropertiesInEffect }; 65 65 enum ShouldPreserveWritingDirection { PreserveWritingDirection, DoNotPreserveWritingDirection }; 66 66 enum ShouldExtractMatchingStyle { ExtractMatchingStyle, DoNotExtractMatchingStyle }; -
TabularUnified trunk/Source/WebCore/editing/markup.cpp ¶
r97499 r98794 186 186 void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, CSSStyleDeclaration* style, Document* document, bool isBlock) 187 187 { 188 // All text-decoration-related elements should have been treated as special ancestors 189 // If we ever hit this ASSERT, we should export StyleChange in ApplyStyleCommand and use it here 190 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyTextDecoration) && propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsInEffect)); 188 // wrappingStyleForSerialization should have removed -webkit-text-decorations-in-effect 189 ASSERT(propertyMissingOrEqualToNone(style, CSSPropertyWebkitTextDecorationsInEffect)); 191 190 DEFINE_STATIC_LOCAL(const String, divStyle, ("<div style=\"")); 192 191 DEFINE_STATIC_LOCAL(const String, styleSpanOpen, ("<span style=\"")); … … 520 519 static bool isElementPresentational(const Node* node) 521 520 { 522 if (node->hasTagName(uTag) || node->hasTagName(sTag) || node->hasTagName(strikeTag) 523 || node->hasTagName(iTag) || node->hasTagName(emTag) || node->hasTagName(bTag) || node->hasTagName(strongTag)) 524 return true; 525 RefPtr<EditingStyle> style = styleFromMatchedRulesAndInlineDecl(node); 526 return style && style->style() && !propertyMissingOrEqualToNone(style->style(), CSSPropertyTextDecoration); 527 } 528 529 static bool shouldIncludeWrapperForFullySelectedRoot(Node* fullySelectedRoot) 530 { 531 if (fullySelectedRoot->isElementNode() && static_cast<Element*>(fullySelectedRoot)->hasAttribute(backgroundAttr)) 532 return true; 533 534 RefPtr<EditingStyle> style = styleFromMatchedRulesAndInlineDecl(fullySelectedRoot); 535 if (!style || !style->style()) 536 return false; 537 538 return style->style()->getPropertyCSSValue(CSSPropertyBackgroundImage) || style->style()->getPropertyCSSValue(CSSPropertyBackgroundColor); 539 } 540 541 static Node* highestAncestorToWrapMarkup(const Range* range, Node* fullySelectedRoot, EAnnotateForInterchange shouldAnnotate) 521 return node->hasTagName(uTag) || node->hasTagName(sTag) || node->hasTagName(strikeTag) 522 || node->hasTagName(iTag) || node->hasTagName(emTag) || node->hasTagName(bTag) || node->hasTagName(strongTag); 523 } 524 525 static Node* highestAncestorToWrapMarkup(const Range* range, EAnnotateForInterchange shouldAnnotate) 542 526 { 543 527 ExceptionCode ec; … … 573 557 if (Node *enclosingAnchor = enclosingNodeWithTag(firstPositionInNode(specialCommonAncestor ? specialCommonAncestor : commonAncestor), aTag)) 574 558 specialCommonAncestor = enclosingAnchor; 575 576 if (shouldAnnotate == AnnotateForInterchange && fullySelectedRoot && shouldIncludeWrapperForFullySelectedRoot(fullySelectedRoot))577 specialCommonAncestor = fullySelectedRoot;578 559 579 560 return specialCommonAncestor; … … 621 602 if (body && areRangesEqual(VisibleSelection::selectionFromContentsOfNode(body).toNormalizedRange().get(), range)) 622 603 fullySelectedRoot = body; 623 Node* specialCommonAncestor = highestAncestorToWrapMarkup(updatedRange.get(), fullySelectedRoot,shouldAnnotate);604 Node* specialCommonAncestor = highestAncestorToWrapMarkup(updatedRange.get(), shouldAnnotate); 624 605 StyledMarkupAccumulator accumulator(nodes, shouldResolveURLs, shouldAnnotate, updatedRange.get(), specialCommonAncestor); 625 606 Node* pastEnd = updatedRange->pastLastNode();
Note:
See TracChangeset
for help on using the changeset viewer.