Commit graph

2880 commits

Author SHA1 Message Date
Marcin Gasperowicz
c21dc21f36
Build: Make Lagom build under macOS (#2341)
Lagom now builds under macOS. Only two minor adjustments were required:

* LibCore TCP/UDP code can't use `SOCK_{NONBLOCK,CLOEXEC}` on macOS,
use ioctl() and fcntl() instead

* LibJS `Heap` code pthread usage ported to MacOS
2020-05-23 15:31:30 +02:00
Andreas Kling
dd924b730a Kernel+LibC: Fix various build issues introduced by ssize_t
Now that ssize_t is derived from size_t, we have to
2020-05-23 15:27:33 +02:00
Andreas Kling
1afbd8936a Kernel+LibC: Let's say that off_t is a ssize_t 2020-05-23 15:25:43 +02:00
Andreas Kling
45450c7edc LibWeb: Make BEGIN_STATE and END_STATE include some {{{ and }}}
This makes it a compile error to omit the END_STATE. Also add some more
missing END_STATE's exposed by this (nice!)

Thanks to @predmond for suggesting the multi-pair trick! :^)
2020-05-23 15:25:43 +02:00
Andreas Kling
a0d3c03950 LibC: Declare ssize_t in a platform-agnostic way
While the compiler provides __SIZE_TYPE__ for declaring size_t,
there's unfortunately no __SSIZE_TYPE__ for ssize_t.

However, we can trick the preprocessor into doing what we want anyway
by doing "#define unsigned signed" before using __SIZE_TYPE__ again.
2020-05-23 15:25:43 +02:00
FalseHonesty
e5c2e53739 LibWeb: Fix HtmlView not scrolling to a url's anchor on page load
Previously, when HtmlView loaded a url, the url's fragment was ignored,
but now it will be automatically scrolled to.
2020-05-23 11:53:25 +02:00
Andreas Kling
2e4147d0fc LibWeb: Add missing END_STATE for TagName
Fixes #2339.
2020-05-23 10:33:23 +02:00
Andreas Kling
a58500fdc5 LibWeb: Teach HTMLTokenizer how to tokenize comments
We can now correctly tokenize the welcome.html test page. :^)
2020-05-23 01:54:26 +02:00
AnotherTest
909ac2a558 LibLine: Make the comments follow the project style 2020-05-23 01:31:41 +02:00
AnotherTest
3c3edf5831 LibLine: Properly paginate suggestions in XtermSuggestionDisplay
This commit adds back suggestion pagination, and makes it 10x better.
Also adds a "< page m of n >" indicator at the bottom if there are more
suggestions than would fit in a page.
It properly handles cycling forwards and backwards :^)
2020-05-23 01:31:41 +02:00
AnotherTest
2427f3b38b LibLine: Add a constructor for CompletionSuggestions purely for comparison
`CompletionSuggestion(text, ForSearch)` creates a suggestion whose only
purpose is to be compared against.
This constructor skips initialising the views.
2020-05-23 01:31:41 +02:00
AnotherTest
f0862cf2b7 LibLine: Refactor suggestion handling and display logic out 2020-05-23 01:31:41 +02:00
AnotherTest
65adf2aea2 LibLine: Correctly handle multibyte codepoints in suggestions 2020-05-23 01:31:41 +02:00
AnotherTest
e2886aabcd LibLine: Make suggest() utf8-aware 2020-05-23 01:31:41 +02:00
FalseHonesty
e0312ec2ce LibGUI: Improve double click selection on documents without spans
Previously, double clicking would select the range around your click up
until it found a space, and in the browser's location bar this behavior
didn't suffice. Now, it will select the range around your click until
there is a "word break". A word break is considered to be when your
selection changes from being alphanumeric to being non alphanumeric, or
vice versa.
2020-05-23 01:30:20 +02:00
Andreas Kling
6caa5661f3 LibWeb: Teach HTMLTokenizer how to tokenize attributes
Properly tokenize single-quoted, double-quoted and unquoted attributes!
2020-05-23 01:22:15 +02:00
Linus Groh
daf74838dd LibJS: Add missing exception check to ArrayPrototype's for_each_item()
Object::get_by_index() cannot throw for positive indices *right now*,
but once we implement descriptors for array index properties, it can.
2020-05-23 00:38:00 +02:00
Linus Groh
843e000f18 LibJS: Fix Array.prototype.lastIndexOf() implementation 2020-05-23 00:02:13 +02:00
Linus Groh
6a4280e6e5 LibJS: Treat missing arg in Array.prototype.{indexOf,lastIndexOf}() as undefined 2020-05-23 00:02:13 +02:00
Linus Groh
75f587d3df LibC: Add (empty) netinet/tcp.h back
This file is required for building the git port.

It was already added before and then removed again when the CI script
for license header checks was added as it seemed irrelevant.
2020-05-22 23:46:24 +02:00
Andreas Kling
004ef9a86b LibWeb: Minor tweaks to HTMLToken declaration 2020-05-22 23:45:02 +02:00
Andreas Kling
272b35d2e1 LibWeb: Begin work on a spec-compliant HTML parser
In order to actually view the web as it is, we're gonna need a proper
HTML parser. So let's build one!

This patch introduces the Web::HTMLTokenizer class, which currently
operates on a StringView input stream where it fetches (ASCII only atm)
codepoints and tokenizes acccording to the HTML spec tokenization algo.

The tokenizer state machine looks a bit weird but is written in a way
that tries to mimic the spec as closely as possible, in order to make
development easier and bugs less likely.

This initial version is far from finished, but it can parse a trivial
document with a DOCTYPE and open/close tags. :^)
2020-05-22 21:46:13 +02:00
Andreas Kling
120cd44011 LibWeb: Move Attribute to its own header file
This will allow us to use it without including Element.h
2020-05-22 21:45:00 +02:00
Sergey Bugaev
f03e452085 LibC: Sync file position when dropping read ahead buffer
When we flush a FILE, we behave differently depending on whether we reading from
the file or writing to it:

* If we're writing, we actually write out the buffered data.
* If we're reading, we just drop the buffered (read ahead) data.

After flushing, there should be no additional buffered state stdio keeps about a
FILE, compared to what is true about the underlying file. This includes file
position (offset). When flushing writes, this is taken care of automatically,
but dropping the buffer is not enough to achieve that when reading. This commit
fixes that by seeking back explicitly in that case.

One way the problem manifested itself was upon fseek(SEEK_CUR) calls, as the
position of the underlying file was oftentimes different to the logical position
of the FILE. Since FILE::seek() already calls FILE::flush() prior to actually
modifying the position, fixing FILE::flush() to sync the positions is enough to
fix that issue.
2020-05-22 18:58:36 +02:00
FalseHonesty
28f74df2e6 LibGUI: Add hook when a context menu is requested on a button 2020-05-22 18:23:02 +02:00
Linus Groh
040c75a3cc LibJS: Make Array.prototype.{join,toString}() generic 2020-05-22 17:43:44 +02:00
Linus Groh
e9ee06b19e LibJS: Make Array.prototype.pop() generic 2020-05-22 17:43:44 +02:00
Linus Groh
4334a1b208 LibJS: Make Array.prototype.push() generic 2020-05-22 17:43:44 +02:00
Linus Groh
9f7a6e116a LibJS: Let Array.prototype.join() ignore additional arguments
I.e.

array.join("x", "y", "z") === array.join("x")

rather than

array.join("x", "y", "z") === array.join()
2020-05-22 17:43:44 +02:00
Matthew Olsson
c35732c011 LibJS: Add object literal getter/setter shorthand
Adds support for the following syntax:

