summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/Document.cpp
AgeCommit message (Collapse)Author
2021-07-05LibWeb: Make WrapperGenerator generate nullable wrapper typesLuke
Previously it was not doing so, and some code relied on this not being the case. In particular, set_caption, set_t_head and set_t_foot in HTMLTableElement relied on this. This commit is not here to fix this, so I added an assertion to make it equivalent to a reference for now.
2021-07-04LibWeb: Hook on_call_stack_emptied after m_interpreter was initializedIdan Horowitz
We must hook `on_call_stack_emptied` after the interpreter was created, as the initialization of the WindowsObject can invoke some internal calls, which will eventually lead to this hook being called without `m_interpreter` being fully initialized yet.
2021-06-29LibWeb: Add JSON serialization method to DOM::NodeAdam Hodgen
This method builds a JSON object representing the full state of the DOM tree. The JSON that is built will be used for building the DOM Inspector widget for the OutOfProcessWebView.
2021-06-27LibJS: Rename Function => FunctionObjectAndreas Kling
2021-06-27LibWeb: Make ExceptionOr capable of holding all error types in the specAli Mohammad Pur
The WebIDL spec specifies a few "simple" exception types in addition to the DOMException type, let's support all of those. This allows functions returning ExceptionOr<T> to throw regular javascript exceptions (as limited by the webidl spec) by returning a `DOM::SimpleException { DOM::SimpleExceptionType::T, "error message" }` which is pretty damn cool :^)
2021-06-25LibWeb: Support :active pseudo-class for hyperlinks, :focus possiblyPaul Irwin
Adds support for the :active pseudo-class for hyperlinks (<a> tags only). Also, since it was very similar to :focus and an element having a focused state was already implemented, I went ahead and implemented that pseudo-class too, although I cannot come up with a working example to validate it.
2021-06-24AK: Rename downcast<T> => verify_cast<T>Andreas Kling
This makes it much clearer what this cast actually does: it will VERIFY that the thing we're casting is a T (using is<T>()).
2021-06-15LibJS: Add the FinalizationRegistry built-in objectIdan Horowitz
As well as the needed functionality in VM to enqueue and run cleanup jobs for the FinalizationRegistry instances.
2021-06-12LibJS: Store and maintain an "execution generation" counterIdan Horowitz
This counter is increased each time a synchronous execution sequence completes, and will allow us to emulate the abstract operations AddToKeptObjects & ClearKeptObjects efficiently.
2021-06-06AK+Everywhere: Disallow constructing Functions from incompatible typesAli Mohammad Pur
Previously, AK::Function would accept _any_ callable type, and try to call it when called, first with the given set of arguments, then with zero arguments, and if all of those failed, it would simply not call the function and **return a value-constructed Out type**. This lead to many, many, many hard to debug situations when someone forgot a `const` in their lambda argument types, and many cases of people taking zero arguments in their lambdas to ignore them. This commit reworks the Function interface to not include any such surprising behaviour, if your function instance is not callable with the declared argument set of the Function, it can simply not be assigned to that Function instance, end of story.
2021-06-03Everywhere: Replace ctype.h to avoid narrowing conversionsMax Wipfli
This replaces ctype.h with CharacterType.h everywhere I could find issues with narrowing conversions. While using it will probably make sense almost everywhere in the future, the most critical places should have been addressed.
2021-05-30LibWeb: Rename Web::Frame to Web::BrowsingContextAndreas Kling
Our "frame" concept very closely matches what the web specs call a "browsing context", so let's rename it to that. :^) The "main frame" becomes the "top-level browsing context", and "sub-frames" are now "nested browsing contexts".
2021-05-16LibWeb: Fix "adopt" => "adopt_ref" change in adoptNode exceptionsLuke
This was accidentally changed in b91c49364df1683c7fe1191eb02b8d9c331874f6
2021-05-07LibWeb: Implement replacing the current body when setting document.bodyLuke
Also adds an exception check to the append at the end.
2021-05-07LibWeb: Add non-const variants of Document::{html_element,body,head}()Luke
2021-05-04LibWeb: Add Document.{images,embeds,plugins,links,forms,scripts}Luke
2021-04-24LibJS+LibWeb: Move exception logging and remove should_log_exceptionsLinus Groh
LibWeb is now responsible for logging unhandled exceptions itself, which means set_should_log_exceptions() is no longer used and can be removed. It turned out to be not the best option for web page exception logging, as we would have no indication regarding whether the exception was later handled of not.
2021-04-24LibJS: Add VM::on_call_stack_emptied callbackLinus Groh
Instead of having to run queued promise jobs in LibWeb in various places, this allows us to consolidate that into one function - this is very close to how the spec describes it as well ("at some future point in time, when there is no running execution context and the execution context stack is empty, the implementation must [...]"). Eventually this will also be used to log unhandled exceptions, and possibly other actions that require JS execution to have ended.
2021-04-23AK: Rename adopt() to adopt_ref()Andreas Kling
This makes it more symmetrical with adopt_own() (which is used to create a NonnullOwnPtr from the result of a naked new.)
2021-04-22Everywhere: Use linusg@serenityos.org for my copyright headersLinus Groh
2021-04-22LibWeb: Implement document.anchorsAndreas Kling
This returns an HTMLCollection of all <a> elements in the document that have a "name" attribute.
2021-04-22LibWeb: Implement document.appletsAndreas Kling
This is a legacy interface that returns an always-empty HTMLCollection.
2021-04-22LibWeb: Implement a slow but functional HTMLCollection :^)Andreas Kling
HTMLCollection is an awkward legacy interface from the DOM spec. It provides a live view of a DOM subtree, with some kind of filtering that determines which elements are part of the collection. We now return HTMLCollection objects from these APIs: - getElementsByClassName() - getElementsByName() - getElementsByTagName() This initial implementation does not do any kind of caching, since that is quite a tricky problem, and there will be plenty of time for tricky problems later on when the engine is more mature.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-16Browser+LibWeb+WebContent: Parse cookies in the OOP tabTimothy Flynn
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-15LibWeb: Expose the MouseEvent::{clientX, clientY} attributesIdan Horowitz
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-14Browser+LibWeb+WebContent: Track the source of document.cookie requestsTimothy Flynn
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-13LibWeb: Fix some FIXMEs related to ExceptionOr<T>AnotherTest
This fixes a few FIXMEs mentioned in 5beacf08a2d578d0eb36d6320255d0f4634a1085, which depended on #6075 being fixed.
2021-04-11LibWeb+WebContent: Hook document.cookie to the backend cookie storageTimothy Flynn
2021-04-10LibWeb: Add a basic implementation of Document.createEvent()Linus Groh
This is a legacy function providing a way of constructing events without using their constructors exposed on the global object. We don't have many of the events it supports yet, nor can we throw a DOMException from it, so that's two FIXMEs for later.
2021-04-06LibWeb: Make the node mutation algorithms more spec compliantLuke
The mutation algorithms now more closely follow the spec and fixes some assertion failures in tests such as Acid3 and Dromaeo. The main thing that is missing right now is passing exceptions to the bindings layer. This is because of issue #6075. I spent a while trying to work it out and got so frustrated I just left it as a FIXME. Besides that, the algorithms bail at the appropriate points. This also makes the adopting steps in the document more spec compliant as it's needed by the insertion algorithm. While I was at it, I added the adoptNode IDL binding. This adds a bunch of ancestor/descendant checks to TreeNode as well. I moved the "remove_all_children" function to Node as it needs to use the full remove algorithm instead of simply removing it from the child list.
2021-04-06LibWeb: Rename "for_each_in_subtree(_of_type)" to ↵Luke
"for_each_in_inclusive_subtree(_of_type)" This is because it includes the initial node that the function was called on, which makes it "inclusive" as according to the spec. This is important as there are non-inclusive variants, particularly used in the node mutation algorithms.
2021-04-05LibWeb: Support two-value background-repeatTimothy Flynn
The background-repeat value may be specified as either one- or two-value identifiers (to be interpreted as horizontal and vertical repeat). This adds two pseudo-properties, background-repeat-x and background-repeat-y, to handle this. One-value identifiers are mapped to two-value in accordance with the spec.
2021-04-03LibWeb: Support rendering background images with 'background-repeat'Timothy Flynn
Update the painting of background images for both <body> nodes and other non-initial nodes. Currently, only the following values are supported: repeat, repeat-x, repeat-y, no-repeat This also doesn't support the two-value syntax which allows for setting horizontal and vertical repetition separately.
2021-04-02LibWeb: Run queued promise jobs after callbacksLinus Groh
We now run queued promise jobs after calling event handler, timer, and requestAnimationFrame() callbacks - this is a bit ad-hoc, but I don't want to switch LibWeb to use an event loop right now - this works just fine, too. We might want to revisit this at a later point and do tasks and microtasks properly.
2021-03-21LibWeb: Only call page_did_change_title() from main frameLinus Groh
Otherwise an embedded iframe will override the page title in the browser, for example.
2021-03-16LibJS: Make Interpreter::run() a void functionLinus Groh
With one small exception, this is how we've been using this API already, and it makes sense: a Program is just a ScopeNode with any number of statements, which are executed one by one. There's no explicit return value at the end, only a completion value of the last value-producing statement, which we then access using VM::last_value() if needed (e.g. in the REPL).
2021-03-15LibWeb: Stub out Document.cookieAndreas Kling
We don't get/set anything, but at least scripts that access document cookies can now progress further. :^)
2021-03-01LibWeb: Provide file name to JavaScript interpreterJean-Baptiste Boric
2021-02-23Everywhere: Rename ASSERT => VERIFYAndreas Kling
(...and ASSERT_NOT_REACHED => VERIFY_NOT_REACHED) Since all of these checks are done in release builds as well, let's rename them to VERIFY to prevent confusion, as everyone is used to assertions being compiled out in release. We can introduce a new ASSERT macro that is specifically for debug checks, but I'm doing this wholesale conversion first since we've accumulated thousands of these already, and it's not immediately obvious which ones are suitable for ASSERT.
2021-02-22LibWeb: Support assigning to document.body when it is nullAndreas Kling
2021-02-21LibWeb: Add Document.createRange()Andreas Kling
Also tidy up DOM::Range a little bit while we're here, and unify the way we create them to use a delegating constructors.
2021-02-20LibWeb: Use DOMException in Document::set_body()Linus Groh
2021-02-10LibWeb: Remove low-hanging LibGUI fruit from LibWebAndreas Kling
We'll want to remove the LibGUI dependency from the WebContent process. This is the first basic step of removing unnecessary LibGUI includes and swapping out GUI::Painter for Gfx::Painter.
2021-02-10LibWeb: Remove a whole bunch of unnecessary #includesAndreas Kling
2021-02-08LibWeb: Make getElementsByClassName() case-insensitive in quirks modeLinus Groh
From https://dom.spec.whatwg.org/#concept-getelementsbyclassname: The comparisons for the classes must be done in an ASCII case- insensitive manner if root’s node document’s mode is "quirks", and in an identical to manner otherwise.
2021-02-08LibWeb: Make getElementsByTagName() case-insensitive for HTML elementsLinus Groh
From https://dom.spec.whatwg.org/#concept-getelementsbytagname: 2. Otherwise, if root’s node document is an HTML document, return a HTMLCollection rooted at root, whose filter matches the following descendant elements: * Whose namespace is the HTML namespace and whose qualified name is qualifiedName, in ASCII lowercase. * Whose namespace is not the HTML namespace and whose qualified name is qualifiedName.
2021-02-03LibWeb: Move main thread JavaScript VM to its own fileAndreas Kling
Instead of being a weird little global function in DOM/Document.cpp, you can now get the main thread JS VM via Bindings::main_thread_vm().
2021-01-31Browser+LibWeb+WebContent: Make the "Debug" menu work in multi-processAndreas Kling
This patch adds an IPC call for debugging requests. It's stringly typed and very simple, and allows us to easily implement all the features in the Browser's Debug menu.
2021-01-28LibWeb: Add simple implementation of Document.createElementNSLuke