Commit 581ed17c authored by mitz@apple.com's avatar mitz@apple.com

text-combine text retains compressed font after adding characters to it

https://bugs.webkit.org/show_bug.cgi?id=56448

Reviewed by Simon Fraser.

Source/WebCore: 

Test: fast/dynamic/text-combine.html

* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty): Allow styles with text-combine to be shared, since
only the clones on the RenderCombineText will be mutated.
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::styleDidChange): Clone the style, to avoid mutating the parent’s
style.
(WebCore::RenderCombineText::combineText): Start off with the original font; restore it if
the text cannot be combined.
* rendering/RenderCombineText.h:
(WebCore::RenderCombineText::originalFont): Added. Returns the parent’s font.

LayoutTests: 

* fast/dynamic/text-combine.html: Added.
* platform/mac/fast/dynamic/text-combine-expected.checksum: Added.
* platform/mac/fast/dynamic/text-combine-expected.png: Added.
* platform/mac/fast/dynamic/text-combine-expected.txt: Added.



git-svn-id: svn://svn.chromium.org/blink/trunk@81251 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 82ae7155
2011-03-16 Dan Bernstein <mitz@apple.com>
Reviewed by Simon Fraser.
text-combine text retains compressed font after adding characters to it
https://bugs.webkit.org/show_bug.cgi?id=56448
* fast/dynamic/text-combine.html: Added.
* platform/mac/fast/dynamic/text-combine-expected.checksum: Added.
* platform/mac/fast/dynamic/text-combine-expected.png: Added.
* platform/mac/fast/dynamic/text-combine-expected.txt: Added.
2011-03-16 Adam Roben <aroben@apple.com>
Disable jquery/effects.html
<meta charset="utf8">
<style>
html { -webkit-writing-mode: vertical-rl; }
div { font-family: 'hiragino mincho pro'; font-size: 24px; }
#combine { -webkit-text-combine: horizontal; }
</style>
<p>
These two lines should be identical:
</p>
<div>
希薄化後の1株当り利益が<span id="combine">3.67</span>ドルでした。
</div>
<div>
希薄化後の1株当り利益が<span>3.667</span>ドルでした。
</div>
<script>
document.body.offsetTop;
document.getElementById("combine").textContent = "3.667";
</script>
28cec0b94e55237d4101f782f8118d5f
\ No newline at end of file
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 784x584
RenderBlock {P} at (0,0) size 18x584
RenderText {#text} at (0,0) size 18x225
text run at (0,0) width 225: "These two lines should be identical:"
RenderBlock {DIV} at (34,0) size 36x584
RenderText {#text} at (6,0) size 24x281
text run at (6,0) width 281: "\x{5E0C}\x{8584}\x{5316}\x{5F8C}\x{306E}1\x{682A}\x{5F53}\x{308A}\x{5229}\x{76CA}\x{304C}"
RenderInline {SPAN} at (0,0) size 24x65
RenderCombineText {#text} at (6,280) size 24x65
text run at (6,280) width 65: "3.667"
RenderText {#text} at (6,344) size 24x146
text run at (6,344) width 146: "\x{30C9}\x{30EB}\x{3067}\x{3057}\x{305F}\x{3002}"
RenderBlock {DIV} at (70,0) size 36x584
RenderText {#text} at (6,0) size 24x281
text run at (6,0) width 281: "\x{5E0C}\x{8584}\x{5316}\x{5F8C}\x{306E}1\x{682A}\x{5F53}\x{308A}\x{5229}\x{76CA}\x{304C}"
RenderInline {SPAN} at (0,0) size 24x65
RenderText {#text} at (6,280) size 24x65
text run at (6,280) width 65: "3.667"
RenderText {#text} at (6,344) size 24x146
text run at (6,344) width 146: "\x{30C9}\x{30EB}\x{3067}\x{3057}\x{305F}\x{3002}"
2011-03-16 Dan Bernstein <mitz@apple.com>
Reviewed by Simon Fraser.
text-combine text retains compressed font after adding characters to it
https://bugs.webkit.org/show_bug.cgi?id=56448
Test: fast/dynamic/text-combine.html
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty): Allow styles with text-combine to be shared, since
only the clones on the RenderCombineText will be mutated.
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::styleDidChange): Clone the style, to avoid mutating the parent’s
style.
(WebCore::RenderCombineText::combineText): Start off with the original font; restore it if
the text cannot be combined.
* rendering/RenderCombineText.h:
(WebCore::RenderCombineText::originalFont): Added. Returns the parent’s font.
2011-03-14 Pavel Podivilov <podivilov@chromium.org>
Reviewed by Yury Semikhatsky.
......
......@@ -6100,8 +6100,6 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
case CSSPropertyWebkitTextCombine:
HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(textCombine, TextCombine)
if (m_style->hasTextCombine())
m_style->setUnique(); // The style could be modified in RenderCombineText depending on text metrics.
return;
case CSSPropertyWebkitTextEmphasisPosition:
......
......@@ -37,6 +37,7 @@ RenderCombineText::RenderCombineText(Node* node, PassRefPtr<StringImpl> string)
void RenderCombineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
{
setStyleInternal(RenderStyle::clone(style()));
RenderText::styleDidChange(diff, oldStyle);
if (m_isCombined)
......@@ -93,12 +94,12 @@ void RenderCombineText::combineText()
return;
TextRun run = TextRun(String(text()));
FontDescription description = style()->font().fontDescription();
FontDescription description = originalFont().fontDescription();
float emWidth = description.computedSize() * textCombineMargin;
bool shouldUpdateFont = false;
description.setOrientation(Horizontal); // We are going to draw combined text horizontally.
m_combinedTextWidth = style()->font().width(run);
m_combinedTextWidth = originalFont().width(run);
m_isCombined = m_combinedTextWidth <= emWidth;
if (m_isCombined)
......@@ -122,12 +123,14 @@ void RenderCombineText::combineText()
}
}
if (!m_isCombined)
shouldUpdateFont = style()->setFontDescription(originalFont().fontDescription());
if (shouldUpdateFont)
style()->font().update(style()->font().fontSelector());
if (m_isCombined) {
static const UChar newCharacter = objectReplacementCharacter;
DEFINE_STATIC_LOCAL(String, objectReplacementCharacterString, (&newCharacter, 1));
DEFINE_STATIC_LOCAL(String, objectReplacementCharacterString, (&objectReplacementCharacter, 1));
RenderText::setTextInternal(objectReplacementCharacterString.impl());
}
}
......
......@@ -34,6 +34,7 @@ public:
void charactersToRender(int start, const UChar*& characters, int& length) const;
bool isCombined() const { return m_isCombined; }
float combinedTextWidth(const Font& font) const { return font.size(); }
const Font& originalFont() const { return parent()->style()->font(); }
private:
virtual bool isCombineText() const { return true; }
......
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