mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Add shell.background-color.rgba to prefs (#30488)
* Add shell.transparent-background.enabled to prefs * Rename config to background_color * Rename to background-color and.rgba add PrefValue::Array variant
This commit is contained in:
parent
ffac882f8f
commit
38a325cc1c
8 changed files with 108 additions and 37 deletions
|
@ -37,41 +37,50 @@ impl Actor for PreferenceActor {
|
|||
_id: StreamId,
|
||||
) -> Result<ActorMessageStatus, ()> {
|
||||
let pref_value = pref_map().get(msg_type);
|
||||
Ok(match pref_value {
|
||||
PrefValue::Float(value) => {
|
||||
let reply = FloatReply {
|
||||
from: self.name(),
|
||||
value: value,
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Int(value) => {
|
||||
let reply = IntReply {
|
||||
from: self.name(),
|
||||
value: value,
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Str(value) => {
|
||||
let reply = CharReply {
|
||||
from: self.name(),
|
||||
value: value,
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Bool(value) => {
|
||||
let reply = BoolReply {
|
||||
from: self.name(),
|
||||
value: value,
|
||||
};
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Missing => handle_missing_preference(self.name(), msg_type, stream),
|
||||
})
|
||||
Ok(handle_preference_value(
|
||||
pref_value,
|
||||
self.name(),
|
||||
msg_type,
|
||||
stream,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_preference_value(
|
||||
pref_value: PrefValue,
|
||||
name: String,
|
||||
msg_type: &str,
|
||||
stream: &mut TcpStream,
|
||||
) -> ActorMessageStatus {
|
||||
match pref_value {
|
||||
PrefValue::Float(value) => {
|
||||
let reply = FloatReply { from: name, value };
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Int(value) => {
|
||||
let reply = IntReply { from: name, value };
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Str(value) => {
|
||||
let reply = CharReply { from: name, value };
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Bool(value) => {
|
||||
let reply = BoolReply { from: name, value };
|
||||
let _ = stream.write_json_packet(&reply);
|
||||
ActorMessageStatus::Processed
|
||||
},
|
||||
PrefValue::Array(values) => {
|
||||
let mut result = ActorMessageStatus::Processed;
|
||||
for value in values {
|
||||
result = handle_preference_value(value, name.clone(), msg_type, stream);
|
||||
}
|
||||
result
|
||||
},
|
||||
PrefValue::Missing => handle_missing_preference(name, msg_type, stream),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue