Repository navigation
frame navigation API - #11607
frame navigation API#11607
Conversation
|
💖 Thanks for opening this pull request! 💖 Here is a list of things that will help get it across the finish line:
|
776406d to
e3a8b80
Compare
|
Hey @bughit, struggling to review this because all the line-endings changed. Can you fix those line-endings please 👍 |
e3a8b80 to
8bfa9c4
Compare
|
@MarshallOfSound fixed I initally create a |
|
@MarshallOfSound could you please comment on the following:
|
|
|
||
| private: | ||
| explicit WebFrame(v8::Isolate* isolate); | ||
| explicit WebFrame(v8::Isolate* isolate, |
There was a problem hiding this comment.
Its better to have two versions of WebFrame constructors rather than having an implicit definition for clarity.
WebFrame(v8::Isolate* isolate);
WebFrame(v8::Isolate* isolate, blink::WebFrame* web_frame);
| return v8::Null(isolate()); | ||
| } | ||
|
|
||
| v8::Local<v8::Value> WebFrame::FindFrameByName(v8::Local<v8::Value> name_value, |
There was a problem hiding this comment.
You can extract the name or selector values directly from mate::Arguments which performs the right string conversion.
v8::Local<v8::Value> WebFrame::FindFrameByName(mate::Arguments* args) {
std::string name;
if (args && args->Length() == 1 && args->GetNext(&name) {}
}
|
|
||
| v8::Local<v8::Value> WebFrame::Opener() const { | ||
| blink::WebLocalFrame* local_frame = | ||
| (blink::WebLocalFrame*) WebFrame::web_frame_->Opener(); |
There was a problem hiding this comment.
Its possible for a blink::WebFrame to be either blink::WebLocalFrame or blink::WebRemoteFrame when traversing frames across process, this model isn't currently enabled in Electron but will soon be. So its better to prepare for it by using the helpers blink::WebFrame::IsWebLocalFrame and blink::WebFrame::ToWebLocalFrame
77bf4f8 to
41961a6
Compare
|
@deepak1556 updated |
41961a6 to
34ee695
Compare
|
Is there anything else I need to do here? |
|
@deepak1556, I made the changes you requested almost a week ago, could you please review them. |
|
Could one of you please explain what I can expect to happen with this pull request? It's been sitting in the "Changes requested" state for 18 days after requested changes were made. Is that not enough time to let me know if the changes are acceptable or if you need anything else? |
|
@bughit sorry for the delay on this. I am not convinced on exposing the traversal methods on |
|
Please look at #5115 (comment) and following. I initially tried that approach and could not figure out how to get a blink::WebElement from a v8::Value (#5115 (comment)), got as far as blink::Element. The current approach resulted as workaround. I am not opposed to the original way (webelement -> webframe), but I would need to know how. |
|
If we are going to communicate with a periodicity of 3 weeks, this will never get done. Besides not being clear on what exactly you want, I don't understand your objection. The api I exposed is:
Opener, Parent, Top, GetFrameForSelector, FindFrameByName are definitely useful and don't create any unnecessary instances. Do you have anything against these? FirstChild, NextSibling, TraverseNext only create unnecessary instances if you are using them to achieve array like indexing (e.g. 5th child). In other cases (collecting the frames, or searching through them) they are not unnecessary. Even in the indexing scenario the the extra instances are hardly significant (pages which have so many frames where this might become an issue are theoretical) |
zcbenz
left a comment
There was a problem hiding this comment.
And can you add some documents for the new APIs in docs/api/web-frame.md?
|
|
||
| v8::Local<v8::Value> WebFrame::Opener() const { | ||
| blink::WebLocalFrame* local_frame = | ||
| WebFrame::web_frame_->Opener()->ToWebLocalFrame(); |
There was a problem hiding this comment.
ToWebLocalFrame would cause assertion under Debug mode when called for remote web frame, we should call IsWebLocalFrame() before doing conversion.
All the ToWebLocalFrame calls bellow should also be checked.
There was a problem hiding this comment.
I would like to understand when a WebFrame is local vs remote.
Does it depend on the chosen process model?
What's the current model? Process per window (which would mean all frames are local)?
Is the process model going to change (so that not all frames are local)?
Will it be possible to configure the process model?
And now to the details, what should these methods return if the frame is not local?
There was a problem hiding this comment.
Regardless of process model, it is always possible to have a remote WebFrame inside any page , especially after Chromium started to enable out-of-process iframes.
I think for now it is fine to return null for remote WebFrame.
|
|
||
| v8::Local<v8::Value> WebFrame::TraverseNext() const { | ||
| blink::WebLocalFrame* local_frame = | ||
| WebFrame::web_frame_->TraverseNext()->ToWebLocalFrame(); |
There was a problem hiding this comment.
The travel would stop when encountered a remote frame. Also TraverseNext returns nullptr at the end so it would then crash here.
If we do not really need this API, I prefer to simply remove this.
There was a problem hiding this comment.
I included it just because it was there, so I am ok with removing it, firstChild and nextSibling should enough to walk the whole tree.
| return v8::Null(isolate()); | ||
| } | ||
|
|
||
| v8::Local<v8::Value> WebFrame::GetFrameForSelector(mate::Arguments* args) |
There was a problem hiding this comment.
You can define the function as GetFrameForSelector(const std::string& selector) and the argument would be converted automatically.
This also applies to FindFrameByName.
34ee695 to
a36710b
Compare
a36710b to
c1df960
Compare
|
@zcbenz I made the requested changes. The docs linting is failing, I am not clear on how to fix it, please advise. |
| webFrame.setZoomFactor(2) | ||
| ``` | ||
|
|
||
| ## Methods |
There was a problem hiding this comment.
This is why linting has failing, if you revert this back to Methods everything should work. webFrame is not a class, it's a module (that happens to be an the instance of a native WebFrame class) but it's a module 😄
There was a problem hiding this comment.
I'll revert it to fix the problem, but webFrame is not a module, unless Electron has its own concept of modules.
- it is an exported object of the electron module
require('electron').webFrame - it is an instance of the WebFrame class (which is not exported because you can't create new frames)
- it represents the top frame of the current window
- its methods are instance methods of the WebFrame class
- till now it was a singleton (the only WebFrame instance you could obtain) but with this pull request you can get others
There was a problem hiding this comment.
Went back to Methods, still failing: Failed to lint electron.d.ts
c1df960 to
88b887f
Compare
|
I added the documentation per your request, but I don't know what it takes to satisfy your linter ( |
|
@MarshallOfSound @deepak1556 @zcbenz Do none of you know what's wrong with the documentation I added? I can take it out, but you asked for it, so why not help me get it right? |
|
@qazbnm456 Is it just the backquotes? Or are properties not allowed at all for "modules"? Speaking of which, where does the electron concept of a module come from? From the node perspective webFrame is not a module.
|
|
@bughit The docs parser is treating |
|
The CI is a bit flaky and the failing tests are not related to this PR, I'm merging with the failing tests ignored. |
|
Congrats on merging your first pull request! 🎉🎉🎉 |
|
@zcbenz Is backporting to a beta branch a possibility? |
|
According our versioning policy, you have to wait for major/minor release for a new feature. |
a couple of things I'm uncertain about