Commit graph

4618 commits

Author SHA1 Message Date
Andreas Kling
2530378f59 LibHTML+Browser: Add debug option to draw borders around line boxes
This will be very useful when debugging line layout.
2019-10-12 15:02:53 +02:00
Andreas Kling
14f0a5943b LibC: Have perror() show the input string on the debugger as well 2019-10-12 14:47:06 +02:00
Andreas Kling
6242459c0f LibHTML: Implement the <br> element for line breaking
The <br> element will produce a special LayoutBreak node in the layout
tree, which forces a break in the line layout whenever encountered.

This patch also makes LayoutBlock use the current line-height as the
minimum effective height for each line box. This ensures that having
multiple <br> elements in a row doesn't create 0-height line boxes.
2019-10-12 13:47:49 +02:00
Andreas Kling
bf79b198f6 Browser: Add a debug menu with actions to dump DOM and Layout trees 2019-10-12 13:44:17 +02:00
Andreas Kling
92b6a7a18f LibHTML: Add StyleProperties::line_height()
We currently hard-code the line height to 140% of the font glyph height
and this patch doesn't fix the hard-coding, but at least moves it out
of LayoutText and into StyleProperties where it can be re-used until
the day we go and do a proper implementation of CSS line-height. :^)
2019-10-12 13:42:58 +02:00
Andreas Kling
3cef6a5cac LibHTML: Make all element tag names lowercase for now
This is not the correct-est way of doing this, but it does make a bunch
of things simpler for now. We can revisit tag name case later on. :^)
2019-10-12 13:04:06 +02:00
Andreas Kling
35def88c8b LibHTML: Move Element construction to a separate file
We now have create_element(document, tag_name) in ElementFactory.
This will be useful for constructing new elements outside of parsing.
2019-10-12 13:02:38 +02:00
Andreas Kling
1f9c4ffd21 LibHTML: Make sure the marker has the same inline state as siblings
Or LayoutBlock will assert when trying to layout its children since
they have inconsistent inline state.
2019-10-11 23:26:25 +02:00
Andreas Kling
724754e39a LibHTML: LayoutBlock::children_are_inline() should check is_inline()
Instead of asking if the first child is not a block, ask if it thinks
it's inline.
2019-10-11 23:23:48 +02:00
Andreas Kling
f5bf8f6380 LibHTML: Add LayoutNode classes for "display: list-item" and its marker
This patch removes the hard-coded hack for "display: list-item" from
LayoutBlock and adds LayoutListItem and LayoutListItemMarker.

Elements with "display: list-item" now generate a LayoutListItem, which
may then also generate a LayoutListItemMarker if appropriate. :^)
2019-10-11 23:16:53 +02:00
Vincent Sanders
d3d972820e Ports: add libiconv port 2019-10-11 12:17:05 +02:00
Vincent Sanders
904bd3b441 Libc: make library internal includes come from private include namespace 2019-10-11 12:17:05 +02:00
Andreas Kling
06113b4ffe LibHTML+Browser: Show the number of pending resource loads
For now this is simply a counter+hook exposed by ResourceLoader and
shown in the Browser status bar.

This is not very nuanced, and it would be nice to expose more info so
we could eventually do something like a progress bar.
2019-10-10 22:07:08 +02:00
Andreas Kling
bf5a65d934 URL: No need to include ":80" when serializing http:// URLs 2019-10-10 22:06:25 +02:00
Andreas Kling
c294c97cdf LibHTML: Show a hand cursor when hovering over a clickable link :^) 2019-10-10 21:35:50 +02:00
Andreas Kling
76266862d1 LibGUI+WindowServer: Add a "Hand" cursor to the standard cursors 2019-10-10 21:35:12 +02:00
Andreas Kling
a6e4c504e2 Kernel: Make SlabAllocator fall back to kmalloc() when slabs run out
This is obviously not ideal, and it would be better to teach it how to
allocate more pages, etc. But since the physical page allocator itself
currently uses SlabAllocator, it's a little bit tricky :^)
2019-10-10 11:58:15 +02:00
Andreas Kling
ebacef36ee LibHTML: Fix relative URL completion when document URL ends in a slash 2019-10-10 11:35:38 +02:00
Andreas Kling
796e63b34c LibHTML: Have TreeNode deref its children before deleting itself
This is definitely not the ideal ownership model here, but it's
something we'll have to iterate on as the engine grows.

At least this prevents us from leaking the entire world. :^)
2019-10-09 21:58:38 +02:00
Andreas Kling
c458327429 LibHTML: Tear down the layout tree before changing the Frame's document
We don't want to deal with document().frame() being null inside layout
tree code, so this makes sure we tear it down before the frame has a
chance to get nulled out.
2019-10-09 21:53:39 +02:00
Andreas Kling
a259832266 LibHTML: Document::detach_from_frame() should actually detach 2019-10-09 21:52:38 +02:00
Andreas Kling
159507f2a6 LibHTML: Move is_ancestor_of() from LayoutNode to TreeNode
This way it becomes available to all the different TreeNode subclasses.
2019-10-09 21:33:34 +02:00
Andreas Kling
fdbad6284c LibHTML: Implement the <blink> element
Just in time for Serenity's 1st birthday, here is the <blink> element!

This patch adds a bunch of different mechanisms to enable partial
repaints of the layout tree (LayoutNode::set_needs_display()))
It also adds LayoutNode::is_visible(), which can be toggled to prevent
a LayoutNode from rendering anything (it still takes up space though.)
2019-10-09 21:25:29 +02:00
Andreas Kling
33043941f9 LibGUI: Add GScrollableWidget::to_widget_position()
This is a complement to to_content_position() :^)
2019-10-09 21:16:49 +02:00
Andreas Kling
fc53867937 LibHTML: Add basic <!DOCTYPE> parsing and a DocumentType class
Plus, Document::fixup() will now make sure that the document always
starts with a doctype node, followed by an <html> element.
2019-10-09 20:17:01 +02:00
Andreas Kling
850955053f LibHTML: Rename Document::normalize() to fixup() and always do it
Node.normalize() is a standard DOM API that coalesces Text nodes.
To avoid clashing with that, rename it to fixup().

This patch also makes it happen automagically as part of parsing.
2019-10-09 18:54:34 +02:00
Andreas Kling
59795aab41 LibHTML: Handle CSS declarations that don't end in ';' 2019-10-09 18:42:08 +02:00
Andreas Kling
2ac190dc5f LibHTML: Collapse whitespace in LayoutText unless white-space: pre;
Before breaking the Text node contents into words, collapse all of the
whitespace into single space (' ') characters. This fixes broken
rendering of paragraphs with newlines in them. :^)
2019-10-09 16:29:35 +02:00
Sergey Bugaev
b4389ca4b0 LibC: Add a missing mbstowcs() declaration
This ensures it gets a C linkage, and so fixes the binutils build.
2019-10-09 15:06:25 +02:00
Andreas Kling
475c6d7112 LibHTML: Use ResourceLoader in HTMLLinkElement
This makes loading external stylesheets from http:// URLs work. :^)
2019-10-09 10:39:28 +02:00
Andreas Kling
75b5638f1c LibGUI: Let's say that Alt+Home is the "go home" keyboard shortcut 2019-10-08 21:45:29 +02:00
Andreas Kling
9bb0374d7d Kernel: Delay moving accepted sockets to SetupState::Completed a bit
Make sure we don't move accepted sockets to the Completed setup state
until we've actually constructed a FileDescription for them.

This is important, since this state transition will trigger connect()
to unblock on the client side, and the client may try writing to the
socket right away.

This makes DNS lookups way more reliable since we don't just fail to
write() right after connect()ing to LookupServer sometimes. :^)
2019-10-08 21:44:50 +02:00
Andreas Kling
3aa27b5b0e Kernel: Don't put LocalSocket in SetupState::Completed in bind()
This was causing connect() to unblock immediately for local sockets,
since that's exactly what ConnectBlocker checks for.

Instead, just move to SetupState::Completed when it's accept()ed.
2019-10-08 21:32:04 +02:00
Andreas Kling
a1c8c754eb LibHTML: Fire the file:// load completion callback asynchronously
This makes it consistent with how http:// callbacks are fired.
It would probably be fine to have file:// be synchronous, but at the
same time it's nice to have consistency.
2019-10-08 19:40:48 +02:00
Andreas Kling
3be6d1aff0 LibHTML: Add ResourceLoader to support protocol-agnostic URL loading
We now support loading both file:// and http:// URLs. Feel free to
visit http://www.serenityos.org/ and enjoy the fancy good times. :^)
2019-10-08 19:37:15 +02:00
Andreas Kling
3fdc595e0c LibCore: CHttpJob::start() should fail asynchronously
Clients are expected to have a chance to set up an on_finish callback
before we finish or fail.
2019-10-08 19:32:34 +02:00
Andreas Kling
31ac19543a LibHTML: Use an enum for CSS property ID's
Instead of using string everywhere, have the CSS parser produce enum
values, since they are a lot nicer to work with.

In the future we should generate most of this code based on a list of
supported CSS properties.
2019-10-08 15:35:05 +02:00
Andreas Kling
19dbfc3153 LibHTML: Move selector matching into a SelectorEngine namespace 2019-10-08 15:35:05 +02:00
Jesse Buhagiar
06b6af61c6 Kernel: Made DiskCache entries a KBuffer
The Cache entries found in `DiskBackedFileSystem` are now stored in a
`KBuffer` object, instead of relying on `kmalloc_eternal`. The number
of entries was exceeding that of the number of bytes allocated to
`kmalloc_eternal`, which in turn caused `mount()` to fail epically
when called.
2019-10-08 11:10:30 +02:00
Andreas Kling
1ce8a175e1 FileManager: Add "Open in TextEditor..." action to context menu 2019-10-07 20:03:19 +02:00
Andreas Kling
5da385c16e Browser: Turn command-line path arguments into file:// URLs 2019-10-07 20:02:29 +02:00
Andreas Kling
90cd363a8e FileManager: Open .html files in Browser instead of "html" 2019-10-07 19:52:35 +02:00
Andreas Kling
6287c2b270 LibHTML: Don't crash when calling set_document(nullptr) 2019-10-07 19:33:06 +02:00
Andreas Kling
edbf09ea29 LibHTML: Make the CSS and HTML parsers take StringViews
This allows us to avoid unnecessary making unnecessary String copies of
all the source text.
2019-10-07 19:11:33 +02:00
Andreas Kling
71e8ddcd1c LibHTML: Start adding support for <link rel="stylesheet">
This patch adds basic support for external stylesheets. It currently
only works with file:// URLs.

We do a synchronous full relayout after loading a stylesheet, which is
definitely on the aggressive side, but it gives us something to work
on improving. :^)
2019-10-07 19:06:47 +02:00
Drew Stratford
c136fd3fe2 Kernel: Send SIGSEGV on seg-fault
Now programs can catch the SIGSEGV signal when they segfault.

This commit also introduced the send_urgent_signal_to_self method,
which is needed to send signals to a thread when handling exceptions
caused by the same thread.
2019-10-07 16:39:47 +02:00
Drew Stratford
7fc903b97a Kernel: Add exception_code to RegisterDump.
Added the exception_code field to RegisterDump, removing the need
for RegisterDumpWithExceptionCode. To accomplish this, I had to
push a dummy exception code during some interrupt entries to properly
pad out the RegisterDump. Note that we also needed to change some code
in sys$sigreturn to deal with the new RegisterDump layout.
2019-10-07 16:39:47 +02:00
supercomputer7
334e039294 PartitionTable: Removing unnecessary declarations from GPT & MBR classes 2019-10-07 11:32:42 +02:00
Andreas Kling
669ee82546 Lagom: Fix TestApp to build after the CObject ref-counting changes 2019-10-07 10:58:23 +02:00
Andreas Kling
a7f538fb63 AK: Make String compile on platforms where size_t==u32
This kind of thing is a bit annoying. On Serenity, size_t is the same
size as u32, but not the same type. Because of "long" or whatever.
This patch makes String not complain about duplicate overloads.
2019-10-07 10:56:44 +02:00