Changeset 65014 in webkit


Ignore:
Timestamp:
Aug 9, 2010 4:25:15 PM (14 years ago)
Author:
rniwa@webkit.org
Message:

2010-08-09 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Justin Garcia.

Undo fails in RemoveCSSPropertyCommand when the corresponding style attribute is removed
https://bugs.webkit.org/show_bug.cgi?id=43639

The bug was caused when RemoveCSSPropertyCommand is called with CSSMutableStyleDeclaration of some styled element,
and the style attribute of the element is removed subsequently. When the attribute removal is undone, new instance of
CSSMutableStyleDeclaration is created and RemoveCSSPropertyCommand's m_style became detached from the element.

Modified RemoveCSSPropertyCommand to store the styled element directly instead of its CSSMutableStyleDeclaration.

Test: editing/undo/remove-css-property-and-remove-style.html

  • WebCore.order:
  • editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::removeCSSStyle): Calls removeCSSProperty. (WebCore::ApplyStyleCommand::extractTextDecorationStyle): Calls removeCSSProperty.
  • editing/CompositeEditCommand.cpp: (WebCore::CompositeEditCommand::removeCSSProperty): Takes StyledElement instead of CSSMutableStyleDeclaration.
  • editing/CompositeEditCommand.h:
  • editing/RemoveCSSPropertyCommand.cpp: (WebCore::RemoveCSSPropertyCommand::RemoveCSSPropertyCommand): Takes StyledElement instead of CSSMutableStyleDeclaration. (WebCore::RemoveCSSPropertyCommand::doApply): See above. (WebCore::RemoveCSSPropertyCommand::doUnapply): See above.
  • editing/RemoveCSSPropertyCommand.h: (WebCore::RemoveCSSPropertyCommand::create): See above.

2010-08-09 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Justin Garcia.

Undo fails in RemoveCSSPropertyCommand when the corresponding style attribute is removed
https://bugs.webkit.org/show_bug.cgi?id=43639

Added a test to remove style attribute after removing a CSS property from the style.
Undo should restore both style attribute and the removed CSS property.

  • editing/undo/remove-css-property-and-remove-style-expected.txt: Added.
  • editing/undo/remove-css-property-and-remove-style.html: Added.
Location:
trunk
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r65006 r65014  
     12010-08-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Justin Garcia.
     4
     5        Undo fails in RemoveCSSPropertyCommand when the corresponding style attribute is removed
     6        https://bugs.webkit.org/show_bug.cgi?id=43639
     7
     8        Added a test to remove style attribute after removing a CSS property from the style.
     9        Undo should restore both style attribute and the removed CSS property.
     10
     11        * editing/undo/remove-css-property-and-remove-style-expected.txt: Added.
     12        * editing/undo/remove-css-property-and-remove-style.html: Added.
     13
    1142010-08-09  Eric Seidel  <eric@webkit.org>
    215
  • trunk/WebCore/ChangeLog

    r65013 r65014  
     12010-08-09  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Justin Garcia.
     4
     5        Undo fails in RemoveCSSPropertyCommand when the corresponding style attribute is removed
     6        https://bugs.webkit.org/show_bug.cgi?id=43639
     7
     8        The bug was caused when RemoveCSSPropertyCommand is called with CSSMutableStyleDeclaration of some styled element,
     9        and the style attribute of the element is removed subsequently. When the attribute removal is undone, new instance of
     10        CSSMutableStyleDeclaration is created and RemoveCSSPropertyCommand's m_style became detached from the element.
     11
     12        Modified RemoveCSSPropertyCommand to store the styled element directly instead of its CSSMutableStyleDeclaration.
     13
     14        Test: editing/undo/remove-css-property-and-remove-style.html
     15
     16        * WebCore.order:
     17        * editing/ApplyStyleCommand.cpp:
     18        (WebCore::ApplyStyleCommand::removeCSSStyle): Calls removeCSSProperty.
     19        (WebCore::ApplyStyleCommand::extractTextDecorationStyle): Calls removeCSSProperty.
     20        * editing/CompositeEditCommand.cpp:
     21        (WebCore::CompositeEditCommand::removeCSSProperty): Takes StyledElement instead of CSSMutableStyleDeclaration.
     22        * editing/CompositeEditCommand.h:
     23        * editing/RemoveCSSPropertyCommand.cpp:
     24        (WebCore::RemoveCSSPropertyCommand::RemoveCSSPropertyCommand): Takes StyledElement instead of CSSMutableStyleDeclaration.
     25        (WebCore::RemoveCSSPropertyCommand::doApply): See above.
     26        (WebCore::RemoveCSSPropertyCommand::doUnapply): See above.
     27        * editing/RemoveCSSPropertyCommand.h:
     28        (WebCore::RemoveCSSPropertyCommand::create): See above.
     29
    1302010-08-09  Ryosuke Niwa  <rniwa@webkit.org>
    231
  • trunk/WebCore/WebCore.order

    r63888 r65014  
    1763617636__ZN7WebCore17ApplyStyleCommandC1EPNS_8DocumentEPNS_19CSSStyleDeclarationERKNS_8PositionES7_NS_10EditActionENS0_14EPropertyLeve
    1763717637__ZN7WebCore17ApplyStyleCommandC2EPNS_8DocumentEPNS_19CSSStyleDeclarationERKNS_8PositionES7_NS_10EditActionENS0_14EPropertyLeve
    17638 __ZN7WebCore20CompositeEditCommand17removeCSSPropertyEN3WTF10PassRefPtrINS_26CSSMutableStyleDeclarationEEE13CSSPropertyID
    17639 __ZN7WebCore24RemoveCSSPropertyCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_26CSSMutableStyleDeclarationEEE13CSSPropertyID
    17640 __ZN7WebCore24RemoveCSSPropertyCommandC2EPNS_8DocumentEN3WTF10PassRefPtrINS_26CSSMutableStyleDeclarationEEE13CSSPropertyID
     17638__ZN7WebCore20CompositeEditCommand17removeCSSPropertyEN3WTF10PassRefPtrINS_13StyledElementEEE13CSSPropertyID
     17639__ZN7WebCore24RemoveCSSPropertyCommandC1EPNS_8DocumentEN3WTF10PassRefPtrINS_13StyledElementEEE13CSSPropertyID
     17640__ZN7WebCore24RemoveCSSPropertyCommandC2EPNS_8DocumentEN3WTF10PassRefPtrINS_13StyledElementEEE13CSSPropertyID
    1764117641__ZN7WebCore24RemoveCSSPropertyCommand7doApplyEv
    1764217642__ZN7WebCore20CompositeEditCommand19removeNodeAttributeEN3WTF10PassRefPtrINS_7ElementEEERKNS_13QualifiedNameE
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r65013 r65014  
    12921292            if (mode == RemoveNone)
    12931293                return true;
    1294             removeCSSProperty(decl, propertyID);
     1294            removeCSSProperty(elem, propertyID);
    12951295            if (propertyID == CSSPropertyUnicodeBidi && !decl->getPropertyValue(CSSPropertyDirection).isEmpty())
    1296                 removeCSSProperty(decl, CSSPropertyDirection);
     1296                removeCSSProperty(elem, CSSPropertyDirection);
    12971297        }
    12981298    }
     
    13541354    RefPtr<CSSValue> property = style->getPropertyCSSValue(CSSPropertyTextDecoration);
    13551355    if (property && !equalIgnoringCase(property->cssText(), "none"))
    1356         removeCSSProperty(style.get(), CSSPropertyTextDecoration);
     1356        removeCSSProperty(element, CSSPropertyTextDecoration);
    13571357
    13581358    return textDecorationStyle.release();
  • trunk/WebCore/editing/CompositeEditCommand.cpp

    r64056 r65014  
    371371}
    372372
    373 void CompositeEditCommand::removeCSSProperty(PassRefPtr<CSSMutableStyleDeclaration> style, CSSPropertyID property)
    374 {
    375     applyCommandToComposite(RemoveCSSPropertyCommand::create(document(), style, property));
     373void CompositeEditCommand::removeCSSProperty(PassRefPtr<StyledElement> element, CSSPropertyID property)
     374{
     375    applyCommandToComposite(RemoveCSSPropertyCommand::create(document(), element, property));
    376376}
    377377
  • trunk/WebCore/editing/CompositeEditCommand.h

    r49985 r65014  
    3535class CSSStyleDeclaration;
    3636class HTMLElement;
     37class StyledElement;
    3738class Text;
    3839
     
    6970    void rebalanceWhitespaceAt(const Position&);
    7071    void prepareWhitespaceAtPositionForSplit(Position&);
    71     void removeCSSProperty(PassRefPtr<CSSMutableStyleDeclaration>, CSSPropertyID);
     72    void removeCSSProperty(PassRefPtr<StyledElement>, CSSPropertyID);
    7273    void removeNodeAttribute(PassRefPtr<Element>, const QualifiedName& attribute);
    7374    void removeChildrenInRange(PassRefPtr<Node>, unsigned from, unsigned to);
  • trunk/WebCore/editing/RemoveCSSPropertyCommand.cpp

    r39456 r65014  
    3232namespace WebCore {
    3333
    34 RemoveCSSPropertyCommand::RemoveCSSPropertyCommand(Document* document, PassRefPtr<CSSMutableStyleDeclaration> style, CSSPropertyID property)
     34RemoveCSSPropertyCommand::RemoveCSSPropertyCommand(Document* document, PassRefPtr<StyledElement> element, CSSPropertyID property)
    3535    : SimpleEditCommand(document)
    36     , m_style(style)
     36    , m_element(element)
    3737    , m_property(property)
    3838    , m_important(false)
    3939{
    40     ASSERT(m_style);
     40    ASSERT(m_element);
    4141}
    4242
    4343void RemoveCSSPropertyCommand::doApply()
    4444{
    45     m_oldValue = m_style->getPropertyValue(m_property);
    46     m_important = m_style->getPropertyPriority(m_property);
    47     m_style->removeProperty(m_property);
     45    CSSMutableStyleDeclaration* style = m_element->inlineStyleDecl();
     46    m_oldValue = style->getPropertyValue(m_property);
     47    m_important = style->getPropertyPriority(m_property);
     48    style->removeProperty(m_property);
    4849}
    4950
    5051void RemoveCSSPropertyCommand::doUnapply()
    5152{
    52     m_style->setProperty(m_property, m_oldValue, m_important);
     53    CSSMutableStyleDeclaration* style = m_element->inlineStyleDecl();
     54    style->setProperty(m_property, m_oldValue, m_important);
    5355}
    5456
  • trunk/WebCore/editing/RemoveCSSPropertyCommand.h

    r43523 r65014  
    3030#include "CSSMutableStyleDeclaration.h"
    3131#include "CSSPropertyNames.h"
     32#include "StyledElement.h"
    3233
    3334namespace WebCore {
     
    3536class RemoveCSSPropertyCommand : public SimpleEditCommand {
    3637public:
    37     static PassRefPtr<RemoveCSSPropertyCommand> create(Document* document, PassRefPtr<CSSMutableStyleDeclaration> style, CSSPropertyID property)
     38    static PassRefPtr<RemoveCSSPropertyCommand> create(Document* document, PassRefPtr<StyledElement> element, CSSPropertyID property)
    3839    {
    39         return adoptRef(new RemoveCSSPropertyCommand(document, style, property));
     40        return adoptRef(new RemoveCSSPropertyCommand(document, element, property));
    4041    }
    4142
    4243private:
    43     RemoveCSSPropertyCommand(Document*, PassRefPtr<CSSMutableStyleDeclaration>, CSSPropertyID property);
     44    RemoveCSSPropertyCommand(Document*, PassRefPtr<StyledElement>, CSSPropertyID property);
    4445
    4546    virtual void doApply();
    4647    virtual void doUnapply();
    4748
    48     RefPtr<CSSMutableStyleDeclaration> m_style;
     49    RefPtr<StyledElement> m_element;
    4950    CSSPropertyID m_property;
    5051    String m_oldValue;
Note: See TracChangeset for help on using the changeset viewer.