Move `TextFormat` over to a new `html` module, which will hold all the stuff necessary for rendering HTML in an `EditText`.

`TextFormat` is owned data and should be collectable as static.
This commit is contained in:
David Wendt 2020-03-09 14:15:22 -04:00
parent 2e7ebbf258
commit ac9cd0cf87
6 changed files with 12 additions and 7 deletions

View File

@ -5,7 +5,7 @@ use crate::avm1::property::Attribute::*;
use crate::avm1::return_value::ReturnValue;
use crate::avm1::{Avm1, Object, ScriptObject, TObject, UpdateContext, Value};
use crate::display_object::{EditText, TDisplayObject};
use crate::font::TextFormat;
use crate::html::TextFormat;
use gc_arena::MutationContext;
/// Implements `TextField`

View File

@ -3,7 +3,8 @@ use crate::avm1::globals::text_field::attach_virtual_properties;
use crate::avm1::{Avm1, Object, StageObject, Value};
use crate::context::{RenderContext, UpdateContext};
use crate::display_object::{DisplayObjectBase, TDisplayObject};
use crate::font::{Font, Glyph, TextFormat};
use crate::font::{Font, Glyph};
use crate::html::TextFormat;
use crate::library::Library;
use crate::prelude::*;
use crate::tag_utils::SwfMovie;

View File

@ -5,10 +5,6 @@ use gc_arena::{Collect, Gc, MutationContext};
type Error = Box<dyn std::error::Error>;
mod text_format;
pub use text_format::TextFormat;
#[derive(Debug, Clone, Collect, Copy)]
#[collect(no_drop)]
pub struct Font<'gc>(Gc<'gc, FontData>);

5
core/src/html.rs Normal file
View File

@ -0,0 +1,5 @@
//! HTML related utilities
mod text_format;
pub use text_format::TextFormat;

View File

@ -1,6 +1,7 @@
//! Classes that store formatting options
use crate::avm1::{Avm1, Object, ScriptObject, TObject, Value};
use crate::context::UpdateContext;
use gc_arena::Collect;
/// A set of text formatting options to be applied to some part, or the whole
/// of, a given text field.
@ -11,7 +12,8 @@ use crate::context::UpdateContext;
/// means that multiple regions of text apply. When setting the format of a
/// particular region of text, `None` means that the existing setting for that
/// property will be retained.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, Collect)]
#[collect(require_static)]
pub struct TextFormat {
font: Option<String>,
size: Option<f64>,

View File

@ -17,6 +17,7 @@ mod context;
mod drawing;
pub mod events;
mod font;
mod html;
mod library;
pub mod loader;
mod player;