Title: [173502] trunk/Source/WebCore
Revision
173502
Author
[email protected]
Date
2014-09-10 17:50:09 -0700 (Wed, 10 Sep 2014)

Log Message

Delete class SavedDrawingStateForMask
https://bugs.webkit.org/show_bug.cgi?id=136498

Patch by Myles C. Maxfield <[email protected]> <[email protected]> on 2014-09-09
Reviewed by Darin Adler.

This class is left over from when text-decoration-skip: ink used
GraphicsContext masking.

No new tests because there is no behavior change.

* rendering/InlineTextBox.cpp:
(WebCore::InlineTextBox::applyShadowToGraphicsContext):
* rendering/InlineTextBox.h:
* rendering/TextPainter.cpp:
(WebCore::TextPainter::TextPainter):
(WebCore::paintTextWithShadows):
(WebCore::TextPainter::paintText):
* rendering/TextPainter.h:
(WebCore::SavedDrawingStateForMask::SavedDrawingStateForMask): Deleted.
* rendering/svg/SVGInlineTextBox.cpp:
(WebCore::SVGInlineTextBox::paintTextWithShadows):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (173501 => 173502)


--- trunk/Source/WebCore/ChangeLog	2014-09-11 00:47:26 UTC (rev 173501)
+++ trunk/Source/WebCore/ChangeLog	2014-09-11 00:50:09 UTC (rev 173502)
@@ -1,3 +1,27 @@
+2014-09-09  Myles C. Maxfield <[email protected]>  <[email protected]>
+
+        Delete class SavedDrawingStateForMask
+        https://bugs.webkit.org/show_bug.cgi?id=136498
+
+        Reviewed by Darin Adler.
+
+        This class is left over from when text-decoration-skip: ink used
+        GraphicsContext masking.
+
+        No new tests because there is no behavior change.
+
+        * rendering/InlineTextBox.cpp:
+        (WebCore::InlineTextBox::applyShadowToGraphicsContext):
+        * rendering/InlineTextBox.h:
+        * rendering/TextPainter.cpp:
+        (WebCore::TextPainter::TextPainter):
+        (WebCore::paintTextWithShadows):
+        (WebCore::TextPainter::paintText):
+        * rendering/TextPainter.h:
+        (WebCore::SavedDrawingStateForMask::SavedDrawingStateForMask): Deleted.
+        * rendering/svg/SVGInlineTextBox.cpp:
+        (WebCore::SVGInlineTextBox::paintTextWithShadows):
+
 2014-09-10  Tim Horton  <[email protected]>
 
         Call setCollectsTimingData only once, and before making any {CF,NS}URLConnections

Modified: trunk/Source/WebCore/rendering/InlineTextBox.cpp (173501 => 173502)


--- trunk/Source/WebCore/rendering/InlineTextBox.cpp	2014-09-11 00:47:26 UTC (rev 173501)
+++ trunk/Source/WebCore/rendering/InlineTextBox.cpp	2014-09-11 00:50:09 UTC (rev 173502)
@@ -424,7 +424,7 @@
     return false;
 }
 
-FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext* context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext)
+FloatSize InlineTextBox::applyShadowToGraphicsContext(GraphicsContext& context, const ShadowData* shadow, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext)
 {
     if (!shadow)
         return FloatSize();
@@ -440,15 +440,15 @@
         FloatRect shadowRect(textRect);
         shadowRect.inflate(shadow->paintingExtent());
         shadowRect.move(shadowOffset);
-        context->save();
-        context->clip(shadowRect);
+        context.save();
+        context.clip(shadowRect);
 
         extraOffset = FloatSize(0, 2 * textRect.height() + std::max(0.0f, shadowOffset.height()) + shadowRadius);
         shadowOffset -= extraOffset;
         didSaveContext = true;
     }
 
-    context->setShadow(shadowOffset, shadowRadius, shadowColor, context->fillColorSpace());
+    context.setShadow(shadowOffset, shadowRadius, shadowColor, context.fillColorSpace());
     return extraOffset;
 }
 

Modified: trunk/Source/WebCore/rendering/InlineTextBox.h (173501 => 173502)


--- trunk/Source/WebCore/rendering/InlineTextBox.h	2014-09-11 00:47:26 UTC (rev 173501)
+++ trunk/Source/WebCore/rendering/InlineTextBox.h	2014-09-11 00:50:09 UTC (rev 173502)
@@ -155,7 +155,7 @@
     virtual float positionForOffset(int offset) const;
 
     // Needs to be public, so the static paintTextWithShadows() function can use it.
-    static FloatSize applyShadowToGraphicsContext(GraphicsContext*, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext);
+    static FloatSize applyShadowToGraphicsContext(GraphicsContext&, const ShadowData*, const FloatRect& textRect, bool stroked, bool opaque, bool horizontal, bool& didSaveContext);
 
 protected:
     void paintCompositionBackground(GraphicsContext*, const FloatPoint& boxOrigin, const RenderStyle&, const Font&, int startPos, int endPos);

Modified: trunk/Source/WebCore/rendering/TextPainter.cpp (173501 => 173502)


--- trunk/Source/WebCore/rendering/TextPainter.cpp	2014-09-11 00:47:26 UTC (rev 173501)
+++ trunk/Source/WebCore/rendering/TextPainter.cpp	2014-09-11 00:50:09 UTC (rev 173502)
@@ -27,6 +27,7 @@
 #include "InlineTextBox.h"
 #include "RenderCombineText.h"
 #include "TextPaintStyle.h"
+#include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
 
@@ -34,20 +35,24 @@
     int startPositionInTextRun, int endPositionInTextBoxString, int length, const AtomicString& emphasisMark, RenderCombineText* combinedText, TextRun& textRun,
     FloatRect& boxRect, FloatPoint& textOrigin, int emphasisMarkOffset, const ShadowData* textShadow, const ShadowData* selectionShadow,
     bool textBoxIsHorizontal, TextPaintStyle& textPaintStyle, TextPaintStyle& selectionPaintStyle)
-    : m_paintSelectedTextOnly(paintSelectedTextOnly)
-    , m_paintSelectedTextSeparately(paintSelectedTextSeparately)
-    , m_font(font)
-    , m_startPositionInTextRun(startPositionInTextRun)
-    , m_endPositionInTextRun(endPositionInTextBoxString)
-    , m_length(length)
-    , m_emphasisMark(emphasisMark)
-    , m_combinedText(combinedText)
-    , m_textRun(textRun)
-    , m_boxRect(boxRect)
-    , m_textOrigin(textOrigin)
-    , m_emphasisMarkOffset(emphasisMarkOffset)
-    , m_textBoxIsHorizontal(textBoxIsHorizontal)
-    , m_savedDrawingStateForMask(&context, &textPaintStyle, &selectionPaintStyle, textShadow, selectionShadow)
+        : m_context(context)
+        , m_textPaintStyle(textPaintStyle)
+        , m_selectionPaintStyle(selectionPaintStyle)
+        , m_textShadow(textShadow)
+        , m_selectionShadow(selectionShadow)
+        , m_paintSelectedTextOnly(paintSelectedTextOnly)
+        , m_paintSelectedTextSeparately(paintSelectedTextSeparately)
+        , m_font(font)
+        , m_startPositionInTextRun(startPositionInTextRun)
+        , m_endPositionInTextRun(endPositionInTextBoxString)
+        , m_length(length)
+        , m_emphasisMark(emphasisMark)
+        , m_combinedText(combinedText)
+        , m_textRun(textRun)
+        , m_boxRect(boxRect)
+        , m_textOrigin(textOrigin)
+        , m_emphasisMarkOffset(emphasisMarkOffset)
+        , m_textBoxIsHorizontal(textBoxIsHorizontal)
 {
 }
 
@@ -67,15 +72,15 @@
     return shadow->location() == IntPoint() && !shadow->radius();
 }
 
