Commit graph

5364 commits

Author SHA1 Message Date
Andreas Kling
396b09a1ec LibGUI: Don't focus BreadcrumbBar segments on click 2020-12-14 21:44:03 +01:00
Andreas Kling
818f7777c8 LibGUI: Add a basic BreadcrumbBar widget! :^)
This can be used to implement segmented path bars in FileManager and
wherever else wanted.
2020-12-14 20:43:42 +01:00
Andreas Kling
b00a347ac5 LibGUI: Protect GUI::Button across firing the on_click hook
If a hook triggers the deletion of the GUI::Button, we would be unable
to proceed in a well-defined manner here, so let's protect ourselves.

This probably needs to be done in a whole lot of places, since GUI
widgets are just ref-counted Core::Objects and running arbitrary code
can mean that they get deleted.
2020-12-14 20:43:42 +01:00
Andreas Kling
dd2e8b7dd0 LibWeb: Use IdentifierStyleValue for CSS 'position' 2020-12-14 20:43:25 +01:00
Andreas Kling
3247ea3581 LibWeb: Use CSS::ValueID for 'text-align' values
Let's start moving away from using raw strings for CSS identifiers.
The idea here is to use IdentifierStyleValue with a CSS::ValueID inside
for all CSS identifier values.
2020-12-14 20:43:25 +01:00
Andreas Kling
08517daa5a LibWeb: Improvements to font lookup
Parse out the font-family, font-size and font-weight values from CSS
and use them to perform a kinda-best-effort lookup against the system
font library.

We also now handle standard font names like "sans-serif", "monospace"
and others.
2020-12-14 20:43:25 +01:00
Andreas Kling
861d22838d LibWeb: Virtualize StyleValue equality check
And use this to simplify comparing two IdentifierStyleValues.
2020-12-14 20:43:25 +01:00
Andreas Kling
bceb5b60f7 LibWeb: Add a little assertion in Document::detach_from_frame()
Let's just assert that we're detaching from the frame we thought we
were in.. just in case.
2020-12-14 13:47:07 +01:00
Andreas Kling
34d0141da3 LibWeb: Simplify <iframe> content frame construction
Now that documents are attached to their frame *before* parsing, we can
create the content frame of <iframe> elements right away, instead of
waiting for the host frame attachment.

Fixes #4408.
2020-12-14 13:45:57 +01:00
Andreas Kling
b861de0a13 LibWeb: Use final box model metrics for absolute 'right' and 'bottom'
We've already converted these to floats, so no need to do it again.
2020-12-14 12:49:35 +01:00
Andreas Kling
6809be436b LibWeb: Limit style update tree traversal to dirty subtrees
This patch adds a second style dirty bit that tracks whether a DOM node
has one or more children with dirty style. This allows the style update
to skip over entire subtrees where all nodes are clean.
2020-12-14 12:04:30 +01:00
Andreas Kling
d1479aef56 LibWeb: Layout absolutely positioned children *after* computing height
This is required for CSS "bottom" to work correctly on absolutely
positioned elements.
2020-12-14 11:33:11 +01:00
Andreas Kling
8b9f2c41fa LibWeb: Don't replace selection on key press in non-editable content 2020-12-14 10:58:10 +01:00
Andreas Kling
19144b753a LibWeb: Make StyleProperties::length_box() default to auto values
Undefined length values can default to auto in all length boxes and
we'll get the values we need. This saves us from having to deal with
undefined lengths later on in layout.

At some point we should break the style application process into
a few more formal steps, but this at least simplifies some things.
2020-12-14 10:53:40 +01:00
Andreas Kling
3c9dcec442 LibWeb: Merge Document::layout() and Document::update_layout()
There is now only Document::update_layout().
2020-12-14 10:39:57 +01:00
AnotherTest
dbfce38c90 LibTLS: Read subjectAltName from certificates and use it
As quite a few certificates use this extension, reading and using it to
find matching certificates is fairly useful :^)
2020-12-13 20:24:58 +01:00
Andreas Kling
7b735b55e1 LibWeb: Set the encoding of HTML documents
Now that we attach the document to the frame before parsing, we have
to make sure we set the encoding on the document before parsing, or
things may not turn out well.
2020-12-13 18:21:52 +01:00
Andreas Kling
024059b49b LibTextCodec: Normalize incoming encodings in decoder_for()
Instead of asserting when you call TextCoded::decoder_for() with a
non-standard encoding name, let's be nice and see if we can't find a
decoder for the standardized version of the encoding name.
2020-12-13 18:20:50 +01:00
Andreas Kling
986ce57be9 LibTLS: TLSv12::read_line() should chomp result string
Match the Core::IODevice::read_line() API change and return a chomped
string from here as well.
2020-12-13 18:19:32 +01:00
Andreas Kling
b73d0bb6c8 LibWeb: Update stale #includes for HTML/TagNames.* move 2020-12-13 17:54:40 +01:00
Andreas Kling
1eee6716e0 LibWeb: Attach DOM::Document to its frame before parsing
FrameLoader now begins by constructing a DOM::Document, and then builds
a document tree inside it based on the MIME type. For text/html we pass
control to the HTMLDocumentParser as before.

This gives us access to things like window.alert() during parsing.

Fixes #3973.
2020-12-13 17:40:48 +01:00
Andreas Kling
22c582a887 LibWeb: Make HTMLDocumentParser take an existing document
We shouldn't really be creating the document objects inside the parser,
since that makes it hard to hook up e.g JavaScript bindings early on.
2020-12-13 16:59:22 +01:00
Andreas Kling
4dbecf0b65 LibWeb: Move DOM/TagNames.* => HTML/TagNames.* 2020-12-13 15:57:09 +01:00
Andreas Kling
59afcddcfe LibWeb: Mark element style dirty on style/id attribute change too 2020-12-13 15:22:41 +01:00
Andreas Kling
294ec3b6a5 LibWeb: Mark element style dirty when class attribute changes
Fixes #4403.
2020-12-13 15:22:22 +01:00
Andreas Kling
6af55a234f LibWeb: Make DOM::Node::set_needs_style_update() schedule the update
After you mark a node as needing new style, there's no situation in
which we don't want a style update to happen, so just take care of
scheduling it automatically.
2020-12-13 15:19:42 +01:00
Andreas Kling
b9b7b2b28a LibCore: Make IODevice::read_line() return a String
Almost everyone using this API actually wanted String instead of a
ByteBuffer anyway, and there were a bunch of slightly different ways
clients would convert to String.

Let's just cut out all the confusion and make it return String. :^)
2020-12-13 11:54:11 +01:00
Andreas Kling
3ee5694e97 LibGUI: Simplify ComboBox/TextEditor relationship a bit
Instead of TextEditor knowing about the ComboBox button on the right
hand side, we now make ComboBox inherit from GUI::Frame, and make the
inner text editor widget frameless.

This allows us to place the button ourselves inside ComboBox without
any frame artifacts, and TextEditor no longer needs to keep track of
the geometry of that button.
2020-12-13 11:49:18 +01:00
Andreas Kling
9d442ba606 LibWeb: Store layout box model metrics as floats
Instead of storing them as CSS::Lengths, we now store the resolved
values for margin/padding/border/offset top/right/bottom/left with
each Layout::NodeWithStyleAndBoxModelMetrics.

This simplifies a lot of code since it's no longer necessary to
resolve values before using them.
2020-12-12 21:28:29 +01:00
Tom
bcb9363a97 LibPthread: Return errors as positive return values
pthread implementations generally return errors as a positive non-zero
value. Our kernel generally returns errors as negative values. If we
receive a negative value from a system call, turn it into a positive
return value to relay the error appropriately.

Also, fix the tt test utility to not rely on errno, as the pthread
library does not use errno.
2020-12-12 21:28:12 +01:00
AnotherTest
0918d8b1f8 LibGfx: Make fill_path() less bad at filling paths
This patchset fixes:
- Some parts of the path being skipped and not drawn (often horizontal)
- The filled shape moving around on an int grid depending on the winding
  number
