mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #10100 - paulrouget:historyOnLocationChange, r=paulrouget
Add history information to mozbrowserlocationchange event This is a change in the Browser API itself. Before, on `mozbrowserlocationchange`, we would call `getCanGoBack()` and `getCanGoForward()`. Two asynchronous methods called on an event, which doesn't make much sense, especially because we already know on `mozbrowserlocationchange` if we can go back/forward. So here I'm adding 2 new properties to the event to tell if the iframe can go back/forward. The way `event.detail` is defined also changed. Before, `event.detail` was a string (the new uri), now it's an object (`{uri:String,canGoBack:bool,canGoForward:bool}`). This is one of the design flaw of the early Browser API: not using objects for the detail property, making it hard to extend the event payload. So that makes this event not backward compatible. We can: 1. just don't care. It's up to the client to test if event.detail is a string or not if it needs to be compatible with Gecko 2. fix it in Gecko. The client will still have to test `event.detail` to make it compatible with older version of gecko 3. rename `mozbrowserlocationchange` to something else (`mozbrowserlocationchange2` ?) Please advise. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10100) <!-- Reviewable:end -->
This commit is contained in:
commit
db63aa423f
8 changed files with 90 additions and 8 deletions
|
@ -6,6 +6,7 @@ use document_loader::{LoadType, LoadBlocker};
|
|||
use dom::attr::{Attr, AttrValue};
|
||||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementIconChangeEventDetail;
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementLocationChangeEventDetail;
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserElementSecurityChangeDetail;
|
||||
use dom::bindings::codegen::Bindings::BrowserElementBinding::BrowserShowModalPromptEventDetail;
|
||||
use dom::bindings::codegen::Bindings::HTMLIFrameElementBinding;
|
||||
|
@ -323,9 +324,16 @@ impl MozBrowserEventDetailBuilder for HTMLIFrameElement {
|
|||
mixedState: None,
|
||||
}.to_jsval(cx, rval);
|
||||
}
|
||||
MozBrowserEvent::LocationChange(ref string) | MozBrowserEvent::TitleChange(ref string) => {
|
||||
MozBrowserEvent::TitleChange(ref string) => {
|
||||
string.to_jsval(cx, rval);
|
||||
}
|
||||
MozBrowserEvent::LocationChange(uri, can_go_back, can_go_forward) => {
|
||||
BrowserElementLocationChangeEventDetail {
|
||||
uri: Some(DOMString::from(uri)),
|
||||
canGoBack: Some(can_go_back),
|
||||
canGoForward: Some(can_go_forward),
|
||||
}.to_jsval(cx, rval);
|
||||
}
|
||||
MozBrowserEvent::IconChange(rel, href, sizes) => {
|
||||
BrowserElementIconChangeEventDetail {
|
||||
rel: Some(DOMString::from(rel)),
|
||||
|
|
|
@ -54,6 +54,12 @@ dictionary BrowserElementSecurityChangeDetail {
|
|||
boolean mixedContent;
|
||||
};
|
||||
|
||||
dictionary BrowserElementLocationChangeEventDetail {
|
||||
DOMString uri;
|
||||
boolean canGoBack;
|
||||
boolean canGoForward;
|
||||
};
|
||||
|
||||
dictionary BrowserElementIconChangeEventDetail {
|
||||
DOMString rel;
|
||||
DOMString href;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue