summaryrefslogtreecommitdiff
path: root/Libraries
AgeCommit message (Collapse)Author
2020-11-28LibJS: Allow Shape without a global objectAndreas Kling
It would be nice to be able to cache some shapes globally in the VM, but then they can't be tied to a specific global object. So let's just get rid of the requirement that shapes are tied to a global object.
2020-11-28LibGUI/FileIconProvider: Initialize s_filetype_image_iconLinus Groh
This was accidentally removed in 1c90321. Fixes #4125.
2020-11-28LibJS: Remove quotes from RegExpCompileError messageLinus Groh
They look a bit out of place, especially for multi-line error messages.
2020-11-28LibRegex: Remove trailing newline from error_string()Linus Groh
2020-11-28LibRegex: Don't print error message in Regex constructorLinus Groh
It should be up to the caller to decide what to do when parsing of the pattern fails.
2020-11-28LibGUI: Make GUI::Dialogs non-minimizable by defaultAndreas Kling
2020-11-28LibGUI: Don't assert when right clicking on a vertical HeaderViewAndreas Kling
Just log a debug message instead. We still need to actually implement vertical header context menus, but for now let's at least not crash.
2020-11-28LibRegex: Allow '-' as the last element of a charclassAnotherTest
Fixes #4189.
2020-11-28LibRegex: Allow unknown escapes in non-unicode mode (for ECMA262)AnotherTest
This makes regexps like `/\x/` to work as normal. Partially deals with #4189.
2020-11-28LibRegex: Fix parsing identity escape sequencesAnotherTest
Also fixes the propagation of default options (the previous implementation reset them to zero before parsing...). Partially deals with #4189.
2020-11-28LibRegex: Stop trying to read a character class when no tokens remainAnotherTest
e.g. in "[". Fixes #4186.
2020-11-28LibJS: Use enumerator macros to define RegExp.prototype flag gettersLinus Groh
2020-11-28LibJS: Make RegExp.prototype.source spec-compliantLinus Groh
Basically: - And edge case for this object being RegExp.prototype.source - Return "(?:)" for empty pattern - Escape some things properly
2020-11-28LibJS: Make RegExp.prototype.toString() spec-compliantLinus Groh
It should use the 'source' and 'flags' properties of the object, and therefore work with non-RegExp objects as well.
2020-11-28LibJS: Make RegExp.prototype.flags spec-compliantLinus Groh
This should be using the individual flag boolean properties rather than the [[OriginalFlags]] internal slot. Use an enumerator macro here for brevity, this will be useful for other things as well. :^)
2020-11-28LibJS: Make RegExp() constructor spec-compliantLinus Groh
- Default values should depend on arguments being undefined, not being missing - "(?:)" for empty pattern happens in RegExp.prototype.source, not the constructor
2020-11-28LibWeb: Don't generate layout nodes for DOM inside replaced elementsAndreas Kling
Before this change, we'd show both a <canvas>, and any fallback content inside the <canvas> for browsers that don't support <canvas>. :^)
2020-11-27LibWeb: Two more edge cases for TreeNode::insert_before.asynts
2020-11-27LibJS: Implement `RegExpPrototype::exec()'AnotherTest
This implements *only* the builtin exec() function.
2020-11-27LibJS: Hook up Regex<ECMA262> to RegExpObject and implement `test()'AnotherTest
This makes RegExpObject compile and store a Regex<ECMA262>, adds all flag-related properties, and implements `RegExpPrototype.test()` (complete with 'lastIndex' support) :^) It should be noted that this only implements `test()' using the builtin `exec()'.
2020-11-27LibRegex: Fix reported compare-against value in debugAnotherTest
2020-11-27LibRegex: Implement an ECMA262-compatible parserAnotherTest
This also adds support for lookarounds and individually-negated comparisons. The only unimplemented part of the parser spec is the unicode stuff.
2020-11-27LibJS+js: Rename RegExp.{content => pattern}AnotherTest
The spec talks about it as 'pattern', so let's use that instead.
2020-11-27LibRegex: Change bytecode value type to a 64-bit valueAnotherTest
To allow storing unicode ranges compactly; this is not utilised at the moment, but changing this later would've been significantly more difficult. Also fixes a few debug logs.
2020-11-27LibRegex: Fix greedy/reluctant modifiers in PosixExtendedParserAnotherTest
Also fixes the issue with assertions causing early termination when they fail.
2020-11-27LibRegex: Remove backup file, remove BOM in RegexParser.cpp, run clang-formatEmanuel Sprung
2020-11-27TextEditor: Add button to match regular expression during searchEmanuel Sprung
2020-11-27LibRegex: Add RegexStringView wrapper to support utf8 and utf32 viewsEmanuel Sprung
2020-11-27LibRegex: Add a regular expression libraryEmanuel Sprung
This commit is a mix of several commits, squashed into one because the commits before 'Move regex to own Library and fix all the broken stuff' were not fixable in any elegant way. The commits are listed below for "historical" purposes: - AK: Add options/flags and Errors for regular expressions Flags can be provided for any possible flavour by adding a new scoped enum. Handling of flags is done by templated Options class and the overloaded '|' and '&' operators. - AK: Add Lexer for regular expressions The lexer parses the input and extracts tokens needed to parse a regular expression. - AK: Add regex Parser and PosixExtendedParser This patchset adds a abstract parser class that can be derived to implement different parsers. A parser produces bytecode to be executed within the regex matcher. - AK: Add regex matcher This patchset adds an regex matcher based on the principles of the T-REX VM. The bytecode pruduced by the respective Parser is put into the matcher and the VM will recursively execute the bytecode according to the available OpCodes. Possible improvement: the recursion could be replaced by multi threading capabilities. To match a Regular expression, e.g. for the Posix standard regular expression matcher use the following API: ``` Pattern<PosixExtendedParser> pattern("^.*$"); auto result = pattern.match("Well, hello friends!\nHello World!"); // Match whole needle EXPECT(result.count == 1); EXPECT(result.matches.at(0).view.starts_with("Well")); EXPECT(result.matches.at(0).view.end() == "!"); result = pattern.match("Well, hello friends!\nHello World!", PosixFlags::Multiline); // Match line by line EXPECT(result.count == 2); EXPECT(result.matches.at(0).view == "Well, hello friends!"); EXPECT(result.matches.at(1).view == "Hello World!"); EXPECT(pattern.has_match("Well,....")); // Just check if match without a result, which saves some resources. ``` - AK: Rework regex to work with opcodes objects This patchsets reworks the matcher to work on a more structured base. For that an abstract OpCode class and derived classes for the specific OpCodes have been added. The respective opcode logic is contained in each respective execute() method. - AK: Add benchmark for regex - AK: Some optimization in regex for runtime and memory - LibRegex: Move regex to own Library and fix all the broken stuff Now regex works again and grep utility is also in place for testing. This commit also fixes the use of regex.h in C by making `regex_t` an opaque (-ish) type, which makes its behaviour consistent between C and C++ compilers. Previously, <regex.h> would've blown C compilers up, and even if it didn't, would've caused a leak in C code, and not in C++ code (due to the existence of `OwnPtr` inside the struct). To make this whole ordeal easier to deal with (for now), this pulls the definitions of `reg*()` into LibRegex. pros: - The circular dependency between LibC and LibRegex is broken - Eaiser to test (without accidentally pulling in the host's libc!) cons: - Using any of the regex.h functions will require the user to link -lregex - The symbols will be missing from libc, which will be a big surprise down the line (especially with shared libs). Co-Authored-By: Ali Mohammad Pur <ali.mpfard@gmail.com>
2020-11-27LibWeb: Update m_previous_sibling in TreeNode::insert_before.asynts
2020-11-27LibWeb: Don't generate a wrap() function for the Event IDL interfaceAndreas Kling
We already have a wrap() in EventWrapperFactory.cpp. It would be nice to generate that at some point but it will require a lot more work on the wrapper generator.
2020-11-26LibWeb: Don't put block boxes inside inlinesAndreas Kling
Inline layout nodes cannot have block children (except inline-block, of course.) When encountering a block box child of an inline, we now hoist the block up to the inline's containing block, and also wrap any preceding inline siblings in an anonymous wrapper block. This improves the ACID2 situation quite a bit (although we still need floats to really bring it home.) I also took this opportunity to move all tree building logic into Layout::TreeBuilder, to continue the theme of absolving our LayoutNode objects of responsibilities. :^)
2020-11-26LibPthread: Fix broken EINVAL check in pthread_attr_setdetachstate()Andreas Kling
Also fix up some misleading error messages in the 'tt' test program.
2020-11-26Lagom: Make BMP fuzzer look like the other image loader fuzzersNico Weber
2020-11-25LibJS: Fix possible OOB read during Lexer constructionLinus Groh
The Lexer constructor calls consume() once, which initializes m_position to be > 0 and sets m_character. consume() calls is_line_terminator(), which wasn't accounting for this state.
2020-11-25LibWeb: Rename Layout::LayoutTreeBuilder => Layout::TreeBuilderAndreas Kling
2020-11-25LibWeb: Keep track of the parent of each formatting contextAndreas Kling
This will allow us to find the containing block formatting context when needed later on.
2020-11-25LibIPC: Fix 'unused private member' error when building with clangLinus Groh
This was breaking the Lagom build when using clang, as m_sockfd's only use is behind an #ifdef __serenity__. (void) it elsewhere to fix that.
2020-11-24LibCore: Make `guess_mime_type_based_on_filename()' recognise CSV filesAnotherTest
2020-11-24LibThread: Add API to join a threadSergey Bugaev
2020-11-24LibPthread: Implement pthread_once()Sergey Bugaev
The implementation uses atomics and futexes (yay!) and is heavily based on the implementation I did for my learning project named "Let's write synchronization primitives" [0]. That project, in fact, started when I tried to implement pthread_once() for Serenity (because it was needed for another project of mine, stay tuned ;) ) and was not very sure I got every case right. So now, after learning some more about code patterns around atomics and futexes, I am reasonably sure, and it's time to contribute the implementation of pthread_once() to Serenity :^) [0] To be published at https://github.com/bugaevc/lets-write-sync-primitives
2020-11-24LibJS: Support receiver in ProxyObject::get/put()Linus Groh
If a receiver is given, e.g. via Reflect.get/set(), forward it to the target object's get()/put() or use it as last argument of the trap function. The default value is the Proxy object itself.
2020-11-24LibGUI: Remove redundant set_title() call in FilePicker (#4153)Zac
2020-11-23LibGUI: Widget::action_for_key_event() should fail for invalid shortcuts (#4137)Jakub Berkop
Previously GUI::Actions which were constructed without initializing m_shortcut could be activated via an invalid GUI::Shortcut. Steps to reproduce: It was possible to enable TextEditor's markdown preview by pressing Ctrl or Alt (Cmd/Ctrl) keys, which should not happen, as this Action did not specify a shortcut. This fix should apply to all other cases where actions where declared without specifying a shortcut.
2020-11-23LibIPC: Support sending file descriptors :^)Sergey Bugaev
It is now possible to use the special IPC::File type in message arguments. In C++, the type is nothing more than a wrapper over a file descriptor. But when serializing/deserializing IPC::File arguments, LibIPC will use the sendfd/recvfd kernel APIs instead of sending the integer inline. This makes it quite convenient to pass files over IPC, and will allow us to significantly tighten sandboxes in the future :^) Closes https://github.com/SerenityOS/serenity/issues/3643
2020-11-23LibIPC: Prepend each message with its sizeSergey Bugaev
This makes it much simpler to determine when we've read a complete message, and will make it possible to integrate recvfd() in the future commit.
2020-11-23LibGUI: Set FilePicker window icon based on mode (#4148)Zac
2020-11-22LibJS: Forward receiver value to native property getters/settersLinus Groh
There's no reason why only (user-defined) accessors would have set the receiver as this value for their getters/setters, this is an oversight.
2020-11-22LibJS: Make call_native_property_{g,s}etter() take a NativeProperty&Linus Groh
Passing in a plain Value and expecting it to be a native property is error prone, let's use a more narrow type and pass a NativeProperty reference directly.
2020-11-22LibWeb: Add the submit event to HTMLFormElementLuke
Also adds the ability to submit from JavaScript.