Closed Bug 858524 Opened 11 years ago Closed 11 years ago

Move BarProp objects to Paris bindings

Categories

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

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: Ms2ger, Assigned: baku)

References

(Blocks 1 open bug)

Details

Attachments

(2 files, 6 obsolete files)

Anyone?
Assignee: nobody → amarchesini
Attached patch part 1 - renaming (obsolete) (deleted) — Splinter Review
Attachment #754925 - Flags: review?(Ms2ger)
Attached patch part 2 - webidl (obsolete) (deleted) — Splinter Review
Attachment #754927 - Flags: review?(Ms2ger)
In the first patch there is an indentation issue but I don't want to submit a new patch just for this.
Comment on attachment 754927 [details] [diff] [review]
part 2 - webidl

Review of attachment 754927 [details] [diff] [review]:
-----------------------------------------------------------------

Just a brief look; I'll try finishing tonight or tomorrow.

::: dom/base/BarProps.cpp
@@ +265,5 @@
>          scroller->GetDefaultScrollbarPreferences(
>                      nsIScrollable::ScrollOrientation_X, &prefValue);
>  
>        if (prefValue == nsIScrollable::Scrollbar_Never)
> +        return false;

With a few early returns, you could deindent this quite a bit, it seems.

::: dom/base/BarProps.h
@@ +38,4 @@
>  
> +  nsPIDOMWindow* GetParentObject() const;
> +
> +  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;

MOZ_FINAL too, I think

::: xpfe/appshell/src/nsXULWindow.cpp
@@ +1987,3 @@
>      contentWin->GetScrollbars(getter_AddRefs(scrollbars));
> +    nsRefPtr<mozilla::dom::BarProp> barProp =
> +      static_cast<mozilla::dom::BarProp*>(scrollbars.get());

I don't like this. If you want to get rid of the interface, can you please add getters on nsPIDOMWindow that return a dom::BarProp* directly? We'll need them for Window anyway.
Attached patch part 2 - webidl (obsolete) (deleted) — Splinter Review
Attachment #754927 - Attachment is obsolete: true
Attachment #754927 - Flags: review?(Ms2ger)
Attachment #755394 - Flags: review?(Ms2ger)
Comment on attachment 754925 [details] [diff] [review]
part 1 - renaming

Review of attachment 754925 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/base/BarProps.cpp
@@ +119,1 @@
>                                       nsIWebBrowserChrome::CHROME_MENUBAR);

Indentation

::: dom/base/BarProps.h
@@ +9,5 @@
>     the appropriate property (window.menubar.visible)
>  */
>  
> +#ifndef mozilla_dom_BarProps_h___
> +#define mozilla_dom_BarProps_h___

Please drop the trailing underscores while you're here

::: dom/base/moz.build
@@ +69,5 @@
>      'DOMError.cpp',
>      'DOMRequest.cpp',
>      'Navigator.cpp',
>      'URL.cpp',
> +    'BarProps.cpp',

Sort

::: dom/base/nsGlobalWindow.h
@@ +1178,5 @@
> +  nsRefPtr<nsDOMWindowUtils>      mWindowUtils;
> +  nsString                        mStatus;
> +  nsString                        mDefaultStatus;
> +  nsGlobalWindowObserver*         mObserver;
> +  nsCOMPtr<nsIDOMCrypto>          mCrypto;

Leave the others alone, please.
Attachment #754925 - Flags: review?(Ms2ger) → review+
Comment on attachment 755394 [details] [diff] [review]
part 2 - webidl

Review of attachment 755394 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/base/BarProps.cpp
@@ +40,5 @@
> +{
> +  return BarPropBinding::Wrap(aCx, aScope, this);
> +}
> +
> +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(BarProp)

Why don't you need to CC the window?

@@ +255,2 @@
>    nsCOMPtr<nsIDOMWindow> domwin(do_QueryReferent(mDOMWindowWeakref));
> +  if (!domwin) { // dom window not deleted

Drop the comment or at least reverse its meaning

@@ +265,5 @@
> +  }
> +
> +  int32_t prefValue;
> +  scroller->GetDefaultScrollbarPreferences(
> +              nsIScrollable::ScrollOrientation_Y, &prefValue);

if (prefValue != nsIScrollable::Scrollbar_Never) {
  return true;
}

@@ +271,5 @@
> +    scroller->GetDefaultScrollbarPreferences(
> +                nsIScrollable::ScrollOrientation_X, &prefValue);
> +  }
> +
> +  return !(prefValue == nsIScrollable::Scrollbar_Never);

prefValue != nsIScrollable::Scrollbar_Never

::: dom/base/BarProps.h
@@ +38,4 @@
>  
> +  nsPIDOMWindow* GetParentObject() const;
> +
> +  virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;

That goes over 80 columns

::: dom/base/nsGlobalWindow.cpp
@@ +3697,5 @@
> +
> +  *aScrollbars = Scrollbars();
> +  if (!*aScrollbars) {
> +    return NS_ERROR_OUT_OF_MEMORY;
> +  }

Drop this

::: dom/interfaces/base/nsIDOMWindow.idl
@@ +52,5 @@
>    readonly attribute nsIDOMHistory                      history;
>  
>  
>    /* [replaceable] locationbar */
> +  readonly attribute nsISupports                        locationbar;

Add /* BarProp */ for all those

::: dom/webidl/BarProp.webidl
@@ +6,5 @@
> +
> +interface BarProp
> +{
> +           [Throws]
> +           attribute boolean          visible;

Use

  [Throws]
           attribute boolean visible;

::: xpfe/appshell/src/nsXULWindow.cpp
@@ +1981,5 @@
>  }
>  
>  void nsXULWindow::SetContentScrollbarVisibility(bool aVisible)
>  {
>    nsCOMPtr<nsIDOMWindow> contentWin(do_GetInterface(mPrimaryContentShell));

Make this nsPIDOMWindow; the cast isn't safe otherwise.
Attachment #755394 - Flags: review?(Ms2ger) → review+
Attached patch part 1 - renaming (deleted) — Splinter Review
Attachment #754925 - Attachment is obsolete: true
Attachment #756485 - Flags: review+
Attached patch part 2 - webidl (obsolete) (deleted) — Splinter Review
Attachment #755394 - Attachment is obsolete: true
Attachment #756488 - Flags: review+
> @@ +40,5 @@
> > +{
> > +  return BarPropBinding::Wrap(aCx, aScope, this);
> > +}
> > +
> > +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_0(BarProp)
> 
> Why don't you need to CC the window?

because mDOMWindow is a raw pointer. There is a comment too. Can you give a glance to this and tell me if we should change it to nsRefPtr<>.
Attachment #756488 - Flags: review+ → review?(Ms2ger)
Comment on attachment 756488 [details] [diff] [review]
part 2 - webidl

Smaug, can you tell me if the use of mDOMWindow without refcount, is right here?
Attachment #756488 - Flags: review?(Ms2ger) → review?(bugs)
nsRefPtr<nsGlobalWindow> mDOMWindow would be good and then drop also the weakref.
Comment on attachment 756488 [details] [diff] [review]
part 2 - webidl

I think I'd like to even see such change before adding new use for mDOMWindow
Attachment #756488 - Flags: review?(bugs) → review-
Attached patch part 2 - webidl (obsolete) (deleted) — Splinter Review
Attachment #756488 - Attachment is obsolete: true
Attachment #756519 - Flags: review?(bugs)
Comment on attachment 756519 [details] [diff] [review]
part 2 - webidl


> already_AddRefed<nsIWebBrowserChrome>
> BarProp::GetBrowserChrome()
> {
>-  // Check that the window is still alive.
>-  nsCOMPtr<nsIDOMWindow> domwin(do_QueryReferent(mDOMWindowWeakref));
>-  if (!domwin)
>-    return nullptr;
>-
>   return mDOMWindow->GetWebBrowserChrome();
Null-check mDOMWindow

>+bool
>+ScrollbarsProp::GetVisible(ErrorResult& aRv)
> {
>-  *aVisible = true; // one assumes
>+  nsCOMPtr<nsIScrollable> scroller =
>+    do_QueryInterface(mDOMWindow->GetDocShell());
Null-check mDOMWindow

>+  nsCOMPtr<nsIScrollable> scroller =
>+    do_QueryInterface(mDOMWindow->GetDocShell());
ditto
>+'BarProp': {
>+    'headerFile': 'mozilla/dom/BarProps.h',
>+},
Hmm, why do we need this. Shouldn't mozilla/dom/BarProps.h be the default value


>+interface BarProp
>+{
>+  [Throws]
>+           attribute boolean          visible;
odd indentation


nsGlobalWindow should traverse/unlink various *Bars
Attachment #756519 - Flags: review?(bugs) → review+
> >+'BarProp': {
> >+    'headerFile': 'mozilla/dom/BarProps.h',
> >+},
> Hmm, why do we need this. Shouldn't mozilla/dom/BarProps.h be the default
> value

Because the object is called 'BarProp' but the header 'BarProps.h' (plural).

> >+interface BarProp
> >+{
> >+  [Throws]
> >+           attribute boolean          visible;
> odd indentation

This is the standard indentation for webidl files. Check the comment written by Ms2ger.
Attached patch part 2 - webidl (obsolete) (deleted) — Splinter Review
Attachment #756519 - Attachment is obsolete: true
Attachment #756893 - Flags: review+
Keywords: checkin-needed
Comment on attachment 756893 [details] [diff] [review]
part 2 - webidl

Review of attachment 756893 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/webidl/BarProp.webidl
@@ +6,5 @@
> +
> +interface BarProp
> +{
> +  [Throws]
> +           attribute boolean          visible;

Just one space between 'boolean' and 'visible'.
Attached patch part 2 - webidl (deleted) — Splinter Review
Attachment #756893 - Attachment is obsolete: true
Attachment #756939 - Flags: review+
https://hg.mozilla.org/mozilla-central/rev/5eb5520a8ff4
https://hg.mozilla.org/mozilla-central/rev/a92e9a47f2c2
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla24
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: