Skip to content

Implement Window::open. #13241

Closed
Closed

Description

@Ms2ger

Blocks #2968.

Activity

  1. added
    A-content/dom
    E-very-complex
    I-enhancement
    A-constellation
    on Sep 12, 2016
  2. gterzian commented on Apr 21, 2017

    @gterzian
    Member

    is anyone working on this one? If not, I am interested...

  3. jdm commented on Apr 21, 2017

    @jdm
    Member

    Nobody is working on it. I don't think anybody has wanted to tackle dealing with multiple toplevel windows and figuring out how that relates to things like the compositor, constellation, and webrender.

  4. gterzian commented on Apr 22, 2017

    @gterzian
    Member

    ouch, that sounds painful, well I guess I'm up for it, please add the 'assigned' label. 😄

    If anything, I love a good piece of glue code!

  5. added
    C-assigned
    on Apr 22, 2017
  6. jdm commented on Apr 22, 2017

    @jdm
    Member

    Related discussion: #13338

  7. jdm commented on Apr 22, 2017

    @jdm
    Member

    Also: #13993, #13994, and a bunch of relevant stuff in the tracking issue for multiple windows: #13997

  8. paulrouget commented on Apr 22, 2017

    @paulrouget
    Contributor

    #13994 needs to happen first (if you have multiple compositors, you will need multiple top level frames). Also, @glennw might be working on something related.

    This issue is about supporting window.open which might not require multiple compositors. Maybe the embedder could just open a new tab instead of a new window, which in this case would only require multiple root frames (not multiple compositors).

    Do we support WindowProxy already? Is it necessary to support window.open?

    Do we want to support window opener and referrer?

    /cc @glennw @asajeffrey

  9. paulrouget commented on Apr 22, 2017

    @paulrouget
    Contributor

    A simple initial approach could be to just fire an event to the embedder and let the embedder create a new top level frame (see how that would work here #13994 (comment)).

    Maybe we could ignore opener and refererrer at first.

    Considerations:

    • window.open is synchronous
    • the embedder might refuse to open the window
    • look at the MozBrowserEvent::OpenWindow event
  10. gterzian commented on Apr 23, 2017

    @gterzian
    Member

    @paulrouget yes I can first work on #13994 and #13993, it sounds like this one needs a bit more infrastructure in place to be completed, and it's nice way to break up the work.

    re the initial approach you mention, am I correct if I say that when you say "just fire an event to the embedder" you mean that window.open would fire something such as the "BrowserEvent::HandleUrl" in your example, and that the "embedder" Tabs, would respond to that event by "asking" for a new browsing context from Servo through the constellation, in your example using new_browser.

    In this case we would also need to add such event handling ourselves in ports/servo, which as I understand it is acting like a default embedder to run servo?

  11. paulrouget commented on Apr 24, 2017

    @paulrouget
    Contributor

    @paulrouget yes I can first work on #13994 and #13993, it sounds like this one needs a bit more infrastructure in place to be completed, and it's nice way to break up the work.

    @asajeffrey is already working on multi top level frames (#13994).

    And if I'm not mistaken, @glennw is working on multiple WR instances. I'm not sure how this plays with multiple compositors. Supporting multiple compositors will also mean that we need to stop using exclusively the compositor channel to talk back to the embedder. We may need another communication channel (see #15934).

    So you need to sync up with them (IRC is a good place for that) to understand where you can help.

    re the initial approach you mention, am I correct if I say that when you say "just fire an event to the embedder" you mean that window.open would fire something such as the "BrowserEvent::HandleUrl" in your example, and that the "embedder" Tabs, would respond to that event by "asking" for a new browsing context from Servo through the constellation, in your example using new_browser.

    You're correct.

    The payload of the event should include enough information for the embedder to be able to create a new frame with the proper context name, opener reference, referrer, etc.

    Something like this:

    WindowMethod::new_window(opener:FrameId (or PipelineId), disposition: WindowDisposition, load_data: LoadData, context_name: String);
    
    // preferred disposition. Up to the embedder to follow this or not:
    pub enum WindowDisposition {
      ForegroundTab,
      BackgroundTab,
      NewWindow,
    }
    
    

    (this event would also be used by target="_blank", not just window.open)

    window.open is synchronous, so that means the script will need to wait on the constellation which will wait on the embedder. But I don't think we ever want the constellation to block on anything, so I don't know how this should be done. @asajeffrey might be able to help here.

    In this case we would also need to add such event handling ourselves in ports/servo, which as I understand it is acting like a default embedder to run servo?

    Yes.

  12. paulrouget commented on Apr 24, 2017

    @paulrouget
    Contributor

    At this point, we can see that a lot of things are required before being able to fully support window.open.

    In term of priorities, supporting multiple compositors is very important for us (more that supporting window.open), along with supporting multiple top frames.

    I am not sure what would be best for you to start with.
    @jdm - what do you think?

  13. 3 remaining items

  14. gterzian commented on Apr 25, 2017

    @gterzian
    Member

    I propose to first work on #13993 and #15934 in parallel, ultimately culminating in an implementation of window.open within the context of this issue that would look somewhat like we sketched above.

    I assume the actual implementation plan for window.open will become clearer as the other issues are resolved first, and I'll communicate some plan for both other issues after having looked more closely into the code.

  15. paulrouget commented on Apr 25, 2017

    @paulrouget
    Contributor

    I propose to first work on #13993 and #15934

    I think this is a good idea.

  16. gterzian commented on May 6, 2018

    @gterzian
    Member

    As an update, once #20678 and #20707 land I intend to work on this one.

    My current perspective:

    1. There is an 'internal' HTML part to this, things like implementing #auxiliary-browsing-contexts and #window-open-steps, and #directly-reachable-browsing-contexts
    2. There is an 'external' servo-specific compositor/embedder/webrender part to this.

    If we create an auxiliary browsing context via the embedder, let's say using NewBrowser, we can 'show' it immediately using SelectBrowser, like a new tab that would actually replace the previous one in the UI, but at least internally work like a separate tab?

    SelectBrowser results in sending the frame tree to webrender, and I don't see this having any effect on the script thread. So in theory, we could create a new auxiliary browsing context, 'select it as the active browser', while leaving the 'opener' browsing context still 'running'(so I assume the event loop of the opener could still "do stuff" which would be important in making tests pass, since test assertions will be done in the opener browsing context in most cases.)

    Or, we create a new browser but never select it, leaving the opener in the UI, and just running the script thread of the auxiliary browsing context 'in the background'(again, goal would be to work towards making relevant HTML tests pass). This might be better because in case you're running a single test, the test results will only be shown in the 'opener' browsing context, not the auxiliary one...

    At that point we basically have separate "tabs", if only from a script_thread/constellation perspective.

    I think this could be a way for me to start working on 1, while leaving webrender/compositor as it is for now?

    What do you think?

  17. gterzian commented on May 7, 2018

    @gterzian
    Member

    Also, since 'multiple webrender' was mentioned a year back, I was looking into webrender and the concept of webrender::api::DocumentId caught my attention. It seems now we use one DocumentId for the entire constellation, and I'm wondering if we couldn't move to having one for each top_level_browsing_context?

    See https://github.com/servo/webrender/blob/eb9415a3b601451476c52be4f444c982a3ed8e0c/webrender/examples/document.rs#L27

    I can imagine something like the below on constellation:

    tabs: HasMap<TopLevelBrowsingContextId, webrender::api::DocumentId>

    Lastly, if we were to have such a setup, do we really need multiple compositors? Could it be suffecient to pass the (TopLevelBrowsingContextId, webrender::api::DocumentId) around in relevant windowing::WindowEvent or compositor_thread::Msg to allow the compositor to handle multiple 'windows' in the form of multiple webrender documents?

  18. paulrouget commented on May 7, 2018

    @paulrouget
    Contributor

    WR can only render one top level browsing context at once, but that doesn't mean other contexts / pipeline are not running. Sending the frametree to WR has not impact in the main event loop or the pipelines (beside the visibility event iirc).

    On open(), we can, like you said, create a new tab, select it, and that's it.

    The user experience will be affected, but that's fine for now. We will eventually implement tab switching (that works already, but we don't save the list of browsers yet, and we didn't bind the shortcuts).

    For tests, I don't think this will have any impact at all. Both pipelines will be running. The one that's on screen should not matter.

  19. added 4 commits that reference this issue on Jun 6, 2018
    412148e
    ccaedd6
    31779c0
    c3c9490
  20. added a commit that references this issue on Jul 19, 2018
    6730bf6
  21. added 3 commits that reference this issue on Aug 10, 2018
    2c09e0d
    7d04e61
    9c24c16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-constellationA-content/domC-assignedE-very-complexI-enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions