mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:07:45 +00:00
LibWebView: Make a best-effort attempt to not "shift" edited attributes
Currently, when editing a DOM attribute, the replacement method first removes the attribute, then adds the replacement attributes. This results in the edited attribute jumping to the end of the attribute list in the Inspector. This patch will try to avoid removing the attribute if one of the replacements has the same name. This will keep the edited attribute in the same location.
This commit is contained in:
parent
777b4f7921
commit
9a5fe740c6
1 changed files with 10 additions and 2 deletions
|
@ -33,6 +33,7 @@
|
||||||
#include <LibWeb/HTML/Storage.h>
|
#include <LibWeb/HTML/Storage.h>
|
||||||
#include <LibWeb/HTML/TraversableNavigable.h>
|
#include <LibWeb/HTML/TraversableNavigable.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/HTML/Window.h>
|
||||||
|
#include <LibWeb/Infra/Strings.h>
|
||||||
#include <LibWeb/Layout/Viewport.h>
|
#include <LibWeb/Layout/Viewport.h>
|
||||||
#include <LibWeb/Loader/ContentFilter.h>
|
#include <LibWeb/Loader/ContentFilter.h>
|
||||||
#include <LibWeb/Loader/ProxyMappings.h>
|
#include <LibWeb/Loader/ProxyMappings.h>
|
||||||
|
@ -705,10 +706,17 @@ void ConnectionFromClient::replace_dom_node_attribute(i32 node_id, String const&
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto& element = static_cast<Web::DOM::Element&>(*dom_node);
|
auto& element = static_cast<Web::DOM::Element&>(*dom_node);
|
||||||
element.remove_attribute(name);
|
bool should_remove_attribute = true;
|
||||||
|
|
||||||
|
for (auto const& attribute : replacement_attributes) {
|
||||||
|
if (should_remove_attribute && Web::Infra::is_ascii_case_insensitive_match(name, attribute.name))
|
||||||
|
should_remove_attribute = false;
|
||||||
|
|
||||||
for (auto const& attribute : replacement_attributes)
|
|
||||||
element.set_attribute(attribute.name, attribute.value).release_value_but_fixme_should_propagate_errors();
|
element.set_attribute(attribute.name, attribute.value).release_value_but_fixme_should_propagate_errors();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (should_remove_attribute)
|
||||||
|
element.remove_attribute(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionFromClient::remove_dom_node(i32 node_id)
|
void ConnectionFromClient::remove_dom_node(i32 node_id)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue