script/dom/execcommand/
basecommand.rs

1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5use crate::dom::bindings::str::DOMString;
6use crate::dom::document::Document;
7use crate::dom::selection::Selection;
8
9pub(crate) trait BaseCommand {
10    /// <https://w3c.github.io/editing/docs/execCommand/#indeterminate>
11    fn is_indeterminate(&self) -> bool {
12        false
13    }
14
15    /// <https://w3c.github.io/editing/docs/execCommand/#state>
16    fn current_state(&self, _document: &Document) -> Option<bool> {
17        None
18    }
19
20    /// <https://w3c.github.io/editing/docs/execCommand/#value>
21    fn current_value(&self, _document: &Document) -> Option<DOMString> {
22        None
23    }
24
25    /// <https://w3c.github.io/editing/docs/execCommand/#action>
26    fn execute(
27        &self,
28        cx: &mut js::context::JSContext,
29        document: &Document,
30        selection: &Selection,
31        value: DOMString,
32    ) -> bool;
33}
34
35#[derive(Default, Clone, Copy, MallocSizeOf)]
36pub(crate) enum DefaultSingleLineContainerName {
37    #[default]
38    Div,
39    Paragraph,
40}