mirror of
https://github.com/servo/servo.git
synced 2025-08-29 17:18:23 +01:00
script: mark image-related node dirty only when image resource loaded (#38916)
Previously, we would always mark the image-related nodes as dirty whenever the fetch status of the image resources changed. However, the corresponding `ImageDisplayItem`s for these image resources are only generated after the image resources have been fully fetched and decoded. Therefore, we only mark the corresponding DOM nodes as dirty when the image resources are completely loaded, thereby reducing the occurrence of reflows. Signed-off-by: sharpshooter_pt <ibluegalaxy_taoj@163.com>
This commit is contained in:
parent
cf13fd4628
commit
4a19f66c31
2 changed files with 4 additions and 4 deletions
|
@ -559,8 +559,6 @@ impl HTMLImageElement {
|
|||
self.upcast::<EventTarget>()
|
||||
.fire_event(atom!("loadend"), can_gc);
|
||||
}
|
||||
|
||||
self.upcast::<Node>().dirty(NodeDamage::Other);
|
||||
}
|
||||
|
||||
fn process_image_response_for_environment_change(
|
||||
|
|
|
@ -646,8 +646,10 @@ impl Window {
|
|||
Entry::Occupied(nodes) => nodes,
|
||||
Entry::Vacant(_) => return,
|
||||
};
|
||||
for node in nodes.get() {
|
||||
node.dirty(NodeDamage::Other);
|
||||
if matches!(response.response, ImageResponse::Loaded(_, _)) {
|
||||
for node in nodes.get() {
|
||||
node.dirty(NodeDamage::Other);
|
||||
}
|
||||
}
|
||||
match response.response {
|
||||
ImageResponse::MetadataLoaded(_) => {},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue