1
0
mirror of https://github.com/SerenityOS/serenity synced 2024-07-09 00:30:47 +00:00
Commit Graph

2594 Commits

Author SHA1 Message Date
Nico Weber
6528f6db26 MacPDF: Make up and down flip pages when PDF view has focus
Previously, it only reacted to arrow left andn arrow right,
and to opt-up and opt-down.
2023-10-11 21:38:15 -04:00
Nico Weber
627b152d49 MacPDF: Make opt-up and opt-down always go to previous / next page
When the outline has focus, arrow keys navigate the outline instead
of changing the current page.

Add opt-up and opt-down as a way to move by one page even when the
outline has focus. (This matches Preview.app.)

xib change: Added two menu Previous Page with key equivalent opt-up
and Next Page with key equivalent opt-down to Go menu and bound them to
goToPreviousPage: and goToNextPage: on First Responder.

When the outline has focus, the responder chain is outline ->
window, so also add the actions on the window controller, and
let that forward to the PDF view.
2023-10-11 21:38:15 -04:00
Andrew Kaster
3e86f88d6a CMake: Actually set the LAGOM_USE_LINKER option automatically
When this feature was finally merged, the serenity_option in
lagom_options.cmake had the unintended side effect of always setting the
cache variable to "" in the initial cache. In order to actually set the
linker to use to be lld or mold, we need to set with the FORCE flag in
the use_linker.cmake file.

Found by checking with the CMake variable_watch() function.

This will stop the build from spamming the "Using LLD to link Lagom"
message all over the place :^)
2023-10-11 15:02:42 -04:00
Andrew Kaster
9a3e9047a5 Meta: Update GN build for recent changes
9a026fc8d5
ae1ac9871b
07b332e17c

And some missed changes from the past that weren't hit because no one
was referencing those symbols :^).
2023-10-11 10:56:24 -06:00
Andrew Kaster
c8cf361bbd LibWeb: Install generated CSS/PseudoClass.h file the same as the others 2023-10-11 12:35:35 -04:00
Andrew Kaster
99ffc935ef Lagom: Include all generated installed files on library targets
Do this with INSTALL_INTERFACE genex include directory rules. We should
really standardize where the generated headers *actually* get installed
to though.
2023-10-11 12:35:35 -04:00
Tim Ledbetter
e6d9bb0774 LibTLS: Don't attempt to read past EOF when parsing TBSCertificate
This allows the decoder to fail gracefully when reading a partial or
malformed TBSCertificate. We also now ensure that the certificate data
is valid before making a copy of it.
2023-10-11 07:08:22 +02:00
Nico Weber
409eb644c8 MacPDF: Unbreak persisting the current page
I broke this when moving from a xib file to creating the UI in code.

https://developer.apple.com/documentation/appkit/nsuserinterfaceitemidentification/1396829-identifier
says:

"Identifiers are used during window restoration operations to uniquely
identify the windows of the application. [...] If you create an item in
Interface Builder and do not set a value for this string, a unique value
is created for the item when the nib file is loaded. For
programmatically created views, you typically set this value after
creating the item but before adding it to a window."

Without this, encodeRestorableStateWithCoder: / restoreStateWithCoder:
in MacPDFView weren't getting called.
2023-10-10 09:50:28 -04:00
Nico Weber
a75f876ec0 MacPF: Add a small group header in front of the outline
This has to be part of the data source, which makes things a bit
annoying.

For PDFs that have no outline, it says "(No outline)".
2023-10-10 09:50:08 -04:00
Nico Weber
fee50cb387 MacPDF: Switch from a cell-based outline view to a view-based one
The documentation is very loud about cell-based things being
deprecated, but it's fairly hidden what to actually do to switch to
the non-deprecated way (implement a certain delegate method).

Session 120 from WWDC 2011 has some notes on this. Apple's official
site no longer seems to have that, but it's e.g. here:
https://docs.huihoo.com/apple/wwdc/2011/session_120__view_based_nstableview.pdf
2023-10-10 09:50:08 -04:00
Nico Weber
25515322e5 MacPDF: Remove outline view header
Just setting headerView to nil removes the header, but also has
the effect of no longer drawing the outline view with a sidebar
background ¯\_(ツ)_/¯.

But also setting drawsBackground to NO on the scroll view restores
the sidebar look, so do that too.

With this, it is no longer necessar to explicitly set style.
The default NSTableViewStyleAutomatic now seems to resolve to
NSTableViewStyleSourceList, so stop explicitly setting it.
(This part has no behavior change.)
2023-10-10 09:50:08 -04:00
Nico Weber
e7d41480fc MacPDF: Make clicking outline items have an effect
Clicking an item in the outline now opens that page.

This requires giving the outline view a delegate, which for some
reason also has th effect of indenting expandable items ¯\_(ツ)_/¯
The vertical alignment of text still looks off, though.
2023-10-10 09:50:08 -04:00
Nico Weber
185301c027 MacPDF: Add PDF outline to sidebar
The outline has drawing artifacts, but it is somewhat functional:
You can click on disclosure triangles to open outline items, and
if the outline doesn't fit in the sidebar, it's scrollable.

The outline view has the correct sidebar look: gray with a slightly
transparent glass effect.

Clicking items doesn't have an effect yet.
2023-10-10 09:50:08 -04:00
Nico Weber
79bba20efc MacPDF: Add an NSOutlineViewDataSource for the PDF outline
Not used yet.
2023-10-10 09:50:08 -04:00
Shannon Booth
b37aab1277 LibWeb: Port named_item_value from DeprecatedFlyString 2023-10-08 08:11:48 -04:00
Shannon Booth
e4f8c59210 LibWeb: Port AttributeNames to FlyString 2023-10-08 08:11:48 -04:00
Nico Weber
f02b84d34d MacPDF: Give sidebar the more modern look
This Just Works with NSToolbarSidebarTrackingSeparatorItemIdentifier,
as long as your window is has NSWindowStyleMaskFullSizeContentView
in its style mask. If it doesn't, things behave pretty weirdly and
at least in the docs I looked at, this requirement wasn't documented
at all :/

Anyways, switch MacPDFView to use safeAreaRect instead of bounds
now that we use NSWindowStyleMaskFullSizeContentView so that we
don't draw parts of the PDF under the title bar.

Also be careful to invalidate the PDF view if safeAreaRect changes,
so that the page is redrawn when toolbar visibility gets toggled.
2023-10-07 09:47:43 +02:00
Nico Weber
b1e9c419a6 MacPDF: Add a split view for a togglable sidebar
It can be toggled with the (only) toolbar button, or via the
menu bar, or the standard shortcut Cmd-Ctrl-S.
2023-10-07 09:47:43 +02:00
Nico Weber
ae1b179474 MacPDF: Add a toolbar with a standard sidebar button 2023-10-07 09:47:43 +02:00
Nico Weber
1f1a596a46 MacPDF: In window controller, use window directly
No need to go through the view now that there's a dedicated
window controller.

No behavior change.
2023-10-07 09:47:43 +02:00
Nico Weber
c0d8131a26 MacPDF: Remove logspam 2023-10-07 09:47:43 +02:00
Nico Weber
6b9afcfb7c MacPDF: Create window UI in code instead of in xib
No intentional behavior change.
2023-10-07 09:47:43 +02:00
Nico Weber
dcf40892b8 MacPDF: Start moving window-related things into MacPDFWindowController
- MacPDFWindowController is now the xib file's owner
- _pdfView moves over
- MacPDFWindowController is now the MacPDFViewDelegate and responsible
  for updating the window's title
- Due to MacPDFWindowController now being the xib file's owner,
  windowControllerDidLoadNib: is no longer called automatically,
  so call a custom windowIsReady method manually instead

No behavior change.
2023-10-07 09:47:43 +02:00
Nico Weber
67f6baead0 MacPDF: Introduce MacPDFWindowController
I'd like to add a sidebar, and NSSplitViewItem apparently isn't
accessibly in .xib files without contortions. So I want to move
to creating the window in code, and this is a step towards that.

No behavior change.
2023-10-07 09:47:43 +02:00
Nico Weber
d6dff83397 MacPDF: Introduce CocoaWrapper.h
No behavior change.
2023-10-07 09:47:43 +02:00
Andreas Kling
65717e3b75 LibJS: Inline fast case for Value::to_{boolean,number,numeric,primitive}
These functions all have a very common case that can be dealt with a
very simple inline check, often avoiding the need to call an out-of-line
function. This patch moves the common case to inline functions in a new
ValueInlines.h header (necessary due to header dependency issues..)

8% speed-up on the entire Kraken benchmark :^)
2023-10-07 07:13:52 +02:00
Shannon Booth
d818bbf918 LibWeb: Remove UseDeprecatedAKString support for IDL generator
We no longer have any interface relying on this :^)
2023-10-06 08:25:40 +02:00
Timothy Flynn
eeb16f03bb LibLocale: Parse day-period hour cycle preferences
For example, the locale "fr-FR" will have the preferred hour cycle list
of "H hB", meaning h23 and h12-with-day-periods. Whether date-times are
actually formatted with day-periods is up to the user, but we need to
parse the hour cycle as h12 to know that the FR region supports h12.

This bug was revealed by LibJS no longer blindly falling back to h12 (if
the `hour12` option is true) or h24 (if the `hour12` option is false).
2023-10-05 17:01:02 +02:00
Timothy Flynn
0bc401a1d6 LibTimeZone+Userland: Include Link entries when returning all time zones
We currently only return primary time zones, i.e. time zones that are
not a Link. LibJS will require knowledge of Link entries, and whether
each entry is or is not a Link.
2023-10-05 17:01:02 +02:00
Andreas Kling
7df1692580 LibJS: Add Object::may_interfere_with_indexed_property_access() virtual
This function must return true if the object may intercept and customize
access to indexed properties (properties where the property name is a
non-negative integer.)

This will be used to implement fast path optimizations for array-like
accesses in subsequent commits.
2023-10-05 16:57:45 +02:00
Bastiaan van der Plaat
3c27843cfe LibWeb: Add DOMMatrix fromFloat32Array and fromFloat64Array 2023-10-03 16:15:14 -06:00
Bastiaan van der Plaat
2e122b16e4 LibWeb: Add DOMMatrix toFloat32Array and toFloat64Array 2023-10-03 16:15:14 -06:00
Shannon Booth
9303e9e76f LibWeb: Port Element::local_name and TagNames from Deprecated String
Which pretty much needs to be done together due to the amount of places
where they are compared together.

This also involves porting over StackOfOpenElements over to FlyString
from DeprecatedFly string to prevent a gazillion calls to
`.to_deprecated_fly_string` calls in HTMLParser.
2023-10-03 14:47:53 +01:00
Dan Klishch
75fd28014c JSSpecCompiler: Add converter from LibCpp's AST
This will effectively allow us to use C++ code as an input for the
compiler. This would be useful for testing, since otherwise we would
have had to specify tests as a spec-like XML, which is not exactly the
most developer-friendly experience.
2023-10-02 21:15:08 +02:00
Dan Klishch
567b1f6e7c JSSpecCompiler: Adopt more C++ terminology
Let's not use strange names like `ExecutionContext`, which nobody will
understand in the future.
2023-10-02 21:15:08 +02:00
Dan Klishch
4578004ad6 JSSpecCompiler: Do not frame nodes with < and > when dumping AST
Let's not pretend we are outputting some invalid HTML.
2023-10-02 21:15:08 +02:00
Dan Klishch
14a86c8fd6 JSSpecCompiler: Elide nested TreeList nodes 2023-10-02 21:15:08 +02:00
Nico Weber
5e15c29e22 MacPDF: Use "MacPDF" in MainMenu.xib
I forgot to rename it there, whoops.
2023-09-30 19:37:39 -06:00
Nico Weber
76f0a09b5e MacPDF: Rename LagomPDFDocument to MacPDFDocument 2023-09-30 19:37:26 -06:00
Nico Weber
f99771d46f MacPDF: Rename LagomPDFView to MacPDFView 2023-09-30 19:37:26 -06:00
Nico Weber
a0b939cef4 MacPDF: Show correct page number in title bar after restore 2023-09-30 08:08:11 +02:00
Nico Weber
e5283cd648 MacPDF: Define AK_DONT_REPLACE_STD
The bots complain that `forward()` could be either from libc++'s
include/c++/v1/__utility/forward.h or from AK/StdLibExtras.h.

I don't see this locally, but Ladybird also defined AK_DONT_REPLACE_STD,
so let's see if this does the trick.
2023-09-30 08:08:11 +02:00
Nico Weber
e4d2aa82e2 MacPDF: Don't hardcode my serenity directory
https://www.africau.edu/images/default/sample.pdf is a good
document for testing that the built-in fonts load.
2023-09-30 08:08:11 +02:00
Nico Weber
8a7d3cb3f4 MacPDF: Override -[NSDocument isEntireFileLoaded]
We keep the NSData object around and stream for it, so that looks
like a good thing to do.
2023-09-30 08:08:11 +02:00
Nico Weber
e9b0ebe55a MacPDF: Use Serenity license headers, remove Xcode boilerplate 2023-09-30 08:08:11 +02:00
Nico Weber
91e0438fca MacPDF: Make buildable from CMake
Use `Meta/serenity.sh build lagom MacPDF` to build, and either of
`open Build/lagom/bin/MacPDF.app` or
`Build/lagom/bin/MacPDF.app/Contents/MacOS/MacPDF` to run.

Xcode used to insert a bunch of things to Info.plist. Now it can
no longer do that, so manually put them there
2023-09-30 08:08:11 +02:00
Nico Weber
0216f34179 MacPDF: Move some files around
1. main.m is now main.mm
2. MainMenu.xib is now no longer in a Base.lproj subfolder
3. Remove SerenityPDF.entitlements since it won't be used in our CMake
   build
2023-09-30 08:08:11 +02:00
Nico Weber
5af30b8f63 MacPDF: Tweak "#pragma mark" comments 2023-09-30 08:08:11 +02:00
Nico Weber
d2bda064da MacPDF: Pre-populate "Go to Page..." dialog with current page 2023-09-30 08:08:11 +02:00
Nico Weber
e67d8cfb2a MacPDF: Show current page and page count in subtitle 2023-09-30 08:08:11 +02:00