Taking a big step towards a world of multiple global object, this patch
adds a new JS::VM object that houses the JS::Heap.
This means that the Heap moves out of Interpreter, and the same Heap
can now be used by multiple Interpreters, and can also outlive them.
The VM keeps a stack of Interpreter pointers. We push/pop on this
stack when entering/exiting execution with a given Interpreter.
This allows us to make this change without disturbing too much of
the existing code.
There is still a 1-to-1 relationship between Interpreter and the
global object. This will change in the future.
Ultimately, the goal here is to make Interpreter a transient object
that only needs to exist while you execute some code. Getting there
will take a lot more work though. :^)
Note that in LibWeb, the global JS::VM is called main_thread_vm(),
to distinguish it from future worker VM's.
When opening something in the left-side treeview, it also opens in the
right-side directory view. That triggers the "path changed" hook in the
directory view, which causes us to fully reveal the opened directory
in the left-side treeview.
This feedback loop made the UI feel weird since it caused directories
to expand just by selecting them in the left-side treeview. So let's
break that loop.
Use the new TreeView::expand_all_parent_of() API to ensure that newly
opened directories are revealed and scrolled-into-view in the left-side
treeview. :^)
When we enter an inaccessible directory, we still allow that directory
to become selected in the left-side treeview, so we need to update the
location box and window title to reflect the new current path.
This is not perfectly factored and there's a bit of duplication between
the model's on_error and on_complete hook callbacks in DirectoryView.
Needs more work. :^)
Instead of popping up a message box whenever we can't read an opened
directory, show the error message inside the DirectoryView (as a label)
instead.
This fixes a visual inconsistency where an inaccessible directory would
be selected in the left-side treeview while the previous directory's
contents were still showing on the right.
This also makes keyboard navigation a bit more pleasant since you're
not suddenly interrupted by a message box.
This gives you something to click on if you actually want to open
the root directory. Previously, if you wanted to get to /, you had to
use the "to parent directory" repeatedly. Silly. :^)
This code was confusing two different versions of scroll_into_view that
were getting mixed up due to member function shadowing.
Adding an "override" to the subclass declaration exposed the problem.
With this fixed, we no longer lose our scroll position wildly when
using the mouse to select TreeView items.
This is our first client of the new JSON GUI declaration thingy.
The skeleton of the TextEditor app GUI is now declared separately from
the C++ logic, and we use the Core::Object::name() of widgets to locate
them once they have been instantiated by the GUI builder.
This is a little bit messy since the left-side treeview also has a
delete action. Because of that, we have to put a focus-dependent action
that delegates to the relevant view-specific action in the tool bar
and menu bar.
I'm not sure yet what a good abstraction would be for this. We'll see
what we can think of.
Indexed bitmaps used to allocate four times the required amount of memory.
Also, we should acknowledge that the underlying data is not always RGBA32,
and instead cast it only when the true type is known.
Currently, every time the wallpaper picker changes, an additional
attempted file load happens on top of the file load to create the
bitmap. The only values that the wallpaper picker can take on are
filenames that can never be valid when loaded without the /res/wallpaper
prefix. To reduce the amount of log spam and speed up wallpaper picking,
this patch only attempts to load wallpapers with slash-prefixed names,
assumed to be the absolute path to that wallpaper. Additional wallpapers
outside of /res/wallpapers/ should still be accessible with this patch,
and the experience is improved for the more common case of selecting a
built-in wallpaper.
The move constructor of a lambda just copies it anyway.
Even if the first move() left an 'empty' closure behind, then
'm_editor->on_cursor_change' would only be able to see an empty
closure, which is certainly not what was intended.
Under the hood, a lambda is just a struct full of pointers/references/copies and whatever else
the compiler deems necessary. In the case of 'update_demo', the struct lives on the stack
frame of FontEditorWidget::FontEditorWidget(). Hence it is still alive when it's called
during the constructor.
However, when 'fixed_width_checkbox.on_checked' fires, that stack frame is no longer alive,
and thus the *reference* to the (struct of) the lambda is invalid\! This meant that
'update_demo' silently read invalid data, tried to call '.update()' on some innocent arbitrary
memory address, and it crashed somewhere unrelated.
Passing 'update_demo' by value (like with all the other event handlers) fixes this issue.
Note that this solution only works because 'update_demo' itself has no state; otherwise
the various copies of 'update_demo' might notice that they are, in fact, independent copies
of the original lambda. But that doesn't matter here.
Until we have better control over cell content alignment, let's make
them all right-aligned by default since that makes numbers look nice,
and numbers are the bread & butter of spreadsheets. :^)
Customize the cell editing delegate to stop editing when one of the
various cursor movement keys is hit. This allows you to type into a
cell and then move to an adjacent cell by simply pressing an arrow.
This may not be the best factoring for this feature, but it's pretty
dang cool and we'll see how it evolves over time. :^)
This commit adds a generic interface for cell types and hooks it up.
There is no way to set these from the UI, and so they're not saved
anywhere yet.
Also implicitly converts numeric values (strictly integers) to numeric
javascript values, as numbery-looking + numbery-looking === string is
not very interesting. :^)
This commit just moves some code around:
- Give Cell its own file
- Pull all forward-declared classes/structs into Forward.h
- Clean up the order of member functions a bit
Now that the table view has a cursor, we can distinguish it from the
selected cells. Draw the cells with a nice variant of the selection
color as background.
Before, we had about these occurrence counts:
COPY: 13 without, 33 with
MOVE: 12 without, 28 with
Clearly, 'with' was the preferred way. However, this introduced double-semicolons
all over the place, and caused some warnings to trigger.
This patch *forces* the usage of a semi-colon when calling the macro,
by removing the semi-colon within the macro. (And thus also gets rid
of the double-semicolon.)
The fact that a `MarkedValueList` had to be created was just annoying,
so here's an alternative.
This patchset also removes some (now) unneeded MarkedValueList.h includes.
This patch introduces the HeaderView class, which is a widget that
implements the column headers of TableView and TreeView.
This greatly simplifies event management in the view implementations
and also makes it much easier to eventually implement row headers.
The motivation for this change is twofold:
- Returning a JS::Value is misleading as one would expect it to carry
some meaningful information, like maybe the error object that's being
created, but in fact it is always empty. Supposedly to serve as a
shortcut for the common case of "throw and return empty value", but
that's just leading us to my second point.
- Inconsistent usage / coding style: as of this commit there are 114
uses of throw_exception() discarding its return value and 55 uses
directly returning the call result (in LibJS, not counting LibWeb);
with the first style often having a more explicit empty value (or
nullptr in some cases) return anyway.
One more line to always make the return value obvious is should be
worth it.
So now it's basically always these steps, which is already being used in
the majority of cases (as outlined above):
- Throw an exception. This mutates interpreter state by updating
m_exception and unwinding, but doesn't return anything.
- Let the caller explicitly return an empty value, nullptr or anything
else itself.
Refactors the Calendar widget into LibGUI and updates the Calendar
app interface. Calendar widget lets layout engine manage most of
its geometry now and has a few new features like tile click
navigation, hover highlighting and a togglable year/month mode.
This is not perfect and kinda clunky to use, but these are the best
input widgets we have available at the moment, so let's make do with
what we have. :^)
urls were previously added to history in the Tab::load()
function, which excluded the setter on window.location.href.
This commit adds all urls to browser history when the page loads,
as long as the load_type is not LoadType::HistoryNavigation.
Closes#3148
Instead of translating between the sorting proxy and the underlying
file system model at all the DirectoryView API boundaries, just hand
out indexes into the sorting proxy model.
The only thing those indexes are used for on the outside is to
retrieve a GUI::FileSystemModel::Node for an index, so add a nice
helper on DirectoryView that turns a ModelIndex into a Node&.
The Node API was obnoxiously requiring you to pass the model into it
all the time, simply because nodes could not find their way back to
the containing model. This patch adds a back-reference to the model
and simplifies the API.
This patch begins the process of converting FileManager's desktop mode
to using the DirectoryView class.
This will allow us to share most of the code between the two different
runtime modes of FileManager.
We lose a bit of functionality in this patch, but we'll bring it back!
I noticed that nothing actually applies the wallpaper on startup.
I wasn't sure where to put the responsibility, so I gave it to
the desktop mode file manager.
Also adds a save_config option to set_wallpaper so it doesn't
needlessly save the config.
If the process table grows or shrinks, we need to invalidate all the
ProcessModel indexes. This is not great, but it's the most precise
invalidation we can do at the moment.
Instead of SortingProxyModel having a column+order, we move that state
to AbstractView. When you click on a column header, the view tells the
model to resort the relevant column with the new order.
This is implemented in SortingProxyModel by simply walking all the
reified source/proxy mappings and resorting their row indexes.
This removes one major source of confusion in DirectoryView. It's still
weird that we mix sorting model indexes with filesystem model indexes
a bit willy-nilly but we'll improve that separately.
This changes the graph caption from KB to KiB, but it keeps just "K"
instead of "KiB" for all the numbers in columns in the table, since "K"
is fairly well-established as abbreviation of "KiB" (the SI prefix is
lower-case), and space is at a premium here.
Let's use the one in AK/NumberFormat.h everywhere.
It has slightly different behavior than some of the copies this
removes, but it's probably nice to have uniform human readable
size outputs across the system.
The SI prefixes "k", "M", "G" mean "10^3", "10^6", "10^9".
The IEC prefixes "Ki", "Mi", "Gi" mean "2^10", "2^20", "2^30".
Let's use the correct name, at least in code.
Only changes the name of the constants, no other behavior change.
This is a follow up to #2936 / d3e3b4ae56aa79d9bde12ca1f143dcf116f89a4c.
Affected programs:
- Applications: Browser (Download, View source, Inspect DOM tree, JS
console), Terminal (Settings)
- Demos: Cube, Eyes, Fire, HelloWorld, LibGfxDemo, WebView,
WidgetGallery
- DevTools: HackStudio, Inspector, Profiler
- Games: 2048, Minesweeper, Snake, Solitaire
- Userland: test-web
A few have been left out where manual positioning is done on purpose,
e.g. ClipboardManager (to be close to the menu bar) or VisualBuilder (to
preserve alignment of the multiple application windows).
Various applications were using the same slightly verbose code to center
themselves on the screen/desktop:
Gfx::IntRect window_rect { 0, 0, width, height };
window_rect.center_within(GUI::Desktop::the().rect());
window->set_rect(window_rect);
Which now becomes:
window->resize(width, height);
window->center_on_screen();