Closed Bug 1002772 Opened 10 years ago Closed 10 years ago

Don't set document's lang and dir in Homescreen

Categories

(Firefox OS Graveyard :: Gaia::Homescreen, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: stas, Assigned: stas)

References

Details

Attachments

(1 file, 1 obsolete file)

Bug 914414 made the localization library take care of setting the lang and dir of the document, so we can remove that from the Homescreen app.
Depends on: 993188
Attached patch Remove land and dir setting (obsolete) — Splinter Review
Pull request: https://github.com/mozilla-b2g/gaia/pull/18765
Assignee: nobody → stas
Status: NEW → ASSIGNED
Attachment #8414057 - Flags: review?(21)
Comment on attachment 8414057 [details] [diff] [review]
Remove land and dir setting

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

LGTM.
Attachment #8414057 - Flags: review?(21) → review+
Comment on attachment 8414057 [details] [diff] [review]
Remove land and dir setting

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

::: apps/homescreen/js/homescreen.js
@@ +8,3 @@
>    var iconGrid = document.getElementById('icongrid');
>  
> +  navigator.mozL10n.ready(GridManager.localize.bind(GridManager));

Alas, this doesn't work.  My bad, fortunately Travis caught it.

GridManager isn't defined when this line is run.  This used to work because in the old code, GridManager was referenced in the closure.  It was just lucky that mozL10n.ready takes a while to fire, and when it did, GridManager was already defined (at least most of the time).

I'll have a new patch in a few.
Attached patch Fixed patchSplinter Review
In this patch, GridManager.localize() is called a bit later, in the callback to GridManager.init().  This ensures that GridManager is defined and all the required Icons have already been created.

Before mozL10n.ready() was fixed (bug 993188) it made slightly more sense to call it early on -- this way it registered a hadnler to the localized event instead of just invoking the callback and returning.  With the new behavior, the callback is guaranteed to be registered as a handler, and also will be invoked on the next turn of the event loop if the localization is ready.
Attachment #8414057 - Attachment is obsolete: true
Attachment #8415342 - Flags: review?(21)
Comment on attachment 8415342 [details] [diff] [review]
Fixed patch

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

r+ with one nit.

::: apps/homescreen/js/homescreen.js
@@ +32,4 @@
>      };
>  
>      GridManager.init(options, function gm_init() {
> +      navigator.mozL10n.ready(GridManager.localize.bind(GridManager));

s/GridManager/this/g
Attachment #8415342 - Flags: review?(21) → review+
(In reply to Vivien Nicolas (:vingtetun) (:21) (NOT reading bugmails, needinfo? please) from comment #5)

> s/GridManager/this/g

The gm_init callback is called with the global object as 'this' [1] so I think using GridManager in that line is correct?

[1] https://github.com/mozilla-b2g/gaia/blob/800800b332d03580f4f8748e5046d71f00a3c7d9/apps/homescreen/js/grid.js#L1080
(In reply to Staś Małolepszy :stas from comment #6)
> (In reply to Vivien Nicolas (:vingtetun) (:21) (NOT reading bugmails,
> needinfo? please) from comment #5)
> 
> > s/GridManager/this/g
> 
> The gm_init callback is called with the global object as 'this' [1] so I
> think using GridManager in that line is correct?
> 
> [1]
> https://github.com/mozilla-b2g/gaia/blob/
> 800800b332d03580f4f8748e5046d71f00a3c7d9/apps/homescreen/js/grid.js#L1080

Vivien, could you explain the rationale behind the s/GridManager/this/g nit?
Flags: needinfo?(21)
(In reply to Staś Małolepszy :stas from comment #7)
> (In reply to Staś Małolepszy :stas from comment #6)
> > (In reply to Vivien Nicolas (:vingtetun) (:21) (NOT reading bugmails,
> > needinfo? please) from comment #5)
> > 
> > > s/GridManager/this/g
> > 
> > The gm_init callback is called with the global object as 'this' [1] so I
> > think using GridManager in that line is correct?
> > 
> > [1]
> > https://github.com/mozilla-b2g/gaia/blob/
> > 800800b332d03580f4f8748e5046d71f00a3c7d9/apps/homescreen/js/grid.js#L1080
> 
> Vivien, could you explain the rationale behind the s/GridManager/this/g nit?

Oh man. I thought we were into GridManager = {
 init: function() ...
}

Forgot about that.
Flags: needinfo?(21)
Cool, I just wanted to make sure.  I'll land the patch as-is.  Thanks!
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: