Changeset 104068 in webkit


Ignore:
Timestamp:
Jan 4, 2012 2:05:18 PM (12 years ago)
Author:
rniwa@webkit.org
Message:

REGRESSION (r92823): Background color not preserved when copying and pasting a table row
https://bugs.webkit.org/show_bug.cgi?id=75330

Reviewed by Tony Chang.

Source/WebCore:

The bug was caused by the background color of the wrapping style overriding the background color
in a matched rule of a highest element to be serialized. Fixed the bug by removing the conflicting
background color prior to the merge.

Tests: editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html

editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html

  • editing/EditingStyle.cpp:

(WebCore::editingStyleFromComputedStyle):
(WebCore::EditingStyle::removeStyleAddedByNode):
(WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):

LayoutTests:

Add a regression test.

  • editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html: Added.
  • editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html: Added.
Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r104046 r104068  
     12012-01-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION (r92823): Background color not preserved when copying and pasting a table row
     4        https://bugs.webkit.org/show_bug.cgi?id=75330
     5
     6        Reviewed by Tony Chang.
     7
     8        Add a regression test.
     9
     10        * editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html: Added.
     11        * editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html: Added.
     12
    1132012-01-04  Alpha Lam  <hclam@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r104060 r104068  
     12012-01-03  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        REGRESSION (r92823): Background color not preserved when copying and pasting a table row
     4        https://bugs.webkit.org/show_bug.cgi?id=75330
     5
     6        Reviewed by Tony Chang.
     7
     8        The bug was caused by the background color of the wrapping style overriding the background color
     9        in a matched rule of a highest element to be serialized. Fixed the bug by removing the conflicting
     10        background color prior to the merge.
     11
     12        Tests: editing/pasteboard/copy-element-with-conflicting-background-color-from-rule-expected.html
     13               editing/pasteboard/copy-element-with-conflicting-background-color-from-rule.html
     14
     15        * editing/EditingStyle.cpp:
     16        (WebCore::editingStyleFromComputedStyle):
     17        (WebCore::EditingStyle::removeStyleAddedByNode):
     18        (WebCore::EditingStyle::removeStyleConflictingWithStyleOfNode):
     19
    1202012-01-03  Antti Koivisto  <antti@apple.com>
    221
  • trunk/Source/WebCore/dom/Element.cpp

    r103883 r104068  
    707707void Element::recalcStyleIfNeededAfterAttributeChanged(Attribute* attr)
    708708{
    709     if (document()->attached() && document()->styleSelector()->hasSelectorForAttribute(attr->name().localName()))
     709    if (!needsStyleRecalc())
     710        return;
     711
     712    if (document()->attached() && document()->styleSelectorIfExists() && document()->styleSelectorIfExists()->hasSelectorForAttribute(attr->name().localName()))
    710713        setNeedsStyleRecalc();
    711714}
  • trunk/Source/WebCore/editing/EditingStyle.cpp

    r99450 r104068  
    8181};
    8282
    83 static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, bool includeNonInheritableProperties = false)
    84 {
    85     if (includeNonInheritableProperties)
     83enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingProperties };
     84
     85static PassRefPtr<CSSMutableStyleDeclaration> copyEditingProperties(CSSStyleDeclaration* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
     86{
     87    if (type == AllEditingProperties)
    8688        return style->copyPropertiesInSet(editingProperties, WTF_ARRAY_LENGTH(editingProperties));
    8789    return style->copyPropertiesInSet(editingProperties + 2, WTF_ARRAY_LENGTH(editingProperties) - 2);
     
    9799}
    98100
    99 static PassRefPtr<CSSMutableStyleDeclaration> editingStyleFromComputedStyle(PassRefPtr<CSSComputedStyleDeclaration> style)
     101static PassRefPtr<CSSMutableStyleDeclaration> editingStyleFromComputedStyle(PassRefPtr<CSSComputedStyleDeclaration> style, EditingPropertiesType type = OnlyInheritableEditingProperties)
    100102{
    101103    if (!style)
    102104        return CSSMutableStyleDeclaration::create();
    103     return copyEditingProperties(style.get());
     105    return copyEditingProperties(style.get(), type);
    104106}
    105107
     
    544546    if (!node || !node->parentNode())
    545547        return;
    546     RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()));
    547     RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node));
     548    RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()), AllEditingProperties);
     549    RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node), AllEditingProperties);
    548550    parentStyle->diff(nodeStyle.get());
    549551    nodeStyle->diff(m_mutableStyle.get());
     
    554556    if (!node || !node->parentNode() || !m_mutableStyle)
    555557        return;
    556     RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()));
    557     RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node));
     558
     559    RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleFromComputedStyle(computedStyle(node->parentNode()), AllEditingProperties);
     560    RefPtr<CSSMutableStyleDeclaration> nodeStyle = editingStyleFromComputedStyle(computedStyle(node), AllEditingProperties);
    558561    parentStyle->diff(nodeStyle.get());
    559562
     
    904907        return;
    905908    case OnlyEditingInheritableProperties:
     909        mergeStyle(copyEditingProperties(element->inlineStyleDecl(), OnlyInheritableEditingProperties).get(), mode);
     910        return;
    906911    case EditingPropertiesInEffect:
    907         mergeStyle(copyEditingProperties(element->inlineStyleDecl(), propertiesToInclude == EditingPropertiesInEffect).get(), mode);
     912        mergeStyle(copyEditingProperties(element->inlineStyleDecl(), AllEditingProperties).get(), mode);
    908913        return;
    909914    }
Note: See TracChangeset for help on using the changeset viewer.