mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Reduce unnecessary debug spam from parse_as_sizes_attribute()
Logging a parse error when the attribute is not present, is not useful, but does fill the debug log with errors that hide any real parsing errors. This patch introduces an early-out in this situation to prevent this spam.
This commit is contained in:
parent
2a0f6fd23e
commit
8b3bcf9c0f
Notes:
github-actions[bot]
2024-09-12 05:40:00 +00:00
Author: https://github.com/AtkinsSJ
Commit: 8b3bcf9c0f
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1374
1 changed files with 6 additions and 1 deletions
|
@ -7932,10 +7932,15 @@ private:
|
|||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/images.html#parsing-a-sizes-attribute
|
||||
LengthOrCalculated Parser::Parser::parse_as_sizes_attribute([[maybe_unused]] DOM::Element const& element, HTML::HTMLImageElement const* img)
|
||||
LengthOrCalculated Parser::Parser::parse_as_sizes_attribute(DOM::Element const& element, HTML::HTMLImageElement const* img)
|
||||
{
|
||||
// When asked to parse a sizes attribute from an element element, with an img element or null img:
|
||||
|
||||
// AD-HOC: If element has no sizes attribute, this algorithm always logs a parse error and then returns 100vw.
|
||||
// The attribute is optional, so avoid spamming the debug log with false positives by just returning early.
|
||||
if (!element.has_attribute(HTML::AttributeNames::sizes))
|
||||
return Length(100, Length::Type::Vw);
|
||||
|
||||
// 1. Let unparsed sizes list be the result of parsing a comma-separated list of component values
|
||||
// from the value of element's sizes attribute (or the empty string, if the attribute is absent).
|
||||
// NOTE: The sizes attribute has already been tokenized into m_token_stream by this point.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue