@@ -33,8 +33,6 @@ static void paint_node(Paintable const& paintable, PaintContext& context, PaintP
33
33
34
34
StackingContext::StackingContext (Paintable& paintable, StackingContext* parent, size_t index_in_tree_order)
35
35
: m_paintable(paintable)
36
- , m_transform(combine_transformations(paintable.computed_values().transformations()))
37
- , m_transform_origin(compute_transform_origin())
38
36
, m_parent(parent)
39
37
, m_index_in_tree_order(index_in_tree_order)
40
38
{
@@ -291,28 +289,13 @@ void StackingContext::paint_internal(PaintContext& context) const
291
289
}
292
290
}
293
291
294
- Gfx::FloatMatrix4x4 StackingContext::combine_transformations (Vector<CSS::Transformation> const & transformations) const
295
- {
296
- // https://drafts.csswg.org/css-transforms-1/#WD20171130 says:
297
- // "No transform on non-replaced inline boxes, table-column boxes, and table-column-group boxes."
298
- // and https://www.w3.org/TR/css-transforms-2/ does not say anything about what to do with inline boxes.
299
-
300
- auto matrix = Gfx::FloatMatrix4x4::identity ();
301
- if (paintable ().is_paintable_box ()) {
302
- for (auto const & transform : transformations)
303
- matrix = matrix * transform.to_matrix (paintable_box ()).release_value ();
304
-
305
- return matrix;
306
- }
307
-
308
- return matrix;
309
- }
310
-
311
292
// FIXME: This extracts the affine 2D part of the full transformation matrix.
312
293
// Use the whole matrix when we get better transformation support in LibGfx or use LibGL for drawing the bitmap
313
294
Gfx::AffineTransform StackingContext::affine_transform_matrix () const
314
295
{
315
- return Gfx::extract_2d_affine_transform (m_transform);
296
+ if (paintable ().is_paintable_box ())
297
+ return Gfx::extract_2d_affine_transform (paintable_box ().transform ());
298
+ return Gfx::AffineTransform {};
316
299
}
317
300
318
301
static Gfx::FloatMatrix4x4 matrix_with_scaled_translation (Gfx::FloatMatrix4x4 matrix, float scale)
@@ -342,14 +325,21 @@ void StackingContext::paint(PaintContext& context) const
342
325
VERIFY_NOT_REACHED ();
343
326
}
344
327
328
+ auto transform_matrix = Gfx::FloatMatrix4x4::identity ();
329
+ Gfx::FloatPoint transform_origin;
330
+ if (paintable ().is_paintable_box ()) {
331
+ transform_matrix = paintable_box ().transform ();
332
+ transform_origin = paintable_box ().transform_origin ().to_type <float >();
333
+ }
334
+
345
335
RecordingPainter::PushStackingContextParams push_stacking_context_params {
346
336
.opacity = opacity,
347
337
.is_fixed_position = paintable ().is_fixed_position (),
348
338
.source_paintable_rect = source_paintable_rect,
349
339
.image_rendering = paintable ().computed_values ().image_rendering (),
350
340
.transform = {
351
- .origin = transform_origin () .scaled (to_device_pixels_scale),
352
- .matrix = matrix_with_scaled_translation (transform_matrix () , to_device_pixels_scale),
341
+ .origin = transform_origin.scaled (to_device_pixels_scale),
342
+ .matrix = matrix_with_scaled_translation (transform_matrix, to_device_pixels_scale),
353
343
},
354
344
};
355
345
@@ -374,19 +364,6 @@ void StackingContext::paint(PaintContext& context) const
374
364
context.recording_painter ().pop_stacking_context ();
375
365
}
376
366
377
- Gfx::FloatPoint StackingContext::compute_transform_origin () const
378
- {
379
- if (!paintable ().is_paintable_box ())
380
- return {};
381
-
382
- auto style_value = paintable ().computed_values ().transform_origin ();
383
- // FIXME: respect transform-box property
384
- auto reference_box = paintable_box ().absolute_border_box_rect ();
385
- auto x = reference_box.left () + style_value.x .to_px (paintable ().layout_node (), reference_box.width ());
386
- auto y = reference_box.top () + style_value.y .to_px (paintable ().layout_node (), reference_box.height ());
387
- return { x.to_float (), y.to_float () };
388
- }
389
-
390
367
template <typename Callback>
391
368
static TraversalDecision for_each_in_inclusive_subtree_within_same_stacking_context_in_reverse (Paintable const & paintable, Callback callback)
392
369
{
@@ -420,7 +397,9 @@ Optional<HitTestResult> StackingContext::hit_test(CSSPixelPoint position, HitTes
420
397
if (!paintable ().is_visible ())
421
398
return {};
422
399
423
- auto transform_origin = this ->transform_origin ().to_type <CSSPixels>();
400
+ CSSPixelPoint transform_origin { 0 , 0 };
401
+ if (paintable ().is_paintable_box ())
402
+ transform_origin = paintable_box ().transform_origin ();
424
403
// NOTE: This CSSPixels -> Float -> CSSPixels conversion is because we can't AffineTransform::map() a CSSPixelPoint.
425
404
Gfx::FloatPoint offset_position {
426
405
(position.x () - transform_origin.x ()).to_float (),
0 commit comments