Skip to content

Truly independent web browser

Compositor: Bound an iframe's raster scale from its unbounded request

Aliaksandr Kalenik4779eac1a2b8
diff --git a/Services/Compositor/ContextPresenter.cpp b/Services/Compositor/ContextPresenter.cpp
index 8502edf3111..c957f6a7a5e 100644
--- a/Services/Compositor/ContextPresenter.cpp
+++ b/Services/Compositor/ContextPresenter.cpp
@@ -116,8 +116,9 @@ Optional<BackingStoreManager::Publication> ContextPresenter::resize_backing_stor
return {};
if (!presents_to_client()) {
// A resize can arrive before the parent's next replay supplies the new embedding transform.
- // Bound the existing scale before allocating backing stores for the new viewport.
- auto scale = bounded_composited_raster_scale(m_raster_scale, m_viewport_size);
+ // Bound the existing embedding's scale for the new viewport before allocating backing stores. Bounding the
+ // already bounded scale instead can round it differently, which would discard the raster on every replay.
+ auto scale = bounded_composited_raster_scale(m_unbounded_raster_scale_of_embedding, m_viewport_size);
if (m_raster_scale != scale) {
m_raster_scale = scale;
m_latest_rendered_surface = nullptr;
@@ -179,9 +180,10 @@ bool ContextPresenter::update_composited_raster_transform(Gfx::FloatRect destina
}
if (!isfinite(scale_x) || !isfinite(scale_y))
return false;
+ m_unbounded_raster_scale_of_embedding = { scale_x, scale_y };
// Perspective keeps the native resolution until we can choose a scale from the visible projected region.
- auto scale = bounded_composited_raster_scale({ scale_x, scale_y }, m_viewport_size);
+ auto scale = bounded_composited_raster_scale(m_unbounded_raster_scale_of_embedding, m_viewport_size);
Gfx::FloatPoint translation;
if (!has_perspective && transform[0, 1] == 0 && transform[1, 0] == 0 && scale.width() == scale_x && scale.height() == scale_y) {
diff --git a/Services/Compositor/ContextPresenter.h b/Services/Compositor/ContextPresenter.h
index 99762150e2f..8baded0bccb 100644
--- a/Services/Compositor/ContextPresenter.h
+++ b/Services/Compositor/ContextPresenter.h
@@ -159,6 +159,7 @@ private:
RefPtr<Gfx::PaintingSurface> m_latest_rendered_surface;
RefPtr<Gfx::PaintingSurface> m_damage_surface;
Optional<RasterizedFrame> m_last_rasterized_frame;
+ Gfx::FloatSize m_unbounded_raster_scale_of_embedding { 1, 1 };
Gfx::FloatSize m_raster_scale { 1, 1 };
Gfx::FloatPoint m_raster_translation;
RefPtr<Core::Timer> m_backing_store_shrink_timer;