LibWeb: Convert a bunch of dbg() to dbgln()

This commit is contained in:
Andreas Kling 2021-01-09 14:02:45 +01:00
parent 4714b04d32
commit 0a3b834346
Notes: sideshowbarker 2024-07-19 00:00:24 +09:00
12 changed files with 31 additions and 38 deletions

View File

@ -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());
}
}

View File

@ -57,11 +57,22 @@ public:
return !(*this == other);
}
String to_string() const;
private:
RefPtr<Node> m_node;
unsigned m_offset { 0 };
};
const LogStream& operator<<(const LogStream&, const Position&);
}
namespace AK {
template<>
struct Formatter<Web::DOM::Position> : Formatter<StringView> {
void format(FormatBuilder& builder, const Web::DOM::Position& value)
{
Formatter<StringView>::format(builder, value.to_string());
}
};
}

View File

@ -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);

View File

@ -50,14 +50,14 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> 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<HTMLElement> 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;
}

View File

@ -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));
};

View File

@ -130,7 +130,7 @@ void HTMLScriptElement::prepare_script(Badge<HTMLDocumentParser>)
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);

View File

@ -38,7 +38,7 @@ RefPtr<ImageData> 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)

View File

@ -94,7 +94,7 @@ void Resource::did_load(Badge<ResourceLoader>, 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());

View File

@ -155,9 +155,6 @@ void OutOfProcessWebView::notify_server_did_paint(Badge<WebContentClient>, i32 s
void OutOfProcessWebView::notify_server_did_invalidate_content_rect(Badge<WebContentClient>, [[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();
}

View File

@ -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<HTML::HTMLAnchorElement> 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())

View File

@ -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 };

View File

@ -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