Title: [106415] trunk
Revision
106415
Author
[email protected]
Date
2012-01-31 17:21:32 -0800 (Tue, 31 Jan 2012)

Log Message

Failing 2d.shadow.enable.off.2.html on Lion
https://bugs.webkit.org/show_bug.cgi?id=77489

Reviewed by Dan Bernstein.

Source/WebCore: 

The canvas spec requires that shadows not be drawn under certain
circumstances outlined here: http://www.whatwg.org/specs/web-apps/current-work/#shadows
This patch adds in those checks which allows us to pass now (on Lion)
the philip canvas test that was checking that constraint.

No new tests. Unskipping the test on Lion that this patch fixes.

* html/canvas/CanvasRenderingContext2D.cpp:
(WebCore::CanvasRenderingContext2D::setAllAttributesToDefault):
(WebCore::CanvasRenderingContext2D::setShadow):
(WebCore::CanvasRenderingContext2D::applyShadow):
(WebCore::CanvasRenderingContext2D::shouldDrawShadows):
* html/canvas/CanvasRenderingContext2D.h:
(CanvasRenderingContext2D):

LayoutTests: 

* platform/mac-lion/Skipped: We can unskip this test now that this patch has us passing this test.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (106414 => 106415)


--- trunk/LayoutTests/ChangeLog	2012-02-01 01:18:38 UTC (rev 106414)
+++ trunk/LayoutTests/ChangeLog	2012-02-01 01:21:32 UTC (rev 106415)
@@ -1,3 +1,12 @@
+2012-01-31  Matthew Delaney  <[email protected]>
+
+        Failing 2d.shadow.enable.off.2.html on Lion
+        https://bugs.webkit.org/show_bug.cgi?id=77489
+
+        Reviewed by Dan Bernstein.
+
+        * platform/mac-lion/Skipped: We can unskip this test now that this patch has us passing this test.
+
 2012-01-31  Oliver Hunt  <[email protected]>
 
         Remove unneeded sourceId property

Modified: trunk/LayoutTests/platform/mac-lion/Skipped (106414 => 106415)


--- trunk/LayoutTests/platform/mac-lion/Skipped	2012-02-01 01:18:38 UTC (rev 106414)
+++ trunk/LayoutTests/platform/mac-lion/Skipped	2012-02-01 01:21:32 UTC (rev 106415)
@@ -1,8 +1,5 @@
 # --- Canvas ---
 
-# <rdar://problem/9121810>
-canvas/philip/tests/2d.shadow.enable.off.2.html
-
 # This test incorrectly checks the shadow blur's distance and needs to be fixed
 # <rdar://problem/9326220>
 fast/canvas/canvas-scale-shadowBlur.html

Modified: trunk/Source/WebCore/ChangeLog (106414 => 106415)


--- trunk/Source/WebCore/ChangeLog	2012-02-01 01:18:38 UTC (rev 106414)
+++ trunk/Source/WebCore/ChangeLog	2012-02-01 01:21:32 UTC (rev 106415)
@@ -1,3 +1,25 @@
+2012-01-31  Matthew Delaney  <[email protected]>
+
+        Failing 2d.shadow.enable.off.2.html on Lion
+        https://bugs.webkit.org/show_bug.cgi?id=77489
+
+        Reviewed by Dan Bernstein.
+
+        The canvas spec requires that shadows not be drawn under certain
+        circumstances outlined here: http://www.whatwg.org/specs/web-apps/current-work/#shadows
+        This patch adds in those checks which allows us to pass now (on Lion)
+        the philip canvas test that was checking that constraint.
+
+        No new tests. Unskipping the test on Lion that this patch fixes.
+
+        * html/canvas/CanvasRenderingContext2D.cpp:
+        (WebCore::CanvasRenderingContext2D::setAllAttributesToDefault):
+        (WebCore::CanvasRenderingContext2D::setShadow):
+        (WebCore::CanvasRenderingContext2D::applyShadow):
+        (WebCore::CanvasRenderingContext2D::shouldDrawShadows):
+        * html/canvas/CanvasRenderingContext2D.h:
+        (CanvasRenderingContext2D):
+
 2012-01-31  Anders Carlsson  <[email protected]>
 
         TileCache::setNeedsDisplayInRect cleanup

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp (106414 => 106415)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-02-01 01:18:38 UTC (rev 106414)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp	2012-02-01 01:21:32 UTC (rev 106415)
@@ -315,7 +315,7 @@
     if (!context)
         return;
 
-    context->setLegacyShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB);
+    applyShadow();
     context->setAlpha(1);
     context->setCompositeOperation(CompositeSourceOver);
 }
@@ -1150,7 +1150,7 @@
     if (!c)
         return;
 
-    c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    applyShadow();
 }
 
 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, const String& color, float alpha)
@@ -1168,7 +1168,7 @@
     if (!c)
         return;
 
-    c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    applyShadow();
 }
 
 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float grayLevel, float alpha)
@@ -1181,7 +1181,7 @@
     if (!c)
         return;
 
-    c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    applyShadow();
 }
 
 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float r, float g, float b, float a)
@@ -1194,7 +1194,7 @@
     if (!c)
         return;
 
-    c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    applyShadow();
 }
 
 void CanvasRenderingContext2D::setShadow(float width, float height, float blur, float c, float m, float y, float k, float a)
@@ -1214,7 +1214,7 @@
     CGContextSetShadowWithColor(dc->platformContext(), adjustedShadowSize(width, -height), blur, shadowColor);
     CGColorRelease(shadowColor);
 #else
-    dc->setLegacyShadow(FloatSize(width, -height), blur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    applyShadow();
 #endif
 }
 
@@ -1232,11 +1232,19 @@
     if (!c)
         return;
 
-    float width = state().m_shadowOffset.width();
-    float height = state().m_shadowOffset.height();
-    c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    if (shouldDrawShadows()) {
+        float width = state().m_shadowOffset.width();
+        float height = state().m_shadowOffset.height();
+        c->setLegacyShadow(FloatSize(width, -height), state().m_shadowBlur, state().m_shadowColor, ColorSpaceDeviceRGB);
+    } else
+        c->setLegacyShadow(FloatSize(), 0, Color::transparent, ColorSpaceDeviceRGB);
 }
 
+bool CanvasRenderingContext2D::shouldDrawShadows() const
+{
+    return alphaChannel(state().m_shadowColor) && (state().m_shadowBlur || !state().m_shadowOffset.isZero());
+}
+
 static LayoutSize size(HTMLImageElement* image)
 {
     if (CachedImage* cachedImage = image->cachedImage())

Modified: trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h (106414 => 106415)


--- trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2012-02-01 01:18:38 UTC (rev 106414)
+++ trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h	2012-02-01 01:21:32 UTC (rev 106415)
@@ -278,6 +278,7 @@
     const State& state() const { return m_stateStack.last(); }
 
     void applyShadow();
+    bool shouldDrawShadows() const;
 
     void didDraw(const FloatRect&, unsigned options = CanvasDidDrawApplyAll);
     void didDrawEntireCanvas();
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to