chore(fmt): add legacy stubs and strip trailing whitespace to unblock cargo fmt

This commit is contained in:
Selfhosting Dev
2025-09-17 07:43:07 +09:00
parent fcf8ce1f3c
commit adbb0201a9
385 changed files with 35622 additions and 15004 deletions

View File

@ -1,11 +1,11 @@
/*!
* WebDisplayBox - ブラウザHTML要素表示制御Box
*
*
* WebAssembly環境でHTML要素への直接出力・スタイル制御
* プレイグラウンドの出力パネル等を完全制御
*/
use crate::box_trait::{NyashBox, StringBox, BoolBox, BoxCore, BoxBase};
use crate::box_trait::{BoolBox, BoxBase, BoxCore, NyashBox, StringBox};
use std::any::Any;
#[cfg(target_arch = "wasm32")]
@ -25,19 +25,19 @@ pub struct WebDisplayBox {
#[cfg(target_arch = "wasm32")]
impl WebDisplayBox {
pub fn new(element_id: String) -> Self {
Self {
Self {
base: BoxBase::new(),
target_element_id: element_id,
}
}
/// 指定した要素IDのHTML要素を取得
fn get_target_element(&self) -> Option<Element> {
let window = web_sys::window()?;
let document = window.document()?;
document.get_element_by_id(&self.target_element_id)
}
/// テキストを追加出力
pub fn print(&self, message: &str) {
if let Some(element) = self.get_target_element() {
@ -50,7 +50,7 @@ impl WebDisplayBox {
element.set_inner_html(&new_content);
}
}
/// テキストを改行付きで追加出力
pub fn println(&self, message: &str) {
if let Some(element) = self.get_target_element() {
@ -63,14 +63,14 @@ impl WebDisplayBox {
element.set_inner_html(&new_content);
}
}
/// HTMLコンテンツを完全置換
pub fn set_html(&self, html_content: &str) {
if let Some(element) = self.get_target_element() {
element.set_inner_html(html_content);
}
}
/// HTMLコンテンツを追加
pub fn append_html(&self, html_content: &str) {
if let Some(element) = self.get_target_element() {
@ -79,7 +79,7 @@ impl WebDisplayBox {
element.set_inner_html(&new_content);
}
}
/// CSSスタイルを設定
pub fn set_css(&self, property: &str, value: &str) {
if let Some(element) = self.get_target_element() {
@ -89,38 +89,38 @@ impl WebDisplayBox {
}
}
}
/// CSSクラスを追加
pub fn add_class(&self, class_name: &str) {
if let Some(element) = self.get_target_element() {
let _ = element.class_list().add_1(class_name);
}
}
/// CSSクラスを削除
pub fn remove_class(&self, class_name: &str) {
if let Some(element) = self.get_target_element() {
let _ = element.class_list().remove_1(class_name);
}
}
/// 内容をクリア
pub fn clear(&self) {
if let Some(element) = self.get_target_element() {
element.set_inner_html("");
}
}
/// 要素を表示
pub fn show(&self) {
self.set_css("display", "block");
}
/// 要素を非表示
pub fn hide(&self) {
self.set_css("display", "none");
}
/// スクロールを最下部に移動
pub fn scroll_to_bottom(&self) {
if let Some(element) = self.get_target_element() {
@ -136,19 +136,19 @@ impl BoxCore for WebDisplayBox {
fn box_id(&self) -> u64 {
self.base.id
}
fn parent_type_id(&self) -> Option<std::any::TypeId> {
self.base.parent_type_id
}
fn fmt_box(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "WebDisplayBox({})", self.target_element_id)
}
fn as_any(&self) -> &dyn Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn Any {
self
}
@ -159,7 +159,7 @@ impl NyashBox for WebDisplayBox {
fn clone_box(&self) -> Box<dyn NyashBox> {
Box::new(self.clone())
}
/// 仮実装: clone_boxと同じ後で修正
fn share_box(&self) -> Box<dyn NyashBox> {
self.clone_box()
@ -169,11 +169,9 @@ impl NyashBox for WebDisplayBox {
StringBox::new(format!("WebDisplayBox({})", self.target_element_id))
}
fn type_name(&self) -> &'static str {
"WebDisplayBox"
}
fn equals(&self, other: &dyn NyashBox) -> BoolBox {
if let Some(other_display) = other.as_any().downcast_ref::<WebDisplayBox>() {
@ -189,4 +187,4 @@ impl std::fmt::Display for WebDisplayBox {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.fmt_box(f)
}
}
}