summaryrefslogtreecommitdiffstats
path: root/widget/RemoteLookAndFeel.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /widget/RemoteLookAndFeel.h
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'widget/RemoteLookAndFeel.h')
-rw-r--r--widget/RemoteLookAndFeel.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/widget/RemoteLookAndFeel.h b/widget/RemoteLookAndFeel.h
new file mode 100644
index 0000000000..aec2a3eb3b
--- /dev/null
+++ b/widget/RemoteLookAndFeel.h
@@ -0,0 +1,71 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+ * vim: sw=2 ts=8 et :
+ */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_widget_RemoteLookAndFeel_h__
+#define mozilla_widget_RemoteLookAndFeel_h__
+
+#include "mozilla/widget/nsXPLookAndFeel.h"
+#include "mozilla/widget/LookAndFeelTypes.h"
+
+namespace mozilla::widget {
+
+/**
+ * A LookAndFeel implementation whose native values are provided by the
+ * parent process.
+ */
+class RemoteLookAndFeel final : public nsXPLookAndFeel {
+ public:
+ explicit RemoteLookAndFeel(FullLookAndFeel&& aTables);
+
+ virtual ~RemoteLookAndFeel();
+
+ void NativeInit() override {}
+
+ nsresult NativeGetInt(IntID aID, int32_t& aResult) override;
+ nsresult NativeGetFloat(FloatID aID, float& aResult) override;
+ nsresult NativeGetColor(ColorID aID, nscolor& aResult) override;
+ bool NativeGetFont(FontID aID, nsString& aFontName,
+ gfxFontStyle& aFontStyle) override;
+
+ char16_t GetPasswordCharacterImpl() override;
+ bool GetEchoPasswordImpl() override;
+
+ // Sets the LookAndFeel data to be used by this content process' singleton
+ // RemoteLookAndFeel object.
+ void SetDataImpl(FullLookAndFeel&& aTables) override;
+
+ // Extracts the data from the platform's default LookAndFeel implementation.
+ //
+ // This is called in the parent process to obtain the data to send down to
+ // content processes when they are created (and when the OS theme changes).
+ //
+ // Note that the pointer returned from here is only valid until the next time
+ // ClearCachedData is called.
+ static const FullLookAndFeel* ExtractData();
+
+ // Clears any cached extracted data from the platform's default LookAndFeel
+ // implementation.
+ //
+ // This is called in the parent process when the default LookAndFeel is
+ // refreshed, to invalidate sCachedLookAndFeelData.
+ static void ClearCachedData();
+
+ private:
+ LookAndFeelTables mTables;
+
+ // A cached copy of the data extracted by ExtractData.
+ //
+ // Storing this lets us avoid doing most of the work of ExtractData each
+ // time we create a new content process.
+ //
+ // Only used in the parent process.
+ static StaticAutoPtr<FullLookAndFeel> sCachedLookAndFeelData;
+};
+
+} // namespace mozilla::widget
+
+#endif // mozilla_widget_RemoteLookAndFeel_h__