Bug 215562 - Resolve with the class used to define the Custom Element
Summary: Resolve with the class used to define the Custom Element
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Platform (show other bugs)
Version: Other
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ryosuke Niwa
URL:
Keywords: InRadar
Depends on:
Blocks: 154907
  Show dependency treegraph
 
Reported: 2020-08-17 03:00 PDT by Andrea Giammarchi
Modified: 2020-08-25 19:43 PDT (History)
12 users (show)

See Also:


Attachments
Implements the new behavior (13.93 KB, patch)
2020-08-20 19:47 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff
Patch for landing (14.59 KB, patch)
2020-08-25 13:54 PDT, Ryosuke Niwa
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrea Giammarchi 2020-08-17 03:00:12 PDT
Accordingly with https://github.com/whatwg/html/issues/5552, `whenDefined` should resolve with the class used to define the custom element in the registry.
Comment 1 Radar WebKit Bug Importer 2020-08-17 17:28:50 PDT
<rdar://problem/67282709>
Comment 2 Ryosuke Niwa 2020-08-20 19:47:29 PDT
Created attachment 406998 [details]
Implements the new behavior
Comment 3 EWS Watchlist 2020-08-20 19:48:32 PDT
This patch modifies the imported WPT tests. Please ensure that any changes on the tests (not coming from a WPT import) are exported to WPT. Please see https://trac.webkit.org/wiki/WPTExportProcess
Comment 4 Darin Adler 2020-08-20 19:54:25 PDT
Comment on attachment 406998 [details]
Implements the new behavior

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

> Source/WebCore/bindings/js/JSDOMPromiseDeferred.h:80
> +        JSC::JSGlobalObject* lexicalGlobalObject = globalObject();

auto

> Source/WebCore/dom/CustomElementRegistry.cpp:81
>      if (auto promise = m_promiseMap.take(localName))
> -        promise.value()->resolve();
> +        return WTFMove(*promise);
> +    return nullptr;

No if statement needed:

    return m_promiseMap.take(localName);
Comment 5 Ryosuke Niwa 2020-08-20 20:17:52 PDT
(In reply to Darin Adler from comment #4)
> Comment on attachment 406998 [details]
> Implements the new behavior
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=406998&action=review
>
> > Source/WebCore/dom/CustomElementRegistry.cpp:81
> >      if (auto promise = m_promiseMap.take(localName))
> > -        promise.value()->resolve();
> > +        return WTFMove(*promise);
> > +    return nullptr;
> 
> No if statement needed:
> 
>     return m_promiseMap.take(localName);

That's what I thought but I was getting (and still getting) this error:

./dom/CustomElementRegistry.cpp:79:12: error: no viable conversion from returned value of type 'WTF::HashMap<WTF::AtomString, WTF::Ref<WebCore::DeferredPromise, WTF::DumbPtrTraits<WebCore::DeferredPromise> >, WTF::DefaultHash<WTF::AtomString>, WTF::HashTraits<WTF::AtomString>, WTF::HashTraits<WTF::Ref<WebCore::DeferredPromise, WTF::DumbPtrTraits<WebCore::DeferredPromise> > > >::MappedTakeType' (aka 'Optional<Ref<WebCore::DeferredPromise> >') to function return type 'RefPtr<WebCore::DeferredPromise>'
    return m_promiseMap.take(localName);
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comment 6 Darin Adler 2020-08-21 09:15:53 PDT
I see. You’ll have to write it this way for now, but we should either change RefHashTraits::TakeType to RefPtr in HashTraits.h, or add a constructor for RefPtr that takes Optional<Ref>&& in RefPtr.h, or possibly do both. Then we can come back here and re-simplify this.
Comment 7 Ryosuke Niwa 2020-08-25 13:54:22 PDT
Created attachment 407227 [details]
Patch for landing
Comment 8 Ryosuke Niwa 2020-08-25 13:54:49 PDT
(In reply to Darin Adler from comment #6)
> I see. You’ll have to write it this way for now, but we should either change
> RefHashTraits::TakeType to RefPtr in HashTraits.h, or add a constructor for
> RefPtr that takes Optional<Ref>&& in RefPtr.h, or possibly do both. Then we
> can come back here and re-simplify this.

Yeah, let me work on that next.
Comment 9 EWS 2020-08-25 14:22:17 PDT
Committed r266142: <https://trac.webkit.org/changeset/266142>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 407227 [details].