Files
palemoon27/browser/components/statusbar/content/urlbarBindings.xml
T
2018-07-25 01:30:56 +08:00

339 lines
10 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!-- This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
<bindings id="status4evar-bindings"
xmlns="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns:xbl="http://www.mozilla.org/xbl">
<binding id="urlbar" extends="chrome://browser/content/urlbarBindings.xml#urlbar">
<content sizetopopup="pref">
<xul:stack anonid="stack" class="progress-stack" flex="1">
<xul:vbox class="urlbar-progress-layer" xbl:inherits="pack=pmpack" flex="1">
<children includes="progressmeter"/>
</xul:vbox>
<xul:hbox anonid="urlbar-input-layer" flex="1">
<xul:hbox anonid="textbox-container" class="autocomplete-textbox-container urlbar-textbox-container" flex="1" xbl:inherits="focused">
<children includes="image|deck|stack|box">
<xul:image class="autocomplete-icon" allowevents="true"/>
</children>
<xul:stack anonid="stack" class="urlbar-stack" flex="1">
<xul:hbox anonid="over-link-layer" class="urlbar-textbox-container urlbar-over-link-layer" xbl:inherits="overlinkstate" flex="1">
<xul:hbox class="urlbar-origin-box" align="center" flex="1">
<xul:label anonid="origin-label" class="urlbar-origin-label" flex="1" crop="end"/>
</xul:hbox>
<xul:hbox anonid="over-link-box" class="urlbar-over-link-box uri-element-right-align" align="center">
<xul:label anonid="over-link-host-label" class="urlbar-over-link-host-label uri-element-right-align"/>
<xul:label anonid="over-link-path-label" class="urlbar-over-link-path-label uri-element-right-align" flex="1"/>
</xul:hbox>
</xul:hbox>
<xul:hbox class="urlbar-textbox-container urlbar-input-layer" xbl:inherits="focused,overlinkstate" flex="1">
<xul:hbox anonid="textbox-input-box" class="textbox-input-box urlbar-input-box" flex="1" xbl:inherits="tooltiptext=inputtooltiptext">
<xul:hbox class="urlbar-input-layer-children" xbl:inherits="overlinkstate">
<children/>
</xul:hbox>
<html:input anonid="input" class="autocomplete-textbox urlbar-input textbox-input uri-element-right-align" allowevents="true"
xbl:inherits="tooltiptext=inputtooltiptext,value,type,maxlength,disabled,size,readonly,placeholder,tabindex,accesskey"/>
</xul:hbox>
<xul:hbox class="urlbar-input-layer-children" xbl:inherits="overlinkstate">
<children includes="hbox"/>
</xul:hbox>
</xul:hbox>
</xul:stack>
</xul:hbox>
<xul:dropmarker anonid="historydropmarker" class="autocomplete-history-dropmarker urlbar-history-dropmarker"
allowevents="true" xbl:inherits="open,enablehistory,parentfocused=focused"/>
<xul:popupset anonid="popupset" class="autocomplete-result-popupset"/>
<children includes="toolbarbutton"/>
</xul:hbox>
</xul:stack>
</content>
<implementation>
<constructor><![CDATA[
this._overLinkLayer.addEventListener("transitionend", this, false);
]]></constructor>
<destructor><![CDATA[
this._overLinkLayer.removeEventListener("transitionend", this, false);
]]></destructor>
<field name="_overLinkLayer" readonly="true"><![CDATA[
document.getAnonymousElementByAttribute(this, "anonid", "over-link-layer");
]]></field>
<field name="_originLabel" readonly="true"><![CDATA[
document.getAnonymousElementByAttribute(this, "anonid", "origin-label");
]]></field>
<field name="_overLinkBox" readonly="true"><![CDATA[
document.getAnonymousElementByAttribute(this, "anonid", "over-link-box");
]]></field>
<field name="_overLinkHostLabel" readonly="true"><![CDATA[
document.getAnonymousElementByAttribute(this, "anonid", "over-link-host-label");
]]></field>
<field name="_overLinkPathLabel" readonly="true"><![CDATA[
document.getAnonymousElementByAttribute(this, "anonid", "over-link-path-label");
]]></field>
<field name="_status"><![CDATA[
null
]]></field>
<field name="_overLinkHostValue"><![CDATA[
null
]]></field>
<field name="_overLinkPathValue"><![CDATA[
null
]]></field>
<field name="s4espos"><![CDATA[
66
]]></field>
<field name="_overLinkState"><![CDATA[
null
]]></field>
<field name="_pmpack"><![CDATA[
null
]]></field>
<field name="_reOverLinkURL" readonly="true"><![CDATA[
/^((?:[a-z0-9+.-]+:\/\/)?[^\/]+\/?)(.*)$/
]]></field>
<property name="s4esalign">
<setter><![CDATA[
this.setAttribute("s4esalign", val);
return val;
]]></setter>
<getter><![CDATA[
return this.getAttribute("s4esalign");
]]></getter>
</property>
<property name="pmpack">
<setter><![CDATA[
this.setAttribute("pmpack", val);
this._pmpack = val;
return val;
]]></setter>
<getter><![CDATA[
return this.getAttribute("pmpack");
]]></getter>
</property>
<method name="handleEvent">
<parameter name="aEvent"/>
<body><![CDATA[
switch(aEvent.type)
{
case "transitionend":
if(aEvent.target == this._overLinkLayer && aEvent.propertyName == "opacity")
{
if(this._overLinkState == "fade-in")
{
this._setOverLinkState("showing");
}
else if(this._overLinkState == "fade-out")
{
this._setOverLinkState(null);
}
}
break;
default:
Object.getPrototypeOf(Object.getPrototypeOf(this)).handleEvent.call(this, aEvent);
break;
}
]]></body>
</method>
<method name="setStatusType">
<parameter name="aValue"/>
<body><![CDATA[
var overLinkBox = this._overLinkBox;
overLinkBox.setAttribute("previoustype", overLinkBox.getAttribute("type"));
overLinkBox.setAttribute("type", aValue);
]]></body>
</method>
<method name="setStatus">
<parameter name="aURL"/>
<body><![CDATA[
// NOTE: This method is called many times in a row very quickly when
// the user mouses over a bookmarks menu, tabs menu, or long list of
// links in a page, or leaves the cursor over a page with many links
// while scrolling. Therefore it's important that it be fast. Don't
// regress performance when you modify it!
this._status = aURL;
// Hide the over-link immediately if necessary.
if(!aURL && (XULBrowserWindow.hideOverLinkImmediately
|| this._hideOverLinkImmediately))
{
this._setOverLinkState(null);
return;
}
if(aURL)
{
this._updateOverLink(aURL);
this._setOverLinkState("fade-in");
}
else if(this._overLinkState)
{
this._setOverLinkState("fade-out");
}
]]></body>
</method>
<method name="_hideOverLink">
<body><![CDATA[
this._hideOverLinkImmediately = true;
this._setOverLinkState(null);
this._hideOverLinkImmediately = false;
]]></body>
</method>
<method name="_setOverLinkState">
<parameter name="aVal"/>
<body><![CDATA[
if(this._overLinkState == aVal)
{
return;
}
let aValOld = this._overLinkState;
this._overLinkState = aVal;
switch(aVal)
{
case "fade-in":
if(aValOld != "showing")
{
this._clearFormatting();
this.setAttribute("overlinkstate", aVal);
}
break;
case "fade-out":
if(aValOld != null)
{
this.setAttribute("overlinkstate", aVal);
}
break;
case "showing":
this._clearFormatting();
this.setAttribute("overlinkstate", aVal);
break;
default:
this.removeAttribute("overlinkstate");
this.formatValue();
break;
}
]]></body>
</method>
<method name="_updateOverLink">
<parameter name="aURL"/>
<body><![CDATA[
// Determine the pre-path and path of the over-link. Include the
// path's leading slash in the pre-path so that if the path is
// truncated its leading slash is visible.
var match = this._reOverLinkURL.exec(aURL);
this._overLinkHostValue = match ? match[1] : "";
this._overLinkPathValue = match ? match[2] : aURL;
this.updateOverLinkLayout();
]]></body>
</method>
<method name="updateOverLinkLayout">
<body><![CDATA[
// Reset the overlay state
var overLinkHost = this._overLinkHostLabel;
overLinkHost.value = "";
overLinkHost.flex = 0;
overLinkHost.crop = "none";
var overLinkPath = this._overLinkPathLabel;
overLinkPath.value = "";
overLinkPath.crop = "none";
var overLinkBox = this._overLinkBox;
overLinkBox.maxWidth = "";
overLinkBox.minWidth = "";
// Calculate the max-width
var maxWidth = this._overLinkLayer.boxObject.width;
var alignMode = this.s4esalign;
if(alignMode != "left")
{
maxWidth *= (this.s4espos / 100);
}
// Do eet!
overLinkHost.value = this._overLinkHostValue;
overLinkPath.value = this._overLinkPathValue;
overLinkPath.crop = this._overLinkHostValue ? "start" : "end";
if(overLinkHost.boxObject.width > maxWidth)
{
overLinkHost.flex = 1;
overLinkHost.crop = "end";
}
overLinkBox.maxWidth = maxWidth;
if(alignMode == "absolute")
{
overLinkBox.minWidth = maxWidth;
}
]]></body>
</method>
<method name="formatValue">
<body><![CDATA[
if(this._overLinkState)
{
return;
}
Object.getPrototypeOf(Object.getPrototypeOf(this)).formatValue.call(this);
]]></body>
</method>
</implementation>
<handlers>
<handler event="focus" phase="capturing"><![CDATA[
this._hideOverLink();
if(this._pmpack == "center")
{
this.setAttribute("pmpack", "end");
}
]]></handler>
<handler event="blur" phase="capturing"><![CDATA[
this.setAttribute("pmpack", this._pmpack);
if(this._status)
{
this._setOverLinkState("fade-in");
}
]]></handler>
<handler event="ValueChange" phase="capturing"><![CDATA[
this._originLabel.value = this.inputField.value;
]]></handler>
</handlers>
</binding>
</bindings>