/
githubmirror
/
servo
Обзор
Документация
Войти
/
githubmirror
/
servo
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
components/script/dom/execcommand/commands/subscript.rs
32 строки
1 KB
Tim van der Lippe
script: Implement subscript and superscript commands (#44677)
03 май 2026, 00:01
Не верифицирован
03 май 2026, 00:01
e4d937f
Код
Авторство
О чём код?
/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ use js::context::JSContext; use crate::dom::document::Document; use crate::dom::execcommand::basecommand::CommandName; use crate::dom::selection::Selection; /// <https://w3c.github.io/editing/docs/execCommand/#the-subscript-command> pub(crate) fn execute_subscript_command( cx: &mut JSContext, document: &Document, selection: &Selection, ) -> bool { // Step 1. Call queryCommandState("subscript"), and let state be the result. let state = CommandName::Subscript.current_state(cx, document); // Step 2. Set the selection's value to null. selection.set_the_selection_value(cx, None, CommandName::Subscript, document); // Step 3. If state is false, set the selection's value to "subscript". if state.is_none_or(|state| !state) { selection.set_the_selection_value( cx, Some("subscript".into()), CommandName::Subscript, document, ); } // Step 4. Return true. true }