Changeset 46286 in webkit


Ignore:
Timestamp:
Jul 23, 2009 2:17:00 PM (15 years ago)
Author:
rniwa@webkit.org
Message:

WebCore:

2009-07-22 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

execCommand('underline') can't remove <U> underlines
https://bugs.webkit.org/show_bug.cgi?id=20215

This patch adds support for u, s, and strike to implicitlyStyledElementShouldBeRemovedWhenApplyingStyle so that
WebKit can remove those presentational tags when necessary.
It also modifies StyleChange::init not to add "text-decoration: none". Not only is this style meaningless
(does not override inherited styles) but it was also causing WebKit to generate extra spans with this style.

  • css/CSSValueList.cpp: (WebCore::CSSValueList::hasValue): True if the property contains the specified value
  • css/CSSValueList.h: Updated prototype
  • editing/ApplyStyleCommand.cpp: (WebCore::StyleChange::init): No longer adds "text-decoration: none" (WebCore::ApplyStyleCommand::implicitlyStyledElementShouldBeRemovedWhenApplyingStyle): Supports text-decoration-related elements

LayoutTests:

2009-07-22 Ryosuke Niwa <rniwa@webkit.org>

Reviewed by Eric Seidel.

execCommand('underline') can't remove <U> underlines
https://bugs.webkit.org/show_bug.cgi?id=20215

This patch rebaselines toggle-styles.html because WebKit now passes three tests it used to fail.
toggle-style-2.html is added to test cases in which multiple styles are specified with tags.
We still fail some tests because WebKit doesn't properly support non-CSS mode but they are visually correct.

  • editing/execCommand/resources/toggle-style-2.js: Added. (testSingleToggle): (testDoubleToggle):
  • editing/execCommand/toggle-style-2-expected.txt: Added.
  • editing/execCommand/toggle-style-2.html: Added.
  • editing/execCommand/toggle-styles-expected.txt: Passes all the tests
Location:
trunk
Files:
3 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r46285 r46286  
     12009-07-22  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        execCommand('underline') can't remove <U> underlines
     6        https://bugs.webkit.org/show_bug.cgi?id=20215
     7
     8        This patch rebaselines toggle-styles.html because WebKit now passes three tests it used to fail.
     9        toggle-style-2.html is added to test cases in which multiple styles are specified with tags.
     10        We still fail some tests because WebKit doesn't properly support non-CSS mode but they are visually correct.
     11
     12        * editing/execCommand/resources/toggle-style-2.js: Added.
     13        (testSingleToggle):
     14        (testDoubleToggle):
     15        * editing/execCommand/toggle-style-2-expected.txt: Added.
     16        * editing/execCommand/toggle-style-2.html: Added.
     17        * editing/execCommand/toggle-styles-expected.txt: Passes all the tests
     18
    1192009-07-23  Jessie Berlin  <jberlin@apple.com>
    220
  • trunk/LayoutTests/editing/execCommand/toggle-styles-expected.txt

    r40384 r46286  
    2020PASS superscript removing vertical-align: super
    2121PASS strikethrough toggle
    22 FAIL strikethrough removing strike -- <strike><span class="Apple-style-span" style="text-decoration: none;">test</span></strike>
     22PASS strikethrough removing strike
    2323PASS strikethrough removing text-decoration: line-through
    24 FAIL strikethrough removing s -- <s><span class="Apple-style-span" style="text-decoration: none;">test</span></s>
     24PASS strikethrough removing s
    2525PASS underline toggle
    26 FAIL underline removing u -- <u><span class="Apple-style-span" style="text-decoration: none;">test</span></u>
     26PASS underline removing u
    2727PASS underline removing text-decoration: underline
    2828PASS successfullyParsed is true
  • trunk/WebCore/ChangeLog

    r46285 r46286  
     12009-07-22  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        execCommand('underline') can't remove <U> underlines
     6        https://bugs.webkit.org/show_bug.cgi?id=20215
     7
     8        This patch adds support for u, s, and strike to implicitlyStyledElementShouldBeRemovedWhenApplyingStyle so that
     9        WebKit can remove those presentational tags when necessary.
     10        It also modifies StyleChange::init not to add "text-decoration: none".  Not only is this style meaningless
     11        (does not override inherited styles) but it was also causing WebKit to generate extra spans with this style.
     12
     13        * css/CSSValueList.cpp:
     14        (WebCore::CSSValueList::hasValue): True if the property contains the specified value
     15        * css/CSSValueList.h: Updated prototype
     16        * editing/ApplyStyleCommand.cpp:
     17        (WebCore::StyleChange::init): No longer adds "text-decoration: none"
     18        (WebCore::ApplyStyleCommand::implicitlyStyledElementShouldBeRemovedWhenApplyingStyle): Supports text-decoration-related elements
     19
    1202009-07-23  Jessie Berlin  <jberlin@apple.com>
    221       
  • trunk/WebCore/css/CSSValueList.cpp

    r46251 r46286  
    8585    return found;
    8686}
     87   
     88bool CSSValueList::hasValue(CSSValue* val)
     89{
     90    // FIXME: we should be implementing operator== to CSSValue and its derived classes
     91    // to make comparison more flexible and fast.
     92    for (size_t index = 0; index < m_values.size(); index++) {
     93        if (m_values.at(index)->cssText() == val->cssText())
     94            return true;
     95    }
     96    return false;
     97}
    8798
    8899String CSSValueList::cssText() const
  • trunk/WebCore/css/CSSValueList.h

    r46251 r46286  
    5454    void prepend(PassRefPtr<CSSValue>);
    5555    bool removeAll(CSSValue*);
     56    bool hasValue(CSSValue*);
    5657
    5758    virtual String cssText() const;
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r46238 r46286  
    9999    if (!document || !document->frame())
    100100        return;
    101        
     101
    102102    bool useHTMLFormattingTags = !document->frame()->editor()->shouldStyleWithCSS();
    103            
    104103    RefPtr<CSSMutableStyleDeclaration> mutableStyle = style->makeMutable();
    105    
     104    // We shouldn't have both text-decoration and -webkit-text-decorations-in-effect because that wouldn't make sense.
     105    ASSERT(!mutableStyle->getPropertyCSSValue(CSSPropertyTextDecoration) || !mutableStyle->getPropertyCSSValue(CSSPropertyWebkitTextDecorationsInEffect));
    106106    String styleText("");
    107 
    108107    bool addedDirection = false;
    109108    CSSMutableStyleDeclaration::const_iterator end = mutableStyle->end();
     
    131130
    132131        // Add this property
    133 
    134         if (property->id() == CSSPropertyWebkitTextDecorationsInEffect) {
    135             // we have to special-case text decorations
    136             // FIXME: Why?
     132        if (property->id() == CSSPropertyTextDecoration || property->id() == CSSPropertyWebkitTextDecorationsInEffect) {
     133            // Always use text-decoration because -webkit-text-decoration-in-effect is internal.
    137134            CSSProperty alteredProperty(CSSPropertyTextDecoration, property->value(), property->isImportant());
    138             styleText += alteredProperty.cssText();
     135            // We don't add "text-decoration: none" because it doesn't override the existing text decorations; i.e. redundant
     136            if (alteredProperty.cssText() != "none")
     137                styleText += alteredProperty.cssText();
    139138        } else
    140139            styleText += property->cssText();
     
    963962                return true;
    964963            break;
     964        case CSSPropertyTextDecoration:
     965        case CSSPropertyWebkitTextDecorationsInEffect:
     966                ASSERT(property.value());
     967                if (property.value()->isValueList()) {
     968                    CSSValueList* valueList = static_cast<CSSValueList*>(property.value());
     969                    DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, underline, (CSSPrimitiveValue::createIdentifier(CSSValueUnderline)));
     970                    DEFINE_STATIC_LOCAL(RefPtr<CSSPrimitiveValue>, lineThrough, (CSSPrimitiveValue::createIdentifier(CSSValueLineThrough)));
     971                    // Because style is new style to be applied, we delete element only if the element is not used in style.
     972                    if (!valueList->hasValue(underline.get()) && elem->hasLocalName(uTag))
     973                        return true;
     974                    if (!valueList->hasValue(lineThrough.get()) && (elem->hasLocalName(strikeTag) || elem->hasLocalName(sTag)))
     975                        return true;
     976                } else {
     977                    // If the value is NOT a list, then it must be "none", in which case we should remove all text decorations.
     978                    ASSERT(property.value()->cssText() == "none");
     979                    if (elem->hasLocalName(uTag) || elem->hasLocalName(strikeTag) || elem->hasLocalName(sTag))
     980                        return true;
     981                }
     982                break;
    965983        }
    966984    }
Note: See TracChangeset for help on using the changeset viewer.