WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
236714
Add -[WKWebProcessPlugInFrame lookUpFrameFromJSValue:]
https://bugs.webkit.org/show_bug.cgi?id=236714
Summary
Add -[WKWebProcessPlugInFrame lookUpFrameFromJSValue:]
Timothy Hatcher
Reported
2022-02-16 09:37:20 PST
Safari needs a way to convert a JS window object or frame DOM element into a WKWebProcessPlugInFrame in the injected bundle for web extensions.
Attachments
Patch
(7.41 KB, patch)
2022-02-16 09:44 PST
,
Timothy Hatcher
no flags
Details
Formatted Diff
Diff
Patch
(7.22 KB, patch)
2022-02-16 13:45 PST
,
Timothy Hatcher
no flags
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Radar WebKit Bug Importer
Comment 1
2022-02-16 09:37:35 PST
<
rdar://problem/89030846
>
Timothy Hatcher
Comment 2
2022-02-16 09:44:10 PST
Created
attachment 452203
[details]
Patch
Chris Dumez
Comment 3
2022-02-16 09:51:36 PST
Comment on
attachment 452203
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=452203&action=review
> Source/WebCore/page/Frame.cpp:1146 > + JSC::JSGlobalObject* globalObject = toJS(context);
I would think you should be able to do: return globalObject ? activeDOMWindow(*globalObject).frame() : nullptr; No?
Chris Dumez
Comment 4
2022-02-16 09:52:24 PST
Comment on
attachment 452203
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=452203&action=review
>> Source/WebCore/page/Frame.cpp:1146 >> + JSC::JSGlobalObject* globalObject = toJS(context); > > I would think you should be able to do: > return globalObject ? activeDOMWindow(*globalObject).frame() : nullptr; > > No?
And if so, we probably don't need this new function on the Frame class at all.
Timothy Hatcher
Comment 5
2022-02-16 09:57:03 PST
Comment on
attachment 452203
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=452203&action=review
>>> Source/WebCore/page/Frame.cpp:1146 >>> + JSC::JSGlobalObject* globalObject = toJS(context); >> >> I would think you should be able to do: >> return globalObject ? activeDOMWindow(*globalObject).frame() : nullptr; >> >> No? > > And if so, we probably don't need this new function on the Frame class at all.
We need to be able to get the Frame from a JSHTMLIFrameElement, JSHTMLFrameElement or JSDOMWindow.
Chris Dumez
Comment 6
2022-02-16 10:28:26 PST
Comment on
attachment 452203
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=452203&action=review
> Source/WebCore/page/Frame.cpp:1141 > +Frame* Frame::fromJSValue(JSContextRef context, JSValueRef valueRef)
I think we should rename to make it clear we want a *content* frame, as suggested below.
> Source/WebCore/page/Frame.cpp:1149 > +
We can simplify a bit here: ``` if (auto* window = JSDOMWindow::toWrapped(vm, value)) return window->frame(); ```
> Source/WebCore/page/Frame.cpp:1159 > + if (auto* frameElement = JSC::jsDynamicCast<JSHTMLIFrameElement*>(vm, value))
I think this may look a bit better: ``` auto* jsNode = JSC::jsDynamicCast<JSNode*>(vm, value); if (!jsNode || !is<HTMLFrameOwnerElement>(jsNode->wrapped())) return nullptr; return downcast<HTMLFrameOwnerElement>(*jsNode->wrapped()).contentFrame(); ```
> Source/WebKit/WebProcess/InjectedBundle/API/Cocoa/WKWebProcessPlugInFramePrivate.h:36 > ++ (instancetype)lookUpFrameFromJSValue:(JSValue *)value;
I think we may want to rename this to lookUpContentFrameFromJSValue given the behavior. You don't really want the frame, you want the "content" frame in the case the value is a <frame> / <iframe>. We may also want to convey the fact that this only works for window and frame elements, maybe something like: lookUpContentFrameForWindowOrFrameElement:
Timothy Hatcher
Comment 7
2022-02-16 13:45:54 PST
Created
attachment 452246
[details]
Patch
Chris Dumez
Comment 8
2022-02-16 13:51:45 PST
Comment on
attachment 452246
[details]
Patch r=me
EWS
Comment 9
2022-02-17 00:01:21 PST
Committed
r290001
(
247387@main
): <
https://commits.webkit.org/247387@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 452246
[details]
.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug