Commit Graph

3563 Commits

Author SHA1 Message Date
Andreas Kling
b74bf31a53 LibWeb: Implement document.anchors
This returns an HTMLCollection of all <a> elements in the document that
have a "name" attribute.
2021-04-22 22:14:55 +02:00
Andreas Kling
43d16fa5b6 LibWeb: Implement document.applets
This is a legacy interface that returns an always-empty HTMLCollection.
2021-04-22 22:11:42 +02:00
Andreas Kling
e4df1b223f LibWeb: Implement a slow but functional HTMLCollection :^)
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-22 21:21:46 +02:00
Andreas Kling
49f3d88baf LibWeb: Allow IDL interfaces to override get_by_index()
You can now specify the "CustomGetByIndex" extended interface attribute
which will cause the generator to emit an override declaration for
JS::Object::get_by_index().

It's up to you to implement that function somewhere. Just like the
CustomGet mechanism already works. :^)
2021-04-22 21:21:46 +02:00
Brian Gianforcaro
dc0fc16981 Everywhere: Use bgianf@serenityos.org for my copyright attribution 2021-04-22 21:15:54 +02:00
Simon Danner
c8d56ee4f4
LibWeb: Improve fallback font selection
Try to find a font that has at least some of the requested properties.
This makes e.g. rfcs on tools.ietf.org easier to read since their
headers are now bold.
2021-04-22 20:47:47 +02:00
Simon Danner
7ab8be9e0b
LibWeb: Encode URL in ResourceLoader::load()
Encode URLs before requesting them - this fixes loading of resources
that have spaces in their URL, for example.
2021-04-22 20:45:59 +02:00
Egor Ananyin
c2280a907d LibWeb: Parse line-height inside font property 2021-04-22 19:17:10 +02:00
Egor Ananyin
174c940479 LibWeb: Fix height computation (again) :^)
Height computation algorithm is actually
different for absolutely positioned boxes
and block formatting contexts (where it doesn't include floats)
Fixes #6408
2021-04-22 19:17:10 +02:00
Andreas Kling
0eedf3bfea SystemMonitor: Only show two decimal digits for the CPU usage 2021-04-22 18:24:12 +02:00
Timothy Flynn
ac0e387beb LibSQL: Parse (most of) SELECT statement
This doesn't yet parse join clauses, windowing functions, or compound
SELECT statements.
2021-04-22 18:08:15 +02:00
Timothy Flynn
9331293e44 LibSQL: Separate parsing of common-table-expression list
Statements like SELECT, INSERT, and UPDATE also optionally include this
list, so move its parsing out of parse_delete_statement(). Since it will
appear before the actual statement, parse it first in next_statement();
then only parse for statements that are allowed to include the list.
2021-04-22 18:08:15 +02:00
Timothy Flynn
6a7d7624a7 LibSQL: Fix parsing of lists of common-table-expression
Misread the graph: In the "WITH [RECURSIVE] common-table-expression"
section, common-table-expression is actually a repeating list. This
changes the parser to correctly parse this section as a list. Create a
new AST node, CommonTableExpressionList, to store both this list and the
boolean RECURSIVE attribute (because every statement that uses this list
also includes the RECURSIVE attribute beforehand).
2021-04-22 18:08:15 +02:00
Brian Gianforcaro
1682f0b760 Everything: Move to SPDX license identifiers in all files.
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-22 11:22:27 +02:00
Linus Groh
024fd9b957 LibWeb: Fix HTML injection on FrameLoader error page
Small regression introduced by 3857148, we still have to escape HTML
entities.
2021-04-22 10:17:00 +02:00
Andreas Kling
a5625686cb WidgetGallery: Fix bogus return type from FileIconsModel::create() 2021-04-22 09:35:15 +02:00
Andreas Kling
de7062af9c LibRegex: Unbreak the ALL_DEBUG build 2021-04-22 09:23:28 +02:00
Andreas Kling
3857148028 LibWeb+Base: Use AK::SourceGenerator for error pages
Instead of storing a format string in a file, let's be reasonable
and use SourceGenerator's template functionality. :^)
2021-04-22 00:00:59 +02:00
Andreas Kling
0005fa0e2b LibELF: Convert String::format() => String::formatted() 2021-04-21 23:49:03 +02:00
Andreas Kling
7254d4c4b8 LibCoreDump: Convert String::format() => String::formatted() 2021-04-21 23:49:03 +02:00
Andreas Kling
f4a15c8d42 LibCore: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
3a891abc37 FontEditor: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
9db2036437 LibGUI: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
9a8dd38493 LibWeb+Base: Convert String::format() to String::formatted()
This error page template is slightly hilarious and should probably
be replaced with AK::SourceGenerator or some such, but for now let's
just get rid of the call to String::format().
2021-04-21 23:49:02 +02:00
Andreas Kling
e924da6c73 TelnetServer: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
83d3003208 LibDebug: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
0058a1173e UserspaceEmulator: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
c68dcf45b6 LibRegex: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
46209ee9d0 readelf: Remove an unnecessary String::format() 2021-04-21 23:49:02 +02:00
Andreas Kling
09cb8aded6 test-web: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
931f3c03d0 useradd: Convert String::format() => String::formatted()
Also make more use of warnln().
2021-04-21 23:49:02 +02:00
Andreas Kling
90ee84621f LibLine: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
4e6d2374b6 LibVT: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
01f6d6c9fa gron: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
3df0ecead8 lspci: Convert String::format() => String::formatted() 2021-04-21 23:49:02 +02:00
Andreas Kling
7747bfe5c0 HackStudio: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
2a6a54dea5 Userland: Use Core::DirIterator::next_full_path()
Simplify some code by using this instead of concatenating the full path
ourselves at the call site.
2021-04-21 23:49:01 +02:00
Andreas Kling
b41b6dd279 Shell: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
dba58ad9ec LibX86: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
e875d4e044 LibGfx: Convert String::format() => String::formatted() 2021-04-21 23:49:01 +02:00
Andreas Kling
d996e43df6 LibGfx: Minor clean-ups in Gfx::FontDatabase
Use Core::DirIterator::next_full_path() instead of manually building
each path.

Also convert a fprintf(stderr, ...) to warnln()
2021-04-21 23:49:01 +02:00
Andreas Kling
d342e9608c WindowServer: Add missing <AK/Debug.h> include and use dbgln_if() 2021-04-21 23:49:01 +02:00
Andreas Kling
2e6de99f1e ImageDecoder: Add missing <AK/Debug.h> include and use dbgln_if() 2021-04-21 23:49:01 +02:00
Andreas Kling
e5318d51e6 LibCore: Remove the barely-used Core::safe_syscall()
This was a helper that would call a syscall repeatedly until it either
succeeded or failed with a non-EINTR error.

It was only used in two places, so I don't think we need this helper.
2021-04-21 23:49:01 +02:00
Rafał
c41c41cc0f
LibGUI: Prevent selecting empty line in TextEditor on double click (#6537) 2021-04-21 23:48:26 +02:00
Timothy Flynn
6cbf88ad4c LibSQL: Rename TestSqlParser -> TestSqlStatementParser
A little bit clearer what is being tested now, since the expression
parser also lives in its own file.
2021-04-21 21:37:55 +02:00
Timothy Flynn
733806b6a1 LibSQL: Parse DELETE statement 2021-04-21 21:37:55 +02:00
Timothy Flynn
ce6c7ae18a LibSQL: Parse most language expressions
https://sqlite.org/lang_expr.html

The entry point to using expressions, parse_expression(), is not used
by SQL::Parser in this commit. But there's so much here that it's easier
to grok as its own commit.
2021-04-21 21:37:55 +02:00
Timothy Flynn
8c8d611fb3 LibSQL: Add forwarding header
SQL AST nodes will need to have other node types forward declared before
using them.
2021-04-21 21:37:55 +02:00
Timothy Flynn
a11f49f627 LibSQL: Add Parser::consume_if helper
The following is a common (and soon to be *very* common) expression:

    if (match(token_type))
        consume();

Using consume_if() makes this a bit simpler and makes it less likely to
forget to invoke consume() after the match().
2021-04-21 21:37:55 +02:00
Timothy Flynn
912c9c93e9 Userland: Syntax highlighting of SQL strings and blobs 2021-04-21 21:37:55 +02:00
Timothy Flynn
570aa57df3 LibSQL: Lex string and blob literals
Blob literals are the same as string literals except prefixed with an
'x' or 'X'.
2021-04-21 21:37:55 +02:00
Lenny Maiorani
ece8aeaaf4 Everywhere: Remove redundant inline keyword with constexpr
Problem:
- `constexpr` functions are additionally decorated with `inline`
  keyword. This is redundant since `constexpr` implies `inline`.

Solution:
- Remove redundancies.
2021-04-21 20:49:49 +02:00
Andreas Kling
3f02742504 Terminal: Use 16x16/settings.png for the terminal settings action 2021-04-21 19:03:55 +02:00
Idan Horowitz
ec67b1ac32 LibWeb: Implement scientific notation parsing in PathDataParser
This was required by webkit.org and is based on the following spec:
https://svgwg.org/svg2-draft/paths.html#PathDataBNF
2021-04-21 18:57:50 +02:00
iCristalrope
8bb4409a5d
LibGUI: Track selection starting index in AbstractView (#6515)
Modifying the selection while holding the shift button and selecting
with the mouse or the arrow keys no longer results in broken selections.

Fixes #6279.
2021-04-21 17:09:04 +02:00
DragonAlex98
fd43ee09e1 Inspector: Add context menu to copy property name/value
I added a context menu for the property tree view to copy the name/value
of a property.
2021-04-21 16:34:23 +02:00
DragonAlex98
0af920b255 Inspector: Select entire property row
With some themes (like the default one), it was possible to select a
property, making the text of its value not visible. I solved this by
setting set_should_fill_selected_rows to true.
2021-04-21 16:34:23 +02:00
jakewestrip
b9fc7780ae LibGUI: Remove premature return in Window::handle_key_event 2021-04-21 15:24:57 +02:00
Ali Mohammad Pur
f90a1f83ed LibJS: Precompile Heap.h and GlobalObject.h
This is somewhat noticable difference (~10s), as these two headers are
basically included in every single JS file anyway.
2021-04-21 14:29:46 +02:00
Ali Mohammad Pur
c4f682606a LookupServer: Use dbgln_if instead of #if
Also adds a missing AK::Formatter specialisation for DNSName, required
for the debug calls to actually work (!)
2021-04-21 14:29:46 +02:00
FalseHonesty
36c17d5371 HackStudio: Clean up debugger thread when debugger exits
Fixes #4393 :^)
2021-04-21 13:42:09 +02:00
FalseHonesty
58d6781cbb HackStudio+LibDebug: Support stopping a debugged process
In LibDebug this required implementing the Kill debug action, and
in HackStudio this required making the toolbar's stop action stop
the debugger if active.
2021-04-21 13:42:09 +02:00
Brian Gianforcaro
5a31ca06db LibPthread: Add non functional pthread_attr_[set|get]scope stubs
Standard: https://pubs.opengroup.org/onlinepubs/009695399/functions/pthread_attr_getscope.html

Needed for https://fio.readthedocs.io
2021-04-21 13:13:23 +02:00
Brian Gianforcaro
14f6425b8f LibC: Add pwrite(..) implementation to match the existing pread(..)
Add a basic non-thread safe implementation of pwrite, following the
existing pread(..) design.

This is needed for https://fio.readthedocs.io
2021-04-21 13:13:23 +02:00
Brian Gianforcaro
56ba3e1cbd LibC: Add LOG_NOWAIT stub to syslog.h
Needed for porting https://fio.readthedocs.io
2021-04-21 13:13:23 +02:00
Brian Gianforcaro
2ebb3f3c0d LibC: Add a definition for INET6_ADDRSTRLEN
Although serenity doesn't implement IPv6 yet, applications
will often declare buffers to be of size `INET6_ADDRSTRLEN`
so it's guaranteed to work in both IPv4 / IPv6 environments.

This is needed specifically for a port of Flexible IO Tester
https://fio.readthedocs.io

This is standardized here:
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/netinet/in.h.html
2021-04-21 08:04:52 +02:00
Brian Gianforcaro
a1720eed2a LibC: Setup a unit test harness for LibC, add ctime_r / asctime_r tests.
LibC is no different than any other code, it should be unit tested where
appropriate / possible.
2021-04-21 08:04:52 +02:00
Brian Gianforcaro
df808f0ed3 LibC: Fix missing '\n' at the end of ctime/ctime_r/asctime/asctime_r
@linusg noticed this bug in the original implementation during code review.
This makes all of these API's more spec conforming.
2021-04-21 08:04:52 +02:00
Brian Gianforcaro
440b81deba LibC: Add ctime_r() and asctime_r() implementations
Need this for a port of FIO (Flexible IO Tester)
https://fio.readthedocs.io/
2021-04-21 08:04:52 +02:00
Marco Biscaro
8124719c3d Tests: Reorganize LibCompress unit tests
Move LibCompress unit tests to LibCompress/Tests directory and register
them with CMake's add_test. This allows us to run these tests with
ninja test instead of running a separate executable.

Also split the existing tests in 3 test files that better follow the
source code structure (inspired by AK tests).
2021-04-21 08:00:32 +02:00
Andreas Kling
78733417a4 LibWeb: Register FormAssociatedElement with their owner form
This will eventually allow us to implement HTMLFormControlsCollection.
2021-04-20 23:38:27 +02:00
Andreas Kling
e454e1a45d LibWeb: Make HTMLSelectElement a FormAssociatedElement 2021-04-20 23:38:27 +02:00
Gunnar Beutner
2520ccfca4 LibPthread: Add stubs for pthread_spin_* functions
The stress-ng port depends on these now that it detects we have
thread support.
2021-04-20 21:08:17 +02:00
Gunnar Beutner
88cebb05ad LibC+LibPthread: Implement function forwarding for libpthread
GCC will insert various calls to pthread functions when compiling
C++ code with static initializers, even when the user doesn't link
their program against libpthread explicitly.

This is used to make static initializers thread-safe, e.g. when
building a library that does not itself use thread functionality
and thus does not link against libpthread - but is intended to
be used with other code that does use libpthread explicitly.

This makes these symbols available in libc.
2021-04-20 21:08:17 +02:00
Linus Groh
7400e3d8fc LibWeb: Don't call ResourceLoader error callback on 4xx status code
A website with a 4xx status code is still a valid website, we should not
artificially hide it. In fact, many websites implement custom 404 error
pages for example, often containing search functionality or links back
to the homepage.
This might have implications regarding the loading of stylesheets where
the request 404s, but since we were not handling 5xx status codes as
errors either, I think that's fine for now (but might need additional
work later). Worst case, the parser rejects to load some error page HTML
as CSS :^)
2021-04-20 19:47:23 +02:00
Linus Groh
7af1d2c170 LibJS: Make Object.getOwnPropertyDescriptor() work with string indexed property
E.g. for "0" we have to contruct a PropertyName with Type::Number so it
looks in the indexed properties as expected.
2021-04-20 18:53:07 +02:00
Linus Groh
614bad86bc LibJS: Fix Object.getOwnPropertyDescriptor() attributes for numeric property
We were getting the attributes of the existing value and then
immediately assigned the default attributes instead.
2021-04-20 18:42:10 +02:00
Maciej Zygmanowski
899698c317 Inspector: Don't allow to inspect Inspector itself
The Inspector hangs when user tries to do that.
2021-04-20 18:35:46 +02:00
Tobias Christiansen
5338708091 LibWeb: Display <ol> and respect list-style-type in <ul>
In the ListItemMarkerBox render the correct thing when painting.
This covers decimal counting for ordered lists as well as square,
disc, and circle for unordered lists. Thus all currently supported
list-style-types are displayed correctly.

This closes #2059
2021-04-20 18:29:19 +02:00
Tobias Christiansen
bfcfe84240 LibWeb: Make the ListItemMarkerBox index-aware.
In the ListItemBox we get the index of the current <li> element in the
parent and pass it to the ListItemMarkerBox.

This patch is work towards #2059
2021-04-20 18:29:19 +02:00
Tobias Christiansen
c09ac536c5 LibWeb: Add capabilities to find the index of a child in its parent.
For Elements depending on the index they are inside their parent. Most
notably the <ol> element.
Also added a typed version to only count children of a certain type.

This patch is work towards #2059
2021-04-20 18:29:19 +02:00
Timothy Flynn
e92bffb2e3 LibSQL: Parse DROP TABLE statement 2021-04-20 18:28:34 +02:00
Timothy Flynn
d41d1d2035 LibSQL: Add unit testing of the SQL parser 2021-04-20 18:28:34 +02:00
Timothy Flynn
5ec471b78d Userland: Add 'sql', a REPL for LibSQL
This adds a simple REPL command line utility for (eventually) executing
SQL statements / files. Currently, it just validates statements from
stdin and prints any errors.
2021-04-20 18:28:34 +02:00
Timothy Flynn
377992d33e LibSQL: Create a very barebones SQL parser
This parser builds on the LibSQL lexer and currently only allows users
to parse 'CREATE TABLE' statements.
2021-04-20 18:28:34 +02:00
Timothy Flynn
90517da9ca LibSQL: Introduce a SQL library with a tokenizer
LibSQL aims to be a SQLite clone for SerenityOS. Step 1 is creating a
tokenizer to lex SQL tokens. This lexer is heavily influenced by the
LibJS lexer.
2021-04-20 18:28:34 +02:00
Gunnar Beutner
111ac4b1f4 Shell: Auto-completion shouldn't suggest non-executable files for the program name 2021-04-20 17:02:10 +02:00
Panagiotis Vasilopoulos
e45e0eeb47 Everywhere: Replace SERENITY_ROOT with SERENITY_SOURCE_DIR 2021-04-20 15:27:52 +02:00
Idan Horowitz
63af67ea01 LibJS: Throw on a regex searchString in String.startsWith
As is required by the specification:
"Let isRegExp be ? IsRegExp(searchString). If isRegExp is true,
throw a TypeError exception."
2021-04-20 14:38:54 +02:00
Idan Horowitz
b1e5330e64 LibJS: Stop early-returning on missing searchString in String.startsWith
A missing searchString is allowed by the specification and is treated
as js_undefined. ("undefined test".startsWith() => true)
2021-04-20 14:38:54 +02:00
Idan Horowitz
81d7d68416 LibWeb: Use correct event name for the onmousemove global event handler
The current event name was accidentally set for the onmousedown event.
2021-04-20 14:38:54 +02:00
Spencer Dixon
1206e9803f Userland: Add support for sending UDP to netcat. 2021-04-20 14:15:35 +02:00
Andreas Kling
b092353e4d LibWeb: Add basic support for HTMLInputElement.form
HTMLInputElement now inherits from FormAssociatedElement, which will
be a common base for the handful of elements that need to track their
owner form (and register with it for the form.elements collection.)

At the moment, the owner form is assigned during DOM insertion/removal
of an HTMLInputElement. I didn't implement any of the legacy behaviors
defined by the HTML parsing spec yet.
2021-04-20 12:05:56 +02:00
Andreas Kling
00d8e3b02b LibWeb: Don't include "Wrapper" suffix in JS wrapper class_name()
The "Wrapper" suffix is not useful information to someone using the
JS console, so let's just drop it from the string returned when calling
class_name() on a JS binding wrapper.
2021-04-20 12:05:56 +02:00
Andreas Kling
4d35ffdf3c LibJS: Include the class name of objects in MarkupGenerator output
Add a little label before the "{ }" so you can see what kind of object
it is. This makes Browser's JS console significantly nicer to use. :^)
2021-04-20 12:05:56 +02:00
Tobias Christiansen
a8915ecd61 FileManager+FileOperation: Report Errors when doing an file operation
Report back errors from the FileOperation to the FileManager and
display them in the MessageBox
2021-04-20 12:02:01 +02:00
Tobias Christiansen
7d60164d93 FileManager: Don't crash on error in FileOperation
did_error() caused the program to crash since the DialogBox tried to
run its own Notifier with the same - now invalid because closed - fd.

In addition to setting the member that is the Notifier to nullptr we
also tell the Notifier that it is not enabled anymore.
2021-04-20 12:02:01 +02:00
Idan Horowitz
28b8a2ec7a LibIPC: Make Connection::send_sync return a NonnullOwnPtr
Since we VERIFY that we received a response, the response pointer is
always non-null.
2021-04-20 10:10:15 +02:00
Idan Horowitz
a2b34b7e6b LibDesktop: Fail gracefully on allowlist failures instead of asserting
IPC::Connection::send_sync asserts that a response was received, so the
current gracefull fail check was useless, as LibIPC would always assert
before reaching it.
2021-04-20 10:10:15 +02:00
Linus Groh
ac3e7ef791 LibJS: Fix crash in Object.{freeze,seal}() with indexed properties
This was failing to take two things into account:

- When constructing a PropertyName from a value, it won't automatically
  convert to Type::Number for something like string "0", even though
  that's how things work internally, since indexed properties are stored
  separately. This will be improved in a future patch, it's a footgun
  and should happen automatically.
- Those can't be looked up on the shape, we have to go through the
  indexed properties instead.

Additionally it now operates on the shape or indexed properties directly
as define_property() was overly strict and would throw if a property was
already non-configurable.

Fixes #6469.
2021-04-20 09:38:22 +02:00
Linus Groh
085816645f LibJS: Take PropertyName in Object::set_integrity_level() internal lambda
At least for IntegrityLevel::Frozen we already construct a PropertyName
from the key value, let's reuse that.
2021-04-20 09:38:22 +02:00
Leandro Pereira
29fd75f22f LibGUI: Make statusbar label flat when displaying override_text
Changing the statusbar appearance when overriding text makes it less
confusing as it's supposed to be something temporary, e.g.  only when
hovering over a toolbar or menu item.

This behavior is present on old Windows systems, although things work
slightly differently there (where only the overridden text is displayed
rather than all the segments).
2021-04-20 09:24:52 +02:00
Andreas Kling
955eef83b0 LibWeb: Add basic support for HTMLCanvasElement.toDataURL() :^)
This allows you to serialize a <canvas> element's bitmap into a
data: URI. Pretty neat! :^)
2021-04-19 23:49:16 +02:00
Andreas Kling
6793574003 LibGfx: Improve PNG encoder API somewhat
This is still far from ideal, but let's at least make it take a
Gfx::Bitmap const&.
2021-04-19 23:49:16 +02:00
Gunnar Beutner
ddcd149224 LibC: Avoid division by zero in fread()/fwrite() 2021-04-19 22:13:52 +02:00
Itamar
4831dc0e30 LibCpp: Support parsing class declarations 2021-04-19 21:48:42 +02:00
Gunnar Beutner
cd432860d8 LibC: Additional functionality for getaddrinfo()
When node is NULL and AI_PASSIVE is specified we are supposed to use
the "any" address, otherwise we should use the loopback address.
2021-04-19 21:00:23 +02:00
Gunnar Beutner
38619a9f24 LibELF: Ignore DT_SYMBOLIC entries
The shared library libicudata.so has a DT_SYMBOLIC entry:

Dynamic Section:
  NEEDED               libgcc_s.so
  SONAME               libicudata.so.69
  SYMBOLIC             0x00000000
  HASH                 0x00000094
  STRTAB               0x000000c8
  SYMTAB               0x000000a8
  STRSZ                0x0000002a
  SYMENT               0x00000010

According to the ELF spec DT_SYMBOLIC has no special meaning
for the dynamic loader.
2021-04-19 20:39:22 +02:00
Gunnar Beutner
6c729993a8 LibELF: Allow shared objects which don't have a text segment
Shared objects without a text segment are perfectly OK. For
example libicudata.so has only data segments:

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .hash         00000014  00000094  00000094  00000094  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .dynsym       00000020  000000a8  000000a8  000000a8  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  2 .dynstr       0000002a  000000c8  000000c8  000000c8  2**0
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  3 .rodata       01b562d0  00000100  00000100  00000100  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  4 .eh_frame     00000000  01b563d0  01b563d0  01b563d0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  5 .dynamic      00000070  01b573d0  01b573d0  01b563d0  2**2
2021-04-19 20:39:22 +02:00
Conor Byrne
68d1469aea Taskbar: Show start menu when super key is pressed
This commit re-adds the functionality of the start menu appearing when
the super key is pressed
2021-04-19 20:03:25 +02:00
Conor Byrne
88ecfa164a LibGUI+WindowServer: Add WM_SuperKeyPressed event
This commit adds an event called WM_SuperKeyPressed which is sent to all
windows via WindowManagerServerConnection.
The event is fired from WindowManager when the super key is pressed,
which is the windows key on most keyboards :)
2021-04-19 20:03:25 +02:00
Brian Gianforcaro
ec3596545a profile: Expose the ability to free the kernel profiling buffer. 2021-04-19 18:30:37 +02:00
Brian Gianforcaro
3e87e43f9d LibC: Expose new profiling_free_buffer(..) syscall.
Expose the new `profiling_free_buffer` syscall to user space.
2021-04-19 18:30:37 +02:00
Brian Gianforcaro
cdd9faaf39 profile: Add an option to wait for user input to disable profiling.
Often you want to enable and then disable profiling after a period of time.
To make this slightly more ergonomic, add an option to wait for user
input after enabling profiling, this will disable profiling on exit
after the key press.
2021-04-19 18:30:37 +02:00
Panagiotis Vasilopoulos
9de58a2d89 LibC: Added sysexits.h 2021-04-19 18:27:55 +02:00
Gunnar Beutner
a5be8d8976 LibC: Improve error logging for execvp() 2021-04-19 18:27:09 +02:00
Itamar
e5f84b53d8 HackStudio: Sort ClassView entries 2021-04-19 18:13:30 +02:00
Gunnar Beutner
bd08f9188a Pthread: Add stubs for pthread_cleanup_{push,pop}
The stubs are necessary to make the xz port properly detect pthread
support. The two functions are only used in the configure script and
nowhere else.
2021-04-19 17:55:35 +02:00
Maciej Zygmanowski
136f6fb7c8 WindowServer: Use VERIFY instead of assert in scale factor check 2021-04-19 17:30:07 +02:00
Ali Mohammad Pur
efb14e95c4 Shell: Don't whine about tcsetpgrp() failing
We intentionally skimp out on checking isatty() before them to cut down
on syscalls, so we should also accept the errors and just let them be.
Closes #6471.
2021-04-19 16:28:33 +02:00
Ali Mohammad Pur
74f0fdab98 LibLine: Avoid trying to restore() if the editor isn't initialized
Fixes #6472.
2021-04-19 16:28:33 +02:00
Ali Mohammad Pur
e1e84fe0fe LibLine: Redraw the suggestions when terminal size changes 2021-04-19 16:28:33 +02:00
Adam Hodgen
b9c6059984 LibWeb: Correctly calculate height of TableRowGroupBox
As well as correctly calculating the height of TableRowBox, this change
calculates the heights of TableRowGroupBoxs also.

As before, this does not correctly take into consideration the 'height'
attribute.

Now the horizontal layout is approximately correct for the
TableRowGroupBoxs we can now see that the `layout_row` method will need
updating to correctly calculate cell width across all rows, not just the
current TableRowGroupBox.
2021-04-19 12:26:05 +02:00
Adam Hodgen
ae02acb8e1 LibWeb: Properly handle thead and tfooter HTML tags
As the spec for the table fixup algorythm says:

> Treat table-row-groups in this spec also encompass the specialized
> table-header-groups and table-footer-groups.
2021-04-19 12:26:05 +02:00
Gunnar Beutner
c32b58873a LibELF: Fix calculation for TLS relocations
The calculation for TLS relocations was incorrect which would
result in overlapping TLS variables when more than one shared
object used TLS variables.

This bug can be reproduced with a shared library and a program
like this:

    $ cat tlstest.c
    #include <string.h>
    __thread char tls_val[1024];
    void set_val() { memset(tls_val, 0, sizeof(tls_val)); }

    $ gcc -g -shared -o usr/lib/libtlstest.so tlstest.c

    $ cat test.c
    void set_val();
    int main() { set_val(); }
    $ gcc -g -o tls test.c -ltlstest

Due to the way the TLS relocations are done this program would
clobber libc's TLS variables (e.g. errno).
2021-04-19 12:14:43 +02:00
Gunnar Beutner
0cca23def5 LibELF: Improve error message for missing symbols 2021-04-19 12:00:40 +02:00
Gunnar Beutner
1dab5ca5fd LibELF: Fix support for relocating weak symbols
Having unresolved weak symbols is allowed and we should initialize
them to zero.
2021-04-19 12:00:40 +02:00
Gunnar Beutner
97d7450571 LibELF: Remove VERIFY() calls and let control flow return to the caller
This way we get better error messages for unresolved symbols because
the caller logs the file and symbol names.
2021-04-19 12:00:40 +02:00
Ali Mohammad Pur
55914841b7 Shell/Tests: Replace 'type f -f' with 'type -f f'
The order of arguments seemed be confusing ArgsParser.
Fixes #6467.
2021-04-19 10:07:58 +02:00
Ali Mohammad Pur
061aaa33e8 Userland/test: Handle '!' being used as a string
e.g. `test ! = !`.
Fixes #6465.
2021-04-19 10:07:58 +02:00
DexesTTP
4f9ab0b982 Userland: Add telws, a CLI REPL to connect to WebSockets 2021-04-18 22:42:10 +02:00
DexesTTP
d3a89ce737 LibWebSocket: Add a new websocket library
This library currently contains a basic WebSocket client that can
handle both standard TCP websockets and TLS websockets.
2021-04-18 22:42:10 +02:00
DexesTTP
b30f5dc8b5 LibCore: Add ArgsParser::add_option(String&)
The API existed for add_positional_argument, but not for named arguments.
2021-04-18 22:42:10 +02:00
Idan Horowitz
397269d21e LibGfx: Report font glyph presence based on glyph's specific width
This uses the per glyph width to determine if the glyph is actually
present in the font, and not just inside the range the font can covers

This means that characters that are in the font's range but that are
missing a glyph will show up as the missing character glyph instead of
being invisible.
2021-04-18 22:10:25 +02:00
Idan Horowitz
18ae37439a FontEditor+LibGfx: Allow user to specify if a specific glyph is present
This replaces the glyph width spinbox in the font editor with a
checkbox when editing fixed width fonts that indicates if the
currently selected character's glyph is present in the edited font
(For variable width fonts a non zero width implies presence)

This commit also changes the background color of glyphs in the glyph
map based on the presence of each specific glyph in the font.
2021-04-18 22:10:25 +02:00
Idan Horowitz
08d1b16a8d LibGfx: Always load font widths array and use it for glyph presence
Since we were always saving the glyph widths array to the font file, we
now also always load it, even on (which also simplifies the logic a bit)
fixed width fonts. We also set it initially to 0 instead of the default
fixed width, which allows us to use it to check for glyph presence in
both fixed width and variable width fonts.
2021-04-18 22:10:25 +02:00
Idan Horowitz
3c894d1e6f LibGfx: Use size_t instead of int for glyph count
The count is always non-negative
2021-04-18 22:10:25 +02:00
Marco Biscaro
7dc95721ee Tests: Fix test-math expected values
Some of the expected values in test-math were wrong, which caused some
tests to fail.

