mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 12:12:45 +00:00 
			
		
		
		
	LibWeb+WebContent: Implement asynchronous DOM Node properties call
This lets us "push" a new style-properties list to the DOM Inspector, for example when JS changes the style of the inspected node.
This commit is contained in:
		
							parent
							
								
									1da07734bb
								
							
						
					
					
						commit
						3b07f49d48
					
				
					 7 changed files with 20 additions and 1 deletions
				
			
		|  | @ -281,6 +281,10 @@ Tab::Tab(BrowserWindow& window) | |||
|             m_dom_inspector_widget->set_dom_json(dom_tree); | ||||
|     }; | ||||
| 
 | ||||
|     hooks().on_get_dom_node_properties = [this](auto node_id, auto& specified, auto& computed) { | ||||
|         m_dom_inspector_widget->set_dom_node_properties_json(node_id, specified, computed); | ||||
|     }; | ||||
| 
 | ||||
|     hooks().on_js_console_output = [this](auto& method, auto& line) { | ||||
|         if (m_console_window) { | ||||
|             auto* console_widget = static_cast<ConsoleWidget*>(m_console_window->main_widget()); | ||||
|  |  | |||
|  | @ -341,6 +341,12 @@ void OutOfProcessWebView::notify_server_did_get_dom_tree(const String& dom_tree) | |||
|         on_get_dom_tree(dom_tree); | ||||
| } | ||||
| 
 | ||||
| void OutOfProcessWebView::notify_server_did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style) | ||||
| { | ||||
|     if (on_get_dom_node_properties) | ||||
|         on_get_dom_node_properties(node_id, specified_style, computed_style); | ||||
| } | ||||
| 
 | ||||
| void OutOfProcessWebView::notify_server_did_js_console_output(const String& method, const String& line) | ||||
| { | ||||
|     if (on_js_console_output) | ||||
|  |  | |||
|  | @ -72,6 +72,7 @@ public: | |||
|     String notify_server_did_request_prompt(Badge<WebContentClient>, const String& message, const String& default_); | ||||
|     void notify_server_did_get_source(const URL& url, const String& source); | ||||
|     void notify_server_did_get_dom_tree(const String& dom_tree); | ||||
|     void notify_server_did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style); | ||||
|     void notify_server_did_js_console_output(const String& method, const String& line); | ||||
|     void notify_server_did_change_favicon(const Gfx::Bitmap& favicon); | ||||
|     String notify_server_did_request_cookie(Badge<WebContentClient>, const URL& url, Cookie::Source source); | ||||
|  |  | |||
|  | @ -136,11 +136,16 @@ void WebContentClient::did_get_source(URL const& url, String const& source) | |||
|     m_view.notify_server_did_get_source(url, source); | ||||
| } | ||||
| 
 | ||||
| void WebContentClient::did_get_dom_tree(const String& dom_tree) | ||||
| void WebContentClient::did_get_dom_tree(String const& dom_tree) | ||||
| { | ||||
|     m_view.notify_server_did_get_dom_tree(dom_tree); | ||||
| } | ||||
| 
 | ||||
| void WebContentClient::did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style) | ||||
| { | ||||
|     m_view.notify_server_did_get_dom_node_properties(node_id, specified_style, computed_style); | ||||
| } | ||||
| 
 | ||||
| void WebContentClient::did_js_console_output(String const& method, String const& line) | ||||
| { | ||||
|     m_view.notify_server_did_js_console_output(method, line); | ||||
|  |  | |||
|  | @ -50,6 +50,7 @@ private: | |||
|     virtual void did_request_image_context_menu(Gfx::IntPoint const&, URL const&, String const&, unsigned, Gfx::ShareableBitmap const&) override; | ||||
|     virtual void did_get_source(URL const&, String const&) override; | ||||
|     virtual void did_get_dom_tree(String const&) override; | ||||
|     virtual void did_get_dom_node_properties(i32 node_id, String const& specified_style, String const& computed_style) override; | ||||
|     virtual void did_js_console_output(String const&, String const&) override; | ||||
|     virtual void did_change_favicon(Gfx::ShareableBitmap const&) override; | ||||
|     virtual void did_request_alert(String const&) override; | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ public: | |||
|     Function<void(DOM::Document*)> on_set_document; | ||||
|     Function<void(const URL&, const String&)> on_get_source; | ||||
|     Function<void(const String&)> on_get_dom_tree; | ||||
|     Function<void(i32 node_id, String const& specified_style, String const& computed_style)> on_get_dom_node_properties; | ||||
|     Function<void(const String& method, const String& line)> on_js_console_output; | ||||
|     Function<String(const URL& url, Cookie::Source source)> on_get_cookie; | ||||
|     Function<void(const URL& url, const Cookie::ParsedCookie& cookie, Cookie::Source source)> on_set_cookie; | ||||
|  |  | |||
|  | @ -28,6 +28,7 @@ endpoint WebContentClient | |||
|     did_request_prompt(String message, String default_) => (String response) | ||||
|     did_get_source(URL url, String source) =| | ||||
|     did_get_dom_tree(String dom_tree) =| | ||||
|     did_get_dom_node_properties(i32 node_id, String specified_style, String computed_style) =| | ||||
|     did_js_console_output(String method, String line) =| | ||||
|     did_change_favicon(Gfx::ShareableBitmap favicon) =| | ||||
|     did_request_cookie(URL url, u8 source) => (String cookie) | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Sam Atkins
						Sam Atkins