chore: Start making use of Mozilla's linter, p=#12656

This commit is contained in:
mr. m
2026-03-07 12:15:32 +01:00
committed by GitHub
parent 7c8ccdedd4
commit 0ee960e3a3
78 changed files with 712 additions and 4842 deletions

View File

@@ -25,10 +25,10 @@ using WindowGlobalChild = mozilla::dom::WindowGlobalChild;
namespace {
/**
* @brief Helper function to fetch the most recent window proxy.
* @param aWindow The window to query.
* @returns The most recent window.
*/
* @brief Helper function to fetch the most recent window proxy.
* @param aWindow The window to query.
* @returns The most recent window.
*/
static nsresult GetMostRecentWindowProxy(mozIDOMWindowProxy** aWindow) {
nsresult rv;
nsCOMPtr<nsIWindowMediator> med(
@@ -40,9 +40,9 @@ static nsresult GetMostRecentWindowProxy(mozIDOMWindowProxy** aWindow) {
return NS_ERROR_FAILURE;
}
/**
* @brief Helper function to query and get a reference to the window.
* @param aWindow The window to query.
*/
* @brief Helper function to query and get a reference to the window.
* @param aWindow The window to query.
*/
static nsCOMPtr<mozIDOMWindowProxy> GetMostRecentWindow() {
nsCOMPtr<mozIDOMWindowProxy> aWindow;
nsresult rv = GetMostRecentWindowProxy(getter_AddRefs(aWindow));
@@ -51,12 +51,12 @@ static nsCOMPtr<mozIDOMWindowProxy> GetMostRecentWindow() {
}
return aWindow;
}
}
} // namespace
using mozilla::dom::WindowGlobalChild;
#define NS_ZEN_CAN_SHARE_FAILURE() \
*canShare = false; \
*canShare = false; \
return NS_OK;
NS_IMETHODIMP
@@ -80,28 +80,29 @@ ZenCommonUtils::CanShare(bool* canShare) {
}
NS_IMETHODIMP
ZenCommonUtils::Share(nsIURI* url, const nsACString& title, const nsACString& text,
uint32_t aX, uint32_t aY, uint32_t aWidth, uint32_t aHeight) {
ZenCommonUtils::Share(nsIURI* url, const nsACString& title,
const nsACString& text, uint32_t aX, uint32_t aY,
uint32_t aWidth, uint32_t aHeight) {
auto aWindow = GetMostRecentWindow();
if (!aWindow) {
return NS_ERROR_NOT_AVAILABLE;
}
if (!IsSharingSupported()) {
return NS_OK; // We don't want to throw an error here
return NS_OK; // We don't want to throw an error here
}
return ShareInternal(aWindow, url, title, text, aX, aY, aWidth, aHeight);
}
nsresult ZenCommonUtils::ShareInternal(nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* url,
const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY,
uint32_t aWidth, uint32_t aHeight) {
nsresult ZenCommonUtils::ShareInternal(nsCOMPtr<mozIDOMWindowProxy>& aWindow,
nsIURI* url, const nsACString& title,
const nsACString& text, uint32_t aX,
uint32_t aY, uint32_t aWidth,
uint32_t aHeight) {
// We shoud've had done pointer checks before, so we can assume
// aWindow is valid.
#ifdef NS_ZEN_CAN_SHARE_NATIVE
return ::nsZenNativeShareInternal::ShowNativeDialog(
aWindow, url, title, text,
aX, aY, aWidth, aHeight
);
return ::nsZenNativeShareInternal::ShowNativeDialog(aWindow, url, title, text,
aX, aY, aWidth, aHeight);
#else
return NS_ERROR_NOT_IMPLEMENTED;
#endif
@@ -118,4 +119,4 @@ auto ZenCommonUtils::IsSharingSupported() -> bool {
#endif
}
} // namespace: zen
} // namespace zen

View File

@@ -40,9 +40,9 @@ class ZenCommonUtils final : public nsIZenCommonUtils {
* @returns A promise that resolves when the share is complete.
*/
static auto ShareInternal(nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* url,
const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY,
uint32_t aWidth, uint32_t aHeight)
-> nsresult;
const nsACString& title, const nsACString& text,
uint32_t aX, uint32_t aY, uint32_t aWidth,
uint32_t aHeight) -> nsresult;
/**
* @brief Helper function to play haptic feedback.
*/
@@ -56,6 +56,6 @@ class ZenCommonUtils final : public nsIZenCommonUtils {
#endif
};
} // namespace zen
} // namespace zen
#endif

View File

@@ -12,26 +12,27 @@
#include "nsIURI.h"
#if defined(XP_WIN) || defined(XP_MACOSX)
#define NS_ZEN_CAN_SHARE_NATIVE true
# define NS_ZEN_CAN_SHARE_NATIVE true
class nsZenNativeShareInternal final {
public:
/**
* @brief Use the native share dialog. This only works on Windows and MacOS
* since the native share dialog is not available on other platforms.
* Macos does need pointer coordinates to show the share dialog while
* Windows does not since it just displays a dialog on the middle of the
* screen.
* @param aWindow The window to use for the share dialog.
* @param aUrl The URL to share.
* @param aTitle The title of the share.
* @param aText The text to share.
* @returns void
*/
static auto ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* aUrl,
const nsACString& aTitle, const nsACString& aText, uint32_t aX = 0, uint32_t aY = 0,
uint32_t aWidth = 0, uint32_t aHeight = 0)
-> nsresult;
* @brief Use the native share dialog. This only works on Windows and MacOS
* since the native share dialog is not available on other platforms.
* Macos does need pointer coordinates to show the share dialog while
* Windows does not since it just displays a dialog on the middle of the
* screen.
* @param aWindow The window to use for the share dialog.
* @param aUrl The URL to share.
* @param aTitle The title of the share.
* @param aText The text to share.
* @returns void
*/
static auto ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aWindow,
nsIURI* aUrl, const nsACString& aTitle,
const nsACString& aText, uint32_t aX = 0,
uint32_t aY = 0, uint32_t aWidth = 0,
uint32_t aHeight = 0) -> nsresult;
nsZenNativeShareInternal() = default;
~nsZenNativeShareInternal() = default;