The updated values were generated by Python's math library, and rounded
to 6 decimals places:

>>> import math
>>> round(math.exp(20.99), 6)
1305693298.670892

Examples of failure outputs:

FAIL: ../Userland/Tests/LibM/test-math.cpp:98:
EXPECT_APPROXIMATE(exp(v.x), v.exp) failed with
lhs=1305693298.670892, rhs=1304956710.432034, (lhs-rhs)=736588.238857

FAIL: ../Userland/Tests/LibM/test-math.cpp:99:
EXPECT_APPROXIMATE(sinh(v.x), v.sinh) failed with
lhs=652846649.335446, rhs=652478355.216017, (lhs-rhs)=368294.119428

FAIL: ../Userland/Tests/LibM/test-math.cpp💯
EXPECT_APPROXIMATE(cosh(v.x), v.cosh) failed with
lhs=652846649.335446, rhs=652478355.216017, (lhs-rhs)=368294.119429
2021-04-18 21:41:17 +02:00
Idan Horowitz
60f82e0626 FontEditor: Update GlyphMap on font type change
Since font type changes also change the amount of glyphs in a font, the
glyph map has to be re-rendered to properly showcase the change.
2021-04-18 18:57:35 +02:00
Idan Horowitz
f461ee7d01 LibGfx: Add support for fonts that include the Hebrew Unicode Block 2021-04-18 18:57:35 +02:00
Linus Groh
8d490aba76 LibJS: Implement console.assert() 2021-04-18 18:28:17 +02:00
Linus Groh
e37421bddc Browser+WebContent: Fix HTML injection in console functions output 2021-04-18 18:28:17 +02:00
Linus Groh
a178255a8b LibJS: Use 'if constexpr' / dbgln_if() instead of '#if LEXER_DEBUG' 2021-04-18 18:14:50 +02:00
Linus Groh
87a43fa87c LibJS: Use 'if constexpr' instead of '#if HEAP_DEBUG' 2021-04-18 18:14:44 +02:00
Linus Groh
51676d7c33 LibJS: Use dbgln_if() instead of '#if OBJECT_DEBUG' 2021-04-18 18:10:42 +02:00
FalseHonesty
52e194c543 HackStudio: Add ability to set hardware watchpoints on variables
We can now add a watchpoint to a variable by right clicking on it
in the variable view, and selecting add watchpoint. To remove a
watchpoint, the exact same action is repeated, except it will now say
remove watchpoint.
2021-04-18 17:02:40 +02:00
FalseHonesty
e0be8a3f59 HackStudio: Don't crash when invalid file is requested to be opened
Previously, if the running debugger asked for HackStudio to open
an invalid file, it would crash trying to switch to it. Now it will
just continue without switching the editor.
2021-04-18 17:02:40 +02:00
FalseHonesty
7a1396f509 LibDebug: Implement ability to set watchpoints
Now we can set hardware watchpoints for our variables! :^)
These watchpoints will be automatically removed when
they go out of scope.
2021-04-18 17:02:40 +02:00
FalseHonesty
3123ffb19d Kernel: Add ptrace commands for reading/writing the debug registers
This adds PT_PEEKDEBUG and PT_POKEDEBUG to allow for reading/writing
the debug registers, and updates the Kernel's debug handler to read the
new information from the debug status register.
2021-04-18 17:02:40 +02:00
Andreas Kling
e98091ad15 FileManager: Show action status tips in the status bar :^) 2021-04-18 16:44:00 +02:00
Andreas Kling
12546259ff Everywhere: Rename title_bar => titlebar 2021-04-18 16:35:18 +02:00
Gunnar Beutner
81daca5dd7 LibC: Implement assignment suppression for vsscanf
The vsscanf library function lets the user skip assigning
parsed values to the arguments, e.g. with %*c - even though
a character is scanned it is not assigned to one of the
arguments.

The figlet port uses this. With this patch the port is actually
usable.
2021-04-18 16:35:00 +02:00
Hendiadyoin1
f682c9f100 LibC: Add netinet/in_systm.h 2021-04-18 15:52:07 +02:00
Gunnar Beutner
07adbf19c4 LibDebug: Implement support for AttributeDataForm::Data8
I came across this while analyzing a crash dump for openttd.
2021-04-18 15:51:13 +02:00
AnotherTest
ae49171755 LibCrypto: Avoid creating bools from anything except bools 2021-04-18 14:18:16 +02:00
AnotherTest
db8f0a2fa6 LibCore: Remove the no-longer-used Core::DateTime::is_before() function 2021-04-18 14:18:16 +02:00
AnotherTest
38f4441103 LibTLS: Parse X.509 certificates with the new ASN.1 parser
As a nice side effect, also correctly test for certificate validity :^)
2021-04-18 14:18:16 +02:00
AnotherTest
13abbc5ea8 LibCrypto: Implement UTCTime and GeneralizedTime parsers 2021-04-18 14:18:16 +02:00
AnotherTest
39997e2ab1 LibCore: Implement operator less-than for Core::DateTime
that just compares their timestamps.
2021-04-18 14:18:16 +02:00
AnotherTest
ed28008d78 LibCrypo: Add an ASN.1/DER pretty-printer
It's much easier to debug things when we can actually *see* them :P
2021-04-18 14:18:16 +02:00
AnotherTest
65de2d236d LibCrypto: Allow the user to override the DER read kind and class
This is useful for parsing non-universal types.
2021-04-18 14:18:16 +02:00
AnotherTest
581f9ff6bb LibCrypto: Add the GeneralizedTime ASN.1 type 2021-04-18 14:18:16 +02:00
Gunnar Beutner
f033416893 Kernel+LibC: Clean up how assertions work in the kernel and LibC
This also brings LibC's abort() function closer to the spec.
2021-04-18 11:11:15 +02:00
Andreas Kling
f77100d66b Browser: Add status tips to most of the actions 2021-04-18 10:58:22 +02:00
Andreas Kling
679feec195 Browser: Show status tips for any entered action 2021-04-18 10:58:22 +02:00
Andreas Kling
7ceb4f5330 LibGUI: Add some more status tips to common actions 2021-04-18 10:58:22 +02:00
Andreas Kling
a2086ad56e LibGUI: Rename Action::long_text to Action::status_tip
This feels a bit more descriptive.
2021-04-18 10:58:22 +02:00
Gunnar Beutner
407b066ba4 Ports: Update the gcc port with the patches from the toolchain 2021-04-18 10:55:25 +02:00
Gunnar Beutner
6cb28ecee8 LibC+LibELF: Implement support for the dl_iterate_phdr helper
This helper is used by libgcc_s to figure out where the .eh_frame sections
are located for all loaded shared objects.
2021-04-18 10:55:25 +02:00
Gunnar Beutner
8dc375da96 LibElf: Allow PT_GNU_EH_FRAME program headers
These are built when compiling an executable with exception support.
2021-04-18 10:55:25 +02:00
Gunnar Beutner
ebca6aabc0 LibC: Make atexit handlers thread-safe 2021-04-18 10:52:05 +02:00
Gunnar Beutner
4075b306f8 LibC+LibPthread: Make sure TLS keys are destroyed after everything else
This ensures that __thread variables can be used when global destructors
are being invoked.
2021-04-18 10:52:05 +02:00
Linus Groh
2b0c361d04 Everywhere: Fix a bunch of typos 2021-04-18 10:30:03 +02:00
Jagger De Leo
cebd3f740b ls: Remove extra spaces after filenames when piping
Fixes #5671
2021-04-18 00:54:39 +02:00
Linus Groh
0d4912826b FileManager: Pluralize empty selection statusbar message properly
"item(s)" is silly, we can be more specific. :^)
2021-04-18 00:48:07 +02:00
Andreas Kling
f07efa1640 Run: Put the window in the bottom left of the desktop
This makes a lot more sense now that it's spawned by the start button.
2021-04-17 23:27:00 +02:00
Andreas Kling
d6c6880674 LibCore: Use is<T> in Object::find_*_of_type helpers
This allows us to add fast-paths for commonly used types.
2021-04-17 23:01:24 +02:00
Idan Horowitz
47dba83d30 Browser: Display full UserAgent string in status bar on menu hover
This uses the new on_action_enter & on_action_leave APIs to display
the full useragent string when hovering over one of the useragent
spoof menu options.
2021-04-17 22:35:13 +02:00
Andreas Kling
b937ebd121 WindowServer: Make MenuItemActivated IPC message pass identifier as u32
This is consistent with the actual storage type.
2021-04-17 22:26:58 +02:00
AnotherTest
fb80d5adda LibLine: Check the terminal size at the start of get_line()
There are cases where the line editor could miss the WINCH signal
(e.g. in the shell, while another program is in the foreground),
This patch makes it so that LibLine notices the change in terminal size
in such cases.
2021-04-17 22:10:35 +02:00
AnotherTest
b58dbc29fc LibLine: Add support for ^X^E
This keybind opens the current buffer in an editor (determined by
EDITOR from the env, or the default_text_editor key in the config file,
and set to /bin/TextEditor by default), and later reads the file back
into the buffer.
Pretty handy :^)
2021-04-17 22:10:35 +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
setepenre
c1a0ad764a ls: list files in cwd before listing directories when listing paths 2021-04-17 21:24:56 +02:00
Andreas Kling
ec6debb46f WindowServer: Don't "enter" menu item when hovering over a separator
Since menu separator items don't have an associated identifier,
make sure we don't falsely report that we've enter item 0.

This fixes an issue where hovering over a separator would behave
as if we'd hovered over the first item in the menu wrt sending
MenuItemEntered.
2021-04-17 20:49:53 +02:00
Andreas Kling
e67f392576 TextEditor: Show action long texts in the status bar :^)
We now display a description of the currently hovered action in the
text editor application's status bar. This is pretty cool! :^)

This is currentl achieved via the hooks on GUI::Application. Longer
term we'll probably want to find a more flexible abstraction for this,
since not all applications will be as simple as TextEditor.
2021-04-17 20:49:53 +02:00
Andreas Kling
22ed6a70eb LibGUI: Add "override text" to GUI::Statusbar
Each statusbar segment now has an optional "override text" which can
be set, and if non-null will be displayed instead of the regular text.

This allows programs to display contextual information in the statusbar
temporarily without losing whatever text was already on there.
2021-04-17 20:49:53 +02:00
Andreas Kling
3bf2f7a329 LibGUI: Make GUI::Toolbar buttons generate ActionEnter and ActionLeave
Now you'll get the same event whether you hover an action in a menu
or in a toolbar. :^)
2021-04-17 20:49:53 +02:00
Andreas Kling
7d0b59cb05 LibGUI: Add action enter/leave hooks on GUI::Application
Apps can now hook into these events by assigning a callback to the
on_action_enter and on_action_leave hooks on GUI::Application. :^)
2021-04-17 20:49:53 +02:00
Andreas Kling
4c6f541d5b LibGUI: Add Action* accessors on GUI::Button 2021-04-17 20:49:53 +02:00
Andreas Kling
e7263a7e75 LibGUI: Add a "long text" string to GUI::Action
Actions can now have a longer text description, in addition to its
regular UI string. The longer text will soon be used to display
a more detailed description of hovered actions in statusbars.
2021-04-17 20:49:53 +02:00
Andreas Kling
ba7e1ca2fb WindowServer+LibGUI: Notify GUI clients about menu item enter/leave
We now send out MenuItemEntered and MenuItemLeft messages to the client
when the user hovers/unhovers menu items.

