diff --git a/engine/core/rendering/RenderBox.cpp b/engine/core/rendering/RenderBox.cpp index a1af5ab2a92..6e19b2e64b8 100644 --- a/engine/core/rendering/RenderBox.cpp +++ b/engine/core/rendering/RenderBox.cpp @@ -184,14 +184,15 @@ void RenderBox::updateTransform(const RenderStyle* oldStyle) m_transform.clear(); // Layers with transforms act as clip rects roots, so clear the cached clip rects here. - layer()->clipper().clearClipRectsIncludingDescendants(); - } else if (localHasTransform) { + if (layer()) + layer()->clipper().clearClipRectsIncludingDescendants(); + } else if (localHasTransform && layer()) { layer()->clipper().clearClipRectsIncludingDescendants(AbsoluteClipRects); } updateTransformationMatrix(); - if (had3DTransform != has3DTransform()) + if (layer() && had3DTransform != has3DTransform()) layer()->dirty3DTransformedDescendantStatus(); } diff --git a/tests/styles/transforms-expected.txt b/tests/styles/transforms-expected.txt index 95a2ab9b31f..e76c7bf17d7 100644 --- a/tests/styles/transforms-expected.txt +++ b/tests/styles/transforms-expected.txt @@ -2,7 +2,8 @@ CONSOLE: unittest-suite-wait-for-done CONSOLE: PASS: pixel translate should roundtrip CONSOLE: PASS: percent translate should roundtrip CONSOLE: PASS: scale should roundtrip +CONSOLE: PASS: removing a transform should not crash CONSOLE: -CONSOLE: All 3 tests passed. +CONSOLE: All 4 tests passed. CONSOLE: unittest-suite-success DONE diff --git a/tests/styles/transforms.sky b/tests/styles/transforms.sky index 9473c915ea7..49c44de4761 100644 --- a/tests/styles/transforms.sky +++ b/tests/styles/transforms.sky @@ -48,5 +48,12 @@ test('scale should roundtrip', () { testTransformRoundTrip('scale(1.2, 0.8)', 'matrix(1.2, 0, 0, 0.8, 0, 0)'); }); + + test('removing a transform should not crash', () { + testBox.style['transform'] = 'translate(0, 0, 0)'; + testBox.getBoundingClientRect(); + testBox.style.removeProperty('transform'); + testBox.getBoundingClientRect(); + }); }