fn exec_command(&mut self, command_id: &str, value: &str) {
        // Ensure that there's an active selection inside the compose area.
        let active_range = self.fetch_range();
        if active_range.range.is_none() || active_range.outside {
            // No active selection range inside the compose area.
            match self.selection_range {
                Some(ref range) => {
                    activate_selection_range(
                        &self
                            .fetch_selection()
                            .expect("Could not get window selection"),
                        range,
                    );
                }
                None => {
                    // No stored selection range. Create a new selection at the end end.
                    let last_child_node = utils::get_last_child(&self.wrapper);
                    self.selection_range = match last_child_node {
                        Some(ref node) => {
                            // Insert at the very end, unless the last element in the
                            // area is a `<br>` node. This is needed because Firefox
                            // always adds a trailing newline that isn't rendered
                            let mut insert_before = false;
                            if let Some(ref element) = node.dyn_ref::<Element>() {
                                if element.tag_name() == "BR" {
                                    insert_before = true;
                                }
                            }
                            if insert_before {
                                set_selection_range(&Position::Before(node), None)
                            } else {
                                set_selection_range(&Position::After(node), None)
                            }
                        }
                        None => set_selection_range(&Position::Offset(&self.wrapper, 0), None),
                    }
                    .map(|range| range.clone_range());
                }
            }
        }

        // Execute command
        self.document
            .dyn_ref::<HtmlDocument>()
            .expect("Document is not a HtmlDocument")
            .exec_command_with_show_ui_and_value(command_id, false, value)
            .expect("Could not exec command");
        self.normalize();
        self.store_selection_range();
    }
/// Ensure that there's an active selection inside the compose are. Then
/// exec the specified command, normalize the compose area and store the
/// new selection range.
Ensure that there's an active selection inside the compose are. Then
exec the specified command, normalize the compose area and store the
new selection range.
Ensure that there ' s an active selection inside the compose are . Then exec the specified command normalize the compose area and store the new selection range .
fn exec_command(&mut self, command_id: &str, value: &str) {
        // Ensure that there's an active selection inside the compose area.
        let active_range = self.fetch_range();
        if active_range.range.is_none() || active_range.outside {
            // No active selection range inside the compose area.
            match self.selection_range {
                Some(ref range) => {
                    activate_selection_range(
                        &self
                            .fetch_selection()
                            .expect("Could not get window selection"),
                        range,
                    );
                }
                None => {
                    // No stored selection range. Create a new selection at the end end.
                    let last_child_node = utils::get_last_child(&self.wrapper);
                    self.selection_range = match last_child_node {
                        Some(ref node) => {
                            // Insert at the very end, unless the last element in the
                            // area is a `<br>` node. This is needed because Firefox
                            // always adds a trailing newline that isn't rendered
                            let mut insert_before = false;
                            if let Some(ref element) = node.dyn_ref::<Element>() {
                                if element.tag_name() == "BR" {
                                    insert_before = true;
                                }
                            }
                            if insert_before {
                                set_selection_range(&Position::Before(node), None)
                            } else {
                                set_selection_range(&Position::After(node), None)
                            }
                        }
                        None => set_selection_range(&Position::Offset(&self.wrapper, 0), None),
                    }
                    .map(|range| range.clone_range());
                }
            }
        }
        // Execute command
        self.document
            .dyn_ref::<HtmlDocument>()
            .expect("Document is not a HtmlDocument")
            .exec_command_with_show_ui_and_value(command_id, false, value)
            .expect("Could not exec command");
        self.normalize();
        self.store_selection_range();
    }
fn exec_command ( & mut self , command_id : & str , value : & str ) { // Ensure that there's an active selection inside the compose area. let active_range = self . fetch_range ( ) ; if active_range . range . is_none ( ) || active_range . outside { // No active selection range inside the compose area. match self . selection_range { Some ( ref range ) => { activate_selection_range ( & self . fetch_selection ( ) . expect ( " " ) , range , ) ; } None => { // No stored selection range. Create a new selection at the end end. let last_child_node = utils :: get_last_child ( & self . wrapper ) ; self . selection_range = match last_child_node { Some ( ref node ) => { // Insert at the very end, unless the last element in the // area is a `<br>` node. This is needed because Firefox // always adds a trailing newline that isn't rendered let mut insert_before = false ; if let Some ( ref element ) = node . dyn_ref :: < Element > ( ) { if element . tag_name ( ) == " " { insert_before = true ; } } if insert_before { set_selection_range ( & Position :: Before ( node ) , None ) } else { set_selection_range ( & Position :: After ( node ) , None ) } } None => set_selection_range ( & Position :: Offset ( & self . wrapper , 0 ) , None ) , } . map ( | range | range . clone_range ( ) ) ; } } } // Execute command self . document . dyn_ref :: < HtmlDocument > ( ) . expect ( " " ) . exec_command_with_show_ui_and_value ( command_id , false , value ) . expect ( " " ) ; self . normalize ( ) ; self . store_selection_range ( ) ; }
Ensure that there's an active selection inside the compose are.
Ensure that there ' s an active selection inside the compose are .
&mut self
command_id
&str
value
&str
&mut self
command_id
&str
value
&str