#include "components/ui_devtools/dom_agent.h"
#include <memory>
#include <string>
#include <utility>
#include "base/containers/adapters.h"
#include "base/memory/raw_ptr.h"
#include "base/observer_list.h"
#include "base/ranges/algorithm.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "components/ui_devtools/devtools_server.h"
#include "components/ui_devtools/root_element.h"
#include "components/ui_devtools/ui_devtools_features.h"
#include "components/ui_devtools/ui_element.h"
#include "ui/base/interaction/element_identifier.h"
namespace {
std::string CreateIdentifier() { … }
}
namespace ui_devtools {
Array;
Node;
Response;
namespace {
bool FindMatchInStylesProperty(const std::string& query,
ui_devtools::UIElement* node) { … }
bool FindMatchByID(const std::string& query, ui_devtools::UIElement* node) { … }
bool FindMatchInDomProperties(const std::string& query,
const std::string& tag_name_query,
const std::string& attribute_query,
bool exact_attribute_match,
ui_devtools::UIElement* node) { … }
}
struct DOMAgent::Query { … };
DOMAgent::DOMAgent() { … }
DOMAgent::~DOMAgent() { … }
Response DOMAgent::disable() { … }
Response DOMAgent::getDocument(std::unique_ptr<Node>* out_root) { … }
Response DOMAgent::pushNodesByBackendIdsToFrontend(
std::unique_ptr<protocol::Array<int>> backend_node_ids,
std::unique_ptr<protocol::Array<int>>* result) { … }
void DOMAgent::OnUIElementAdded(UIElement* parent, UIElement* child) { … }
void DOMAgent::OnUIElementReordered(UIElement* parent, UIElement* child) { … }
void DOMAgent::OnUIElementRemoved(UIElement* ui_element) { … }
void DOMAgent::OnUIElementBoundsChanged(UIElement* ui_element) { … }
void DOMAgent::AddObserver(DOMAgentObserver* observer) { … }
void DOMAgent::RemoveObserver(DOMAgentObserver* observer) { … }
UIElement* DOMAgent::GetElementFromNodeId(int node_id) const { … }
int DOMAgent::GetParentIdOfNodeId(int node_id) const { … }
std::unique_ptr<Node> DOMAgent::BuildNode(
const std::string& name,
std::unique_ptr<std::vector<std::string>> attributes,
std::unique_ptr<Array<Node>> children,
int node_ids) { … }
std::unique_ptr<Node> DOMAgent::BuildDomNodeFromUIElement(UIElement* root) { … }
std::unique_ptr<Node> DOMAgent::BuildInitialTree() { … }
void DOMAgent::OnElementBoundsChanged(UIElement* ui_element) { … }
void DOMAgent::RemoveDomNode(UIElement* ui_element, bool update_node_id_map) { … }
void DOMAgent::Reset() { … }
DOMAgent::Query DOMAgent::PreprocessQuery(protocol::String query) { … }
void DOMAgent::SearchDomTree(const DOMAgent::Query& query_data,
std::vector<int>* result_collector) { … }
Response DOMAgent::performSearch(
const protocol::String& whitespace_trimmed_query,
protocol::Maybe<bool> optional_include_user_agent_shadow_dom,
protocol::String* search_id,
int* result_count) { … }
Response DOMAgent::getSearchResults(
const protocol::String& search_id,
int from_index,
int to_index,
std::unique_ptr<protocol::Array<int>>* node_ids) { … }
Response DOMAgent::discardSearchResults(const protocol::String& search_id) { … }
protocol::Response DOMAgent::dispatchMouseEvent(
int node_id,
std::unique_ptr<protocol::DOM::MouseEvent> event) { … }
protocol::Response DOMAgent::dispatchKeyEvent(
int node_id,
std::unique_ptr<protocol::DOM::KeyEvent> event) { … }
}