servo: Merge #14210 - Add missing action in CreateContextualFragment method (from GuillaumeGomez:fragment_node); r=nox
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Mon, 21 Nov 2016 10:20:18 -0600
changeset 340191 7889a0e6fd8baf1205ed17c4c80c48f73cf614b9
parent 340190 e0734ef3e87ba3f3eda79a56fe8d6d81426d69de
child 340192 ad973d89dae31942d6e0a48d899b057537fd4551
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnox
servo: Merge #14210 - Add missing action in CreateContextualFragment method (from GuillaumeGomez:fragment_node); r=nox r? @nox Source-Repo: https://github.com/servo/servo Source-Revision: d562d101809fbbb3d43511ae4cd3acbee280a7e7
servo/components/script/dom/htmlscriptelement.rs
servo/components/script/dom/range.rs
--- a/servo/components/script/dom/htmlscriptelement.rs
+++ b/servo/components/script/dom/htmlscriptelement.rs
@@ -590,16 +590,20 @@ impl HTMLScriptElement {
                 // https://github.com/rust-lang/rust/issues/21114
                 is_js
             }
         };
         // https://github.com/rust-lang/rust/issues/21114
         is_js
     }
 
+    pub fn set_parser_inserted(&self, parser_inserted: bool) {
+        self.parser_inserted.set(parser_inserted);
+    }
+
     pub fn set_already_started(&self, already_started: bool) {
         self.already_started.set(already_started);
     }
 
     fn dispatch_event(&self,
                       type_: Atom,
                       bubbles: EventBubbles,
                       cancelable: EventCancelable) -> EventStatus {
--- a/servo/components/script/dom/range.rs
+++ b/servo/components/script/dom/range.rs
@@ -898,19 +898,19 @@ impl RangeMethods for Range {
     }
 
     // https://dvcs.w3.org/hg/innerhtml/raw-file/tip/index.html#extensions-to-the-range-interface
     fn CreateContextualFragment(&self, fragment: DOMString) -> Fallible<Root<DocumentFragment>> {
         // Step 1.
         let node = self.StartContainer();
         let element = match node.type_id() {
             NodeTypeId::Document(_) | NodeTypeId::DocumentFragment => None,
-            NodeTypeId::Element(_) => Some(node),
+            NodeTypeId::Element(_) => Some(Root::downcast::<Element>(node).unwrap()),
             NodeTypeId::CharacterData(CharacterDataTypeId::Comment) |
-            NodeTypeId::CharacterData(CharacterDataTypeId::Text) => node.GetParentNode(),
+            NodeTypeId::CharacterData(CharacterDataTypeId::Text) => node.GetParentElement(),
             NodeTypeId::CharacterData(CharacterDataTypeId::ProcessingInstruction) |
             NodeTypeId::DocumentType => unreachable!(),
         };
 
         // Step 2.
         let should_create_body = element.as_ref().map_or(true, |elem| {
             let elem = elem.downcast::<Element>().unwrap();
             elem.local_name() == &local_name!("html") && elem.html_element_in_html_document()
@@ -923,16 +923,17 @@ impl RangeMethods for Range {
 
         // Step 3.
         let fragment_node = try!(element.parse_fragment(fragment));
 
         // Step 4.
         for node in fragment_node.upcast::<Node>().traverse_preorder() {
             if let Some(script) = node.downcast::<HTMLScriptElement>() {
                 script.set_already_started(false);
+                script.set_parser_inserted(false);
             }
         }
 
         // Step 5.
         Ok(fragment_node)
     }
 }