Closed Bug 284695 Opened 20 years ago Closed 20 years ago

Move GetMainWidget() to nsGlobalWindow, and do some random code cleanup

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jst, Assigned: jst)

Details

Attachments

(2 files)

There's one place in nsGlobalWindow that could use GetMainWidget(), so that
should be moved from nsGlobalChromeWindow to nsGlobalWindow. And while I was
staring at this code I found a few other minor things to clean up, and a warning
to quiet down... Patch coming up.
Attached patch Fix.Splinter Review
Attachment #176211 - Flags: superreview?(peterv)
Attachment #176211 - Flags: review?(peterv)
Comment on attachment 176211 [details] [diff] [review]
Fix (diff -w for review).

>Index: dom/src/base/nsGlobalWindow.cpp
>===================================================================

>@@ -3476,63 +3483,58 @@ nsGlobalWindow::Close()

>+    // UniversalBrowserWrite will be enabled if it's been explicityl

explicitly

>           if (stringBundleService) {
>             nsCOMPtr<nsIStringBundle> stringBundle;
>-            rv = stringBundleService->CreateBundle(
>-                                        kDOMSecurityWarningsBundleURL,
>+          rv = stringBundleService->CreateBundle(kDOMSecurityWarningsBundleURL,
>                                         getter_AddRefs(stringBundle));
>-            if (NS_SUCCEEDED(rv) && stringBundle) {
>+          if (stringBundle) {

No need to set rv to the result of CreateBundle, you're not using it anymore.

> NS_IMETHODIMP
> nsGlobalChromeWindow::Maximize()
> {
>-  nsCOMPtr<nsIWidget> widget;
>-  nsresult rv = GetMainWidget(getter_AddRefs(widget));
>+  nsCOMPtr<nsIWidget> widget = GetMainWidget();
> 
>   if (widget) {
>-    rv = widget->SetSizeMode(nsSizeMode_Maximized);
>+    widget->SetSizeMode(nsSizeMode_Maximized);
>   }
> 
>-  return rv;
>+  return NS_OK;

Don't we want to propagate the error here?

> }
> 
> NS_IMETHODIMP
> nsGlobalChromeWindow::Minimize()
> {
>-  nsCOMPtr<nsIWidget> widget;
>-  nsresult rv = GetMainWidget(getter_AddRefs(widget));
>+  nsCOMPtr<nsIWidget> widget = GetMainWidget();
> 
>   if (widget) {
>     // minimize doesn't send deactivate events on windows,
>     // so we need to forcefully restore the os chrome
>     nsCOMPtr<nsIFullScreen> fullScreen =
>       do_GetService("@mozilla.org/browser/fullscreen;1");
>     if (fullScreen)
>       fullScreen->ShowAllOSChrome();
> 
>-    rv = widget->SetSizeMode(nsSizeMode_Minimized);
>+    widget->SetSizeMode(nsSizeMode_Minimized);
>   }
> 
>-  return rv;
>+  return NS_OK;

Or here?

> }
> 
> NS_IMETHODIMP
> nsGlobalChromeWindow::Restore()
> {
>-  nsCOMPtr<nsIWidget> widget;
>-  nsresult rv = GetMainWidget(getter_AddRefs(widget));
>+  nsCOMPtr<nsIWidget> widget = GetMainWidget();
> 
>   if (widget) {
>-    rv = widget->SetSizeMode(nsSizeMode_Normal);
>+    widget->SetSizeMode(nsSizeMode_Normal);
>   }
> 
>-  return rv;
>+  return NS_OK;

Or here?

> }
> 
> NS_IMETHODIMP
> nsGlobalChromeWindow::GetAttention()
> {
>   return GetAttentionWithCycleCount(-1);
> }
> 
> NS_IMETHODIMP
> nsGlobalChromeWindow::GetAttentionWithCycleCount(PRInt32 aCycleCount)
> {
>-  nsCOMPtr<nsIWidget> widget;
>-  nsresult rv = GetMainWidget(getter_AddRefs(widget));
>+  nsCOMPtr<nsIWidget> widget = GetMainWidget();
> 
>   if (widget) {
>-    rv = widget->GetAttention(aCycleCount);
>+    widget->GetAttention(aCycleCount);
>   }
> 
>-  return rv;
>+  return NS_OK;

Or here?
Attachment #176211 - Flags: superreview?(peterv)
Attachment #176211 - Flags: superreview+
Attachment #176211 - Flags: review?(peterv)
Attachment #176211 - Flags: review+
Sure, changed all that :)

FIXED.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: