Commit 5df9b802 authored by mitz@apple.com's avatar mitz@apple.com

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:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43243 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 39ffc4de
2009-05-05 Dan Bernstein <mitz@apple.com>
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:
2009-05-05 Eric Seidel <eric@webkit.org>
Reviewed by Adam Roben.
This 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.
<pre><span class="Apple-style-span" style="font-family: Times; font-size: 16px; white-space: normal; "><hr></span></pre>
<pre><span class="Apple-style-span" style="font-family: Times; white-space: normal; "><hr></span></pre>
......@@ -2,6 +2,6 @@ This tests for a crash when removing format from two paragraphs that are inside
<div style="text-align: right;">
<div style="text-align: auto;">foo<br><div style="text-align: auto;">bar</div></div>
<div>foo<br><div style="text-align: auto;">bar</div></div>
</div>
......@@ -16,10 +16,9 @@ layer at (0,0) size 800x600
RenderText {#text} at (0,0) size 31x18
text run at (0,0) width 31: "hello"
RenderBlock {DIV} at (0,18) size 784x56 [border: (2px solid #FF0000)]
RenderInline {FONT} at (0,0) size 0x22
RenderInline {SPAN} at (0,0) size 0x18
RenderInline {FONT} at (0,0) size 0x28
RenderInline {SPAN} at (0,0) size 0x28
RenderBR {BR} at (14,14) size 0x28
RenderInline {SPAN} at (0,0) size 0x18
RenderInline {FONT} at (0,0) size 0x28
RenderInline {SPAN} at (0,0) size 0x28
RenderBR {BR} at (14,14) size 0x28
RenderBlock (anonymous) at (0,74) size 784x0
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
caret: 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
......@@ -15,7 +15,6 @@ layer at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x584
RenderBlock {DIV} at (0,0) size 784x46 [border: (2px solid #FF0000)]
RenderBlock (anonymous) at (14,14) size 756x18
RenderInline {FONT} at (0,0) size 0x18
RenderInline {SPAN} at (0,0) size 0x18
RenderBR {BR} at (0,0) size 0x18
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
RenderInline {SPAN} at (0,0) size 0x18
RenderBR {BR} at (0,0) size 0x18
caret: position 0 of child 0 {BR} of child 0 {SPAN} of child 1 {DIV} of child 1 {BODY} of child 0 {HTML} of document
......@@ -16,7 +16,9 @@ layer at (0,0) size 800x600
text run at (0,0) width 722: "This tests that RemoveFormat not only removes style from the selected part of the DOM, but that it also applies the"
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."
RenderBlock {DIV} at (0,52) size 784x18
RenderText {#text} at (0,0) size 305x18
text run at (0,0) width 305: "This text should look the same as the text above."
RenderText {#text} at (0,0) size 28x18
text run at (0,0) width 28: "This"
RenderText {#text} at (28,0) size 277x18
text run at (28,0) width 277: " text should look the same as the text above."
selection start: position 0 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
selection end: position 4 of child 0 {#text} of child 2 {DIV} of child 1 {BODY} of child 0 {HTML} of document
dca49965de716b797f22b7c91f983942
\ No newline at end of file
e4120b331169668f85721755e0874d62
\ No newline at end of file
......@@ -2,20 +2,20 @@ layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x576
RenderBody {BODY} at (8,8) size 784x579
RenderBlock {P} at (0,0) size 784x36
RenderText {#text} at (0,0) size 765x36
text run at (0,0) width 414: "This tests a bug when copying HTML markup inside <pre> tags. "
text run at (414,0) width 351: "When pasted, this content would appear as the rendered"
text run at (0,18) width 134: "form of that markup. "
text run at (134,18) width 333: "You should see markup in the editable region below."
RenderBlock {PRE} at (0,52) size 784x18
RenderBlock {PRE} at (0,52) size 784x15
RenderBlock (anonymous) at (0,0) size 784x0
RenderInline {SPAN} at (0,0) size 0x0
RenderBlock (anonymous) at (0,0) size 784x18
RenderBlock {PRE} at (0,0) size 784x18
RenderText {#text} at (0,0) size 410x18
text run at (0,0) width 410: "<input type='button'>foo<br>bar<b>baz</b>"
RenderBlock (anonymous) at (0,34) size 784x0
RenderBlock (anonymous) at (0,0) size 784x15
RenderBlock {PRE} at (0,0) size 784x15
RenderText {#text} at (0,0) size 328x15
text run at (0,0) width 328: "<input type='button'>foo<br>bar<b>baz</b>"
RenderBlock (anonymous) at (0,28) size 784x0
RenderInline {SPAN} at (0,0) size 0x0
caret: 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
64cf24533dc634bc90c5d5daac7f92fb
\ No newline at end of file
0c6f9d4d736653b2141ebd55f069296e
\ No newline at end of file
......@@ -12,7 +12,7 @@ layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x600
RenderBlock {HTML} at (0,0) size 800x600
RenderBody {BODY} at (8,8) size 784x576
RenderBody {BODY} at (8,8) size 784x579
RenderBlock {DIV} at (0,0) size 784x36
RenderText {#text} at (0,0) size 147x18
text run at (0,0) width 147: "This is a layout test for "
......@@ -24,17 +24,17 @@ layer at (0,0) size 800x600
text run at (689,0) width 95: "The text below"
text run at (0,18) width 263: "is selected, copied, and pasted over itself. "
text run at (263,18) width 205: "You'll see foo/nbar if successful."
RenderBlock {DIV} at (0,52) size 784x36
RenderBlock {DIV} at (0,0) size 784x36
RenderBlock {PRE} at (0,0) size 784x36
RenderBlock {DIV} at (0,49) size 784x30
RenderBlock {DIV} at (0,0) size 784x30
RenderBlock {PRE} at (0,0) size 784x30
RenderBlock (anonymous) at (0,0) size 784x0
RenderInline {SPAN} at (0,0) size 0x0
RenderBlock (anonymous) at (0,0) size 784x36
RenderBlock {PRE} at (0,0) size 784x36
RenderText {#text} at (0,0) size 30x36
text run at (0,0) width 30: "foo"
text run at (30,0) width 0: " "
text run at (0,18) width 30: "bar"
RenderBlock (anonymous) at (0,52) size 784x0
RenderBlock (anonymous) at (0,0) size 784x30
RenderBlock {PRE} at (0,0) size 784x30
RenderText {#text} at (0,0) size 24x30
text run at (0,0) width 24: "foo"
text run at (24,0) width 0: " "
text run at (0,15) width 24: "bar"
RenderBlock (anonymous) at (0,43) size 784x0
RenderInline {SPAN} at (0,0) size 0x0
caret: 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
......@@ -53,11 +53,10 @@ layer at (0,0) size 800x600
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderBlock {DIV} at (0,110) size 784x55
RenderInline {FONT} at (0,0) size 0x55
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderBlock {DIV} at (0,165) size 784x55
RenderInline {SPAN} at (0,0) size 24x55
RenderText {#text} at (0,0) size 24x55
text run at (0,0) width 24: "x"
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
caret: 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
......@@ -56,7 +56,6 @@ layer at (0,0) size 800x600
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderBlock {DIV} at (0,110) size 784x55
RenderInline {FONT} at (0,0) size 0x55
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
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
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
caret: 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
......@@ -54,9 +54,8 @@ layer at (0,0) size 800x600
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderBlock {DIV} at (0,110) size 784x55
RenderInline {FONT} at (0,0) size 0x55
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderInline {SPAN} at (0,0) size 0x55
RenderBR {BR} at (0,0) size 0x55
RenderBlock {DIV} at (0,165) size 784x55
RenderInline {SPAN} at (0,0) size 24x55
RenderText {#text} at (0,0) size 24x55
......
2009-05-05 Dan Bernstein <mitz@apple.com>
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.
2009-05-05 Oliver Hunt <oliver@apple.com>
Reviewed by Maciej Stachowiak.
......@@ -538,11 +538,62 @@ void CSSComputedStyleDeclaration::setCssText(const String&, ExceptionCode& ec)
ec = NO_MODIFICATION_ALLOWED_ERR;
}
static int cssIdentifierForFontSizeKeyword(int keywordSize)
{
ASSERT_ARG(keywordSize, keywordSize);
ASSERT_ARG(keywordSize, keywordSize <= 8);
return CSSValueXxSmall + keywordSize - 1;
}
PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getFontSizeCSSValuePreferringKeyword() const
{
Node* node = m_node.get();
if (!node)
return 0;
node->document()->updateLayoutIgnorePendingStylesheets();
RefPtr<RenderStyle> style = node->computedStyle();
if (!style)
return 0;
if (int keywordSize = style->fontDescription().keywordSize())
return CSSPrimitiveValue::createIdentifier(cssIdentifierForFontSizeKeyword(keywordSize));
return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
}
PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID) const
{
return getPropertyCSSValue(propertyID, UpdateLayout);
}
static int toCSSIdentifier(FontDescription::GenericFamilyType genericFamily)
{
switch (genericFamily) {
case FontDescription::SerifFamily:
return CSSValueSerif;
break;
case FontDescription::SansSerifFamily:
return CSSValueSansSerif;
break;
case FontDescription::MonospaceFamily:
return CSSValueMonospace;
break;
case FontDescription::CursiveFamily:
return CSSValueCursive;
break;
case FontDescription::FantasyFamily:
return CSSValueFantasy;
break;
case FontDescription::StandardFamily:
case FontDescription::NoFamily:
default:
return 0;
break;
}
}
PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int propertyID, EUpdateLayout updateLayout) const
{
Node* node = m_node.get();
......@@ -723,9 +774,13 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
return CSSPrimitiveValue::create(style->emptyCells());
case CSSPropertyFloat:
return CSSPrimitiveValue::create(style->floating());
case CSSPropertyFontFamily:
case CSSPropertyFontFamily: {
// FIXME: This only returns the first family.
if (int id = toCSSIdentifier(style->fontDescription().genericFamily()))
return CSSPrimitiveValue::createIdentifier(id);
return CSSPrimitiveValue::create(style->fontDescription().family().family().string(), CSSPrimitiveValue::CSS_STRING);
}
case CSSPropertyFontSize:
return CSSPrimitiveValue::create(style->fontDescription().computedPixelSize(), CSSPrimitiveValue::CSS_PX);
case CSSPropertyWebkitBinding:
......@@ -1432,6 +1487,8 @@ PassRefPtr<CSSMutableStyleDeclaration> CSSComputedStyleDeclaration::copyInherita
if (!m_node->computedStyle()->textStrokeColor().isValid())
style->removeProperty(CSSPropertyWebkitTextStrokeColor, ec);
ASSERT(ec == 0);
if (int keywordSize = m_node->computedStyle()->fontDescription().keywordSize())
style->setProperty(CSSPropertyFontSize, cssIdentifierForFontSizeKeyword(keywordSize));
}
return style.release();
}
......
......@@ -50,6 +50,7 @@ public:
virtual PassRefPtr<CSSMutableStyleDeclaration> makeMutable();
PassRefPtr<CSSValue> getPropertyCSSValue(int propertyID, EUpdateLayout) const;
PassRefPtr<CSSValue> getFontSizeCSSValuePreferringKeyword() const;
#if ENABLE(SVG)
PassRefPtr<CSSValue> getSVGPropertyCSSValue(int propertyID, EUpdateLayout) const;
#endif
......
......@@ -229,7 +229,11 @@ bool StyleChange::currentlyHasStyle(const Position &pos, const CSSProperty *prop
{
ASSERT(pos.isNotNull());
RefPtr<CSSComputedStyleDeclaration> style = pos.computedStyle();
RefPtr<CSSValue> value = style->getPropertyCSSValue(property->id(), DoNotUpdateLayout);
RefPtr<CSSValue> value;
if (property->id() == CSSPropertyFontSize)
value = style->getFontSizeCSSValuePreferringKeyword();
else
value = style->getPropertyCSSValue(property->id(), DoNotUpdateLayout);
if (!value)
return false;
return equalIgnoringCase(value->cssText(), property->value()->cssText());
......
......@@ -81,7 +81,7 @@ public:
GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
bool usePrinterFont() const { return m_usePrinterFont; }
FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
int keywordSize() const { return m_keywordSize; }
unsigned keywordSize() const { return m_keywordSize; }
FontTraitsMask traitsMask() const;
......@@ -95,7 +95,7 @@ public:
void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
void setKeywordSize(int s) { m_keywordSize = s; }
void setKeywordSize(unsigned s) { m_keywordSize = s; }
private:
FontFamily m_familyList; // The list of font families to be used.
......@@ -114,7 +114,7 @@ private:
unsigned m_renderingMode : 1; // Used to switch between CG and GDI text on Windows.
int m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium). If so,
unsigned m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium). If so,
// then we can accurately translate across different generic families to adjust for different preference settings
// (e.g., 13px monospace vs. 16px everything else). Sizes are 1-8 (like the HTML size values for <font>).
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment