Bug 148531

Summary: Document window.NodeFilter properties
Product: WebKit Reporter: Chris Dumez <cdumez>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: bfulgham, commit-queue, darin, dbates, ggaren, kling, rniwa, sam
Priority: P2    
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=148602
Bug Depends on:    
Bug Blocks: 148415    
Attachments:
Description Flags
Patch ggaren: review+

Description Chris Dumez 2015-08-27 10:32:54 PDT
Document window.NodeFilter properties to detect changes to them. This is in preparation of Bug 148415 as this will help detect unwanted changes to the interface when making NodeFilter a callback interface.
Comment 1 Chris Dumez 2015-08-27 10:36:20 PDT
Created attachment 260068 [details]
Patch
Comment 2 Geoffrey Garen 2015-08-27 14:39:04 PDT
Comment on attachment 260068 [details]
Patch

r=me
Comment 3 Chris Dumez 2015-08-27 14:42:44 PDT
Committed r189059: <http://trac.webkit.org/changeset/189059>
Comment 4 Brent Fulgham 2015-08-28 09:19:28 PDT
This produces an interesting test failure on Windows:

--- /home/buildbot/slave/win-release-tests/build/layout-test-results/fast/dom/node-filter-interface-expected.txt
+++ /home/buildbot/slave/win-release-tests/build/layout-test-results/fast/dom/node-filter-interface-actual.txt
@@ -10,7 +10,7 @@
 * FILTER_SKIP
 [Configurable: false, enumerable: true, writable: false, value: 3]
 * SHOW_ALL
-[Configurable: false, enumerable: true, writable: false, value: 4294967295]
+[Configurable: false, enumerable: true, writable: false, value: -1]
 * SHOW_ATTRIBUTE
 [Configurable: false, enumerable: true, writable: false, value: 2]
 * SHOW_CDATA_SECTION

It looks like Windows is using an unsigned value for whatever flag is being displayed here. Windows uses a signed value for enums by default -- is this flag an enum?

I might need to make sure the enum is typed as unsigned so the Windows build works properly.
Comment 5 Chris Dumez 2015-08-28 09:31:48 PDT
(In reply to comment #4)
> This produces an interesting test failure on Windows:
> 
> ---
> /home/buildbot/slave/win-release-tests/build/layout-test-results/fast/dom/
> node-filter-interface-expected.txt
> +++
> /home/buildbot/slave/win-release-tests/build/layout-test-results/fast/dom/
> node-filter-interface-actual.txt
> @@ -10,7 +10,7 @@
>  * FILTER_SKIP
>  [Configurable: false, enumerable: true, writable: false, value: 3]
>  * SHOW_ALL
> -[Configurable: false, enumerable: true, writable: false, value: 4294967295]
> +[Configurable: false, enumerable: true, writable: false, value: -1]
>  * SHOW_ATTRIBUTE
>  [Configurable: false, enumerable: true, writable: false, value: 2]
>  * SHOW_CDATA_SECTION
> 
> It looks like Windows is using an unsigned value for whatever flag is being
> displayed here. Windows uses a signed value for enums by default -- is this
> flag an enum?
> 
> I might need to make sure the enum is typed as unsigned so the Windows build
> works properly.

Yes, it looks like a bad bug if NodeFilter.SHOW_ALL maps to -1 on Windows. It is supposed to be 0xFFFFFFFF as per the spec. It looks like we may need to tweak the following enum in NodeFilter.h to do the right thing on Windows as well:
enum {
        SHOW_ALL                       = 0xFFFFFFFF,
        SHOW_ELEMENT                   = 0x00000001,
        SHOW_ATTRIBUTE                 = 0x00000002,
        SHOW_TEXT                      = 0x00000004,
        SHOW_CDATA_SECTION             = 0x00000008,
        SHOW_ENTITY_REFERENCE          = 0x00000010,
        SHOW_ENTITY                    = 0x00000020,
        SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
        SHOW_COMMENT                   = 0x00000080,
        SHOW_DOCUMENT                  = 0x00000100,
        SHOW_DOCUMENT_TYPE             = 0x00000200,
        SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
        SHOW_NOTATION                  = 0x00000800
    };
Comment 6 Chris Dumez 2015-08-28 09:33:23 PDT
(In reply to comment #5)
> (In reply to comment #4)
> > This produces an interesting test failure on Windows:
> > 
> > ---
> > /home/buildbot/slave/win-release-tests/build/layout-test-results/fast/dom/
> > node-filter-interface-expected.txt
> > +++
> > /home/buildbot/slave/win-release-tests/build/layout-test-results/fast/dom/
> > node-filter-interface-actual.txt
> > @@ -10,7 +10,7 @@
> >  * FILTER_SKIP
> >  [Configurable: false, enumerable: true, writable: false, value: 3]
> >  * SHOW_ALL
> > -[Configurable: false, enumerable: true, writable: false, value: 4294967295]
> > +[Configurable: false, enumerable: true, writable: false, value: -1]
> >  * SHOW_ATTRIBUTE
> >  [Configurable: false, enumerable: true, writable: false, value: 2]
> >  * SHOW_CDATA_SECTION
> > 
> > It looks like Windows is using an unsigned value for whatever flag is being
> > displayed here. Windows uses a signed value for enums by default -- is this
> > flag an enum?
> > 
> > I might need to make sure the enum is typed as unsigned so the Windows build
> > works properly.
> 
> Yes, it looks like a bad bug if NodeFilter.SHOW_ALL maps to -1 on Windows.
> It is supposed to be 0xFFFFFFFF as per the spec. It looks like we may need
> to tweak the following enum in NodeFilter.h to do the right thing on Windows
> as well:
> enum {
>         SHOW_ALL                       = 0xFFFFFFFF,
>         SHOW_ELEMENT                   = 0x00000001,
>         SHOW_ATTRIBUTE                 = 0x00000002,
>         SHOW_TEXT                      = 0x00000004,
>         SHOW_CDATA_SECTION             = 0x00000008,
>         SHOW_ENTITY_REFERENCE          = 0x00000010,
>         SHOW_ENTITY                    = 0x00000020,
>         SHOW_PROCESSING_INSTRUCTION    = 0x00000040,
>         SHOW_COMMENT                   = 0x00000080,
>         SHOW_DOCUMENT                  = 0x00000100,
>         SHOW_DOCUMENT_TYPE             = 0x00000200,
>         SHOW_DOCUMENT_FRAGMENT         = 0x00000400,
>         SHOW_NOTATION                  = 0x00000800
>     };

Are you able to try something like this?

diff --git a/Source/WebCore/dom/NodeFilter.h b/Source/WebCore/dom/NodeFilter.h
index 26f7663..061129a 100644
--- a/Source/WebCore/dom/NodeFilter.h
+++ b/Source/WebCore/dom/NodeFilter.h
@@ -53,7 +53,7 @@ public:
      * their values are derived by using a bit position corresponding
      * to the value of NodeType for the equivalent node type.
      */
-    enum {
+    enum : unsigned long {
         SHOW_ALL                       = 0xFFFFFFFF,
         SHOW_ELEMENT                   = 0x00000001,
         SHOW_ATTRIBUTE                 = 0x00000002,