let foo = {
    get x() {
        // ...
    },
    set x(value) {
        // ...
    }
}
2020-05-22 10:59:05 +02:00
Linus Groh
27913154ea LibJS: Disallow multiple parameters in paren-less arrow function
Fixes #2323.
2020-05-22 00:50:57 +02:00
Matthew Olsson
45dfa094e9 LibJS: Add getter/setter support
This patch adds a GetterSetterPair object. Values can now store pointers
to objects of this type. These objects are created when using
Object.defineProperty and providing an accessor descriptor.
2020-05-21 22:56:18 +02:00
Linus Groh
a4d04cc748 LibJS: Refactor Array.prototype callback functions and make them generic 2020-05-21 22:50:14 +02:00
Linus Groh
5db9becc4a LibJS: Treat missing arg in Array.prototype.includes() as undefined 2020-05-21 22:50:14 +02:00
Linus Groh
fbcfc8dcd0 LibLine: Hide debug output behind SUGGESTIONS_DEBUG define 2020-05-21 22:50:14 +02:00
FalseHonesty
bf2e6325a4 LibGUI: Add hook when a context menu is requested on a tab 2020-05-21 21:53:17 +02:00
Andreas Kling
ff98f55b85 LibGUI: Fix view column auto-sizing of icon-only columns
For icon columns, just use the item height as the auto width for now.
This gives us 16x16 icons, which is always what we want anyway.
2020-05-21 20:54:21 +02:00
Andreas Kling
248f2d5cf5 LibGUI: Remove Model::row_name() since nothing used it 2020-05-21 20:19:43 +02:00
Andreas Kling
278b307713 LibGUI: Make all views use CenterLeft as the default text alignment
If a model doesn't specify a text alignment for a given field, we now
fall back to CenterLeft. This will look better than Center in the vast
majority of cases.
2020-05-21 19:55:44 +02:00
Andreas Kling
2adb0a07e5 LibGUI: Get rid of Model::ColumnMetadata and always use auto-sizing
Auto-sizing of view columns is now enabled by default. This removes the
last remaining need for ColumnMetadata, so this patch gets rid of it.
2020-05-21 19:55:44 +02:00
Andreas Kling
c666c251c8 LibGUI: Replace ColumnMetadata::sortable => Model::is_column_sortable()
Now there's only one thing left in ColumnMetadata: the initial width.
2020-05-21 19:55:44 +02:00
Andreas Kling
2e03bded43 LibGUI: Add Model::Role::TextAlignment and remove from ColumnMetadata 2020-05-21 19:55:44 +02:00
Andreas Kling
04187576ff LibGUI: Models should always specify font via Model::Role::Font
This gets rid of one field in ColumnData. The goal is to get rid of all
fields and lose ColumnData entirely.
2020-05-21 19:55:44 +02:00
Luke
57d15acd4c LibJS: Add Array.prototype.every 2020-05-21 19:44:59 +02:00
Andreas Kling
4cdbdf0a84 LibGUI: Always paint the cursor visible when focusing a TextEditor
If the cursor happened to be blinking in the invisible state, it would
take 500ms before we actually see the cursor in a newly focused editor
widget. This patch makes it show up right away.
2020-05-21 17:38:01 +02:00
Andreas Kling
4806cd122d LibGUI: Focus the first focusable widget added to a window
It feels really awkward if nothing is focused when opening a window.
2020-05-21 17:26:09 +02:00
Linus Groh
4e657c370c LibJS: Make Interpreter::call() this_value a required argument
Right now the default is an empty value, which we accidentally exposed
in set{Interval,Timeout}() by not providing a custom this value, which
should't happen at all. Let's just make it a required argument instead.
2020-05-21 15:18:08 +02:00
Linus Groh
14dffe4721 LibWeb: Set window object as this value in set{Interval,Timeout}() 2020-05-21 15:18:08 +02:00
Linus Groh
7defc521be LibWeb: Ignore non-finite args in CanvasRenderingContext2D.{scale,translate}() 2020-05-21 15:16:48 +02:00
Linus Groh
b962728c4e LibWeb: Enforce set{Interval,Timeout}() min interval of 0 2020-05-21 15:16:48 +02:00