Title: [156500] trunk/Source/WebCore
Revision
156500
Author
[email protected]
Date
2013-09-26 15:01:38 -0700 (Thu, 26 Sep 2013)

Log Message

Don't mutate style in RenderCombineText
https://bugs.webkit.org/show_bug.cgi?id=121979

Reviewed by Andreas Kling.

Text renderers should always have the same style as the parent.

* rendering/InlineTextBox.cpp:
(WebCore::fontToUse):
(WebCore::InlineTextBox::localSelectionRect):
(WebCore::InlineTextBox::paint):
(WebCore::InlineTextBox::offsetForPosition):
(WebCore::InlineTextBox::positionForOffset):
        
    Select the modified font for text-combine.

* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::styleDidChange):
(WebCore::RenderCombineText::combineText):
* rendering/RenderCombineText.h:
        
    Move the text-combine specific font style to a member of its own.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (156499 => 156500)


--- trunk/Source/WebCore/ChangeLog	2013-09-26 21:45:22 UTC (rev 156499)
+++ trunk/Source/WebCore/ChangeLog	2013-09-26 22:01:38 UTC (rev 156500)
@@ -1,3 +1,28 @@
+2013-09-26  Antti Koivisto  <[email protected]>
+
+        Don't mutate style in RenderCombineText
+        https://bugs.webkit.org/show_bug.cgi?id=121979
+
+        Reviewed by Andreas Kling.
+
+        Text renderers should always have the same style as the parent.
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::fontToUse):
+        (WebCore::InlineTextBox::localSelectionRect):
+        (WebCore::InlineTextBox::paint):
+        (WebCore::InlineTextBox::offsetForPosition):
+        (WebCore::InlineTextBox::positionForOffset):
+        
+            Select the modified font for text-combine.
+
+        * rendering/RenderCombineText.cpp:
+        (WebCore::RenderCombineText::styleDidChange):
+        (WebCore::RenderCombineText::combineText):
+        * rendering/RenderCombineText.h:
+        
+            Move the text-combine specific font style to a member of its own.
+
 2013-09-26  Anders Carlsson  <[email protected]>
 
         Remove PassWeak.h

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (156499 => 156500)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-09-26 21:45:22 UTC (rev 156499)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2013-09-26 22:01:38 UTC (rev 156500)
@@ -189,6 +189,16 @@
     length += hyphenString.length();
 }
 
+static const Font& fontToUse(const RenderStyle& style, const RenderText& renderer)
+{
+    if (style.hasTextCombine() && renderer.isCombineText()) {
+        const RenderCombineText& textCombineRenderer = toRenderCombineText(renderer);
+        if (textCombineRenderer.isCombined())
+            return textCombineRenderer.textCombineFont();
+    }
+    return style.font();
+}
+
 LayoutRect InlineTextBox::localSelectionRect(int startPos, int endPos)
 {
     int sPos = max(startPos - m_start, 0);
@@ -202,7 +212,7 @@
     LayoutUnit selTop = selectionTop();
     LayoutUnit selHeight = selectionHeight();
     RenderStyle* styleToUse = renderer().style(isFirstLineStyle());
-    const Font& font = styleToUse->font();
+    const Font& font = fontToUse(*styleToUse, renderer());
 
     BufferForAppendingHyphen charactersWithHyphen;
     bool respectHyphen = ePos == m_len && hasHyphen();
@@ -660,7 +670,7 @@
     }
 
     // Set our font.
-    const Font& font = styleToUse->font();
+    const Font& font = fontToUse(*styleToUse, renderer());
 
     FloatPoint textOrigin = FloatPoint(boxOrigin.x(), boxOrigin.y() + font.fontMetrics().ascent());
 
@@ -1544,7 +1554,7 @@
     FontCachePurgePreventer fontCachePurgePreventer;
 
     RenderStyle* style = renderer().style(isFirstLineStyle());
-    const Font& font = style->font();
+    const Font& font = fontToUse(*style, renderer());
     return font.offsetForPosition(constructTextRun(style, font), lineOffset - logicalLeft(), includePartialGlyphs);
 }
 
@@ -1560,7 +1570,7 @@
 
     RenderStyle* styleToUse = renderer().style(isFirstLineStyle());
     ASSERT(styleToUse);
-    const Font& font = styleToUse->font();
+    const Font& font = fontToUse(*styleToUse, renderer());
     int from = !isLeftToRightDirection() ? offset - m_start : 0;
     int to = !isLeftToRightDirection() ? m_len : offset - m_start;
     // FIXME: Do we need to add rightBearing here?

Modified: trunk/Source/WebCore/rendering/RenderCombineText.cpp (156499 => 156500)


--- trunk/Source/WebCore/rendering/RenderCombineText.cpp	2013-09-26 21:45:22 UTC (rev 156499)
+++ trunk/Source/WebCore/rendering/RenderCombineText.cpp	2013-09-26 22:01:38 UTC (rev 156500)
@@ -38,7 +38,9 @@
 
 void RenderCombineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
-    setStyleInternal(RenderStyle::clone(style()));
+    // FIXME: This is pretty hackish.
+    m_combineFontStyle = RenderStyle::clone(style());
+
     RenderText::styleDidChange(diff, oldStyle);
 
     if (m_isCombined) {
@@ -110,7 +112,7 @@
     FontSelector* fontSelector = style()->font().fontSelector();
 
     if (m_isCombined)
-        shouldUpdateFont = style()->setFontDescription(description); // Need to change font orientation to horizontal.
+        shouldUpdateFont = m_combineFontStyle->setFontDescription(description); // Need to change font orientation to horizontal.
     else {
         // Need to try compressed glyphs.
         static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth, QuarterWidth };
@@ -124,17 +126,17 @@
                 m_isCombined = true;
 
                 // Replace my font with the new one.
-                shouldUpdateFont = style()->setFontDescription(description);
+                shouldUpdateFont = m_combineFontStyle->setFontDescription(description);
                 break;
             }
         }
     }
 
     if (!m_isCombined)
-        shouldUpdateFont = style()->setFontDescription(originalFont().fontDescription());
+        shouldUpdateFont = m_combineFontStyle->setFontDescription(originalFont().fontDescription());
 
     if (shouldUpdateFont)
-        style()->font().update(fontSelector);
+        m_combineFontStyle->font().update(fontSelector);
 
     if (m_isCombined) {
         DEFINE_STATIC_LOCAL(String, objectReplacementCharacterString, (&objectReplacementCharacter, 1));

Modified: trunk/Source/WebCore/rendering/RenderCombineText.h (156499 => 156500)


--- trunk/Source/WebCore/rendering/RenderCombineText.h	2013-09-26 21:45:22 UTC (rev 156499)
+++ trunk/Source/WebCore/rendering/RenderCombineText.h	2013-09-26 22:01:38 UTC (rev 156500)
@@ -40,6 +40,7 @@
     bool isCombined() const { return m_isCombined; }
     float combinedTextWidth(const Font& font) const { return font.size(); }
     const Font& originalFont() const { return parent()->style()->font(); }
+    const Font& textCombineFont() const { return m_combineFontStyle->font(); }
 
 private:
     void node() const WTF_DELETED_FUNCTION;
@@ -50,6 +51,7 @@
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle);
     virtual void setTextInternal(const String&) OVERRIDE;
 
+    RefPtr<RenderStyle> m_combineFontStyle;
     float m_combinedTextWidth;
     bool m_isCombined : 1;
     bool m_needsFontUpdate : 1;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to