Closed Bug 1031051 Opened 10 years ago Closed 10 years ago

Remove the xpidl-based event generator

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla33

People

(Reporter: khuey, Assigned: khuey)

References

Details

Attachments

(18 files, 3 obsolete files)

6.94 KB, patch
smaug
: review+
bzbarsky
: review+
Details | Diff | Splinter Review
12.77 KB, patch
smaug
: review+
Details | Diff | Splinter Review
11.08 KB, patch
smaug
: review+
Details | Diff | Splinter Review
11.14 KB, patch
wchen
: review+
Details | Diff | Splinter Review
13.59 KB, patch
smaug
: review+
Details | Diff | Splinter Review
16.39 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.55 KB, patch
smaug
: review+
Details | Diff | Splinter Review
8.11 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.39 KB, patch
smaug
: review+
Details | Diff | Splinter Review
15.56 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.40 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.58 KB, patch
smaug
: review+
Details | Diff | Splinter Review
15.52 KB, patch
smaug
: review+
Details | Diff | Splinter Review
47.03 KB, patch
smaug
: review+
Details | Diff | Splinter Review
18.92 KB, patch
smaug
: review+
Details | Diff | Splinter Review
3.52 KB, patch
khuey
: review+
Details | Diff | Splinter Review
20.56 KB, patch
smaug
: review+
Details | Diff | Splinter Review
10.41 KB, patch
smaug
: review+
Details | Diff | Splinter Review
      No description provided.
The empty type string when created from document.createEvent matches Chrome.
Attachment #8446840 - Flags: review?(bugs)
William tells me this is dead.
Attachment #8446842 - Flags: review?(wchen)
AFAICT this is Gecko only so we can remove the createEvent bit.
Attachment #8446848 - Flags: review?(bugs)
This also matches Chrome with the empty type string.
Attachment #8446851 - Flags: review?(bugs)
Copying Chrome again (and the spec on the nullable bits).
Attachment #8446857 - Flags: review?(bugs)
We still need the XPIDL interface for this one unfortunately.
Attachment #8446861 - Flags: review?(bugs)
Comment on attachment 8446839 [details] [diff] [review]
Part 1: Add a way to codegen InitFooEvent methods for legacy event types

LegacyEventInit is a bit ugly, but ugly it can be since no one should
need to use it.
Attachment #8446839 - Flags: review?(bugs) → review+
Comment on attachment 8446840 [details] [diff] [review]
Part 2: Migrate HashChangeEvent

I would leave web phasing API changes to another bug.
So, oldURL and newURL could stay nullable
Attachment #8446840 - Flags: review?(bugs) → review+
Comment on attachment 8446841 [details] [diff] [review]
Part 3: Migrate CloseEvent

document.createEvent shouldn't set .type.
So, in EventDispatcher::CreateEvent s/NS_LITERAL_STRING("close")/EmptyString()/

+[Constructor(DOMString type, optional CloseEventInit eventInitDict),LegacyEventInit]
space after ,

Please don't remove ? from reason.
Attachment #8446841 - Flags: review?(bugs) → review+
Comment on attachment 8446848 [details] [diff] [review]
Part 5: Migrate PopupBlockedEvent

You're firing wrong event.
No event should have type PopupBlockedEvents.

(I doubt you got green try results from this patch ;) )
Attachment #8446848 - Flags: review?(bugs) → review-
Comment on attachment 8446839 [details] [diff] [review]
Part 1: Add a way to codegen InitFooEvent methods for legacy event types

>+            self.wantsConstructorForNativeCaller = True

This member seems to be write-only.  Just nix it.

>+            if method.identifier.name == "init" + iface.identifier.name and \

I'd prefer parens around the condition to using backslash to continue line.

>+               self.originalArgs[0].argType == "const nsAString&" and \

Why not signature[1][0].type.isDOMString() ?

>+               self.originalArgs[1].argType == "bool" and \
>+               self.originalArgs[2].argType == "bool" and \

And similar here.

>+               len(self.originalArgs) - 3 == len(filter(lambda x: isinstance(x, IDLAttribute), iface.members)) - 1:

And len(signature[1])-3 on the LHS here.

Also, please document where the -3 and -1 come from.  And perhaps:

  len(x for x in iface.members if x.isAttr())

?  Or keep the filter() but isAttr() instead of using isinstance.

>+            i = 3 # Skip the boilerplate args

Maybe "Skip the boilerplate args: type, bubbles, cancelable."

>+            for m in self.descriptorProvider.getDescriptor(iface.identifier.name).interface.members:

This is moderately bogus.  We already assumed that self.descriptorProvider is a Descriptor when we got its .interface.  And in particular, iface == self.descriptorProvider.getDescriptor(iface.identifier.name), I would think.  So this can just be:

  for m in iface.members:

no?

>+                    # We initialize all the other member variables in the
>+                    # Constructor except those ones coming from the Event.

  We need to initialize all the member variables that do not come from Event.

perhaps?

>+                               cgClass.descriptor.interface).identifier.name == "Event":

Isn't cgClass.descriptor.interface == self.descriptorProvider.interface?  Might as well be consistent about which one we use, if so.  Pick one or the other.

However, in this case we should really use "iface" as the third arg, since "m" came from "iface".  The only reason this code works is because we explicitly avoid entering the loop at all when iface is "Event".

>+              aRv = rv;

  aRv.Throw(rv);

r=me with those fixed.
Attachment #8446839 - Flags: review?(bzbarsky) → review+
Comment on attachment 8446859 [details] [diff] [review]
Part 14: Migrate DOMTransactionEvent

Review of attachment 8446859 [details] [diff] [review]:
-----------------------------------------------------------------

::: content/html/content/src/UndoManager.cpp
@@ +14,5 @@
>  #include "nsIVariant.h"
>  #include "nsVariant.h"
>  #include "nsINode.h"
> +#include "mozilla/dom/DOMTransactionEvent.h"
> +#include "mozilla/dom/BindingUtils.h"

What do you need BindingUtils.h for?
Comment on attachment 8446842 [details] [diff] [review]
Part 4: Remove ElementReplaceEvent

Review of attachment 8446842 [details] [diff] [review]:
-----------------------------------------------------------------

This event was only ever used in a very old version of the custom elements spec.
Attachment #8446842 - Flags: review?(wchen) → review+
Comment on attachment 8447569 [details] [diff] [review]
Part 12.999: Support nsTArray<CallbackObject*> in ToJSValue

>+ToJSValue(JSContext* aCx,
>+          T (&aArguments)[N],
>+          JS::MutableHandle<JS::Value> aValue)

Why was this needed for nsTArray?

In any case, please put this next to the existing overload that's just like that but taking const T[N]?

r=me
Attachment #8447569 - Flags: review?(bzbarsky) → review+
I suspect it's not needed anymore.  It is an artifact of iterating.
(In reply to :Ms2ger from comment #22)
> Comment on attachment 8446859 [details] [diff] [review]
> Part 13: Migrate DOMTransactionEvent
> 
> Review of attachment 8446859 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: content/html/content/src/UndoManager.cpp
> @@ +14,5 @@
> >  #include "nsIVariant.h"
> >  #include "nsVariant.h"
> >  #include "nsINode.h"
> > +#include "mozilla/dom/DOMTransactionEvent.h"
> > +#include "mozilla/dom/BindingUtils.h"
> 
> What do you need BindingUtils.h for?

I don't.  I actually need ToJSValue.h there.  Fixed.
Attachment #8446859 - Attachment description: Part 13: Migrate DOMTransactionEvent → Part 14: Migrate DOMTransactionEvent
Attachment #8446860 - Attachment description: Part 14: Migrate Speech events → Part 15: Migrate Speech events
Attachment #8446861 - Attachment is obsolete: true
Attachment #8446861 - Flags: review?(bugs)
Attachment #8447700 - Flags: review?(bugs)
Attachment #8446863 - Attachment description: Part 16: Remove the event generator → Part 18: Remove the event generator
Comment on attachment 8446850 [details] [diff] [review]
Part 6: Migrate PopStateEvent

>+  bool result = true;
>+  nsPIDOMWindow* outerWindow = GetOuterWindow();
>+  nsCOMPtr<EventTarget> outerWindowET = do_QueryInterface(outerWindow);
>+  NS_ENSURE_TRUE(outerWindowET, NS_ERROR_FAILURE);
>+
>+  AutoJSAPI jsapi;
>+  result = jsapi.Init(outerWindow);
>+  NS_ENSURE_TRUE(result, NS_ERROR_FAILURE);
>+
>+  JSContext* cx = jsapi.cx();
>+  JS::Rooted<JS::Value> stateJSValue(cx, JSVAL_NULL);
JS::NullValue()

>+  if (aEventType.LowerCaseEqualsLiteral("popstateevent")) {
>+    AutoJSContext cx;
>+    RootedDictionary<PopStateEventInit> init(cx);
>+    nsRefPtr<PopStateEvent> event =
>+      PopStateEvent::Constructor(aOwner, NS_LITERAL_STRING("popstate"), init);
EmptyString(), not "popstate"


/me cries. Adding explicit JSAPI usage.
Attachment #8446850 - Flags: review?(bugs) → review+
Comment on attachment 8446850 [details] [diff] [review]
Part 6: Migrate PopStateEvent

>-  if (aEventType.LowerCaseEqualsLiteral("popstateevent"))
>-    return NS_NewDOMPopStateEvent(aDOMEvent, aOwner, aPresContext, nullptr);
>   if (aEventType.LowerCaseEqualsLiteral("closeevent")) {
>     CloseEventInit init;
>     nsRefPtr<CloseEvent> event =
>       CloseEvent::Constructor(aOwner, NS_LITERAL_STRING("close"), init);
>     event.forget(aDOMEvent);
>     return NS_OK;
>   }
>+  if (aEventType.LowerCaseEqualsLiteral("popstateevent")) {
>+    AutoJSContext cx;
>+    RootedDictionary<PopStateEventInit> init(cx);
>+    nsRefPtr<PopStateEvent> event =
>+      PopStateEvent::Constructor(aOwner, NS_LITERAL_STRING("popstate"), init);
>+    event.forget(aDOMEvent);
>+    return NS_OK;
>+  }

Actually, since you remove init*Event for popstateevent, you should remove support for document.createEvent too.
Comment on attachment 8446851 [details] [diff] [review]
Part 7: Migrate PageTransitionEvent

>-  if (aEventType.LowerCaseEqualsLiteral("pagetransition"))
>-    return NS_NewDOMPageTransitionEvent(aDOMEvent, aOwner, aPresContext, nullptr);
>+  if (aEventType.LowerCaseEqualsLiteral("pagetransition")) {
>+    PageTransitionEventInit init;
>+    nsRefPtr<PageTransitionEvent> event =
>+      PageTransitionEvent::Constructor(aOwner, EmptyString(), init);
>+    event.forget(aDOMEvent);
>+    return NS_OK;
>+  }
Since you remove init*Event, you should remove support for document.createEvent("pagetransition") too
Attachment #8446851 - Flags: review?(bugs) → review+
Attachment #8446853 - Flags: review?(bugs) → review+
> /me cries. Adding explicit JSAPI usage.

We could do a followup to store the state as a JS::Value, not a variant, right?
Attachment #8446854 - Flags: review?(bugs) → review+
Attachment #8446856 - Flags: review?(bugs) → review+
Comment on attachment 8446857 [details] [diff] [review]
Part 11: Migrate DeviceOrientationEvent

? changes are unrelated to this bug, but fine.
Attachment #8446857 - Flags: review?(bugs) → review+
Attachment #8446858 - Flags: review?(bugs) → review+
Comment on attachment 8446859 [details] [diff] [review]
Part 14: Migrate DOMTransactionEvent

Could you file a followup to sort out this transaction event / undomanager stuff.
AFAIK we don't expose Undomanager by default, so why do we have
transaction event?

CC ehsan to that bug.
Attachment #8446859 - Flags: review?(bugs) → review+
Attachment #8446860 - Flags: review?(bugs) → review+
Attachment #8447568 - Flags: review?(bugs) → review+
Attachment #8447700 - Flags: review?(bugs) → review+
Comment on attachment 8447701 [details] [diff] [review]
Part 17: Manually implement CustomEvent

>+CustomEvent::Constructor(const GlobalObject& aGlobal,
>+                         const nsAString& aType,
>+                         const CustomEventInit& aParam,
>+                         ErrorResult& aRv)
>+{
>+  nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
>+  nsRefPtr<CustomEvent> e = new CustomEvent(t, nullptr, nullptr);
>+  bool trusted = e->Init(t);
>+  JS::Rooted<JS::Value> detail(aGlobal.Context(), aParam.mDetail);
Why do you need rooted detail? Just pass aParam.mDetail.

>+CustomEvent::InitCustomEvent(JSContext* aCx,
>+                             const nsAString& aType,
>+                             bool aCanBubble,
>+                             bool aCancelable,
>+                             JS::Handle<JS::Value> aDetail,
>+                             ErrorResult& aRv)
>+{
>+  nsCOMPtr<nsIVariant> detail;
>+  nsContentUtils::XPConnect()->JSToVariant(aCx, aDetail, getter_AddRefs(detail));
Hmm, I guess we don't execute this when xpconnect is down.
I wouldn't mind a null check, though.
Attachment #8447701 - Flags: review?(bugs) → review+
Attachment #8446863 - Flags: review?(bugs) → review+
Depends on: 1033343
Depends on: 1251082
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: