Browse Source

LibWeb: Detach paintables from *all* DOM nodes before committing layout

Before this change, we were not detaching paintables from DOM nodes
within shadow subtrees.

This appears to be the main reason that keyboard editing was doing
immediate forced relayout: doing a full layout invalidation meant we'd
build a new layout tree, which then hid the problem with with
still-attached paintables.

By detaching them before committing a new layout, we make it possible
for keyboard editing to just use normal relayout, instead of full forced
invalidation & relayout.
Andreas Kling 1 năm trước cách đây
mục cha
commit
c51a4cc007
1 tập tin đã thay đổi với 6 bổ sung1 xóa
  1. 6 1
      Userland/Libraries/LibWeb/Layout/LayoutState.cpp

+ 6 - 1
Userland/Libraries/LibWeb/Layout/LayoutState.cpp

@@ -1,11 +1,12 @@
 /*
- * Copyright (c) 2022-2023, Andreas Kling <kling@serenityos.org>
+ * Copyright (c) 2022-2024, Andreas Kling <kling@serenityos.org>
  * Copyright (c) 2024, Sam Atkins <atkinssj@serenityos.org>
  *
  * SPDX-License-Identifier: BSD-2-Clause
  */
 
 #include <AK/Debug.h>
+#include <LibWeb/DOM/ShadowRoot.h>
 #include <LibWeb/Layout/AvailableSpace.h>
 #include <LibWeb/Layout/BlockContainer.h>
 #include <LibWeb/Layout/InlineNode.h>
@@ -209,6 +210,10 @@ void LayoutState::commit(Box& root)
         node.set_paintable(nullptr);
         return IterationDecision::Continue;
     });
+    root.document().for_each_shadow_including_inclusive_descendant([&](DOM::Node& node) {
+        node.set_paintable(nullptr);
+        return IterationDecision::Continue;
+    });
 
     HashTable<Layout::TextNode*> text_nodes;