diff options
author | Timothy Flynn <trflynn89@pm.me> | 2022-11-10 10:33:29 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-11-10 17:02:11 +0000 |
commit | 30d6a73d0ee552ee889a8550b2c87cd7d10957ff (patch) | |
tree | 14fbfa8c35c7516767af5392ee9a84b6fa80bb49 /Userland/Services/WebDriver | |
parent | 9dd62228c8a1a8cb68875381a05a20e765fd7d61 (diff) | |
download | serenity-30d6a73d0ee552ee889a8550b2c87cd7d10957ff.zip |
Browser+WebContent+WebDriver: Move Get Element Rect to WebContent
Diffstat (limited to 'Userland/Services/WebDriver')
-rw-r--r-- | Userland/Services/WebDriver/Client.cpp | 3 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.cpp | 41 | ||||
-rw-r--r-- | Userland/Services/WebDriver/Session.h | 1 |
3 files changed, 1 insertions, 44 deletions
diff --git a/Userland/Services/WebDriver/Client.cpp b/Userland/Services/WebDriver/Client.cpp index b72975532c..287cec4b27 100644 --- a/Userland/Services/WebDriver/Client.cpp +++ b/Userland/Services/WebDriver/Client.cpp @@ -708,8 +708,7 @@ Web::WebDriver::Response Client::handle_get_element_rect(Vector<StringView> cons { dbgln_if(WEBDRIVER_DEBUG, "Handling GET /session/<session_id>/element/<element_id>/rect"); auto* session = TRY(find_session_with_id(parameters[0])); - auto result = TRY(session->get_element_rect(parameters[1])); - return make_json_value(result); + return session->web_content_connection().get_element_rect(parameters[1]); } // 12.4.8 Is Element Enabled, https://w3c.github.io/webdriver/#dfn-is-element-enabled diff --git a/Userland/Services/WebDriver/Session.cpp b/Userland/Services/WebDriver/Session.cpp index a1e5814b3d..e4b6b3fb25 100644 --- a/Userland/Services/WebDriver/Session.cpp +++ b/Userland/Services/WebDriver/Session.cpp @@ -300,17 +300,6 @@ Web::WebDriver::Response Session::get_window_handles() const return JsonValue { handles }; } -static JsonValue serialize_rect(Gfx::IntRect const& rect) -{ - JsonObject serialized_rect = {}; - serialized_rect.set("x", rect.x()); - serialized_rect.set("y", rect.y()); - serialized_rect.set("width", rect.width()); - serialized_rect.set("height", rect.height()); - - return serialized_rect; -} - // https://w3c.github.io/webdriver/#dfn-get-a-known-connected-element static ErrorOr<i32, Web::WebDriver::Error> get_known_connected_element(StringView element_id) { @@ -323,36 +312,6 @@ static ErrorOr<i32, Web::WebDriver::Error> get_known_connected_element(StringVie return maybe_element_id.release_value(); } -// 12.4.7 Get Element Rect, https://w3c.github.io/webdriver/#dfn-get-element-rect -Web::WebDriver::Response Session::get_element_rect(StringView parameter_element_id) -{ - // 1. If the current browsing context is no longer open, return error with error code no such window. - TRY(check_for_open_top_level_browsing_context_or_return_error()); - - // FIXME: 2. Handle any user prompts and return its value if it is an error. - - // 3. Let element be the result of trying to get a known connected element with url variable element id. - auto element_id = TRY(get_known_connected_element(parameter_element_id)); - - // 4. Calculate the absolute position of element and let it be coordinates. - // 5. Let rect be element’s bounding rectangle. - auto rect = m_browser_connection->get_element_rect(element_id); - - // 6. Let body be a new JSON Object initialized with: - // "x" - // The first value of coordinates. - // "y" - // The second value of coordinates. - // "width" - // Value of rect’s width dimension. - // "height" - // Value of rect’s height dimension. - auto body = serialize_rect(rect); - - // 7. Return success with data body. - return body; -} - // 12.4.8 Is Element Enabled, https://w3c.github.io/webdriver/#dfn-is-element-enabled Web::WebDriver::Response Session::is_element_enabled(StringView parameter_element_id) { diff --git a/Userland/Services/WebDriver/Session.h b/Userland/Services/WebDriver/Session.h index fc99d610fa..b20ffab75a 100644 --- a/Userland/Services/WebDriver/Session.h +++ b/Userland/Services/WebDriver/Session.h @@ -58,7 +58,6 @@ public: Web::WebDriver::Response get_window_handle(); ErrorOr<void, Variant<Web::WebDriver::Error, Error>> close_window(); Web::WebDriver::Response get_window_handles() const; - Web::WebDriver::Response get_element_rect(StringView element_id); Web::WebDriver::Response is_element_enabled(StringView element_id); Web::WebDriver::Response get_source(); Web::WebDriver::Response execute_script(JsonValue const& payload); |