Commit Graph

29740 Commits

Author SHA1 Message Date
Ben Wiederhake
4e55d649d7 Services: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
b3e9a4e603 Libraries: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
3796d417e0 Demos+DevTools+Games: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
465af4c4d4 Applications: Fix visibility of Object-derivative constructors
Derivatives of Core::Object should be constructed through
ClassName::construct(), to avoid handling ref-counted objects with
refcount zero. Fixing the visibility means that misuses like this are
more difficult.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
6b75a4dfc3 Everywhere: Mark overridden methods 'override'
This is good practice, and fixes some IDE warnings.
2021-11-02 22:56:53 +01:00
Ben Wiederhake
2e6bb987a3 AK+WindowServer: Remove did_construct() framework used only once
There is also make_ref_counted(), which does not call did_construct(),
so the method was not guaranteed to be run. Since there is only a single
user, and `WindowServer::Window` is a final class anyway (so there is no
need to separate the constructor and post-constructor phases), let's get
rid of this concept.

(The following commits reduce the opportunities to call
make_ref_counted, but still.)
2021-11-02 22:56:53 +01:00
Andreas Kling
68c8d23e39 LibWeb+Browser: Show DOM comments with syntax_comment color in inspector
This required a hack since models can't return a color role directly
from data(). I've added a FIXME about it.
2021-11-02 22:30:06 +01:00
Andreas Kling
5088846606 LibWeb: Show DOM comment contents in DOM inspector 2021-11-02 22:30:06 +01:00
Andreas Kling
5db51d85a3 LibWeb: Hide uninteresting whitespace text nodes from DOM inspector
Use a simple heuristic to exclude uninteresting whitespace and
de-clutter the inspector's DOM tree.

Uninteresting whitespace is currently one of these:
- Non-rendered whitespace-only text nodes
- Rendered whitespace-only text nodes between block-level elements
2021-11-02 22:30:06 +01:00
Luke Wilde
b83e3fd01d LibJS: Implement Temporal.PlainTime.prototype.round 2021-11-02 21:42:40 +01:00
Idan Horowitz
853fab352d LibJS: Convert the InitializeReferencedBinding AO to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Idan Horowitz
1aaaf521b8 LibJS: Convert the PutValue AO to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Idan Horowitz
390a04a985 LibJS: Convert the GetValue AO to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Idan Horowitz
d73b258874 LibJS: Convert reference deletion to ThrowCompletionOr 2021-11-02 19:48:35 +01:00
Linus Groh
330ac1e5ad LibJS: Implement Temporal.PlainTime.prototype.toZonedDateTime() 2021-11-02 18:40:37 +01:00
Linus Groh
070f056926 LibJS: Implement Temporal.PlainDateTime.prototype.toZonedDateTime() 2021-11-02 18:40:37 +01:00
Linus Groh
e27bb94038 LibJS: Implement Temporal.PlainDate.prototype.toZonedDateTime() 2021-11-02 18:40:37 +01:00
thislooksfun
fc411695c7 LibGUI: Keep autocomplete open after applying 'layout: ' 2021-11-02 17:53:22 +01:00
thislooksfun
7a2c8452f1 LibGUI: Don't re-trigger the autocomplete box when the timer fires
Previously there was a situation where the autocomplete box would
appear to "jump" to the side. This was due to the following race
condition:

1. Start typing, thus triggering the autocomplete timer to start
2. Manually trigger autocomplete before the timer finishes
3. Continue typing
4. The autocomplete timer now fires

When the timer fires it causes the autocomplete box to show, which, if
it is already shown, has the effect of moving the box to the current
cursor position.
2021-11-02 17:53:22 +01:00
thislooksfun
8462234208 HackStudio: Don't close autocomplete after applying #include directories 2021-11-02 17:53:22 +01:00
thislooksfun
d5baf1c1fa LibGUI: Allow autocomplete to stay open after applying
Previously the autocomplete box would always close after applying a
suggestion. This is the desired behavior in almost all cases, but there
are some situations (like autocompleting paths) where it would be nicer
to keep the autocomplete box open after applying the suggestion.
2021-11-02 17:53:22 +01:00
thislooksfun
352f593958 LibGUI: Add and use TextEditor::hide_autocomplete()
There were cases where the autocomplete box was being hidden but the
autocomplete timer wasn't being cancelled.
2021-11-02 17:53:22 +01:00
thislooksfun
81f00c0aa8 HackStudio: Remove unused #include
Found this while looking at who uses GUI::AutocompleteProvider.
2021-11-02 17:53:22 +01:00
thislooksfun
aea9ba3b42 LibGUI: Refactor out common code
This is prepping for a future commit.
2021-11-02 17:53:22 +01:00
thislooksfun
713b6badb0 LibGUI: Add AutocompleteProvider::has_suggestions() 2021-11-02 17:53:22 +01:00
thislooksfun
1bf428d296 LibGUI: Add missing #include 2021-11-02 17:53:22 +01:00
thislooksfun
6bd16cc309 LibGUI: Always pre-select the first autocomplete suggestion
Previously we would only pre-select the row the first time the box
was shown, which is not ideal. Now we behave like other editors.
2021-11-02 17:53:22 +01:00
thislooksfun
86ea41970d LibGUI: Hide autocomplete on any event other than typing
Moving the cursor to a different location, by any means, should
dismiss the autocomplete popup. This is the behavior of virtually
every editor/IDE out there, and it is really annoying (and
confusing) when our autocomplete doesn't behave like that.
2021-11-02 17:53:22 +01:00
thislooksfun
0627ed9900 LibGUI: Always show a box when the user requests autocomplete
Previously if there were no suggestions, we simply wouldn't show the
autocomplete popup at all. This is functional, but when there are no
resultes it does leave the user wondering if it actually worked.

Now, if the user requests autocomplete and we do have requests, it
behaves exactly as before, but if there' aren't any we now show a box
with the message "No suggestions" to show the user that we got the
request, there just isn't anything to suggest.
2021-11-02 17:53:22 +01:00
thislooksfun
6c776d267a LibGUI: Remove unnecessary braces 2021-11-02 17:53:22 +01:00
thislooksfun
4e5bf5c138 LibGUI: Abstract out even more duplicated logic 2021-11-02 17:53:22 +01:00
thislooksfun
d4eef0f17d LibGUI: Abstract out and name repeated logic 2021-11-02 17:53:22 +01:00
thislooksfun
d73d044f2b LibGUI: Suggest classes when typing identifiers
We now suggest classes even if the line does not start with an @.
After all, we now have fuzzy matching, so why *shouldn't* "color"
match @GUI::ColorInput as well as background_color?
2021-11-02 17:53:22 +01:00
thislooksfun
22a955b2d7 LibGUI: Abstract out widget and layout class matching 2021-11-02 17:53:22 +01:00
thislooksfun
e1e856132c LibGUI: Don't suggest widgets inside layouts
Having a widget inside a layout is meaningless, so why suggest them in
the first place?
2021-11-02 17:53:22 +01:00
thislooksfun
e403796842 LibGUI: Abstract out some duplicated logic for suggesting properties
A lot of the code in this area is duplicated, which is not great. In
fact this also fixes a bug where suggested partially matched props
would include read-only properties, since that check had only been
added to one of the two loops.
2021-11-02 17:53:22 +01:00
thislooksfun
0be3f5b4ae HackStudio: Append a / when completing a directory 2021-11-02 17:53:22 +01:00
thislooksfun
8b3a2cdad9 HackStudio: Correctly handle nested paths
Previously the paths were concatinated incorrectly, so triggering
the autocomplete on `#include "foo/bar"` would never work. Now it
does. :^)
2021-11-02 17:53:22 +01:00
thislooksfun
a6a71869d7 HackStudio: Handle autocomplete inside #include's <> and "" 2021-11-02 17:53:22 +01:00
thislooksfun
4143f6f906 LibGUI: Make sure that children are actually widgets
Previously this section of code would blindly add *anything* as a child
as long as it has been registered as an object. Since there is no
guarentee that those objects are, in fact, Widgets, this feels like a
logical fallacy.

For example, up until this change, this is perfectly valid GML:

```
@GUI::Widget {
    layout: @GUI::VerticalBoxLayout {
    }

    @GUI::VerticalBoxLayout {
    }
}
```

What exactly does it do? Who knows! It doesn't seem to *break*, but I
think we can all agree it shouldn't be valid.

Instead, we now actually verify that the registered class inherets from
GUI::Widget before adding it as a child. We also error if it's not,
which should hopefully help new GML writers from forgetting to write
'layout: ' before the layout definition and being confused as to why
it's not working.
2021-11-02 17:53:22 +01:00
thislooksfun
eb3ca64819 LibGUI: Dynamically process layouts from GML files
There are only two layouts at the moment, but that could (and probably
will) change in the future. Why limit ourselves by hardcoding these
checks when we can do it dynamically instead?
2021-11-02 17:53:22 +01:00
thislooksfun
03b52e26f0 LibGUI: Use fuzzy matching for GML suggestions 2021-11-02 17:53:22 +01:00
thislooksfun
1a3ea0c892 LibGUI: Add myself to the copyright header 2021-11-02 17:53:22 +01:00
thislooksfun
49b4dfd6cd LibGUI: Suggest 'layout' even before the user starts typing 2021-11-02 17:53:22 +01:00
thislooksfun
8863fe5852 LibGUI: Remove unused check
This check was removed as it will now never trigger.

The completion has the suffix ': ' on it, and the key does not.
Therefore if the user has not yet typed the ':', it will not be equal,
and after they do the check on line 167 will fail so the entry won't be
in the list to begin with.
2021-11-02 17:53:22 +01:00
thislooksfun
9a70ae1593 LibGUI: Automatically append ': ' after autocompleted GML properties 2021-11-02 17:53:22 +01:00
thislooksfun
f7f9d09e72 LibGUI: Remove GUI::AutocompleteProvider::Entry::kind
The only code using it was removed in the previous commit.
2021-11-02 17:53:22 +01:00
thislooksfun
f699dbdc3f HackStudio+LibGUI: Handle #include quotes and brackets in the engine
Previously we had a special case in order to auto-append quotes or
angle brackets to #include statements. After the previous commit this
is no longer necessary.
2021-11-02 17:53:22 +01:00
thislooksfun
a5b3c3f85f LibGUI: Allow completion suggestions to fill and display different text
There are times when it is nice to display one suggestion but fill
something different. This lays the groundwork for allowing
GMLAutocompleteProvider to automatically add ': ' to the end of
suggested properties, while keeping the ': ' suffix from cluttering up
the suggestion UI.
2021-11-02 17:53:22 +01:00
thislooksfun
96029a4ac6 LibGUI: Replace the already typed text when autocompleting
This was a great optimization before, but it locks us out of some neat
features, like fuzzy matching.
2021-11-02 17:53:22 +01:00