{"size": 2832, "ext": "js", "max_stars_repo_path": "b2g_sdk/x86_64/b2g/modules/devtools/gcli/commands/highlight.js", "max_stars_repo_name": "yonglongliu/gaia", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "b2g_sdk/x86_64/b2g/modules/devtools/gcli/commands/highlight.js", "max_issues_repo_name": "yonglongliu/gaia", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "b2g_sdk/x86_64/b2g/modules/devtools/gcli/commands/highlight.js", "max_forks_repo_name": "yonglongliu/gaia", "max_forks_repo_forks_event_min_datetime": "2019-03-31T04:27:13.000Z", "max_forks_repo_forks_event_max_datetime": "2020-04-12T17:58:15.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 3, "avg_line_length": 283.2, "max_line_length": 1209, "alphanum_fraction": 0.8082627119}
"use strict";const{Cc,Ci,Cu}=require("chrome");const gcli=require("gcli/index");require("devtools/server/actors/inspector");const{BoxModelHighlighter}=require("devtools/server/actors/highlighter");XPCOMUtils.defineLazyGetter(this,"nodesSelected",function(){return Services.strings.createBundle("chrome://browser/locale/devtools/gclicommands.properties");});XPCOMUtils.defineLazyModuleGetter(this,"PluralForm","resource://gre/modules/PluralForm.jsm");const MAX_HIGHLIGHTED_ELEMENTS=100;
exports.highlighters=[];function unhighlightAll(){for(let highlighter of exports.highlighters){highlighter.destroy();}
exports.highlighters.length=0;}
exports.items=[{name:"highlight",description:gcli.lookup("highlightDesc"),manual:gcli.lookup("highlightManual"),params:[{name:"selector",type:"nodelist",description:gcli.lookup("highlightSelectorDesc"),manual:gcli.lookup("highlightSelectorManual")},{group:gcli.lookup("highlightOptionsDesc"),params:[{name:"hideguides",type:"boolean",description:gcli.lookup("highlightHideGuidesDesc"),manual:gcli.lookup("highlightHideGuidesManual")},{name:"showinfobar",type:"boolean",description:gcli.lookup("highlightShowInfoBarDesc"),manual:gcli.lookup("highlightShowInfoBarManual")},{name:"showall",type:"boolean",description:gcli.lookup("highlightShowAllDesc"),manual:gcli.lookup("highlightShowAllManual")},{name:"region",type:{name:"selection",data:["content","padding","border","margin"]},description:gcli.lookup("highlightRegionDesc"),manual:gcli.lookup("highlightRegionManual"),defaultValue:"border"},{name:"fill",type:"string",description:gcli.lookup("highlightFillDesc"),manual:gcli.lookup("highlightFillManual"),defaultValue:null},{name:"keep",type:"boolean",description:gcli.lookup("highlightKeepDesc"),manual:gcli.lookup("highlightKeepManual"),}]}],exec:function(args,context){ if(!args.keep){unhighlightAll();}
let env=context.environment; env.target.once("navigate",unhighlightAll);
let tabContext={browser:env.chromeWindow.gBrowser.getBrowserForDocument(env.document),window:env.window};let i=0;for(let node of args.selector){if(!args.showall&&i>=MAX_HIGHLIGHTED_ELEMENTS){break;}
let highlighter=new BoxModelHighlighter(tabContext);if(args.fill){highlighter.regionFill[args.region]=args.fill;}
highlighter.show(node,{region:args.region,hideInfoBar:!args.showinfobar,hideGuides:args.hideguides,showOnly:args.region});exports.highlighters.push(highlighter);i++;}
let highlightText=nodesSelected.GetStringFromName("highlightOutputConfirm2");let output=PluralForm.get(args.selector.length,highlightText).replace("%1$S",args.selector.length);if(args.selector.length>i){output=gcli.lookupFormat("highlightOutputMaxReached",[""+args.selector.length,""+i]);}
return output;}},{name:"unhighlight",description:gcli.lookup("unhighlightDesc"),manual:gcli.lookup("unhighlightManual"),exec:unhighlightAll}];