Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign up[WIP] Implement History State #13781
Conversation
highfive
commented
Oct 15, 2016
|
Heads up! This PR modifies the following files:
|
| @@ -80,4 +149,22 @@ impl HistoryMethods for History { | |||
| fn Forward(&self) { | |||
| self.traverse_history(TraversalDirection::Forward(1)); | |||
| } | |||
|
|
|||
| // https://html.spec.whatwg.org/multipage/#dom-history-pushtstae | |||
This comment has been minimized.
This comment has been minimized.
emilio
Oct 15, 2016
Member
This link seems to go nowhere? (also, it looks like it was manually written, given pushtsae instead of pushstate.
This comment has been minimized.
This comment has been minimized.
cbrewster
Oct 16, 2016
Author
Member
Woops, yeah a typo it should be https://html.spec.whatwg.org/multipage/#dom-history-pushstate
|
|
|
Review status: 0 of 32 files reviewed at latest revision, 9 unresolved discussions, some commit checks failed. components/constellation/constellation.rs, line 221 at r14 (raw file):
Make this optional? components/constellation/constellation.rs, line 221 at r14 (raw file):
Rather than storing multiple components/constellation/constellation.rs, line 248 at r14 (raw file):
If we made the history state id optional, we'd get rid of the hard-coded state id. components/constellation/constellation.rs, line 269 at r14 (raw file):
We should be able to avoid cloning here, using components/constellation/constellation.rs, line 342 at r14 (raw file):
If we used a vector of pushed states, then each pipeline would only have one entry in the frame tree. components/constellation/constellation.rs, line 864 at r14 (raw file):
At some point, this would need the url and title? components/constellation/constellation.rs, line 1557 at r14 (raw file):
Add a warning? components/constellation/constellation.rs, line 2255 at r14 (raw file):
Oh good, distributed gc. At least I think we don't have to deal with cycles, as we can reclaim Frame objects when their iframe becomes detached from the DOM. Comments from Reviewable |
|
Reviewed 1 of 3 files at r8, 1 of 6 files at r10. components/script/dom/browsingcontext.rs, line 78 at r14 (raw file):
I think all we need to store is the hash map from Comments from Reviewable |
|
Reviewed 1 of 3 files at r1, 1 of 3 files at r8, 1 of 6 files at r10, 1 of 4 files at r12, 1 of 1 files at r13, 1 of 1 files at r14. components/script/dom/browsingcontext.rs, line 78 at r14 (raw file):
|
|
Reviewed 21 of 23 files at r11, 1 of 4 files at r12. tests/wpt/metadata/html/browsers/history/the-history-interface/005.html.ini, line 3 at r14 (raw file):
TIMEOUT? tests/wpt/metadata/html/browsers/history/the-history-interface/007.html.ini, line 10 at r14 (raw file):
Yay, passing tests! tests/wpt/metadata/html/browsers/history/the-history-interface/combination_history_004.html.ini, line 3 at r14 (raw file):
TIMEOUT? Comments from Reviewable |
|
Reviewed 2 of 23 files at r11. tests/wpt/metadata/html/browsers/history/the-history-interface/history_back.html.ini, line 3 at r14 (raw file):
TIMEOUT? Comments from Reviewable |
|
This is looking pretty good! The main question is whether to store a vector of pushed states or just a single pushed state in the constellation. Also, I'm not sure how we're handling the url and title? Review status: all files reviewed at latest revision, 14 unresolved discussions, some commit checks failed. Comments from Reviewable |
|
Review status: all files reviewed at latest revision, 14 unresolved discussions, some commit checks failed. components/constellation/constellation.rs, line 221 at r14 (raw file):
|
|
Review status: all files reviewed at latest revision, 13 unresolved discussions, some commit checks failed. components/constellation/constellation.rs, line 221 at r14 (raw file):
|
|
Added popstate event, I still need to investigate the failures and see if its an issue with my implementation. |
|
|
f0e7d97
to
6d7e5f2
|
Rebased. I enable 001 and 002 which were disabled due to #12580 and added them to the intermittent checker. I fixed which state value was turned and the test results look much better now. Review status: 1 of 40 files reviewed at latest revision, 13 unresolved discussions, some commit checks pending. components/constellation/constellation.rs, line 221 at r14 (raw file):
|
|
@bors-servo try |
[WIP] Implement History State <!-- Please describe your changes on the following line: --> This is a work in progress, I still need to figure out how to handle `title` and `url` in push/replace state as well as throwing the proper errors according to the spec. Also when the URL changes there needs to be a way to change the actual document url. @asajeffrey this is my first draft idea of how to handle history states, let me know what you think. r? @asajeffrey --- <!-- 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 - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- 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/13781) <!-- Reviewable:end -->
|
|
|
|
|
|
Add HistoryStateId Added state id to browsing context add history state removal Updated test expectations fix tidy issues and remove document parameter fix spec link Add popstate event address review comments enable 001 and 002 history interface tests Add 001 and 002 to the intermittent check rebased. fix tidy issues Update test expectations rebase Store and set Url, compare FrameState during traversal
| @@ -1713,6 +1718,21 @@ impl<Message, LTF, STF> Constellation<Message, LTF, STF> | |||
| let _ = sender.send(length as u32); | |||
| } | |||
|
|
|||
| fn handle_history_state_pushed(&mut self, pipeline_id: PipelineId, state_id: HistoryStateId) { | |||
| if !self.pipeline_is_in_current_frame(pipeline_id) { | |||
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jan 20, 2017
Member
Might be worth doing this check after looking up the frame, to avoid looking up the frame twice.
| @@ -29,6 +29,9 @@ pub struct Frame { | |||
| /// The pipeline for the current session history entry | |||
| pub pipeline_id: PipelineId, | |||
|
|
|||
| /// The id that maps to the history state entry in the script thread | |||
| pub state_id: HistoryStateId, | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
cbrewster
Jan 20, 2017
Author
Member
I suppose we could make it optional and have the BC return null for history.state if the active state_id is None
| } | ||
|
|
||
| /// Add an entry representing a new history state. | ||
| pub fn push_state(&mut self, state_id: HistoryStateId) { |
This comment has been minimized.
This comment has been minimized.
| @@ -97,6 +119,19 @@ pub struct FrameState { | |||
|
|
|||
| /// The frame that this session history entry is part of | |||
| pub frame_id: FrameId, | |||
|
|
|||
| /// The id that maps to the history state entry in the script thread | |||
| pub state_id: HistoryStateId, | |||
This comment has been minimized.
This comment has been minimized.
| pub fn replace_pipeline(&mut self, pipeline_id: PipelineId, url: ServoUrl) { | ||
| self.pipeline_id = Some(pipeline_id); | ||
| self.url = url; | ||
| self.state_id = HistoryStateId(0); |
This comment has been minimized.
This comment has been minimized.
| @@ -33,24 +44,38 @@ use std::cell::Cell; | |||
| pub struct BrowsingContext { | |||
This comment has been minimized.
This comment has been minimized.
| /// Has this browsing context been discarded? | ||
| discarded: Cell<bool>, | ||
|
|
||
| active_state: Cell<HistoryStateId>, | ||
|
|
||
| next_state_id: Cell<HistoryStateId>, |
This comment has been minimized.
This comment has been minimized.
| state: HandleValue) { | ||
| let mut states = self.states.borrow_mut(); | ||
| states.insert(self.active_state.get(), HistoryState::new(Some(state), Some(title), url)); | ||
| // NOTE: We do not need to notify the constellation, as the history state id |
This comment has been minimized.
This comment has been minimized.
asajeffrey
Jan 20, 2017
Member
Not sure about that, what if the document is discarded then reloaded? The constellation needs to know the new URL.
| self.states.borrow_mut().insert(next_id, HistoryState::new(Some(state), Some(title), url)); | ||
| self.active_state.set(next_id); | ||
|
|
||
| // Notify the constellation about this new entry so it can be added to the |
This comment has been minimized.
This comment has been minimized.
| }; | ||
|
|
||
| // 6.4 | ||
| if url.scheme() != document_url.scheme() || |
This comment has been minimized.
This comment has been minimized.
| [history.length should update when setting location.hash] | ||
| expected: FAIL | ||
|
|
||
| [history.pushState must exist] |
This comment has been minimized.
This comment has been minimized.
| [history.state should also reference a clone of the original object (2)] | ||
| expected: FAIL | ||
|
|
||
| [history.state should be a separate clone of the object, not a reference to the object passed to the event handler] | ||
| expected: FAIL | ||
|
|
||
| [replaceState should not actually load the new URL] | ||
| expected: FAIL |
This comment has been minimized.
This comment has been minimized.
|
|
|
Superseded by #15261 |
cbrewster commentedOct 15, 2016
•
edited by larsbergstrom
This is a work in progress, I still need to figure out how to handle
titleandurlin push/replace state as well as throwing the proper errors according to the spec. Also when the URL changes there needs to be a way to change the actual document url.@asajeffrey this is my first draft idea of how to handle history states, let me know what you think.
r? @asajeffrey
./mach build -ddoes not report any errors./mach test-tidydoes not report any errorsThis change is