Auto merge of #13646 - asajeffrey:script-lookup-iframes-by-frameid, r=ConnorGBrewster

Script lookup iframes by frameid

<!-- Please describe your changes on the following line: -->

Lookup iframes by `FrameId` rather than `PipelineId`. This should make lookup much more reliable, since the frame id doesn't change.

cc @ConnorGBrewster @aneeshusa
---

<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because refactoring

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---

This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13646)

<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-03 18:11:05 -05:00 committed by GitHub
commit ce725c9475
13 changed files with 187 additions and 164 deletions

View file

@ -168,7 +168,9 @@ pub struct NewLayoutInfo {
pub parent_pipeline_id: PipelineId,
/// Id of the newly-created pipeline.
pub new_pipeline_id: PipelineId,
/// Type of the new frame associated with this pipeline.
/// Id of the frame associated with this pipeline.
pub frame_id: FrameId,
/// Type of the frame associated with this pipeline.
pub frame_type: FrameType,
/// Network request data which will be initiated by the script thread.
pub load_data: LoadData,
@ -208,22 +210,20 @@ pub enum ConstellationControlMsg {
/// Notifies script thread whether frame is visible
ChangeFrameVisibilityStatus(PipelineId, bool),
/// Notifies script thread that frame visibility change is complete
/// First PipelineId is for the parent, second PipelineId is for the actual pipeline.
NotifyVisibilityChange(PipelineId, PipelineId, bool),
/// PipelineId is for the parent, FrameId is for the actual frame.
NotifyVisibilityChange(PipelineId, FrameId, bool),
/// Notifies script thread that a url should be loaded in this iframe.
/// First PipelineId is for the parent, second PipelineId is for the actual pipeline.
Navigate(PipelineId, PipelineId, LoadData, bool),
/// PipelineId is for the parent, FrameId is for the actual frame.
Navigate(PipelineId, FrameId, LoadData, bool),
/// Requests the script thread forward a mozbrowser event to an iframe it owns,
/// or to the window if no child pipeline id is provided.
/// First PipelineId is for the parent, second PipelineId is for the actual pipeline.
MozBrowserEvent(PipelineId, Option<PipelineId>, MozBrowserEvent),
/// or to the window if no child frame id is provided.
MozBrowserEvent(PipelineId, Option<FrameId>, MozBrowserEvent),
/// Updates the current pipeline ID of a given iframe.
/// First PipelineId is for the parent, second is the old PipelineId for the frame,
/// third is the new PipelineId for the frame.
UpdatePipelineId(PipelineId, PipelineId, PipelineId),
/// First PipelineId is for the parent, second is the new PipelineId for the frame.
UpdatePipelineId(PipelineId, FrameId, PipelineId),
/// Set an iframe to be focused. Used when an element in an iframe gains focus.
/// First PipelineId is for the parent, second PipelineId is for the actual pipeline.
FocusIFrame(PipelineId, PipelineId),
/// PipelineId is for the parent, FrameId is for the actual frame.
FocusIFrame(PipelineId, FrameId),
/// Passes a webdriver command to the script thread for execution
WebDriverScriptCommand(PipelineId, WebDriverScriptCommand),
/// Notifies script thread that all animations are done
@ -235,14 +235,16 @@ pub enum ConstellationControlMsg {
WebFontLoaded(PipelineId),
/// Cause a `load` event to be dispatched at the appropriate frame element.
DispatchFrameLoadEvent {
/// The pipeline that has been marked as loaded.
target: PipelineId,
/// The frame that has been marked as loaded.
target: FrameId,
/// The pipeline that contains a frame loading the target pipeline.
parent: PipelineId,
/// The pipeline that has completed loading.
child: PipelineId,
},
/// Notifies a parent frame that one of its child frames is now active.
/// First PipelineId is for the parent, second PipelineId is for the actual pipeline.
FramedContentChanged(PipelineId, PipelineId),
/// Notifies a parent pipeline that one of its child frames is now active.
/// PipelineId is for the parent, FrameId is the child frame.
FramedContentChanged(PipelineId, FrameId),
/// Report an error from a CSS parser for the given pipeline
ReportCSSError(PipelineId, String, usize, usize, String),
/// Reload the given page.
@ -430,6 +432,8 @@ pub struct InitialScriptState {
/// The subpage ID of this pipeline to create in its pipeline parent.
/// If `None`, this is the root.
pub parent_info: Option<(PipelineId, FrameType)>,
/// The ID of the frame this script is part of.
pub frame_id: FrameId,
/// A channel with which messages can be sent to us (the script thread).
pub control_chan: IpcSender<ConstellationControlMsg>,
/// A port on which messages sent by the constellation to script can be received.