core: Make `EditText::set_html_text` accept a `&str`
This commit is contained in:
parent
0787662079
commit
a900aae63e
|
@ -347,7 +347,7 @@ pub fn set_html_text<'gc>(
|
|||
value: Value<'gc>,
|
||||
) -> Result<(), Error<'gc>> {
|
||||
let text = value.coerce_to_string(activation)?;
|
||||
let _ = this.set_html_text(text.to_string(), &mut activation.context);
|
||||
let _ = this.set_html_text(&text, &mut activation.context);
|
||||
// Changing the htmlText does NOT update variable bindings (does not call EditText::propagate_text_binding).
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -211,7 +211,7 @@ impl<'gc> TObject<'gc> for StageObject<'gc> {
|
|||
.filter(|binding| swf_string_eq(&binding.variable_name, &name, case_sensitive))
|
||||
{
|
||||
let _ = binding.text_field.set_html_text(
|
||||
value.coerce_to_string(activation)?.to_string(),
|
||||
&value.coerce_to_string(activation)?,
|
||||
&mut activation.context,
|
||||
);
|
||||
}
|
||||
|
|
|
@ -341,13 +341,11 @@ pub fn set_html_text<'gc>(
|
|||
{
|
||||
let html_text = args
|
||||
.get(0)
|
||||
.cloned()
|
||||
.unwrap_or(Value::Undefined)
|
||||
.coerce_to_string(activation)?
|
||||
.to_string();
|
||||
.unwrap_or(&Value::Undefined)
|
||||
.coerce_to_string(activation)?;
|
||||
|
||||
this.set_is_html(&mut activation.context, true);
|
||||
this.set_html_text(html_text, &mut activation.context)?;
|
||||
this.set_html_text(&html_text, &mut activation.context)?;
|
||||
}
|
||||
|
||||
Ok(Value::Undefined)
|
||||
|
|
|
@ -455,7 +455,7 @@ impl<'gc> EditText<'gc> {
|
|||
|
||||
pub fn set_html_text(
|
||||
self,
|
||||
text: String,
|
||||
text: &str,
|
||||
context: &mut UpdateContext<'_, 'gc, '_>,
|
||||
) -> Result<(), Error> {
|
||||
if self.is_html() {
|
||||
|
@ -471,7 +471,7 @@ impl<'gc> EditText<'gc> {
|
|||
}
|
||||
|
||||
self.set_html_tree(document, context);
|
||||
} else if let Err(err) = self.set_text(&text, context) {
|
||||
} else if let Err(err) = self.set_text(text, context) {
|
||||
log::error!("Error when setting TextField.htmlText: {}", err);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1113,10 +1113,7 @@ impl<'gc> EditText<'gc> {
|
|||
if object.has_property(activation, property) {
|
||||
let value = object.get(property, activation).unwrap();
|
||||
let _ = self.set_html_text(
|
||||
value
|
||||
.coerce_to_string(activation)
|
||||
.unwrap_or_default()
|
||||
.to_string(),
|
||||
&value.coerce_to_string(activation).unwrap_or_default(),
|
||||
&mut activation.context,
|
||||
);
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue