summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
AgeCommit message (Collapse)Author
2021-05-21LibGfx+WindowServer: Have WindowServer broadcast system font settingsAndreas Kling
Instead of everybody getting their system fonts from Gfx::FontDatabase (where it's all hardcoded), they now get it from WindowServer. These are then plumbed into the usual Gfx::FontDatabase places so that the old default_font() and default_fixed_width_font() APIs keep working.
2021-05-21LibWeb: Ignore vendor-specific CSS propertiesTobias Christiansen
If we can't parse a property we previously a log-line was generated. However it is in our best interest to simply ignore vendor-specific properties (e.g -moz-something or -webkit-something) since they are not part of the spec. The vendor-specific-ness is determined by looking whether the property starts with '-'. If we want to support some vendor-specific stuff, this doesn't get in the way since this check takes place after the parser determined that the current property is invalid. This cuts down the log-noise of the parser.
2021-05-21LibWeb: Make tag names bold in syntax-highlighted HTML :^)Andreas Kling
2021-05-21Revert "Userland: static vs non-static constexpr variables"Linus Groh
This reverts commit 800ea8ea969835297dc7e7da345a45b9dc5e751a. Booting the system no longer worked after these changes.
2021-05-21Userland: static vs non-static constexpr variablesLenny Maiorani
Problem: - `static` variables consume memory and sometimes are less optimizable. - `static const` variables can be `constexpr`, usually. - `static` function-local variables require an initialization check every time the function is run. Solution: - If a global `static` variable is only used in a single function then move it into the function and make it non-`static` and `constexpr`. - Make all global `static` variables `constexpr` instead of `const`. - Change function-local `static const[expr]` variables to be just `constexpr`.
2021-05-21LibWeb: Fix invalid behaviour of HTMLTokenizer::skip() and restore_to()Ali Mohammad Pur
skip() is supposed to end up keeping the previous iterator only one index behind the current one, and restore_to() should actually do the restore instead of just removing the now-useless source positions. Fixes #7331.
2021-05-20LibWeb: Deal with Boxes that have a background, border and -radiusTobias Christiansen
This hack allows for Boxes that have a background to be painted and a border to accurately paint their border-radii if needed. For that the box in with the background is drawn is extended to the bordered_rect. The border is later drawn over this regardless. Previously when drawing a Box that had all three, background, border and a border-radius, there could be some white between the filling and the border.
2021-05-20LibWeb: Take border-radius into account when painting bordersTobias Christiansen
This applies to thicker borders. When drawing them we now don't chamfer the corner if there is a border-radius present.
2021-05-20LibWeb: Introduce struct to hold border radii and normalize onceTobias Christiansen
The struct BorderRadiusData contains the four radii of the box. In case the specified borders are too large for the dimensions of the box, they get scaled down.
2021-05-20LibWeb: Draw rounded corners for the backgrounds of BoxesTobias Christiansen
Even if the Box doesn't have a border-radius, we'll pass the rendering of the Box and its corners to the Painter.
2021-05-20LibWeb: Basic rendering of border-radiusTobias Christiansen
It supports all four corners.
2021-05-20LibWeb: Resolve shorthand for border-radiusTobias Christiansen
This takes care of the 1, 2, 3 and 4 parameter shorthand of the border- radius identifier. There are more as well as the ominous '/' character but that is for another time. The 2 and 3 parameter versions are weird enough already. I don't think anybody uses anything other than the 1 or 4 parameter version or even the elliptical stuff.
2021-05-20LibWeb: Make border-radius attibutes accessibleTobias Christiansen
2021-05-20LibWeb: Add border-radius to the CSS-parserTobias Christiansen
And resolve the shorthands.
2021-05-20LibWeb: Handle background-painting of Box in seperate functionTobias Christiansen
2021-05-20LibWeb: Move the painting of the border out of paint()Tobias Christiansen
So other Boxes can override this function.
2021-05-20LibWeb: Add a super basic HTML syntax highlighterAli Mohammad Pur
This can currently highlight tag names and attribute names/values.
2021-05-20LibWeb: Add position tracking information to HTML tokensAli Mohammad Pur
2021-05-20LibWeb: Sort CMakeLists SOURCES entriesAli Mohammad Pur
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_fixed_width_font()Andreas Kling
Ask for a bold_variant() of the default_fixed_width_font() instead.
2021-05-20LibGfx: Remove Gfx::FontDatabase::default_bold_font()Andreas Kling
Instead use default_font().bold_variant() in cases where we want a bold variant of the default font. :^)
2021-05-19LibWeb: Use -libweb-palette-base-text for text color in default CSSLinus Groh
This makes un-styled text readable when using a dark system theme, previously such text would be black, regardless of the theme background color. Fixes #7274.
2021-05-19Everywhere: Add missing includes for <AK/OwnPtr.h>Gunnar Beutner
Previously <AK/Function.h> also included <AK/OwnPtr.h>. That's about to change though. This patch fixes a few build problems that will occur when that change happens.
2021-05-19LibWeb: Support X-Content-Type-Options to opt out of MIME type sniffingBrendan Coles
2021-05-18LibWeb: Implement encoding sniffing algorithmMax Wipfli
This patch implements the HTML specification's "encoding sniffing algorithm", which is used when no encoding can be obtained from the Content-Type header (either because it doesn't contain a charset=...) value or the file has not been opened via HTTP (as with local files). It also modifies the creator of the HTMLDocumentParser to use the new HTMLDocumentParser::create_with_uncertain_encoding static method, which runs the encoding sniffing algorithm before instantiating the parser. This now allows us to load local HTML pages (or remote pages without a charset specified in the 'Content-Type' header) with a non-UTF-8 encoding such as 'windows-1252'. This would previously crash the browser. :^)
2021-05-18LibWeb: Change Document's m_encoding to Optional<String>Max Wipfli
This modifies the Document class to use Optional<String> for the encoding. If the encoding is unknown, the Optional will not have a value. It also implements the has_encoding() and encoding_or_default() instance methods, the latter of which will return "UTF-8" as a fallback if no encoding is present. The usage of Optional<String> instead of the null string is part of an effort to explicitly indicate that a string could not have a value. This also modifies the former callers of encoding() to use encoding_or_default(). Furthermore, the encoding will now only be set if it is actually known, rather than just guessed by earlier code.
2021-05-18LibWeb: Change Resource's m_encoding to Optional<String>Max Wipfli
This modifies the Resource class to use Optional<String> for the encoding. If the encoding is unknown, the Optional will not have a value (instead of using the null state of the String class). It also implements a has_encoding() instance method and modifies the callers of Resource::encoding() to use the new API.
2021-05-18LibWeb: Use Optional<String> for encoding_from_content_typeMax Wipfli
This patch changes the encoding_from_content_type function to only return an encoding if it actually finds one, and leave it up to the caller to decided on a default to use. It also modifies the caller to expect an Optional<String> (instead of relying on the null state of the String class) as a return value and separates the encoding and MIME type determination. This will be built upon in a further commit.
2021-05-18LibTextCodec: Use Optional<String> for get_standardized_encodingMax Wipfli
This patch changes get_standardized_encoding to use an Optional<String> return type instead of just returning the null string when unable to match the provided encoding to one of the canonical encoding names. This is part of an effort to move away from using null strings towards explicitly using Optional<String> to indicate that the String may not have a value.
2021-05-18LibWeb: Implement test-web in terms of LibTest/JavaScriptTestRunnerAli Mohammad Pur
This deduplicates the test-js copy-ism :^)
2021-05-17LibWeb: Resolve 2-part and 3-part border-color valuesTimothy Flynn
2021-05-17LibWeb: Resolve 3-part and 4-part border-width valuesTimothy Flynn
2021-05-17Everywhere: Fix a bunch of typosLinus Groh
2021-05-16LibWeb: Fix "adopt" => "adopt_ref" change in adoptNode exceptionsLuke
This was accidentally changed in b91c49364df1683c7fe1191eb02b8d9c331874f6
2021-05-16AK+Userland: Remove nullability feature for the ByteBuffer typeGunnar Beutner
Nobody seems to use this particular feature, in fact there were some bugs which were uncovered by removing operator bool.
2021-05-15LibWeb: Fix incorrect variable names when parsing CSSGunnar Beutner
2021-05-13LibWeb: Propagate body background properties to root HTML elementTimothy Flynn
The Acid1 test has a bit of an unusual background - the html and body tags have different background colors. Our painting order of the DOM was such that the body background was painted first, then all other elements were painted in-phase according to Appendix E of CSS 2.1. So the html element's background color was painted over the body background. This removes the special handling of the body background from InitialContainingBlockBox and now all boxes are painted in-phase. Doing this also exposed that we weren't handling Section 2.11.2 of the spec; when the html background is unset, the body's background should be propagated to the html element.
2021-05-13LibWeb: Fix off-by-one for alphabetical markers in <ol>sTobias Christiansen
The ListItemMarker gets its index 1-based while the String::bijective_base_from expects its index to be 0-based. This patch adjusts the index passed around accordingly.
2021-05-12LibCore+Everywhere: Move OpenMode out of IODeviceAli Mohammad Pur
...and make it an enum class so people don't omit "OpenMode".
2021-05-12LibWeb: Position the ListItemMarkers according to their widthTobias Christiansen
Previously they were positioned with a fixed offset. However this lead to wider markers with more than one character to collide with the element itself. Now the ListItemMarkerBox generates and stores the appropriate String in its constructor and sets its own width according to that. The ListItemBox then lays out the Marker taking this width into account. This also made the painting a lot easier since we don't generate the needed Strings every time we repaint, just once.
2021-05-12LibWeb: Remove unused alphabet constants from ListItemMarkerBoxTobias Christiansen
Why exactly the linter didn't whine about this is a mystery. These constants aren't needed anymore since the functionality moved to AK/String a while ago.
2021-05-12LibWeb: Move clearing boxes below preceding floating boxesTimothy Flynn
When computing the y-position of a clearing element, use the height of the border box of the associated floating elements. This also extracts this block of code to a helper lambda since it is used twice.
2021-05-11LibWeb: Add a maximum redirects limit to FrameLoaderIdan Horowitz
This prevents the browser from crashing when trying to load an infinite redirects loop. The chosen limit is based on the fetch specification: "If request's redirect count is twenty, return a network error."
2021-05-11LibWeb: Implement :nth-last-child pseudo-classmiere43
2021-05-11LibWeb: Paint an element's foreground before painting its childrenTimothy Flynn
The current implementation is missing the emphasized text of the following rule in the painting order spec: 7. Otherwise: *first for the element*, then for all its in-flow, non-positioned, block-level descendants in tree order... This ensures the foreground is painted for the current element before descending into its children.
2021-05-11LibWeb: Make Element::tag_name return the HTML uppercased qualified nameLuke
I forgot to change tag_name when this was added. Also makes html_uppercased_qualified_name return a const reference.
2021-05-11LibWeb: Expose Element.{prefix,localName}Luke
2021-05-09LibWeb: Add tests for HTMLTableElement attributesAdam Hodgen
These tests aim to exercise all attributes on <html> elements, including all edge cases.
2021-05-09LibWeb: Fix nodeName attribute in testsAdam Hodgen
Commit 19731fc14c (#6864) made all nodeName attributes on HTML elements uppercased. This change fixes that in all HTML & DOM tests.
2021-05-09LibWeb: Implement HTMLTableElement tbody attributesAdam Hodgen
* tBodies - returns a HTMLCollection of all tbody elements * createTBody - If necessary, creates a new tbody element and add it to the table after the last tbody element