LibWeb: Resolve editing background colors without layout
removeFormat computes effective command values for nodes in the active selection. Hidden editable elements can be selected without having a styled layout node, but background-color resolution only needs an element color context. Use the element color context instead of requiring Layout::NodeWithStyle. Add reduced crash coverage for removeFormat with a hidden button.
This commit is contained in:
parent
998fa908db
commit
eb2200e33d
2 changed files with 11 additions and 2 deletions
|
|
@ -1142,8 +1142,7 @@ Optional<Utf16String> effective_command_value(GC::Ptr<DOM::Node> node, FlyString
|
|||
auto background_color = resolved_background_color();
|
||||
if (!background_color)
|
||||
return NumericLimits<u8>::max();
|
||||
VERIFY(is<Layout::NodeWithStyle>(node->layout_node()));
|
||||
return background_color->to_color(CSS::ColorResolutionContext::for_layout_node_with_style(*static_cast<Layout::NodeWithStyle*>(node->layout_node()))).value().alpha();
|
||||
return background_color->to_color(CSS::ColorResolutionContext::for_element({ node_as_element() })).value().alpha();
|
||||
};
|
||||
while (resolved_background_alpha() == 0 && node->parent() && is<DOM::Element>(*node->parent()))
|
||||
node = node->parent();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,10 @@
|
|||
<script>
|
||||
function runTest()
|
||||
{
|
||||
document.execCommand("selectAll", false);
|
||||
document.documentElement.setAttribute("contenteditable", "true");
|
||||
document.execCommand("removeFormat", false);
|
||||
}
|
||||
</script>
|
||||
<body onload="runTest()">
|
||||
<button hidden>|@QXs,uQhRb({z6)</button>
|
||||
Loading…
Reference in a new issue