On the client side, these become GUI::ActionEvent, with one of two
types: ActionEnter or ActionLeave. They are sent to the Application.

This will allow GUI applications to react to these events.
2021-04-17 20:49:53 +02:00
Georgiy Komarov
f8c2beec7c
DHCPClient: Fix undefined behaviour when calling memcpy() (#6416)
Calling memcpy with null pointers results in undefined behaviour, even
if count is zero.

This in turns is exploited by GCC. For example, the following code:
    memcpy (dst, src, n);
    if (!src)
      return;
    src[0] = 0xcafe;
will be optimized as:
    memcpy (dst, src, n);
    src[0] = 0xcafe;
IOW the test for NULL is gone.
2021-04-17 20:49:22 +02:00
Linus Groh
eedde500eb LibJS: Replace MAX_U32 with NumericLimits<u32>::max() 2021-04-17 19:35:32 +02:00
Idan Horowitz
4a2c0d721f LibTextCodec: Implement a Windows-1255 decoder.
This is a superset of ascii that adds in the hebrew alphabet.
(Google currently assumes we are running windows due to not
recognizing Serenity as the OS in the user agent, resulting
in this encoding instead of UTF8 in google search results)
2021-04-17 18:13:20 +02:00
Idan Horowitz
79b1270711 LibJS: Take reference instead of pointer in prepare_arguments_list
This argument is always non-null (and the function assumes so), so
theres no point to taking a pointer instead of a reference.
2021-04-17 17:38:50 +02:00
Idan Horowitz
6cd318d784 LibJS: Convert matched regex result to string in Symbol.replace
This would crash on an undefined match (no match), since the matched
result was assumed to be a string (such as on discord.com). The spec
suggests converting it to a string as well:
https://tc39.es/ecma262/#sec-regexp.prototype-@@replace (14#c)
2021-04-17 16:10:45 +02:00
Andreas Kling
358697a32f LibGUI: Make sure we depend on the WindowManager IPC endpoints 2021-04-17 15:58:34 +02:00
sin-ack
c8ef8d2db5 Taskbar: Use WM connection for window management operations
Since WM operations are moved to a separate endpoint pair, Taskbar now
uses those to perform window management related operations.
Additionally, it now explicitly declares to WindowServer that it is a
window manager.
2021-04-17 13:06:25 +02:00
sin-ack
aa56f9a1e0 LibGUI+WindowServer: Separate window manager IPC from regular IPC
With this patch the window manager related functionality is split out
onto a new endpoint pair named WindowManagerServer/Client.  This allows
window manager functionality to be potentially privilege separated in
the future.  To this end, a new client named WMConnectionClient
is used to maintain a window manager connection.  When a process
connects to the endpoint and greets the WindowServer as a window manager
(via Window::make_window_manager(int)), they're subscribed to the events
they requested via the WM event mask.

This patch also removes the hardcoding of the Taskbar WindowType to
receive WM events automatically.  However, being a window manager still
requires having an active window, at the moment.
2021-04-17 13:06:25 +02:00