Closed Bug 1446246 Opened 6 years ago Closed 6 years ago

Common up the HTMLConstructor implementations

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: bzbarsky, Assigned: bzbarsky)

References

Details

Attachments

(3 files)

We have a bunch of HTMLConstructor implementations that are all very similar.  The infrastructure from bug 1444286 lets us common them up into a single function.  This saves about 80KB of codesize, if I am measuring right.
The codegen changes are mostly a backout of the changes made in bug 1274159.

The HTMLConstructor implementation is mostly copied from one of the
code-generated ones, with a few modifications:

* Derive the interface name from the proto id instead of hardcoding it.
* Use the proto/constructor ids to get constructor and prototype objects.
* Use ErrorResult instead of FastErrorResult; we don't want the precedent of
  using FastErrorResult in non-generated code.

There will be further changes to combine HTMLConstructor and
CreateXULOrHTMLElement, in a separate changeset.
Attachment #8959675 - Flags: review?(peterv)
This fixes an observable bug we had due to doing the steps in a different order
from the spec: the 'prototype' get can have side-effects so needs to happen
after some of the other sanity checks.
Attachment #8959676 - Flags: review?(peterv)
Priority: -- → P2
Attachment #8959675 - Flags: review?(peterv) → review+
Blocks: 1447454
Comment on attachment 8959676 [details] [diff] [review]
part 2.  Combine HTMLConstructor and CreateXULOrHTMLElement into a single function

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

::: dom/bindings/BindingUtils.cpp
@@ +3748,5 @@
> +      }
> +    }
> +
> +    // Step 12.
> +    constructionStack.LastElement() = nullptr;

It might make things more understandable to use ALREADY_CONSTRUCTED_MARKER here?
Attachment #8959676 - Flags: review?(peterv) → review+
> It might make things more understandable to use ALREADY_CONSTRUCTED_MARKER here?

Yes, fixed.
Pushed by bzbarsky@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b470762b4676
part 1.  Use a single handwritten HTMLConstructor implementation, instead of code-generating lots of very similar implementations. r=peterv
https://hg.mozilla.org/integration/mozilla-inbound/rev/9ed0718ede32
part 2.  Combine HTMLConstructor and CreateXULOrHTMLElement into a single function.  r=peterv
https://hg.mozilla.org/mozilla-central/rev/b470762b4676
https://hg.mozilla.org/mozilla-central/rev/9ed0718ede32
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
Created web-platform-tests PR https://github.com/w3c/web-platform-tests/pull/10311 for changes under testing/web-platform/tests
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: