Demo/bin/Debug/front_end/elements_module.js
(开头部分) 297KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
WebInspector.InspectElementModeController=function()
{this._toggleSearchAction=WebInspector.actionRegistry.action("elements.toggle-element-search");if(Runtime.experiments.isEnabled("layoutEditor")){this._layoutEditorButton=new WebInspector.ToolbarButton(WebInspector.UIString("Toggle Layout Editor"),"layout-editor-toolbar-item");this._layoutEditorButton.addEventListener("click",this._toggleLayoutEditor,this);}
this._mode=DOMAgent.InspectMode.None;WebInspector.targetManager.addEventListener(WebInspector.TargetManager.Events.SuspendStateChanged,this._suspendStateChanged,this);WebInspector.targetManager.observeTargets(this,WebInspector.Target.Type.Page);}
WebInspector.InspectElementModeController.prototype={targetAdded:function(target)
{if(this._mode===DOMAgent.InspectMode.None)
return;var domModel=WebInspector.DOMModel.fromTarget(target);domModel.setInspectMode(this._mode);},targetRemoved:function(target)
{},isInInspectElementMode:function()
{return this._mode===DOMAgent.InspectMode.SearchForNode||this._mode===DOMAgent.InspectMode.SearchForUAShadowDOM;},isInLayoutEditorMode:function()
{return this._mode===DOMAgent.InspectMode.ShowLayoutEditor;},stopInspection:function()
{if(this._mode&&this._mode!==DOMAgent.InspectMode.None)
this._toggleInspectMode();},_toggleLayoutEditor:function()
{var mode=this.isInLayoutEditorMode()?DOMAgent.InspectMode.None:DOMAgent.InspectMode.ShowLayoutEditor;this._setMode(mode);},_toggleInspectMode:function()
{if(WebInspector.targetManager.allTargetsSuspended())
return;var mode;if(this.isInInspectElementMode())
mode=DOMAgent.InspectMode.None;else
mode=WebInspector.moduleSetting("showUAShadowDOM").get()?DOMAgent.InspectMode.SearchForUAShadowDOM:DOMAgent.InspectMode.SearchForNode;this._setMode(mode);},_setMode:function(mode)
{this._mode=mode;for(var domModel of WebInspector.DOMModel.instances())
domModel.setInspectMode(mode);if(this._layoutEditorButton){this._layoutEditorButton.setEnabled(!this.isInInspectElementMode());this._layoutEditorButton.setToggled(this.isInLayoutEditorMode());}
this._toggleSearchAction.setEnabled(!this.isInLayoutEditorMode());this._toggleSearchAction.setToggled(this.isInInspectElementMode());},_suspendStateChanged:function()
{if(!WebInspector.targetManager.allTargetsSuspended())
return;this._mode=DOMAgent.InspectMode.None;this._toggleSearchAction.setToggled(false);if(this._layoutEditorButton)
this._layoutEditorButton.setToggled(false);}}
WebInspector.InspectElementModeController.ToggleSearchActionDelegate=function()
{}
WebInspector.InspectElementModeController.ToggleSearchActionDelegate.prototype={handleAction:function(context,actionId)
{if(!WebInspector.inspectElementModeController)
return false;WebInspector.inspectElementModeController._toggleInspectMode();return true;}}
WebInspector.InspectElementModeController.LayoutEditorButtonProvider=function()
{}
WebInspector.InspectElementModeController.LayoutEditorButtonProvider.prototype={item:function()
{if(!WebInspector.inspectElementModeController)
return null;return WebInspector.inspectElementModeController._layoutEditorButton;}}
WebInspector.inspectElementModeController=Runtime.queryParam("isSharedWorker")?null:new WebInspector.InspectElementModeController();;WebInspector.BezierUI=function(width,height,marginTop,controlPointRadius,linearLine)
{this.width=width;this.height=height;this.marginTop=marginTop;this.radius=controlPointRadius;this.linearLine=linearLine;}
WebInspector.BezierUI.prototype={curveWidth:function()
{return this.width-this.radius*2;},curveHeight:function()
{return this.height-this.radius*2-this.marginTop*2;},_drawLine:function(parentElement,className,x1,y1,x2,y2)
{var line=parentElement.createSVGChild("line",className);line.setAttribute("x1",x1+this.radius);line.setAttribute("y1",y1+this.radius+this.marginTop);line.setAttribute("x2",x2+this.radius);line.setAttribute("y2",y2+this.radius+this.marginTop);},_drawControlPoints:function(parentElement,startX,startY,controlX,controlY)
{this._drawLine(parentElement,"bezier-control-line",startX,startY,controlX,controlY);var circle=parentElement.createSVGChild("circle","bezier-control-circle");circle.setAttribute("cx",controlX+this.radius);circle.setAttribute("cy",controlY+this.radius+this.marginTop);circle.setAttribute("r",this.radius);},drawCurve:function(bezier,svg)
{if(!bezier)
return;var width=this.curveWidth();var height=this.curveHeight();svg.setAttribute("width",this.width);svg.setAttribute("height",this.height);svg.removeChildren();var group=svg.createSVGChild("g");if(this.linearLine)
this._drawLine(group,"linear-line",0,height,width,0);var curve=group.createSVGChild("path","bezier-path");var curvePoints=[new WebInspector.Geometry.Point(bezier.controlPoints[0].x*width+this.radius,(1-bezier.controlPoints[0].y)*height+this.radius+this.marginTop),new WebInspector.Geometry.Point(bezier.controlPoints[1].x*width+this.radius,(1-bezier.controlPoints[1].y)*height+this.radius+this.marginTop),new WebInspector.Geometry.Point(width+this.radius,this.marginTop+this.radius)];curve.setAttribute("d","M"+this.radius+","+(height+this.radius+this.marginTop)+" C"+curvePoints.join(" "));this._drawControlPoints(group,0,height,bezier.controlPoints[0].x*width,(1-bezier.controlPoints[0].y)*height);this._drawControlPoints(group,width,0,bezier.controlPoints[1].x*width,(1-bezier.controlPoints[1].y)*height);}}
WebInspector.BezierUI.Height=26;WebInspector.BezierUI.drawVelocityChart=function(bezier,path,width)
{var height=WebInspector.BezierUI.Height;var pathBuilder=["M",0,height];const sampleSize=1/40;var prev=bezier.evaluateAt(0);for(var t=sampleSize;t<1+sampleSize;t+=sampleSize){var current=bezier.evaluateAt(t);var slope=(current.y-prev.y)/(current.x-prev.x);var weightedX=prev.x*(1-t)+current.x*t;slope=Math.tanh(slope/1.5);pathBuilder=pathBuilder.concat(["L",(weightedX*width).toFixed(2),(height-slope*height).toFixed(2)]);prev=current;}
pathBuilder=pathBuilder.concat(["L",width.toFixed(2),height,"Z"]);path.setAttribute("d",pathBuilder.join(" "));};WebInspector.StylesPopoverHelper=function()
{this._popover=new WebInspector.Popover();this._popover.setCanShrink(false);this._popover.setNoMargins(true);this._popover.element.addEventListener("mousedown",consumeEvent,false);this._hideProxy=this.hide.bind(this,true);this._boundOnKeyDown=this._onKeyDown.bind(this);this._repositionBound=this.reposition.bind(this);this._boundFocusOut=this._onFocusOut.bind(this);}
WebInspector.StylesPopoverHelper.prototype={_onFocusOut:function(event)
{if(!event.relatedTarget||event.relatedTarget.isSelfOrDescendant(this._view.contentElement))
return;this._hideProxy();},isShowing:function()
{return this._popover.isShowing();},show:function(view,anchorElement,hiddenCallback)
{if(this._popover.isShowing()){if(this._anchorElement===anchorElement)
return;this.hide(true);}
delete this._isHidden;this._anchorElement=anchorElement;this._view=view;this._hiddenCallback=hiddenCallback;this.reposition();var document=this._popover.element.ownerDocument;document.addEventListener("mousedown",this._hideProxy,false);document.defaultView.addEventListener("resize",this._hideProxy,false);this._view.contentElement.addEventListener("keydown",this._boundOnKeyDown,false);this._scrollerElement=anchorElement.enclosingNodeOrSelfWithClass("style-panes-wrapper");if(this._scrollerElement)
this._scrollerElement.addEventListener("scroll",this._repositionBound,false);},reposition:function(event)
{if(!this._previousFocusElement)
this._previousFocusElement=WebInspector.currentFocusElement();this._view.contentElement.removeEventListener("focusout",this._boundFocusOut,false);this._popover.showView(this._view,this._anchorElement);this._view.contentElement.addEventListener("focusout",this._boundFocusOut,false);WebInspector.setCurrentFocusElement(this._view.contentElement);},hide:function(commitEdit)
{if(this._isHidden)
return;var document=this._popover.element.ownerDocument;this._isHidden=true;this._popover.hide();if(this._scrollerElement)
this._scrollerElement.removeEventListener("scroll",this._repositionBound,false);document.removeEventListener("mousedown",this._hideProxy,false);document.defaultView.removeEventListener("resize",this._hideProxy,false);if(this._hiddenCallback)
this._hiddenCallback.call(null,!!commitEdit);WebInspector.setCurrentFocusElement(this._previousFocusElement);delete this._previousFocusElement;delete this._anchorElement;if(this._view){this._view.detach();this._view.contentElement.removeEventListener("keydown",this._boundOnKeyDown,false);this._view.contentElement.removeEventListener("focusout",this._boundFocusOut,false);delete this._view;}},_onKeyDown:function(event)
后面还有 1788+ 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。