Commit Graph

291 Commits

Author SHA1 Message Date
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
Andreas Kling
5e945c5169 LibWeb: Don't load anything for <iframe> without src attribute
Completing an empty URL string from the document base URL will just
return the document URL, so any document that had an "<iframe>"
would endlessly load itself in recursive iframes.
2021-04-17 21:38:38 +02:00
Egor Ananyin
1d343116a9 LibWeb: Fix height calculation for absolutely positioned boxes
This commit fixes algorithm for computing auto height (CSS 2.2 10.6.7)
by including floating boxes into computation and implements one of the cases
for computing the height of absolutely positioned, non-replaced elements (10.6.4 rule 3)
2021-04-17 09:48:27 +02:00
Tobias Christiansen
7744048d0f LibWeb: Fix misplaced bullet points on list items
The bullet point should not be centered in the height of the list item,
but rather stay in front of the first line.
So, instead of giving the marker the full height of the ListItemBox,
it gets the height of a single line.

This closes #6384
2021-04-17 00:28:55 +02:00
Timothy Flynn
2381b19719 Browser+LibWeb+WebContent: Parse cookies in the OOP tab
To protect the main Browser process against nefarious cookies, parse the
cookies out-of-process and then send the parsed result over IPC to the
main process. This way, if the cookie parser blows up, only that tab
will be affected.
2021-04-16 19:19:31 +02:00
Timothy Flynn
67884f6747 LibWeb: Impose a sane max cookie size
Drop cookies larger than 4KiB. This value is the RFC's recommendation:
https://tools.ietf.org/html/rfc6265#section-6.1
2021-04-16 19:19:31 +02:00
Nicholas-Baron
73dd293ec4 Everywhere: Add -Wdouble-promotion warning
This warning informs of float-to-double conversions. The best solution
seems to be to do math *either* in 32-bit *or* in 64-bit, and only to
cross over when absolutely necessary.
2021-04-16 19:01:54 +02:00
Nicholas-Baron
c4ede38542 Everything: Add -Wnon-virtual-dtor flag
This flag warns on classes which have `virtual` functions but do not
have a `virtual` destructor.

This patch adds both the flag and missing destructors. The access level
of the destructors was determined by a two rules of thumb:
1. A destructor should have a similar or lower access level to that of a
   constructor.
2. Having a `private` destructor implicitly deletes the default
   constructor, which is probably undesirable for "interface" types
   (classes with only virtual functions and no data).

In short, most of the added destructors are `protected`, unless the
compiler complained about access.
2021-04-15 20:57:13 +02:00
Idan Horowitz
ad8e2f481d LibWeb: Expose the MouseEvent::{clientX, clientY} attributes
These provide the cursor coordinate within the viewport at which the
event occurred (as opposed to the page relative coordinates exposed via
offsetX, offsetY).
2021-04-15 20:22:08 +02:00
Idan Horowitz
815934a95d LibWeb: Expose the HTMLElement::{offsetLeft, offsetTop} attributes
These describe the border box of an element relative to their parent.
2021-04-15 20:22:08 +02:00
Idan Horowitz
c5769a7033 LibWeb: Check radius sign in CanvasRenderingContext2D::{arc, ellipse}
As required by the specification: 'If either radiusX or radiusY are
negative, then throw an "IndexSizeError" DOMException.'
2021-04-15 20:22:08 +02:00
Idan Horowitz
00114ab01d LibWeb: Add a naive implemention of CanvasRenderingContext2D::fill_text
This doesnt actually account for several unimplemented attributes
(like ltr/rtl, alignment, etc) yet, so this should be expanded in
the future.
2021-04-15 20:22:08 +02:00
Idan Horowitz
a257ef0f35 LibWeb: Add support for optional double arguments with no default value
This is implemented by emitting AK::Optional, similar to optional
boolean arguments.
2021-04-15 20:22:08 +02:00
Idan Horowitz
0072581693 LibWeb: Emit optional boolean variable definition in WrapperGenerator
The removed if in this commit was inside the else branch of an if with
the same condition, making it a no-op, as well as breaking optional
booleans.
2021-04-15 20:22:08 +02:00
AnotherTest
801daf47f0 LibGfx+LibWeb: Wire up CanvasRenderingContext2D.ellipse()
Note that this is *extremely* naive, and not very good at being correct.
2021-04-15 17:50:16 +02:00
AnotherTest
1ea466661f LibGfx+LibWeb: Move out the EllipticArcTo() logic into Path
At its previous state, the interface allowed invalid "ellipses" to be
specified, instead of doing that, simply use the parameters that SVG
uses :^)
2021-04-15 17:50:16 +02:00
Timothy Flynn
0f47a23e8e LibWeb: Set Cookie header on remaining resource requests 2021-04-15 09:46:49 +02:00
Timothy Flynn
0cacc52990 LibWeb: Set Cookie header on <img> and <object> resource requests
This required passing a reference to the owning HTML*Element to
ImageLoader, the same way that CSSLoader has a reference to its owner.
2021-04-15 09:46:49 +02:00
Timothy Flynn
347838a240 LibWeb: Set Cookie header on <script> resource requests
This required changing the load_sync API to take a LoadRequest instead
of just a URL. Since HTMLScriptElement was the only (non-test) user of
this API, it didn't seem useful to instead add an overload of load_sync
for this.
2021-04-15 09:46:49 +02:00
Timothy Flynn
3cc5286565 LibWeb: Helper for creating load requests with a Cookie header
Instead of all interested parties needing to write out the code to get
the cookie value for a load request, add a static helper to do it in
one location.
2021-04-15 09:46:49 +02:00
Idan Horowitz
bc9cd55da4 Browser+LibWeb: Add support for spoofing the browser user agent
This is helpful when testing certain sites like twitter.com which
display differently based on the user agent.
2021-04-14 23:06:32 +02:00
Idan Horowitz
aab99d5945 LibWeb: Implement the CanvasRenderingContext2D::rect path method
This method adds a rectangle to the current 2D path.
2021-04-14 23:01:23 +02:00
Idan Horowitz
4c0937225e LibWeb: Make CanvasRenderingContext2D::fill's fillRule argument optional
As defined by the specification (and used by the website i am testing):
interface mixin CanvasDrawPath {
  undefined fill(optional CanvasFillRule fillRule = "nonzero");
}
2021-04-14 23:01:23 +02:00
Idan Horowitz
0a580ef891 LibWeb: Request repaint on canvas path finalizaiton via fill/stroke
Since these were not requesting a repaint the drawn path was not being
rendered until a repaint was forced in some other way (window resize).
2021-04-14 23:01:23 +02:00
Timothy Flynn
c00760c5f9 Browser+LibWeb+WebContent: Track the source of document.cookie requests
To implement the HttpOnly attribute, the CookieJar needs to know where a
request originated from. Namely, it needs to distinguish between HTTP /
non-HTTP (i.e. JavaScript) requests. When the HttpOnly attribute is set,
requests from JavaScript are to be blocked.
2021-04-14 16:07:46 +02:00
Timothy Flynn
7193e518d1 Browser+LibWeb: Move the cookie structure into LibWeb 2021-04-14 16:07:46 +02:00
Timothy Flynn
c2d38abe6f Browser+LibWeb: Move cookie parser into LibWeb
This moves the cookie parsing steps out of CookieJar into their own file
inside LibWeb. It makes sense for the cookie structures to be in LibWeb
for a couple reasons:

1. There are some steps in the spec that will need to partially happen
   from LibWeb, such as the HttpOnly attribute.
2. Parsing the cookie string will be safer if it happens in the OOP tab
   rather than the main Browser process. Then if the parser blows up due
   to a malformed cookie, only that tab will be affected.
3. Cookies in general are a Web concept not specific to a browser.
2021-04-14 16:07:46 +02:00
Linus Groh
5da4c9bf1e LibWeb: Implement Node.cloneNode()
With this we can now successfully run a Vue.js 2 hello world! :^)
2021-04-14 09:30:29 +02:00
Linus Groh
d721c93beb LibWeb: Add Element::prefix()
Just a getter for m_qualified_name.prefix(), just like local_name() and
namespace_().
2021-04-14 09:30:29 +02:00
AnotherTest
d2b5c4d8dc LibWeb: Actually return an empty value when an exception is thrown via
throw_dom_exception_if_needed()

Fixes #6298.
2021-04-13 23:56:19 +02:00
AnotherTest
9c201767a0 LibWeb: Fix some FIXMEs related to ExceptionOr<T>
This fixes a few FIXMEs mentioned in 5beacf08a2,
which depended on #6075 being fixed.
2021-04-13 22:31:06 +02:00
AnotherTest
8ba2b5f36f LibWeb: Make ExceptionOr work with non-JS::Value types
Fixes #6075.
2021-04-13 22:31:06 +02:00
Egor Ananyin
d5def1cad0 LibWeb: Use min-height in calculating height 2021-04-13 22:04:25 +02:00
Egor Ananyin
fe544feb17 LibWeb: Start parsing font property 2021-04-13 22:04:25 +02:00
Linus Groh
e4b3591ac4 LibWeb: Fix a TODO in the adoption agency algorithm
There's still a much bigger one at the end of the function though. :^)
2021-04-13 21:59:55 +02:00
Andreas Kling
a2baab38fd Everywhere: It's now "Foobar", not "FooBar", and not "foo bar"
I hereby declare these to be full nouns that we don't split,
neither by space, nor by underscore:

- Breadcrumbbar
- Coolbar
- Menubar
- Progressbar
- Scrollbar
- Statusbar
- Taskbar
- Toolbar

This patch makes everything consistent by replacing every other variant
of these with the proper one. :^)
2021-04-13 16:58:15 +02:00
Egor Ananyin
86290c0e4e LibWeb: Set border width to zero if style is none 2021-04-12 17:47:59 +02:00
Egor Ananyin
d5eb09adc2 LibWeb: Parse border-style correctly 2021-04-12 17:47:59 +02:00
Linus Groh
da177c6517 LibJS: Make Errors fully spec compliant
The previous handling of the name and message properties specifically
was breaking websites that created their own error types and relied on
the error prototype working correctly - not assuming an JS::Error this
object, that is.

The way it works now, and it is supposed to work, is:

- Error.prototype.name and Error.prototype.message just have initial
  string values and are no longer getters/setters
- When constructing an error with a message, we create a regular
  property on the newly created object, so a lookup of the message
  property will either get it from the object directly or go though the
  prototype chain
- Internal m_name/m_message properties are no longer needed and removed

This makes printing errors slightly more complicated, as we can no
longer rely on the (safe) internal properties, and cannot trust a
property lookup either - get_without_side_effects() is used to solve
this, it's not perfect but something we can revisit later.

I did some refactoring along the way, there was some really old stuff in
there - accessing vm.call_frame().arguments[0] is not something we (have
to) do anymore :^)

Fixes #6245.
2021-04-12 09:38:57 +02:00
Luke
9ec4defdd2 LibWeb: Add Window.parent and fix Window.top attributes
This returns the parent frame of the current frame. If it's the
main frame, it returns itself.

Also fixes the attributes of Window.top, as they were accidentally
being passed in as the setter.

Required by Web Platform Tests.
2021-04-12 09:01:08 +02:00
Luke
83d2c3f2f5 LibWeb: Move element_child_count to ParentNode and add its IDL attribute
I initially had it in Node just because, but then saw it was part of
ParentNode in the spec.
2021-04-11 18:32:42 +02:00
Luke
fc9abee84b LibWeb: Add Event.initEvent
Used by YouTube after creating an event with Document.createEvent
2021-04-11 18:27:52 +02:00
Luke
8da14bf880 LibWeb: Add support for optional default values and optional bools in IDL
Fixed the DOMException constructor as it had the default value version
commented out.
2021-04-11 18:27:52 +02:00
Timothy Flynn
4152f807bc LibWeb: Store cookies sent via the Set-Cookie HTTP header
Note: HTTP response headers are currently stored in a hash map, so the
Set-Cookie entry will only appear once here.
2021-04-11 18:24:34 +02:00
Timothy Flynn
1ef48d50ff LibWeb+WebContent: Hook document.cookie to the backend cookie storage 2021-04-11 18:24:34 +02:00
Timothy Flynn
e54837add5 Browser+LibWeb: Add hooks for getting and setting cookies 2021-04-11 18:24:34 +02:00
Andreas Kling
54cd8dfc4d LibWeb+WebContent: Support image context menus in OOPWV
You can now right-click images in web content and get a context menu.
2021-04-11 16:49:25 +02:00
Brian Gianforcaro
c4226ca646 LibWeb: Remove trailing ';' from WrapperGenerator functions. 2021-04-11 12:50:33 +02:00
Brian Gianforcaro
988c23fff0 LibWeb: Add implementation of Node.compareDocumentPosition()
While looking into getting Duck Duck Go loading further in the
Browser, I noticed that it was complaining about the missing
method Node.compareDocumentPosition.

This change implements as much of the DOM spec as possible
with the current implementation of the DOM to date. The
implementation is validated by new tests in the Node.js.
2021-04-11 09:40:06 +02:00
Brian Gianforcaro
0f8932d7ab LibWeb: Connect existing implementation of Node::is_connected to JS.
I was looking at implementing something else, and saw this was low
hanging fruit, that brings the browser closer to standards conformance.

Add a basic test as well to validate it's implementation.
2021-04-11 09:40:06 +02:00