After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 679944 - A lot of looking glass cleanups
A lot of looking glass cleanups
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-07-15 02:11 UTC by Jasper St. Pierre (not reading bugmail)
Modified: 2013-03-03 21:14 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
lookingGlass: Use a more standard chevron (1.74 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
lookingGlass: Remove old signal handler (1.07 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
link: Remove (5.23 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
lookingGlass: Don't use a global (8.37 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
lookingGlass: Use one red border effect (3.22 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review
lookingGlass: Don't use a command header (11.74 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
lookingGlass: Split off the Evaluator tab into its own class (18.47 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
reviewed Details | Review
lookingGlass: Keep track of tabs, not children (7.24 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
lookingGlass: Align the inspector results to the bottom (1.46 KB, patch)
2012-07-15 02:11 UTC, Jasper St. Pierre (not reading bugmail)
accepted-commit_now Details | Review
util: Remove unused imports (692 bytes, patch)
2012-07-15 02:12 UTC, Jasper St. Pierre (not reading bugmail)
committed Details | Review

Description Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:34 UTC
I started by trying to have a standard chevron and align results to the
bottom, and then this happened.
Comment 1 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:36 UTC
Created attachment 218830 [details] [review]
lookingGlass: Use a more standard chevron

'>>>' is used by the REPL history (as well as plenty of other REPLs).
Using 'js>>>' to enter things makes the history look unaligned and strange.
Comment 2 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:39 UTC
Created attachment 218831 [details] [review]
lookingGlass: Remove old signal handler

This 'selected' signal is from the days of the "Heirarchy" tab, before
it was replaced by the "Windows" tab. Those were the days.
Comment 3 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:41 UTC
Created attachment 218832 [details] [review]
link: Remove

The looking glass is the only consumer of the Link, and it's such a
basic wrapper around a button that it's not worth it.
Comment 4 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:44 UTC
Created attachment 218833 [details] [review]
lookingGlass: Don't use a global

As part of wanting to reuse some of the looking glass components,
don't use Main.lookingGlass, but instead pass the parent around.
Don't adjust the evaluator just yet, though. We'll split it into
a separate class soon.
Comment 5 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:47 UTC
Created attachment 218834 [details] [review]
lookingGlass: Use one red border effect

This makes the code a bit cleaner, and reduces the chances of
having a border effect "leaking", or having two at the same time.
Comment 6 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:49 UTC
Created attachment 218835 [details] [review]
lookingGlass: Don't use a command header

Instead, explicitly create a custom scope for the eval, which has the
declarations we need. This prevents leaking unintended things into the
eval call, and also will help us not rely on a global LookingGlass for
'it' and 'r'.
Comment 7 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:53 UTC
Created attachment 218836 [details] [review]
lookingGlass: Split off the Evaluator tab into its own class
Comment 8 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:55 UTC
Created attachment 218837 [details] [review]
lookingGlass: Keep track of tabs, not children

Code cleanups
Comment 9 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:11:59 UTC
Created attachment 218838 [details] [review]
lookingGlass: Align the inspector results to the bottom
Comment 10 Jasper St. Pierre (not reading bugmail) 2012-07-15 02:12:01 UTC
Created attachment 218839 [details] [review]
util: Remove unused imports
Comment 11 Colin Walters 2012-07-15 11:49:33 UTC
Review of attachment 218830 [details] [review]:

I think I originally had it that way but someone asked it to change...anyways this sounds fine =)
Comment 12 Colin Walters 2012-07-15 11:52:35 UTC
Review of attachment 218831 [details] [review]:

Confirmed.
Comment 13 Colin Walters 2012-07-15 11:53:03 UTC
Review of attachment 218832 [details] [review]:

Ah, that's some old code dead now, nice.
Comment 14 Colin Walters 2012-07-15 11:54:41 UTC
Review of attachment 218833 [details] [review]:

Ok; I'm curious what the reuse is.
Comment 15 Colin Walters 2012-07-15 11:56:08 UTC
Review of attachment 218834 [details] [review]:

Odd that we had it in two places.  Ok.
Comment 16 Colin Walters 2012-07-15 12:04:11 UTC
Review of attachment 218835 [details] [review]:

::: js/misc/jsParse.js
@@ +2,3 @@
 
+function scopedEval(scope, expr) {
+    let func = new Function('with(this) { return ' + expr + '; }');

So the JS compiler people really, really hate "with", because it makes all sorts of optimizations much harder.

https://developer.mozilla.org/en/JavaScript/Reference/Statements/with

"Using with is not recommended, and is forbidden in ECMAScript 5 strict mode."

In this case, can't we expand the complete text of GLOBAL_SCOPE into each scopedEval, rather than evaluating it at global scope and passing that object down as "with" context?
Comment 17 Colin Walters 2012-07-15 12:05:10 UTC
Review of attachment 218836 [details] [review]:

::: js/ui/lookingGlass.js
@@ +1167,3 @@
             return;
 
+        if (!Main.pushModal(this.actor))

Hm, does it really work to call Main.pushModal() on a container actor and not the entry itself?
Comment 18 Colin Walters 2012-07-15 12:05:56 UTC
Review of attachment 218837 [details] [review]:

Looks fine.
Comment 19 Colin Walters 2012-07-15 12:07:02 UTC
Review of attachment 218838 [details] [review]:

The second hunk has nothing to do with alignment, but eh...I won't mind if you sneak it in.
Comment 20 Colin Walters 2012-07-15 12:07:19 UTC
Review of attachment 218839 [details] [review]:

Go go gadget commit.
Comment 21 Jasper St. Pierre (not reading bugmail) 2012-07-15 16:21:30 UTC
(In reply to comment #16)
> Review of attachment 218835 [details] [review]:
> 
> ::: js/misc/jsParse.js
> @@ +2,3 @@
> 
> +function scopedEval(scope, expr) {
> +    let func = new Function('with(this) { return ' + expr + '; }');
> 
> So the JS compiler people really, really hate "with", because it makes all
> sorts of optimizations much harder.
> 
> https://developer.mozilla.org/en/JavaScript/Reference/Statements/with
> 
> "Using with is not recommended, and is forbidden in ECMAScript 5 strict mode."

I hate 'with' too, but I also hate 'eval' and things. I don't know of any way to lock the scope of an eval, so that 'a = global.get_window_actors()' doesn't get punted to the global object.

> In this case, can't we expand the complete text of GLOBAL_SCOPE into each
> scopedEval, rather than evaluating it at global scope and passing that object
> down as "with" context?

Something that does assignment, like our 'a = global.get_window_actors()' above, won't stick otherwise.

(In reply to comment #17)
> Review of attachment 218836 [details] [review]:
> 
> ::: js/ui/lookingGlass.js
> @@ +1167,3 @@
>              return;
> 
> +        if (!Main.pushModal(this.actor))
> 
> Hm, does it really work to call Main.pushModal() on a container actor and not
> the entry itself?

Since I navigate focus to the tab itself, afterwards in selectIndex, yes.
(In reply to comment #19)
> Review of attachment 218838 [details] [review]:
> 
> The second hunk has nothing to do with alignment, but eh...I won't mind if you
> sneak it in.

It does, though. Since I'm adding an actor, I can't just use get_children().length and destroy the first child, otherwise the bin will be destroyed.
Comment 22 Colin Walters 2012-07-15 17:36:57 UTC
(In reply to comment #21)

> I hate 'with' too, but I also hate 'eval' and things. 

The main problem with JavaScript's eval is that it might affect local scope, which means it has the same problems as "with".  See:

http://whereswalden.com/2011/01/10/new-es5-strict-mode-support-new-vars-created-by-strict-mode-eval-code-are-local-to-that-code-only/

Other languages like Scheme don't have that problem.

> I don't know of any way
> to lock the scope of an eval, so that 'a = global.get_window_actors()' doesn't
> get punted to the global object.

Right.  That concern makes sense...if you think it's worth using "with" for that, then that's OK by me.  But if we were moving towards strict mode (which might make sense eventually), we'd have to drop "with".
Comment 23 Colin Walters 2012-07-15 17:37:23 UTC
(Feel free to commit either way)
Comment 24 Jasper St. Pierre (not reading bugmail) 2012-07-17 00:40:16 UTC
Attachment 218830 [details] pushed as 8b81f23 - lookingGlass: Use a more standard chevron
Attachment 218831 [details] pushed as 4f7c554 - lookingGlass: Remove old signal handler
Attachment 218832 [details] pushed as 75d0362 - link: Remove
Attachment 218833 [details] pushed as d0807c8 - lookingGlass: Don't use a global
Attachment 218834 [details] pushed as 360e6e7 - lookingGlass: Use one red border effect
Comment 25 Jasper St. Pierre (not reading bugmail) 2012-07-17 16:14:30 UTC
Comment on attachment 218839 [details] [review]
util: Remove unused imports

Attachment 218839 [details] pushed as 76472b8 - util: Remove unused imports
Comment 26 Jasper St. Pierre (not reading bugmail) 2013-03-03 21:14:37 UTC
Let's close this as the eval changes were bad.