mirror of
https://github.com/zen-browser/desktop.git
synced 2026-04-02 05:39:18 +00:00
feat: Added last details, b=(no-bug), c=common
This commit is contained in:
@@ -82,13 +82,15 @@ var gZenCommonActions = {
|
||||
Services.io.newURI(currentUrl),
|
||||
'',
|
||||
'',
|
||||
buttonRect.left - buttonRect.width / 2,
|
||||
buttonRect.top + buttonRect.height
|
||||
buttonRect.left,
|
||||
window.innerHeight - buttonRect.bottom,
|
||||
buttonRect.width,
|
||||
buttonRect.height
|
||||
);
|
||||
},
|
||||
};
|
||||
}
|
||||
gZenUIManager.showToast('zen-copy-current-url-confirmation', { button });
|
||||
gZenUIManager.showToast('zen-copy-current-url-confirmation', { button, timeout: 3000 });
|
||||
}
|
||||
},
|
||||
copyCurrentURLAsMarkdownToClipboard() {
|
||||
|
||||
@@ -73,8 +73,8 @@ ZenCommonUtils::CanShare(bool* canShare) {
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ZenCommonUtils::Share(nsIURI* url, const nsACString& title,
|
||||
const nsACString& text, uint32_t aX, uint32_t aY) {
|
||||
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;
|
||||
@@ -82,15 +82,19 @@ ZenCommonUtils::Share(nsIURI* url, const nsACString& title,
|
||||
if (!IsSharingSupported()) {
|
||||
return NS_OK; // We don't want to throw an error here
|
||||
}
|
||||
return ShareInternal(aWindow, url, title, text, aX, aY);
|
||||
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) {
|
||||
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);
|
||||
return ::nsZenNativeShareInternal::ShowNativeDialog(
|
||||
aWindow, url, title, text,
|
||||
aX, aY, aWidth, aHeight
|
||||
);
|
||||
#else
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
#endif
|
||||
|
||||
@@ -40,7 +40,8 @@ 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)
|
||||
const nsACString& title, const nsACString& text, uint32_t aX, uint32_t aY,
|
||||
uint32_t aWidth, uint32_t aHeight)
|
||||
-> nsresult;
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ class nsZenNativeShareInternal final {
|
||||
* @returns void
|
||||
*/
|
||||
static auto ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* aUrl,
|
||||
const nsACString& aTitle, const nsACString& aText, uint32_t aX = 0, uint32_t aY = 0)
|
||||
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;
|
||||
|
||||
@@ -41,7 +41,8 @@ static nsresult GetNativeWindowPointerFromDOMWindow(mozIDOMWindowProxy* a_window
|
||||
}
|
||||
|
||||
auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aWindow,
|
||||
nsIURI* aUrl, const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY)
|
||||
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
|
||||
@@ -69,9 +70,9 @@ auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aW
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
// Create a rect for the sharing picker
|
||||
NSRect rect = NSMakeRect(aX, aY, 0, 0);
|
||||
NSRect rect = NSMakeRect(aX, aY, aWidth, aHeight);
|
||||
[sharingPicker showRelativeToRect:rect
|
||||
ofView:cocoaMru.contentView
|
||||
preferredEdge:NSMinYEdge];
|
||||
preferredEdge:NSMaxYEdge];
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ interface nsIZenCommonUtils : nsISupports {
|
||||
* @returns A promise that resolves when the share is complete.
|
||||
*/
|
||||
void share(in nsIURI url, in ACString title, in ACString text,
|
||||
in uint32_t x, in uint32_t y);
|
||||
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.
|
||||
* @param window The window to check.
|
||||
|
||||
@@ -19,8 +19,9 @@ inline NS_ConvertUTF8toUTF16 NS_ConvertUTF8toUTF16_MaybeVoid(
|
||||
}
|
||||
} // namespace: zen
|
||||
|
||||
auto nsZenNativeShareInternal::ShowNativeDialog(nsCOMPtr<mozIDOMWindowProxy>& aWindow, nsIURI* aUrl,
|
||||
const nsACString& aTitle, const nsACString& aText, uint32_t aX, uint32_t aY)
|
||||
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 {
|
||||
nsAutoCString urlString;
|
||||
if (aUrl) {
|
||||
|
||||
Reference in New Issue
Block a user