diff --git a/Libraries/LibWeb/DOM/Position.cpp b/Libraries/LibWeb/DOM/Position.cpp index aa80758f628..e78139f7881 100644 --- a/Libraries/LibWeb/DOM/Position.cpp +++ b/Libraries/LibWeb/DOM/Position.cpp @@ -39,11 +39,11 @@ Position::~Position() { } -const LogStream& operator<<(const LogStream& stream, const Position& position) +String Position::to_string() const { - if (!position.node()) - return stream << "DOM::Position(nullptr, " << position.offset() << ")"; - return stream << "DOM::Position(" << position.node()->node_name() << "{" << position.node() << "}, " << position.offset() << ")"; + if (!node()) + return String::formatted("DOM::Position(nullptr, {})", offset()); + return String::formatted("DOM::Position({} ({})), {})", node()->node_name(), node(), offset()); } } diff --git a/Libraries/LibWeb/DOM/Position.h b/Libraries/LibWeb/DOM/Position.h index 75ef1a2f880..b2c5a17ceb9 100644 --- a/Libraries/LibWeb/DOM/Position.h +++ b/Libraries/LibWeb/DOM/Position.h @@ -57,11 +57,22 @@ public: return !(*this == other); } + String to_string() const; + private: RefPtr m_node; unsigned m_offset { 0 }; }; -const LogStream& operator<<(const LogStream&, const Position&); +} + +namespace AK { +template<> +struct Formatter : Formatter { + void format(FormatBuilder& builder, const Web::DOM::Position& value) + { + Formatter::format(builder, value.to_string()); + } +}; } diff --git a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp index 406f18c7e86..d0152254601 100644 --- a/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp @@ -80,11 +80,11 @@ static Gfx::IntSize bitmap_size_for_canvas(const HTMLCanvasElement& canvas) area *= height; if (area.has_overflow()) { - dbg() << "Refusing to create " << width << "x" << height << " canvas (overflow)"; + dbgln("Refusing to create {}x{} canvas (overflow)", width, height); return {}; } if (area.value() > max_canvas_area) { - dbg() << "Refusing to create " << width << "x" << height << " canvas (exceeds maximum size)"; + dbgln("Refusing to create {}x{} canvas (exceeds maximum size)", width, height); return {}; } return Gfx::IntSize(width, height); diff --git a/Libraries/LibWeb/HTML/HTMLFormElement.cpp b/Libraries/LibWeb/HTML/HTMLFormElement.cpp index b05ebdce0fc..b632dab4821 100644 --- a/Libraries/LibWeb/HTML/HTMLFormElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLFormElement.cpp @@ -50,14 +50,14 @@ void HTMLFormElement::submit_form(RefPtr submitter, bool from_submi return; if (action().is_null()) { - dbg() << "Unsupported form action ''"; + dbgln("Unsupported form action ''"); return; } auto effective_method = method().to_lowercase(); if (effective_method == "dialog") { - dbg() << "Failed to submit form: Unsupported form method '" << method() << "'"; + dbgln("Failed to submit form: Unsupported form method '{}'", method()); return; } @@ -97,21 +97,21 @@ void HTMLFormElement::submit_form(RefPtr submitter, bool from_submi URL url(document().complete_url(action())); if (!url.is_valid()) { - dbg() << "Failed to submit form: Invalid URL: " << action(); + dbgln("Failed to submit form: Invalid URL: {}", action()); return; } if (url.protocol() == "file") { if (document().url().protocol() != "file") { - dbg() << "Failed to submit form: Security violation: " << document().url() << " may not submit to " << url; + dbgln("Failed to submit form: Security violation: {} may not submit to {}", document().url(), url); return; } if (effective_method != "get") { - dbg() << "Failed to submit form: Unsupported form method '" << method() << "' for URL: " << url; + dbgln("Failed to submit form: Unsupported form method '{}' for URL: {}", method(), url); return; } } else if (url.protocol() != "http" && url.protocol() != "https") { - dbg() << "Failed to submit form: Unsupported protocol for URL: " << url; + dbgln("Failed to submit form: Unsupported protocol for URL: {}", url); return; } diff --git a/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 8ab82632738..61b99f0ffa5 100644 --- a/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -46,7 +46,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, const QualifiedName& }; m_image_loader.on_fail = [this] { - dbg() << "HTMLImageElement: Resource did fail: " << this->src(); + dbgln("HTMLImageElement: Resource did fail: {}", src()); this->document().update_layout(); dispatch_event(DOM::Event::create(EventNames::error)); }; diff --git a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp index c1b2f84e11c..cc3031984c4 100644 --- a/Libraries/LibWeb/HTML/HTMLScriptElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLScriptElement.cpp @@ -130,7 +130,7 @@ void HTMLScriptElement::prepare_script(Badge) url, [this, url](auto data, auto&) { if (data.is_null()) { - dbg() << "HTMLScriptElement: Failed to load " << url; + dbgln("HTMLScriptElement: Failed to load {}", url); return; } m_script_source = String::copy(data); diff --git a/Libraries/LibWeb/HTML/ImageData.cpp b/Libraries/LibWeb/HTML/ImageData.cpp index 4dcee14f47d..085cc887281 100644 --- a/Libraries/LibWeb/HTML/ImageData.cpp +++ b/Libraries/LibWeb/HTML/ImageData.cpp @@ -38,7 +38,7 @@ RefPtr ImageData::create_with_size(JS::GlobalObject& global_object, i if (width > 16384 || height > 16384) return nullptr; - dbg() << "Creating ImageData with " << width << "x" << height; + dbgln("Creating ImageData with {}x{}", width, height); auto* data = JS::Uint8ClampedArray::create(global_object, width * height * 4); if (!data) diff --git a/Libraries/LibWeb/Loader/Resource.cpp b/Libraries/LibWeb/Loader/Resource.cpp index 539cb272e17..b063cd11ac5 100644 --- a/Libraries/LibWeb/Loader/Resource.cpp +++ b/Libraries/LibWeb/Loader/Resource.cpp @@ -94,7 +94,7 @@ void Resource::did_load(Badge, ReadonlyBytes data, const HashMap auto content_type = headers.get("Content-Type"); if (content_type.has_value()) { #ifdef RESOURCE_DEBUG - dbg() << "Content-Type header: _" << content_type.value() << "_"; + dbgln("Content-Type header: '{}'", content_type.value()); #endif m_encoding = encoding_from_content_type(content_type.value()); m_mime_type = mime_type_from_content_type(content_type.value()); diff --git a/Libraries/LibWeb/OutOfProcessWebView.cpp b/Libraries/LibWeb/OutOfProcessWebView.cpp index 18e8953d5e6..d30025d678f 100644 --- a/Libraries/LibWeb/OutOfProcessWebView.cpp +++ b/Libraries/LibWeb/OutOfProcessWebView.cpp @@ -155,9 +155,6 @@ void OutOfProcessWebView::notify_server_did_paint(Badge, i32 s void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge, [[maybe_unused]] const Gfx::IntRect& content_rect) { -#ifdef DEBUG_SPAM - dbg() << "server did invalidate content_rect: " << content_rect << ", current front_shbuf_id=" << m_front_bitmap->shbuf_id() << ", current back_shbuf_id=" << m_back_bitmap->shbuf_id(); -#endif request_repaint(); } diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index 1640f6818be..7a69085aa4a 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -110,10 +110,8 @@ bool EventHandler::handle_mouseup(const Gfx::IntPoint& position, unsigned button handled_event = true; } - if (button == GUI::MouseButton::Left) { - dump_selection("MouseUp"); + if (button == GUI::MouseButton::Left) m_in_mouse_selection = false; - } return handled_event; } @@ -174,7 +172,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (RefPtr link = node->enclosing_link_element()) { auto href = link->href(); auto url = document->complete_url(href); - dbg() << "Web::EventHandler: Clicking on a link to " << url; + dbgln("Web::EventHandler: Clicking on a link to {}", url); if (button == GUI::MouseButton::Left) { auto href = link->href(); auto url = document->complete_url(href); @@ -205,7 +203,6 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt if (result.layout_node && result.layout_node->dom_node()) { m_frame.set_cursor_position(DOM::Position(*node, result.index_in_node)); layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} }); - dump_selection("MouseDown"); m_in_mouse_selection = true; } } else if (button == GUI::MouseButton::Right) { @@ -271,7 +268,6 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt if (hit.layout_node && hit.layout_node->dom_node()) { layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node }); } - dump_selection("MouseMove"); if (auto* page = m_frame.page()) page->client().page_did_change_selection(); } @@ -301,15 +297,6 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt return true; } -void EventHandler::dump_selection([[maybe_unused]] const char* event_name) const -{ -#ifdef SELECTION_DEBUG - dbg() << event_name << " selection start: " - << layout_root()->selection().start().layout_node << ":" << layout_root()->selection().start().index_in_node << ", end: " - << layout_root()->selection().end().layout_node << ":" << layout_root()->selection().end().index_in_node; -#endif -} - bool EventHandler::focus_next_element() { if (!m_frame.document()) diff --git a/Libraries/LibWeb/Page/EventHandler.h b/Libraries/LibWeb/Page/EventHandler.h index 09334a5d446..7ea12d64612 100644 --- a/Libraries/LibWeb/Page/EventHandler.h +++ b/Libraries/LibWeb/Page/EventHandler.h @@ -60,8 +60,6 @@ private: Layout::InitialContainingBlockBox* layout_root(); const Layout::InitialContainingBlockBox* layout_root() const; - void dump_selection(const char* event_name) const; - Frame& m_frame; bool m_in_mouse_selection { false }; diff --git a/Libraries/LibWeb/Page/Frame.cpp b/Libraries/LibWeb/Page/Frame.cpp index f1226d66c8c..8866fea7efe 100644 --- a/Libraries/LibWeb/Page/Frame.cpp +++ b/Libraries/LibWeb/Page/Frame.cpp @@ -221,7 +221,7 @@ void Frame::set_cursor_position(const DOM::Position& position) if (m_cursor_position.node() && m_cursor_position.node()->layout_node()) m_cursor_position.node()->layout_node()->set_needs_display(); - dbg() << "Cursor position: " << m_cursor_position; + dbgln("Cursor position: {}", m_cursor_position); } String Frame::selected_text() const