Title: [172153] trunk
Revision
172153
Author
mmaxfi...@apple.com
Date
2014-08-06 10:35:59 -0700 (Wed, 06 Aug 2014)

Log Message

Text-shadow with (0, 0) offset and radius = 0 is ugly
https://bugs.webkit.org/show_bug.cgi?id=135357

Reviewed by Darin Adler.

Source/WebCore:

Instead, check for this kind of shadow and don't draw it.

Test: fast/text/empty-shadow.html

* rendering/TextPainter.cpp:
(WebCore::isEmptyShadow): Does a shadow match these criteria?
(WebCore::paintTextWithShadows): If so, don't draw it.

LayoutTests:

Check that this kind of shadow ends up invisible.

* fast/text/empty-shadow-expected.html: Added
* fast/text/empty-shadow.html: Added

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (172152 => 172153)


--- trunk/LayoutTests/ChangeLog	2014-08-06 17:27:41 UTC (rev 172152)
+++ trunk/LayoutTests/ChangeLog	2014-08-06 17:35:59 UTC (rev 172153)
@@ -1,3 +1,15 @@
+2014-07-28  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Text-shadow with (0, 0) offset and radius = 0 is ugly
+        https://bugs.webkit.org/show_bug.cgi?id=135357
+
+        Reviewed by Darin Adler.
+
+        Check that this kind of shadow ends up invisible.
+
+        * fast/text/empty-shadow-expected.html: Added
+        * fast/text/empty-shadow.html: Added
+
 2014-08-06  Mihnea Ovidenie  <mih...@adobe.com>
 
         [CSSRegions] Move full screen tests into fast/regions/fullscreen

Added: trunk/LayoutTests/fast/text/empty-shadow-expected.html (0 => 172153)


--- trunk/LayoutTests/fast/text/empty-shadow-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/empty-shadow-expected.html	2014-08-06 17:35:59 UTC (rev 172153)
@@ -0,0 +1,3 @@
+This tests that text drawn with text-shadows of radius 0 and (0, 0) offset are not drawn.
+This is a better outcome than them being drawn in an ugly way.
+This test is successful if the text below is completely invisible.

Added: trunk/LayoutTests/fast/text/empty-shadow.html (0 => 172153)


--- trunk/LayoutTests/fast/text/empty-shadow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/empty-shadow.html	2014-08-06 17:35:59 UTC (rev 172153)
@@ -0,0 +1,4 @@
+This tests that text drawn with text-shadows of radius 0 and (0, 0) offset are not drawn.
+This is a better outcome than them being drawn in an ugly way.
+This test is successful if the text below is completely invisible.
+<div style="color:#fff;text-shadow:0 0 #000">This is some text</div>

Modified: trunk/Source/WebCore/ChangeLog (172152 => 172153)


--- trunk/Source/WebCore/ChangeLog	2014-08-06 17:27:41 UTC (rev 172152)
+++ trunk/Source/WebCore/ChangeLog	2014-08-06 17:35:59 UTC (rev 172153)
@@ -1,3 +1,18 @@
+2014-07-28  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Text-shadow with (0, 0) offset and radius = 0 is ugly
+        https://bugs.webkit.org/show_bug.cgi?id=135357
+
+        Reviewed by Darin Adler.
+
+        Instead, check for this kind of shadow and don't draw it.
+
+        Test: fast/text/empty-shadow.html
+
+        * rendering/TextPainter.cpp:
+        (WebCore::isEmptyShadow): Does a shadow match these criteria?
+        (WebCore::paintTextWithShadows): If so, don't draw it.
+
 2014-08-06  Andy Estes  <aes...@apple.com>
 
         [iOS] QuickLook returns an invalid MIME type for some documents

Modified: trunk/Source/WebCore/rendering/TextPainter.cpp (172152 => 172153)


--- trunk/Source/WebCore/rendering/TextPainter.cpp	2014-08-06 17:27:41 UTC (rev 172152)
+++ trunk/Source/WebCore/rendering/TextPainter.cpp	2014-08-06 17:35:59 UTC (rev 172153)
@@ -60,6 +60,13 @@
         context.drawEmphasisMarks(font, textRun, emphasisMark, point + IntSize(0, emphasisMarkOffset), from, to);
 }
 
+static bool isEmptyShadow(const ShadowData* shadowPtr)
+{
+    if (!shadowPtr)
+        return true;
+    return shadow->location() == IntPoint() && !shadow->radius();
+}
+
 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)
@@ -72,7 +79,8 @@
 
     do {
         IntSize extraOffset;
-        if (shadow)
+        bool shadowIsEmpty = isEmptyShadow(shadow);
+        if (!shadowIsEmpty)
             extraOffset = roundedIntSize(InlineTextBox::applyShadowToGraphicsContext(context, shadow, boxRect, stroked, opaque, horizontal));
         else if (!opaque)
             context->setFillColor(fillColor, fillColorSpace);
@@ -91,7 +99,7 @@
 
         if (shadow->next() || stroked || !opaque)
             context->restore();
-        else
+        else if (!shadowIsEmpty)
             context->clearShadow();
 
         shadow = shadow->next();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to