-static void paintTextWithShadows(GraphicsContext* context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark,
+static void paintTextWithShadows(GraphicsContext& context, const Font& font, const TextRun& textRun, const AtomicString& emphasisMark,
     int emphasisMarkOffset, int startOffset, int endOffset, int truncationPoint, const FloatPoint& textOrigin, const FloatRect& boxRect,
     const ShadowData* shadow, bool stroked, bool horizontal)
 {
-    Color fillColor = context->fillColor();
-    ColorSpace fillColorSpace = context->fillColorSpace();
+    Color fillColor = context.fillColor();
+    ColorSpace fillColorSpace = context.fillColorSpace();
     bool opaque = !fillColor.hasAlpha();
     if (!opaque)
-        context->setFillColor(Color::black, fillColorSpace);
+        context.setFillColor(Color::black, fillColorSpace);
 
     do {
         if (isEmptyShadow(shadow)) {
@@ -88,24 +93,24 @@
         if (shadow)
             extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, horizontal, didSaveContext));
         else if (!opaque)
-            context->setFillColor(fillColor, fillColorSpace);
+            context.setFillColor(fillColor, fillColorSpace);
 
         if (startOffset <= endOffset)
-            drawTextOrEmphasisMarks(*context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, endOffset);
+            drawTextOrEmphasisMarks(context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, endOffset);
         else {
             if (endOffset > 0)
-                drawTextOrEmphasisMarks(*context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, 0, endOffset);
+                drawTextOrEmphasisMarks(context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, 0, endOffset);
             if (startOffset < truncationPoint)
-                drawTextOrEmphasisMarks(*context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, truncationPoint);
+                drawTextOrEmphasisMarks(context, font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + extraOffset, startOffset, truncationPoint);
         }
 
         if (!shadow)
             break;
 
         if (didSaveContext)
-            context->restore();
+            context.restore();
         else
-            context->clearShadow();
+            context.clearShadow();
 
         shadow = shadow->next();
     } while (shadow || stroked || !opaque);
@@ -113,62 +118,59 @@
 
 void TextPainter::paintText()
 {
-    ASSERT(m_savedDrawingStateForMask.m_textPaintStyle);
-    ASSERT(m_savedDrawingStateForMask.m_selectionPaintStyle);
-    
     FloatPoint boxOrigin = m_boxRect.location();
 
     if (!m_paintSelectedTextOnly) {
         // For stroked painting, we have to change the text drawing mode. It's probably dangerous to leave that mutated as a side
         // effect, so only when we know we're stroking, do a save/restore.
-        GraphicsContextStateSaver stateSaver(*m_savedDrawingStateForMask.m_context, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0);
+        GraphicsContextStateSaver stateSaver(m_context, m_textPaintStyle.strokeWidth > 0);
 
-        updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_textPaintStyle);
+        updateGraphicsContext(m_context, m_textPaintStyle);
         if (!m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun) {
             // FIXME: Truncate right-to-left text correctly.
-            paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_font, m_textRun, nullAtom, 0, 0, m_length, m_length, m_textOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
+            paintTextWithShadows(m_context, m_font, m_textRun, nullAtom, 0, 0, m_length, m_length, m_textOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
         } else
-            paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_font, m_textRun, nullAtom, 0, m_endPositionInTextRun, m_startPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
+            paintTextWithShadows(m_context, m_font, m_textRun, nullAtom, 0, m_endPositionInTextRun, m_startPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
 
         if (!m_emphasisMark.isEmpty()) {
-            updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_textPaintStyle, UseEmphasisMarkColor);
+            updateGraphicsContext(m_context, m_textPaintStyle, UseEmphasisMarkColor);
 
-            DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1));
-            TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun : m_textRun;
+            static NeverDestroyed<TextRun> objectReplacementCharacterTextRun(&objectReplacementCharacter, 1);
+            TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun.get() : m_textRun;
             FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin;
             if (m_combinedText)
-                m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Clockwise));
+                m_context.concatCTM(rotation(m_boxRect, Clockwise));
 
             if (!m_paintSelectedTextSeparately || m_endPositionInTextRun <= m_startPositionInTextRun) {
                 // FIXME: Truncate right-to-left text correctly.
-                paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, 0, m_length, m_length, emphasisMarkTextOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
+                paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, 0, m_length, m_length, emphasisMarkTextOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
             } else
-                paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_endPositionInTextRun, m_startPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_savedDrawingStateForMask.m_textShadow, m_savedDrawingStateForMask.m_textPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
+                paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_endPositionInTextRun, m_startPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_textShadow, m_textPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
 
             if (m_combinedText)
-                m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Counterclockwise));
+                m_context.concatCTM(rotation(m_boxRect, Counterclockwise));
         }
     }
 
     if ((m_paintSelectedTextOnly || m_paintSelectedTextSeparately) && m_startPositionInTextRun < m_endPositionInTextRun) {
         // paint only the text that is selected
-        GraphicsContextStateSaver stateSaver(*m_savedDrawingStateForMask.m_context, m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth > 0);
+        GraphicsContextStateSaver stateSaver(m_context, m_selectionPaintStyle.strokeWidth > 0);
 
-        updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_selectionPaintStyle);
-        paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_font, m_textRun, nullAtom, 0, m_startPositionInTextRun, m_endPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_savedDrawingStateForMask.m_selectionShadow, m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
+        updateGraphicsContext(m_context, m_selectionPaintStyle);
+        paintTextWithShadows(m_context, m_font, m_textRun, nullAtom, 0, m_startPositionInTextRun, m_endPositionInTextRun, m_length, m_textOrigin, m_boxRect, m_selectionShadow, m_selectionPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
         if (!m_emphasisMark.isEmpty()) {
-            updateGraphicsContext(*m_savedDrawingStateForMask.m_context, *m_savedDrawingStateForMask.m_selectionPaintStyle, UseEmphasisMarkColor);
+            updateGraphicsContext(m_context, m_selectionPaintStyle, UseEmphasisMarkColor);
 
             DEPRECATED_DEFINE_STATIC_LOCAL(TextRun, objectReplacementCharacterTextRun, (&objectReplacementCharacter, 1));
             TextRun& emphasisMarkTextRun = m_combinedText ? objectReplacementCharacterTextRun : m_textRun;
             FloatPoint emphasisMarkTextOrigin = m_combinedText ? FloatPoint(boxOrigin.x() + m_boxRect.width() / 2, boxOrigin.y() + m_font.fontMetrics().ascent()) : m_textOrigin;
             if (m_combinedText)
-                m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Clockwise));
+                m_context.concatCTM(rotation(m_boxRect, Clockwise));
 
-            paintTextWithShadows(m_savedDrawingStateForMask.m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_startPositionInTextRun, m_endPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_savedDrawingStateForMask.m_selectionShadow, m_savedDrawingStateForMask.m_selectionPaintStyle->strokeWidth > 0, m_textBoxIsHorizontal);
+            paintTextWithShadows(m_context, m_combinedText ? m_combinedText->originalFont() : m_font, emphasisMarkTextRun, m_emphasisMark, m_emphasisMarkOffset, m_startPositionInTextRun, m_endPositionInTextRun, m_length, emphasisMarkTextOrigin, m_boxRect, m_selectionShadow, m_selectionPaintStyle.strokeWidth > 0, m_textBoxIsHorizontal);
 
             if (m_combinedText)
-                m_savedDrawingStateForMask.m_context->concatCTM(rotation(m_boxRect, Counterclockwise));
+                m_context.concatCTM(rotation(m_boxRect, Counterclockwise));
         }
     }
 }

Modified: trunk/Source/WebCore/rendering/TextPainter.h (173501 => 173502)


--- trunk/Source/WebCore/rendering/TextPainter.h	2014-09-11 00:47:26 UTC (rev 173501)
+++ trunk/Source/WebCore/rendering/TextPainter.h	2014-09-11 00:50:09 UTC (rev 173502)
@@ -41,23 +41,6 @@
         : AffineTransform(0, -1, 1, 0, boxRect.x() - boxRect.maxY(), boxRect.x() + boxRect.maxY());
 }
 
-struct SavedDrawingStateForMask {
-    SavedDrawingStateForMask(GraphicsContext* context, TextPaintStyle* textPaintStyle, TextPaintStyle* selectionPaintStyle,
-    const ShadowData* textShadow, const ShadowData* selectionShadow)
-        : m_context(context)
-        , m_textPaintStyle(textPaintStyle)
-        , m_selectionPaintStyle(selectionPaintStyle)
-        , m_textShadow(textShadow)
-        , m_selectionShadow(selectionShadow)
-    {
-    }
-    GraphicsContext* m_context;
-    TextPaintStyle* m_textPaintStyle;
-    TextPaintStyle* m_selectionPaintStyle;
-    const ShadowData* m_textShadow;
-    const ShadowData* m_selectionShadow;
-};
-
 class TextPainter {
 public:
     TextPainter(GraphicsContext&, bool paintSelectedTextOnly, bool paintSelectedTextSeparately, const Font&,
@@ -70,6 +53,11 @@
     DashArray dashesForIntersectionsWithRect(const FloatRect& lineExtents);
 
 private:
+    GraphicsContext& m_context;
+    TextPaintStyle& m_textPaintStyle;
+    TextPaintStyle& m_selectionPaintStyle;
+    const ShadowData* m_textShadow;
+    const ShadowData* m_selectionShadow;
     bool m_paintSelectedTextOnly;
     bool m_paintSelectedTextSeparately;
     const Font& m_font;
@@ -83,7 +71,6 @@
     FloatPoint m_textOrigin;
     int m_emphasisMarkOffset;
     bool m_textBoxIsHorizontal;
-    SavedDrawingStateForMask m_savedDrawingStateForMask;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp (173501 => 173502)


--- trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2014-09-11 00:47:26 UTC (rev 173501)
+++ trunk/Source/WebCore/rendering/svg/SVGInlineTextBox.cpp	2014-09-11 00:50:09 UTC (rev 173502)
@@ -597,7 +597,7 @@
         FloatSize extraOffset;
         bool didSaveContext = false;
         if (shadow)
-            extraOffset = applyShadowToGraphicsContext(context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */, didSaveContext);
+            extraOffset = applyShadowToGraphicsContext(*context, shadow, shadowRect, false /* stroked */, true /* opaque */, true /* horizontal */, didSaveContext);
 
         context->save();
         context->scale(FloatSize(1 / scalingFactor, 1 / scalingFactor));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to