- Winding number mess-up with four-way intersections
2020-12-12 20:10:04 +01:00
Andreas Kling
2b8c7faee4 LibWeb: Use the margin box of floating elements for flowing around
Inline content flows around the entire margin box of floating elements,
not just the content box.
2020-12-12 19:59:24 +01:00
Andreas Kling
66e9dde86f LibWeb: Don't place floating boxes before everything else
Instead, just handle them as we go about laying out block-level boxes.
2020-12-12 19:31:46 +01:00
Andreas Kling
ec89302fbe LibWeb: Make the ad-hoc CSS parser a little more tolerant
Just bail when encountering some unexpected character. This makes it
much more tolerable to type a stylesheet into TextEditor with live
HTML preview enabled.
2020-12-12 11:47:11 +01:00
Andreas Kling
b60801a9ba LibWeb: Apply 'min-width' and 'max-width' constraints to replaced boxes
This is definitely not 100% correct but I tried implementing the basic
algorithms described in CSS 2.2. It's good enough to render the penguin
on @linusg's homepage at the right size. :^)
2020-12-12 00:29:49 +01:00
Andreas Kling
552ba1b0a3 LibWeb: Remove some unnecessary is_replaced() checks in BFC
BFC::compute_width() has a short-circuit path for replaced elements.
2020-12-11 22:59:46 +01:00
Andreas Kling
67732df034 LibWeb: Move replaced element layout out of Layout::ReplacedBox
Replaced elements are now laid out by the current formatting context.
Since the logic is almost identical in BFC and IFC, it's implemented
by static helpers in FormattingContext.
2020-12-11 22:59:46 +01:00
Andreas Kling
e8d6691470 LibWeb: Fix inline-block width computation with no specified width
Undefined width should be treated the same as width:auto;
2020-12-11 22:59:46 +01:00
Andreas Kling
aec54af04f LibDebug: Clean up DebugSession construction a little bit
No need to wrap MappedFile in a NonnullOwnPtr. Also make the session
constructor private and use adopt_own().
2020-12-11 22:59:46 +01:00
Sahan Fernando
66f9a2d9ec LibDebug: Fix crash when debugging short lived programs 2020-12-11 09:55:31 +01:00
Zac
dea399ff08 FileManager: focus_dependent_delete_action is correctly enabled/disabled
The focus_dependent_delete_action that sits in the file manager's
toolbar would always remain enabled, even if nothing was selected,
activating it if nothing was selected would then crash the application.

The action is now correctly enabled/disabled, but due to the way
selection works in TreeViews, something is always selected, what really
matters is if the TreeView has something selected, and it has focus.
As it currently stands, there is no way to know when the TreeView's
is_focused status changes. In order for this to work I added a callback
to the Widget class which fires when a widget receives or looses focus.
In that callback, the focus_dependent_delete_action's enabled value is
recalculated.
2020-12-11 09:36:44 +01:00
AnicJov
f631e73519 Chess: Added abilty to import PGN files
This patch allows the user to load games using PGN files. The parsing
is not complete and has a bunch of work left to be done, but it's
okay for our use case here. It can load all of the games our PGN
exporter can save. As the Chess program impoves so can the PGN parser.
2020-12-10 20:40:51 +01:00
AnicJov
cf8fce368a Chess: Added ability to copy board state as FEN
You can now copy the board state as Forsyth-Edwards Notation. You can
then paste this into other chess programs/games, or into ours when
it gets implemented.
2020-12-10 20:40:51 +01:00
Andreas Kling
350b2c6d9e LibWeb: Use the surrounding text color as the caret color
This way you can always see the cursor as long (as you can see the text
you are editing.)
2020-12-10 11:39:47 +01:00
Linus Groh
5d77a19af5 LibWeb: Replace IDL 'void' return type with 'undefined'
From the Web IDL spec: https://heycam.github.io/webidl/#idl-undefined

[...]
undefined constant values in IDL are represented with the `undefined`
token.
[...]
Note: This value was previously spelled `void`, and more limited in how
it was allowed to be used.
2020-12-10 11:02:46 +01:00
Linus Groh
c1dfb2d883 LibWeb: Expect IDL namespace to end with semicolon
From the Web IDL spec: https://heycam.github.io/webidl/#prod-Namespace

Namespace ::
    namespace identifier { NamespaceMembers } ;
2020-12-10 11:02:46 +01:00
Andreas Kling
a34e023a33 LibC: Make getdelim() fail with EINVAL on null input pointers
This matches some other libc's.
2020-12-09 21:12:40 +01:00
asynts
2981f10a5e LibWeb: Apply suggested fixes. 2020-12-09 21:05:06 +01:00
asynts
1c7a834278 LibWeb: Expose DOM::Range to JavaScript. 2020-12-09 21:05:06 +01:00
asynts
10f9c85090 LibWeb: Make DOM::Range more suitable for JS. 2020-12-09 21:05:06 +01:00