View File

@@ -21,7 +21,8 @@ namespace zen {
nsresult ZenCommonUtils::PlayHapticFeedbackInternal() {
NS_OBJC_BEGIN_TRY_BLOCK_RETURN;
if (@available(macOS 10.14, *)) {
id<NSHapticFeedbackPerformer> performer = [NSHapticFeedbackManager defaultPerformer];
id<NSHapticFeedbackPerformer> performer =
[NSHapticFeedbackManager defaultPerformer];
[performer performFeedbackPattern:NSHapticFeedbackPatternAlignment
performanceTime:NSHapticFeedbackPerformanceTimeDefault];
}
@@ -29,4 +30,4 @@ nsresult ZenCommonUtils::PlayHapticFeedbackInternal() {
NS_OBJC_END_TRY_BLOCK_RETURN(NS_OK);
}
}
} // namespace zen

View File

@@ -26,8 +26,8 @@ using ::mozilla::widget::WidgetUtils;
* @param a_nativeWindow The pointer to the native NSWindow.
* @return NS_OK on success, or an error code on failure.
*/
static nsresult GetNativeWindowPointerFromDOMWindow(mozIDOMWindowProxy* a_window,
NSWindow** a_nativeWindow) {
static nsresult GetNativeWindowPointerFromDOMWindow(
mozIDOMWindowProxy* a_window, NSWindow** a_nativeWindow) {
*a_nativeWindow = nil;
if (!a_window) return NS_ERROR_INVALID_ARG;
nsPIDOMWindowOuter* win = nsPIDOMWindowOuter::From(a_window);
@@ -38,12 +38,12 @@ static nsresult GetNativeWindowPointerFromDOMWindow(mozIDOMWindowProxy* a_window
*a_nativeWindow = (NSWindow*)widget->GetNativeData(NS_NATIVE_WINDOW);
return NS_OK;
}
}
} // namespace zen
auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aWindow,
nsIURI* aUrl, const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY,
uint32_t aWidth, uint32_t aHeight)
-> nsresult {
auto nsZenNativeShareInternal::ShowNativeDialog(
nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* aUrl,
const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY,
uint32_t aWidth, uint32_t aHeight) -> nsresult {
// Just use the URL since apple doesn't support sharing text
// and title in the share dialog
nsAutoCString pageUrlAsStringTemp;
@@ -53,9 +53,8 @@ auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aW
} else {
pageUrlAsStringTemp.SetIsVoid(true);
}
NSURL* pageUrl = nsCocoaUtils::ToNSURL(
NS_ConvertUTF8toUTF16(pageUrlAsStringTemp)
);
NSURL* pageUrl =
nsCocoaUtils::ToNSURL(NS_ConvertUTF8toUTF16(pageUrlAsStringTemp));
if (!pageUrl || (![pageUrl.scheme isEqualToString:@"https"] &&
![pageUrl.scheme isEqualToString:@"http"])) {
return NS_ERROR_FAILURE;

View File

@@ -20,7 +20,7 @@ interface nsIZenCommonUtils : nsISupports {
* @param y The y coordinate of the share dialog.
* @returns A promise that resolves when the share is complete.
*/
void share(in nsIURI url, in ACString title, in ACString text,
void share(in nsIURI url, in ACString title, in ACString text,
in uint32_t x, in uint32_t y, in uint32_t width, in uint32_t height);
/*
* @brief Check if the current context can share data.
@@ -33,4 +33,3 @@ interface nsIZenCommonUtils : nsISupports {
*/
void playHapticFeedback();
};

View File

@@ -7,22 +7,22 @@
namespace zen {
/**
* @brief Helper function to convert UTF-8 to UTF-16.
* @param aStr The UTF-8 string to convert.
* @returns The converted UTF-16 string.
*/
* @brief Helper function to convert UTF-8 to UTF-16.
* @param aStr The UTF-8 string to convert.
* @returns The converted UTF-16 string.
*/
inline NS_ConvertUTF8toUTF16 NS_ConvertUTF8toUTF16_MaybeVoid(
const nsACString& aStr) {
auto str = NS_ConvertUTF8toUTF16(aStr);
str.SetIsVoid(aStr.IsVoid());
return str;
}
} // namespace: zen
} // namespace zen
auto nsZenNativeShareInternal::ShowNativeDialog(
nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* aUrl, const nsACString& aTitle,
const nsACString& aText, uint32_t aX, uint32_t aY, uint32_t aWidth, uint32_t aHeight)
-> nsresult {
nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* aUrl,
const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY,
uint32_t aWidth, uint32_t aHeight) -> nsresult {
nsAutoCString urlString;
if (aUrl) {
nsresult rv = aUrl->GetSpec(urlString);