servo: Merge #15527 - Make HTMLOptionsCollection constructor accept a HTMLSelectElement argument. Fixes #15521 (from simon-whitehead:fix-15521); r=cbrewster

<!-- Please describe your changes on the following line: -->
Moves the `HTMLSelectElement.upcast()` call into the `HTMLOptionsCollection` constructors, replacing their signatures with `&HTMLSelectElement` references. This limits the surface area for misuse by only allowing `HTMLSelectElement` instances to be passed in rather than `Node` instances.

---
<!-- 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 #15521.

<!-- Either: -->
- [ ] There are tests for these changes OR
- [x] These changes do not require tests because: the linked issue explicitly says building without errors is good enough.

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

Source-Repo: https://github.com/servo/servo
Source-Revision: da8d15427cbe82dabb3ce48580738b775c9086d0

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 7512fd9b2fcfb14eff9695b1416ce7b7a957c959
This commit is contained in:
Simon Whitehead 2017-02-13 13:31:33 -08:00
Родитель e008dcee70
Коммит 0601a4ec8f
2 изменённых файлов: 6 добавлений и 5 удалений

Просмотреть файл

@ -16,6 +16,7 @@ use dom::bindings::str::DOMString;
use dom::element::Element;
use dom::htmlcollection::{CollectionFilter, HTMLCollection};
use dom::htmloptionelement::HTMLOptionElement;
use dom::htmlselectelement::HTMLSelectElement;
use dom::node::{document_from_node, Node};
use dom::window::Window;
@ -25,16 +26,16 @@ pub struct HTMLOptionsCollection {
}
impl HTMLOptionsCollection {
fn new_inherited(root: &Node, filter: Box<CollectionFilter + 'static>) -> HTMLOptionsCollection {
fn new_inherited(select: &HTMLSelectElement, filter: Box<CollectionFilter + 'static>) -> HTMLOptionsCollection {
HTMLOptionsCollection {
collection: HTMLCollection::new_inherited(root, filter),
collection: HTMLCollection::new_inherited(select.upcast(), filter),
}
}
pub fn new(window: &Window, root: &Node, filter: Box<CollectionFilter + 'static>)
pub fn new(window: &Window, select: &HTMLSelectElement, filter: Box<CollectionFilter + 'static>)
-> Root<HTMLOptionsCollection>
{
reflect_dom_object(box HTMLOptionsCollection::new_inherited(root, filter),
reflect_dom_object(box HTMLOptionsCollection::new_inherited(select, filter),
window,
HTMLOptionsCollectionBinding::Wrap)
}

Просмотреть файл

@ -243,7 +243,7 @@ impl HTMLSelectElementMethods for HTMLSelectElement {
self.options.or_init(|| {
let window = window_from_node(self);
HTMLOptionsCollection::new(
&window, self.upcast(), box OptionsFilter)
&window, self, box OptionsFilter)
})
}