Bug 144137

Summary: SVGFilterBuilder should drive the builtin sourceAlpha from the passed sourceGraphic
Product: WebKit Reporter: Said Abou-Hallawa <sabouhallawa>
Component: SVGAssignee: Said Abou-Hallawa <sabouhallawa>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
test case
none
Patch
none
Patch none

Description Said Abou-Hallawa 2015-04-23 18:37:58 PDT
Created attachment 251526 [details]
test case

Open the attached test case.

Result: A black square is displayed.
Expected: A lime square should be displayed.

When creating the SVGFilterBuilder, we create a SourceAlpha object from the current SourceGraphic. We should create the SourceAlpha from the previousEffect. If there is no effect applied before, the previousEffect will be the sourceGraphic.

In the attached test case. Here is what is happening:

1. A lime <div> is created.
2. On top of it, a red <div> is created. But two filter are applied to this <div>
   a. The first filter is css opacity(0) filter, which results a transparent square (the alpha bytes are all zeros)
   b. The second filter is an SVG filter which merges the SourceAlpha of the filter with the existing drawing.

The bug happens because we create the SourceAlpha of the SVGFilterBuilder from the current SourceGraphic. And since the current SourceGraphic is a lime square, the sourceAlpha will be black square (the r, g, b are zeros but a is 1). So when it is merged with the existing drawing it draws a black square.
Comment 1 Said Abou-Hallawa 2015-04-24 12:36:43 PDT
Created attachment 251565 [details]
Patch
Comment 2 WebKit Commit Bot 2015-04-24 12:38:13 PDT
Attachment 251565 [details] did not pass style-queue:


ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp:29:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp:36:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.cpp:39:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.cpp:55:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.h:37:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.h:54:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h:40:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h:42:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 8 in 87 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 3 Darin Adler 2015-04-26 12:08:40 PDT
Comment on attachment 251565 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=251565&action=review

> Source/WebCore/platform/graphics/filters/SourceAlpha.cpp:32
> +Ref<SourceAlpha> SourceAlpha::create(FilterEffect* sourceEffect)

Should be a reference, since the code below assumes it’s non-null. Could do that in a later patch, though.

> Source/WebCore/platform/graphics/filters/SourceAlpha.cpp:75
> +SourceAlpha::SourceAlpha(FilterEffect* sourceEffect)

Should be a reference, since the code below assumes it’s non-null. Could do that in a later patch, though.
Comment 4 Said Abou-Hallawa 2015-04-26 18:44:41 PDT
Created attachment 251717 [details]
Patch
Comment 5 WebKit Commit Bot 2015-04-26 18:47:22 PDT
Attachment 251717 [details] did not pass style-queue:


ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp:29:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.cpp:36:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.cpp:39:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.cpp:55:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.h:37:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFEImage.h:54:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h:40:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
ERROR: Source/WebCore/svg/graphics/filters/SVGFilterBuilder.h:42:  The parameter type should use PassRefPtr instead of RefPtr.  [readability/pass_ptr] [5]
Total errors found: 8 in 87 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 6 Said Abou-Hallawa 2015-04-26 20:05:42 PDT
(In reply to comment #3)
> Comment on attachment 251565 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=251565&action=review
> 
> > Source/WebCore/platform/graphics/filters/SourceAlpha.cpp:32
> > +Ref<SourceAlpha> SourceAlpha::create(FilterEffect* sourceEffect)
> 
> Should be a reference, since the code below assumes it’s non-null. Could do
> that in a later patch, though.
> 

Done.

> > Source/WebCore/platform/graphics/filters/SourceAlpha.cpp:75
> > +SourceAlpha::SourceAlpha(FilterEffect* sourceEffect)
> 
> Should be a reference, since the code below assumes it’s non-null. Could do
> that in a later patch, though.

Done.
Comment 7 WebKit Commit Bot 2015-04-26 20:52:36 PDT
Comment on attachment 251717 [details]
Patch

Clearing flags on attachment: 251717

Committed r183381: <http://trac.webkit.org/changeset/183381>
Comment 8 WebKit Commit Bot 2015-04-26 20:52:39 PDT
All reviewed patches have been landed.  Closing bug.
Comment 9 Radar WebKit Bug Importer 2015-04-26 20:53:24 PDT
<rdar://problem/20704289>