mirror of
https://github.com/servo/servo.git
synced 2025-06-17 04:44:28 +00:00
Auto merge of #20036 - paavininanda:BrowsingNames, r=jdm
Browsing context names <!-- Please describe your changes on the following line: --> --- <!-- 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 fix https://github.com/servo/servo/issues/14453 <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- 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/20036) <!-- Reviewable:end -->
This commit is contained in:
commit
7de2043b9c
11 changed files with 76 additions and 39 deletions
|
@ -457,6 +457,22 @@ impl HTMLIFrameElementMethods for HTMLIFrameElement {
|
|||
make_getter!(FrameBorder, "frameborder");
|
||||
// https://html.spec.whatwg.org/multipage/#other-elements,-attributes-and-apis:attr-iframe-frameborder
|
||||
make_setter!(SetFrameBorder, "frameborder");
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-name
|
||||
fn SetName(&self, name: DOMString) {
|
||||
if let Some(window) = self.GetContentWindow() {
|
||||
window.set_name(name)
|
||||
}
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-iframe-name
|
||||
fn Name(&self) -> DOMString {
|
||||
if let Some(window) = self.GetContentWindow() {
|
||||
window.get_name()
|
||||
} else {
|
||||
DOMString::new()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualMethods for HTMLIFrameElement {
|
||||
|
@ -498,6 +514,11 @@ impl VirtualMethods for HTMLIFrameElement {
|
|||
self.process_the_iframe_attributes(ProcessingMode::NotFirstTime);
|
||||
}
|
||||
},
|
||||
&local_name!("name") => {
|
||||
let new_value = mutation.new_value(attr);
|
||||
let value = new_value.as_ref().map_or("", |v| &v);
|
||||
self.SetName(DOMString::from(value.to_owned()));
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,8 @@ interface HTMLIFrameElement : HTMLElement {
|
|||
// [CEReactions]
|
||||
// attribute DOMString srcdoc;
|
||||
|
||||
// https://github.com/servo/servo/issues/14453
|
||||
// [CEReactions]
|
||||
// attribute DOMString name;
|
||||
[CEReactions]
|
||||
attribute DOMString name;
|
||||
|
||||
[SameObject, PutForwards=value]
|
||||
readonly attribute DOMTokenList sandbox;
|
||||
|
|
|
@ -10,8 +10,7 @@
|
|||
[BinaryName="Self_", Replaceable] readonly attribute WindowProxy self;
|
||||
[Unforgeable] readonly attribute Document document;
|
||||
|
||||
// https://github.com/servo/servo/issues/14453
|
||||
// attribute DOMString name;
|
||||
attribute DOMString name;
|
||||
|
||||
[/*PutForwards=href, */Unforgeable] readonly attribute Location location;
|
||||
readonly attribute History history;
|
||||
|
|
|
@ -1025,6 +1025,16 @@ impl WindowMethods for Window {
|
|||
fn TestRunner(&self) -> DomRoot<TestRunner> {
|
||||
self.test_runner.or_init(|| TestRunner::new(self.upcast()))
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-name
|
||||
fn SetName(&self, name: DOMString) {
|
||||
self.window_proxy().set_name(name);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-name
|
||||
fn Name(&self) -> DOMString {
|
||||
self.window_proxy().get_name()
|
||||
}
|
||||
}
|
||||
|
||||
impl Window {
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::cell::DomRefCell;
|
||||
use dom::bindings::conversions::{ToJSValConvertible, root_from_handleobject};
|
||||
use dom::bindings::error::{Error, throw_dom_exception};
|
||||
use dom::bindings::inheritance::Castable;
|
||||
use dom::bindings::proxyhandler::{fill_property_descriptor, get_property_descriptor};
|
||||
use dom::bindings::reflector::{DomObject, Reflector};
|
||||
use dom::bindings::root::{Dom, DomRoot, RootedReference};
|
||||
use dom::bindings::str::DOMString;
|
||||
use dom::bindings::trace::JSTraceable;
|
||||
use dom::bindings::utils::{WindowProxyHandler, get_array_index_from_id, AsVoidPtr};
|
||||
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
|
||||
|
@ -55,6 +57,8 @@ pub struct WindowProxy {
|
|||
/// In the case that this is a top-level window, this is our id.
|
||||
top_level_browsing_context_id: TopLevelBrowsingContextId,
|
||||
|
||||
/// The name of the browsing context
|
||||
name: DomRefCell<DOMString>,
|
||||
/// The pipeline id of the currently active document.
|
||||
/// May be None, when the currently active document is in another script thread.
|
||||
/// We do not try to keep the pipeline id for documents in other threads,
|
||||
|
@ -80,10 +84,12 @@ impl WindowProxy {
|
|||
parent: Option<&WindowProxy>)
|
||||
-> WindowProxy
|
||||
{
|
||||
let name = frame_element.map_or(DOMString::new(), |e| e.get_string_attribute(&local_name!("name")));
|
||||
WindowProxy {
|
||||
reflector: Reflector::new(),
|
||||
browsing_context_id: browsing_context_id,
|
||||
top_level_browsing_context_id: top_level_browsing_context_id,
|
||||
name: DomRefCell::new(name),
|
||||
currently_active: Cell::new(currently_active),
|
||||
discarded: Cell::new(false),
|
||||
frame_element: frame_element.map(Dom::from_ref),
|
||||
|
@ -276,6 +282,14 @@ impl WindowProxy {
|
|||
pub fn currently_active(&self) -> Option<PipelineId> {
|
||||
self.currently_active.get()
|
||||
}
|
||||
|
||||
pub fn get_name(&self) -> DOMString {
|
||||
self.name.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn set_name(&self, name: DOMString) {
|
||||
*self.name.borrow_mut() = name;
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue