Some important features of Odysseus are to open/save webpages and to view a page’s source code.
The “Open” option is essentially just an alternative to the addressbar, so this morning I’ll describe how the save & viewsource options work. And then if I have time how WebKit implements zooming in/out.
I guess this would also be a great time to describe how the GtkFileDialog works as well.
The .save_to_file() method Odysseus calls on the embedding widget wraps the sandbox’s .getContentsAsMHTML() method with GIO operations.
Which then uses the WebCore’s MHTMLArchive class to iterate over and serialize all the page’s resources, in turn wrapping a PageSerializer and a StringBuilder.
As for viewSource, the WebKit.WebView captures a reference to the sandboxed “frame” on load, and the corresponding Page asks it’s loader within the sandbox for this source code.
As for zoom features, WebKitGTK can be configured to apply it to just the text or the entire page. These values are tracked both in the sandbox and in the embedder, and are routed via the Page to the frame’s .setPageAndTextZoomFactors() method.
After tidying things up and adjusting the scroll position this method recomputes style for these new zoom factors, before recursing over the frame hierarchy. With these values serving as fundamental CSS units like “px”.
The UI for open/save (as well as “Save as” on downloads) is provided by GtkFileChooserNative.
Which in turn wraps GtkFileChooserNativeWin32, GtkFileChooserNativeQuartz, or GtkFileChooserNativePortal before falling back to GtkFileChooserDialog. All of which implements the same interface.
GtkFileChooserNativePortal simply wraps a DBus interface to allow for better sandboxing and desktop-specific UIs, and the other GtkFileChooserNative* classes wrap other UI framworks.
GtkFileChooserDialog does little more than wrap GtkFileChooserWidget with a GtkDialog.
GtkFileChooserWidget in turn is where all the logic is (if not overriden out-of-process). This wraps GtkPlacesSidebar & GtkPathBar, hooks the GIO filesystem objects up to GtkTree, and managers several other widgets besides. It also implements the GtkFileChooser interface.
GtkPlacesSidebar wraps a GtkListBox and populates from multiple sources including an XML file, and GtkPathBar does some custom rendering