michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: %browserDTD; michael@0: ]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 0 || this.valueIsTyped) michael@0: return selectedVal; michael@0: michael@0: // The selection doesn't span the full domain if it doesn't contain a slash and is michael@0: // followed by some character other than a slash. michael@0: if (!selectedVal.contains("/")) { michael@0: let remainder = inputVal.replace(selectedVal, ""); michael@0: if (remainder != "" && remainder[0] != "/") michael@0: return selectedVal; michael@0: } michael@0: michael@0: let uriFixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup); michael@0: michael@0: let uri; michael@0: try { michael@0: uri = uriFixup.createFixupURI(inputVal, Ci.nsIURIFixup.FIXUP_FLAG_NONE); michael@0: } catch (e) {} michael@0: if (!uri) michael@0: return selectedVal; michael@0: michael@0: // Only copy exposable URIs michael@0: try { michael@0: uri = uriFixup.createExposableURI(uri); michael@0: } catch (ex) {} michael@0: michael@0: // If the entire URL is selected, just use the actual loaded URI. michael@0: if (inputVal == selectedVal) { michael@0: // ... but only if isn't a javascript: or data: URI, since those michael@0: // are hard to read when encoded michael@0: if (!uri.schemeIs("javascript") && !uri.schemeIs("data")) { michael@0: // Parentheses are known to confuse third-party applications (bug 458565). michael@0: selectedVal = uri.spec.replace(/[()]/g, function (c) escape(c)); michael@0: } michael@0: michael@0: return selectedVal; michael@0: } michael@0: michael@0: // Just the beginning of the URL is selected, check for a trimmed value michael@0: let spec = uri.spec; michael@0: let trimmedSpec = this._trimURL(spec); michael@0: if (spec != trimmedSpec) { michael@0: // Prepend the portion that trimURL removed from the beginning. michael@0: // This assumes trimURL will only truncate the URL at michael@0: // the beginning or end (or both). michael@0: let trimmedSegments = spec.split(trimmedSpec); michael@0: selectedVal = trimmedSegments[0] + selectedVal; michael@0: } michael@0: michael@0: return selectedVal; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0) { michael@0: aURL = aURL.substring(0, firstSlash) + suffix + aURL.substring(firstSlash + 1); michael@0: } else { michael@0: aURL = aURL + suffix; michael@0: } michael@0: aURL = "http://www." + aURL; michael@0: } michael@0: } michael@0: michael@0: return aURL; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0 || michael@0: this._searches.selectedIndex >= 0); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: null michael@0: michael@0: document.getAnonymousElementByAttribute(this, 'anonid', 'results'); michael@0: document.getAnonymousElementByAttribute(this, 'anonid', 'results-container'); michael@0: michael@0: document.getAnonymousElementByAttribute(this, 'anonid', 'searches-header'); michael@0: document.getAnonymousElementByAttribute(this, 'anonid', 'searches'); michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: lastMatch) { michael@0: item.removeAttribute("value"); michael@0: item.removeAttribute("autocomplete"); michael@0: continue; michael@0: } michael@0: michael@0: let value = controller.getValueAt(i); michael@0: let label = controller.getCommentAt(i) || value; michael@0: let iconURI = controller.getImageAt(i); michael@0: michael@0: item.setAttribute("autocomplete", true); michael@0: item.setAttribute("label", label); michael@0: item.setAttribute("value", value); michael@0: item.setAttribute("iconURI", iconURI); michael@0: let xpFaviconURI = Services.io.newURI(iconURI.replace("moz-anno:favicon:",""), null, null); michael@0: Task.spawn(function() { michael@0: let colorInfo = yield ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI); michael@0: if ( !(colorInfo && colorInfo.background && colorInfo.foreground) michael@0: || (item.getAttribute("iconURI") != iconURI) ) { michael@0: return; michael@0: } michael@0: let { background, foreground } = colorInfo; michael@0: item.style.color = foreground; //color text michael@0: item.setAttribute("customColor", background); michael@0: // when bound, use the setter to propogate the color change through the tile michael@0: if ('color' in item) { michael@0: item.color = background; michael@0: } michael@0: }).then(null, err => Components.utils.reportError(err)); michael@0: } michael@0: michael@0: this._results.arrangeItems(); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: [] michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: 0) michael@0: this._searches.removeItemAt(0, true); michael@0: michael@0: this._engines.forEach(function (anEngine) { michael@0: let item = this._searches.appendItem("", anEngine.name, true); michael@0: item.setAttribute("autocomplete", "true"); michael@0: item.setAttribute("search", "true"); michael@0: michael@0: let largeImage = anEngine.getIconURLBySize(74,74); michael@0: if (largeImage) { michael@0: item.setAttribute("iconsize", "large"); michael@0: item.setAttribute("iconURI", largeImage); michael@0: } else if (anEngine.iconURI && anEngine.iconURI.spec) { michael@0: item.setAttribute("iconURI", anEngine.iconURI.spec); michael@0: item.setAttribute("customColor", "#fff"); michael@0: } michael@0: }.bind(this)); michael@0: michael@0: this._searches.arrangeItems(); michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: = 0) { michael@0: let url = this.input.controller.getValueAt(this._results.selectedIndex); michael@0: this.input.value = url; michael@0: return this.input.submitURL(); michael@0: } michael@0: michael@0: if (this._isGridBound(this._searches) && michael@0: this._searches.selectedIndex >= 0) { michael@0: let engine = this._engines[this._searches.selectedIndex]; michael@0: return this.input.submitSearch(engine.name); michael@0: } michael@0: michael@0: return false; michael@0: ]]> michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: michael@0: