Changeset 43243 in webkit


Ignore:
Timestamp:
May 5, 2009 10:33:10 AM (15 years ago)
Author:
mitz@apple.com
Message:

WebCore:

Reviewed by Darin Adler.

  • fix <rdar://problem/5760774> Replying to a Mail message that contains fixed width text can change the size of the text

Covered by existing tests: editing/pasteboard/5027857.html

editing/pasteboard/paste-pre-002.html

  • css/CSSComputedStyleDeclaration.cpp: (WebCore::CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword): Added. If the font-size is keyword-based, returns the keyword value instead of the pixel size. (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): If font-family is a generic family, return the generic family instead of the the internal string -webkit-[serif|sans-serif|cursive|fantasy |monospace]. (WebCore::CSSComputedStyleDeclaration::copyInheritableProperties): For the font-size property, prefer a keyword value over a pixel size.
  • css/CSSComputedStyleDeclaration.h:
  • editing/ApplyStyleCommand.cpp: (WebCore::StyleChange::currentlyHasStyle): For the font-size property, call getFontSizeCSSValuePreferringKeyword().
  • platform/graphics/FontDescription.h: (WebCore::FontDescription::keywordSize): Changed the return type to unsigned. (WebCore::FontDescription::setKeywordSize): Changed the parameter type to unsigned. (WebCore::FontDescription::m_keywordSize): Changed the type of this 4-bit field to unsigned, because it takes values as high as 8.

LayoutTests:

Reviewed by Darin Adler.

  • updated results for <rdar://problem/5760774> Replying to a Mail message that contains fixed width text can change the size of the text
  • editing/execCommand/19089-expected.txt:
  • editing/execCommand/5770834-1-expected.txt:
  • platform/mac/editing/deleting/delete-br-011-expected.txt:
  • platform/mac/editing/deleting/delete-select-all-001-expected.txt:
  • platform/mac/editing/execCommand/remove-formatting-2-expected.txt:
  • platform/mac/editing/pasteboard/5027857-expected.checksum:
  • platform/mac/editing/pasteboard/5027857-expected.png:
  • platform/mac/editing/pasteboard/5027857-expected.txt:
  • platform/mac/editing/pasteboard/paste-pre-002-expected.checksum:
  • platform/mac/editing/pasteboard/paste-pre-002-expected.png:
  • platform/mac/editing/pasteboard/paste-pre-002-expected.txt:
  • platform/mac/editing/style/block-style-004-expected.txt:
  • platform/mac/editing/style/block-style-005-expected.txt:
  • platform/mac/editing/style/block-style-006-expected.txt:
Location:
trunk
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r43238 r43243  
     12009-05-05  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - updated results for <rdar://problem/5760774> Replying to a Mail
     6          message that contains fixed width text can change the size of the text
     7
     8        * editing/execCommand/19089-expected.txt:
     9        * editing/execCommand/5770834-1-expected.txt:
     10        * platform/mac/editing/deleting/delete-br-011-expected.txt:
     11        * platform/mac/editing/deleting/delete-select-all-001-expected.txt:
     12        * platform/mac/editing/execCommand/remove-formatting-2-expected.txt:
     13        * platform/mac/editing/pasteboard/5027857-expected.checksum:
     14        * platform/mac/editing/pasteboard/5027857-expected.png:
     15        * platform/mac/editing/pasteboard/5027857-expected.txt:
     16        * platform/mac/editing/pasteboard/paste-pre-002-expected.checksum:
     17        * platform/mac/editing/pasteboard/paste-pre-002-expected.png:
     18        * platform/mac/editing/pasteboard/paste-pre-002-expected.txt:
     19        * platform/mac/editing/style/block-style-004-expected.txt:
     20        * platform/mac/editing/style/block-style-005-expected.txt:
     21        * platform/mac/editing/style/block-style-006-expected.txt:
     22
    1232009-05-05  Eric Seidel  <eric@webkit.org>
    224
  • trunk/LayoutTests/editing/execCommand/19089-expected.txt

    r34390 r43243  
    11This tests to make sure an ASSERT doesn't fire when performing a FormatBlock operation on a selection that ends just after a horizontal rule that is the last element in the document. The test should not assert.
    2 <pre><span class="Apple-style-span" style="font-family: Times; font-size: 16px; white-space: normal; "><hr></span></pre>
     2<pre><span class="Apple-style-span" style="font-family: Times; white-space: normal; "><hr></span></pre>
  • trunk/LayoutTests/editing/execCommand/5770834-1-expected.txt

    r30987 r43243  
    33
    44<div style="text-align: right;">
    5 <div style="text-align: auto;">foo<br><div style="text-align: auto;">bar</div></div>
     5<div>foo<br><div style="text-align: auto;">bar</div></div>
    66</div>
    77
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-br-011-expected.txt

    r34681 r43243  
    1717          text run at (0,0) width 31: "hello"
    1818      RenderBlock {DIV} at (0,18) size 784x56 [border: (2px solid #FF0000)]
    19         RenderInline {FONT} at (0,0) size 0x22
    20           RenderInline {SPAN} at (0,0) size 0x18
    21             RenderInline {FONT} at (0,0) size 0x28
    22               RenderInline {SPAN} at (0,0) size 0x28
    23                 RenderBR {BR} at (14,14) size 0x28
     19        RenderInline {SPAN} at (0,0) size 0x18
     20          RenderInline {FONT} at (0,0) size 0x28
     21            RenderInline {SPAN} at (0,0) size 0x28
     22              RenderBR {BR} at (14,14) size 0x28
    2423      RenderBlock (anonymous) at (0,74) size 784x0
    25 caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 0 {FONT} of child 0 {SPAN} of child 0 {FONT} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     24caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 0 {FONT} of child 0 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/deleting/delete-select-all-001-expected.txt

    r25970 r43243  
    1616      RenderBlock {DIV} at (0,0) size 784x46 [border: (2px solid #FF0000)]
    1717        RenderBlock (anonymous) at (14,14) size 756x18
    18           RenderInline {FONT} at (0,0) size 0x18
    19             RenderInline {SPAN} at (0,0) size 0x18
    20               RenderBR {BR} at (0,0) size 0x18
    21 caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 0 {FONT} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     18          RenderInline {SPAN} at (0,0) size 0x18
     19            RenderBR {BR} at (0,0) size 0x18
     20caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/execCommand/remove-formatting-2-expected.txt

    r30635 r43243  
    1717          text run at (0,18) width 625: "document default style to the selection if that's necessary in order to leave the selected text unstyled."
    1818      RenderBlock {DIV} at (0,52) size 784x18
    19         RenderText {#text} at (0,0) size 305x18
    20           text run at (0,0) width 305: "This text should look the same as the text above."
     19        RenderText {#text} at (0,0) size 28x18
     20          text run at (0,0) width 28: "This"
     21        RenderText {#text} at (28,0) size 277x18
     22          text run at (28,0) width 277: " text should look the same as the text above."
    2123selection start: position 0 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
    2224selection end:   position 4 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/pasteboard/5027857-expected.checksum

    r38122 r43243  
    1 dca49965de716b797f22b7c91f983942
     1e4120b331169668f85721755e0874d62
  • trunk/LayoutTests/platform/mac/editing/pasteboard/5027857-expected.txt

    r43215 r43243  
    33layer at (0,0) size 800x600
    44  RenderBlock {HTML} at (0,0) size 800x600
    5     RenderBody {BODY} at (8,8) size 784x576
     5    RenderBody {BODY} at (8,8) size 784x579
    66      RenderBlock {P} at (0,0) size 784x36
    77        RenderText {#text} at (0,0) size 765x36
     
    1010          text run at (0,18) width 134: "form of that markup. "
    1111          text run at (134,18) width 333: "You should see markup in the editable region below."
    12       RenderBlock {PRE} at (0,52) size 784x18
     12      RenderBlock {PRE} at (0,52) size 784x15
    1313        RenderBlock (anonymous) at (0,0) size 784x0
    1414          RenderInline {SPAN} at (0,0) size 0x0
    15         RenderBlock (anonymous) at (0,0) size 784x18
    16           RenderBlock {PRE} at (0,0) size 784x18
    17             RenderText {#text} at (0,0) size 410x18
    18               text run at (0,0) width 410: "<input type='button'>foo<br>bar<b>baz</b>"
    19         RenderBlock (anonymous) at (0,34) size 784x0
     15        RenderBlock (anonymous) at (0,0) size 784x15
     16          RenderBlock {PRE} at (0,0) size 784x15
     17            RenderText {#text} at (0,0) size 328x15
     18              text run at (0,0) width 328: "<input type='button'>foo<br>bar<b>baz</b>"
     19        RenderBlock (anonymous) at (0,28) size 784x0
    2020          RenderInline {SPAN} at (0,0) size 0x0
    2121caret: position 41 of child 0 {#text} of child 0 {PRE} of child 0 {SPAN} of child 2 {PRE} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/pasteboard/paste-pre-002-expected.checksum

    r38122 r43243  
    1 64cf24533dc634bc90c5d5daac7f92fb
     10c6f9d4d736653b2141ebd55f069296e
  • trunk/LayoutTests/platform/mac/editing/pasteboard/paste-pre-002-expected.txt

    r25970 r43243  
    1313layer at (0,0) size 800x600
    1414  RenderBlock {HTML} at (0,0) size 800x600
    15     RenderBody {BODY} at (8,8) size 784x576
     15    RenderBody {BODY} at (8,8) size 784x579
    1616      RenderBlock {DIV} at (0,0) size 784x36
    1717        RenderText {#text} at (0,0) size 147x18
     
    2525          text run at (0,18) width 263: "is selected, copied, and pasted over itself. "
    2626          text run at (263,18) width 205: "You'll see foo/nbar if successful."
    27       RenderBlock {DIV} at (0,52) size 784x36
    28         RenderBlock {DIV} at (0,0) size 784x36
    29           RenderBlock {PRE} at (0,0) size 784x36
     27      RenderBlock {DIV} at (0,49) size 784x30
     28        RenderBlock {DIV} at (0,0) size 784x30
     29          RenderBlock {PRE} at (0,0) size 784x30
    3030            RenderBlock (anonymous) at (0,0) size 784x0
    3131              RenderInline {SPAN} at (0,0) size 0x0
    32             RenderBlock (anonymous) at (0,0) size 784x36
    33               RenderBlock {PRE} at (0,0) size 784x36
    34                 RenderText {#text} at (0,0) size 30x36
    35                   text run at (0,0) width 30: "foo"
    36                   text run at (30,0) width 0: " "
    37                   text run at (0,18) width 30: "bar"
    38             RenderBlock (anonymous) at (0,52) size 784x0
     32            RenderBlock (anonymous) at (0,0) size 784x30
     33              RenderBlock {PRE} at (0,0) size 784x30
     34                RenderText {#text} at (0,0) size 24x30
     35                  text run at (0,0) width 24: "foo"
     36                  text run at (24,0) width 0: " "
     37                  text run at (0,15) width 24: "bar"
     38            RenderBlock (anonymous) at (0,43) size 784x0
    3939              RenderInline {SPAN} at (0,0) size 0x0
    4040caret: position 7 of child 0 {#text} of child 0 {PRE} of child 0 {SPAN} of child 1 {PRE} of child 1 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/style/block-style-004-expected.txt

    r25970 r43243  
    5454            RenderBR {BR} at (0,0) size 0x55
    5555        RenderBlock {DIV} at (0,110) size 784x55
    56           RenderInline {FONT} at (0,0) size 0x55
    57             RenderInline {SPAN} at (0,0) size 0x55
    58               RenderBR {BR} at (0,0) size 0x55
     56          RenderInline {SPAN} at (0,0) size 0x55
     57            RenderBR {BR} at (0,0) size 0x55
    5958        RenderBlock {DIV} at (0,165) size 784x55
    6059          RenderInline {SPAN} at (0,0) size 24x55
    6160            RenderText {#text} at (0,0) size 24x55
    6261              text run at (0,0) width 24: "x"
    63 caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 0 {FONT} of child 3 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     62caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 3 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/style/block-style-005-expected.txt

    r25970 r43243  
    5757            RenderBR {BR} at (0,0) size 0x55
    5858        RenderBlock {DIV} at (0,110) size 784x55
    59           RenderInline {FONT} at (0,0) size 0x55
    60             RenderInline {SPAN} at (0,0) size 0x55
    61               RenderBR {BR} at (0,0) size 0x55
    62 caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 0 {FONT} of child 3 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
     59          RenderInline {SPAN} at (0,0) size 0x55
     60            RenderBR {BR} at (0,0) size 0x55
     61caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 3 {DIV} of child 3 {DIV} of child 1 {BODY} of child 0 {HTML} of document
  • trunk/LayoutTests/platform/mac/editing/style/block-style-006-expected.txt

    r41465 r43243  
    5555            RenderBR {BR} at (0,0) size 0x55
    5656        RenderBlock {DIV} at (0,110) size 784x55
    57           RenderInline {FONT} at (0,0) size 0x55
    58             RenderInline {SPAN} at (0,0) size 0x55
    59               RenderBR {BR} at (0,0) size 0x55
     57          RenderInline {SPAN} at (0,0) size 0x55
     58            RenderBR {BR} at (0,0) size 0x55
    6059        RenderBlock {DIV} at (0,165) size 784x55
    6160          RenderInline {SPAN} at (0,0) size 24x55
  • trunk/WebCore/ChangeLog

    r43242 r43243  
     12009-05-05  Dan Bernstein  <mitz@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        - fix <rdar://problem/5760774> Replying to a Mail message that contains
     6          fixed width text can change the size of the text
     7
     8        Covered by existing tests: editing/pasteboard/5027857.html
     9                                   editing/pasteboard/paste-pre-002.html
     10
     11        * css/CSSComputedStyleDeclaration.cpp:
     12        (WebCore::CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword):
     13        Added. If the font-size is keyword-based, returns the keyword value
     14        instead of the pixel size.
     15        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): If
     16        font-family is a generic family, return the generic family instead of
     17        the the internal string -webkit-[serif|sans-serif|cursive|fantasy
     18        |monospace].
     19        (WebCore::CSSComputedStyleDeclaration::copyInheritableProperties):
     20        For the font-size property, prefer a keyword value over a pixel size.
     21        * css/CSSComputedStyleDeclaration.h:
     22        * editing/ApplyStyleCommand.cpp:
     23        (WebCore::StyleChange::currentlyHasStyle): For the font-size property,
     24        call getFontSizeCSSValuePreferringKeyword().
     25        * platform/graphics/FontDescription.h:
     26        (WebCore::FontDescription::keywordSize): Changed the return type to
     27        unsigned.
     28        (WebCore::FontDescription::setKeywordSize): Changed the parameter type
     29        to unsigned.
     30        (WebCore::FontDescription::m_keywordSize): Changed the type of this
     31        4-bit field to unsigned, because it takes values as high as 8.
     32
    1332009-05-05  Oliver Hunt  <oliver@apple.com>
    234
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r42116 r43243  
    539539}
    540540
     541static int cssIdentifierForFontSizeKeyword(int keywordSize)
     542{
     543    ASSERT_ARG(keywordSize, keywordSize);
     544    ASSERT_ARG(keywordSize, keywordSize <= 8);
     545    return CSSValueXxSmall + keywordSize - 1;
     546}
     547
     548PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
     549{
     550    Node* node = m_node.get();
     551    if (!node)
     552        return 0;
     553
     554    node->document()->updateLayoutIgnorePendingStylesheets();
     555
     556    RefPtr<RenderStyle> style = node->computedStyle();
     557    if (!style)
     558        return 0;
     559
     560    if (int keywordSize = style->fontDescription().keywordSize())
     561        return CSSPrimitiveValue::createIdentifier(cssIdentifierForFontSizeKeyword(keywordSize));
     562
     563    return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
     564}
     565
    541566PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
    542567{
    543568    return getPropertyCSSValue(propertyID, UpdateLayout);
     569}
     570
     571static int toCSSIdentifier(FontDescription::GenericFamilyType genericFamily)
     572{
     573    switch (genericFamily) {
     574        case FontDescription::SerifFamily:
     575            return CSSValueSerif;
     576            break;
     577        case FontDescription::SansSerifFamily:
     578            return CSSValueSansSerif;
     579            break;
     580        case FontDescription::MonospaceFamily:
     581            return CSSValueMonospace;
     582            break;
     583        case FontDescription::CursiveFamily:
     584            return CSSValueCursive;
     585            break;
     586        case FontDescription::FantasyFamily:
     587            return CSSValueFantasy;
     588            break;
     589        case FontDescription::StandardFamily:
     590        case FontDescription::NoFamily:
     591        default:
     592            return 0;
     593            break;
     594    }
    544595}
    545596
     
    724775        case CSSPropertyFloat:
    725776            return CSSPrimitiveValue::create(style->floating());
    726         case CSSPropertyFontFamily:
     777        case CSSPropertyFontFamily: {
    727778            // FIXME: This only returns the first family.
     779            if (int id = toCSSIdentifier(style->fontDescription().genericFamily()))
     780                return CSSPrimitiveValue::createIdentifier(id);
     781
    728782            return CSSPrimitiveValue::create(style->fontDescription().family().family().string(), CSSPrimitiveValue::CSS_STRING);
     783        }
    729784        case CSSPropertyFontSize:
    730785            return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
     
    14331488            style->removeProperty(CSSPropertyWebkitTextStrokeColor, ec);
    14341489        ASSERT(ec == 0);
     1490        if (int keywordSize = m_node->computedStyle()->fontDescription().keywordSize())
     1491            style->setProperty(CSSPropertyFontSize, cssIdentifierForFontSizeKeyword(keywordSize));
    14351492    }
    14361493    return style.release();
  • trunk/WebCore/css/CSSComputedStyleDeclaration.h

    r39601 r43243  
    5151
    5252    PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
     53    PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
    5354#if ENABLE(SVG)
    5455    PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
  • trunk/WebCore/editing/ApplyStyleCommand.cpp

    r43187 r43243  
    230230    ASSERT(pos.isNotNull());
    231231    RefPtr<CSSComputedStyleDeclaration> style = pos.computedStyle();
    232     RefPtr<CSSValue> value = style->getPropertyCSSValue(property->id(), DoNotUpdateLayout);
     232    RefPtr<CSSValue> value;
     233    if (property->id() == CSSPropertyFontSize)
     234        value = style->getFontSizeCSSValuePreferringKeyword();
     235    else
     236        value = style->getPropertyCSSValue(property->id(), DoNotUpdateLayout);
    233237    if (!value)
    234238        return false;
  • trunk/WebCore/platform/graphics/FontDescription.h

    r34794 r43243  
    8282    bool usePrinterFont() const { return m_usePrinterFont; }
    8383    FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
    84     int keywordSize() const { return m_keywordSize; }
     84    unsigned keywordSize() const { return m_keywordSize; }
    8585
    8686    FontTraitsMask traitsMask() const;
     
    9696    void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
    9797    void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
    98     void setKeywordSize(int s) { m_keywordSize = s; }
     98    void setKeywordSize(unsigned s) { m_keywordSize = s; }
    9999
    100100private:
     
    115115    unsigned m_renderingMode : 1;  // Used to switch between CG and GDI text on Windows.
    116116
    117     int m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium).  If so,
     117    unsigned m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium).  If so,
    118118                           // then we can accurately translate across different generic families to adjust for different preference settings
    119119                           // (e.g., 13px monospace vs. 16px everything else).  Sizes are 1-8 (like the HTML size values for <font>).
Note: See TracChangeset for help on using the changeset viewer.