Backed out changeset 6636e1cd0c41 (bug 1529969) for causing node tests newtab failures. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2019-12-17 21:55:48 +02:00
Родитель 35c54fbf80
Коммит 205ac58f1b
11 изменённых файлов: 35 добавлений и 120 удалений

Просмотреть файл

@ -1,79 +0,0 @@
/* 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/. */
"use strict";
function ContentSearchHandoffUIController() {
this._isPrivateWindow = false;
this._engineIcon = null;
window.addEventListener("ContentSearchService", this);
this._sendMsg("GetEngine");
}
ContentSearchHandoffUIController.prototype = {
handleEvent(event) {
let methodName = "_onMsg" + event.detail.type;
if (methodName in this) {
this[methodName](event.detail.data);
}
},
_onMsgEngine({ isPrivateWindow, engine }) {
this._isPrivateWindow = isPrivateWindow;
this._updateEngineIcon(engine);
},
_onMsgCurrentEngine(engine) {
if (!this._isPrivateWindow) {
this._updateEngineIcon(engine);
}
},
_onMsgCurrentPrivateEngine(engine) {
if (this._isPrivateWindow) {
this._updateEngineIcon(engine);
}
},
_updateEngineIcon(engine) {
if (this._engineIcon) {
URL.revokeObjectURL(this._engineIcon);
}
if (engine.iconData) {
this._engineIcon = this._getFaviconURIFromIconData(engine.iconData);
} else {
this._engineIcon = "chrome://mozapps/skin/places/defaultFavicon.svg";
}
document.body.style.setProperty(
"--newtab-search-icon",
"url(" + this._engineIcon + ")"
);
},
// If the favicon is an array buffer, convert it into a Blob URI.
// Otherwise just return the plain URI.
_getFaviconURIFromIconData(data) {
if (typeof data === "string") {
return data;
}
// If typeof(data) != "string", we assume it's an ArrayBuffer
let blob = new Blob([data]);
return URL.createObjectURL(blob);
},
_sendMsg(type, data = null) {
dispatchEvent(
new CustomEvent("ContentSearchClient", {
detail: {
type,
data,
},
})
);
},
};

Просмотреть файл

@ -94,7 +94,6 @@ browser.jar:
content/browser/sanitizeDialog.js (content/sanitizeDialog.js)
content/browser/sanitizeDialog.css (content/sanitizeDialog.css)
content/browser/contentSearchUI.js (content/contentSearchUI.js)
content/browser/contentSearchHandoffUI.js (content/contentSearchHandoffUI.js)
content/browser/contentSearchUI.css (content/contentSearchUI.css)
content/browser/tabbrowser.css (content/tabbrowser.css)
content/browser/tabbrowser.js (content/tabbrowser.js)

Просмотреть файл

@ -28,7 +28,6 @@ function templateHTML(options) {
const debugString = options.debug ? "-dev" : "";
const scripts = [
"chrome://browser/content/contentSearchUI.js",
"chrome://browser/content/contentSearchHandoffUI.js",
"chrome://browser/content/contentTheme.js",
`${options.baseUrl}vendor/react${debugString}.js`,
`${options.baseUrl}vendor/react-dom${debugString}.js`,

Просмотреть файл

@ -2,7 +2,7 @@
* 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/. */
/* globals ContentSearchUIController, ContentSearchHandoffUIController */
/* globals ContentSearchUIController */
"use strict";
import { actionCreators as ac, actionTypes as at } from "common/Actions.jsm";
@ -18,7 +18,6 @@ export class _Search extends React.PureComponent {
this.onSearchHandoffPaste = this.onSearchHandoffPaste.bind(this);
this.onSearchHandoffDrop = this.onSearchHandoffDrop.bind(this);
this.onInputMount = this.onInputMount.bind(this);
this.onInputMountHandoff = this.onInputMountHandoff.bind(this);
this.onSearchHandoffButtonMount = this.onSearchHandoffButtonMount.bind(
this
);
@ -104,14 +103,6 @@ export class _Search extends React.PureComponent {
}
}
onInputMountHandoff(input) {
if (input) {
// The handoff UI controller helps usset the search icon and reacts to
// changes to default engine to keep everything in sync.
this._handoffSearchController = new ContentSearchHandoffUIController();
}
}
onSearchHandoffButtonMount(button) {
// Keep a reference to the button for use during "paste" event handling.
this._searchHandoffButton = button;
@ -176,10 +167,18 @@ export class _Search extends React.PureComponent {
aria-hidden="true"
onDrop={this.onSearchHandoffDrop}
onPaste={this.onSearchHandoffPaste}
ref={this.onInputMountHandoff}
/>
<div className="fake-caret" />
</button>
{/*
This dummy and hidden input below is so we can load ContentSearchUIController.
Why? It sets --newtab-search-icon for us and it isn't trivial to port over.
*/}
<input
type="search"
style={{ display: "none" }}
ref={this.onInputMount}
/>
</div>
)}
</div>

Просмотреть файл

@ -10286,7 +10286,7 @@ __webpack_require__.r(__webpack_exports__);
* 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/. */
/* globals ContentSearchUIController, ContentSearchHandoffUIController */
/* globals ContentSearchUIController */
@ -10301,7 +10301,6 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
this.onSearchHandoffPaste = this.onSearchHandoffPaste.bind(this);
this.onSearchHandoffDrop = this.onSearchHandoffDrop.bind(this);
this.onInputMount = this.onInputMount.bind(this);
this.onInputMountHandoff = this.onInputMountHandoff.bind(this);
this.onSearchHandoffButtonMount = this.onSearchHandoffButtonMount.bind(this);
}
@ -10391,14 +10390,6 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
}
}
onInputMountHandoff(input) {
if (input) {
// The handoff UI controller helps usset the search icon and reacts to
// changes to default engine to keep everything in sync.
this._handoffSearchController = new ContentSearchHandoffUIController();
}
}
onSearchHandoffButtonMount(button) {
// Keep a reference to the button for use during "paste" event handling.
this._searchHandoffButton = button;
@ -10450,11 +10441,16 @@ class _Search extends react__WEBPACK_IMPORTED_MODULE_3___default.a.PureComponent
tabIndex: "-1",
"aria-hidden": "true",
onDrop: this.onSearchHandoffDrop,
onPaste: this.onSearchHandoffPaste,
ref: this.onInputMountHandoff
onPaste: this.onSearchHandoffPaste
}), react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("div", {
className: "fake-caret"
}))));
})), react__WEBPACK_IMPORTED_MODULE_3___default.a.createElement("input", {
type: "search",
style: {
display: "none"
},
ref: this.onInputMount
})));
}
}

Просмотреть файл

@ -20,7 +20,6 @@
<div id="root"></div>
<div id="footer-asrouter-container" role="presentation"></div>
<script src="chrome://browser/content/contentSearchUI.js"></script>
<script src="chrome://browser/content/contentSearchHandoffUI.js"></script>
<script src="chrome://browser/content/contentTheme.js"></script>
<script src="resource://activity-stream/vendor/react-dev.js"></script>
<script src="resource://activity-stream/vendor/react-dom-dev.js"></script>

Просмотреть файл

@ -20,7 +20,6 @@
<div id="root"></div>
<div id="footer-asrouter-container" role="presentation"></div>
<script src="chrome://browser/content/contentSearchUI.js"></script>
<script src="chrome://browser/content/contentSearchHandoffUI.js"></script>
<script src="chrome://browser/content/contentTheme.js"></script>
<script src="resource://activity-stream/vendor/react.js"></script>
<script src="resource://activity-stream/vendor/react-dom.js"></script>

Просмотреть файл

@ -118,5 +118,14 @@ document.addEventListener("DOMContentLoaded", function() {
});
// Load contentSearchUI so it sets the search engine icon for us.
new window.ContentSearchHandoffUIController();
// TODO: FIXME. We should eventually refector contentSearchUI to do only what
// we need and have it do the common search handoff work for
// about:newtab and about:privatebrowsing.
let input = document.getElementById("dummy-input");
new window.ContentSearchUIController(
input,
input.parentNode,
"aboutprivatebrowsing",
"aboutprivatebrowsing"
);
});

Просмотреть файл

@ -15,7 +15,7 @@
<link rel="localization" href="branding/brand.ftl"/>
<link rel="localization" href="browser/aboutPrivateBrowsing.ftl"/>
<script src="chrome://browser/content/aboutPrivateBrowsing.js"></script>
<script src="chrome://browser/content/contentSearchHandoffUI.js"></script>
<script src="chrome://browser/content/contentSearchUI.js"></script>
</head>
<body>
@ -50,6 +50,7 @@
<input id="fake-editable" class="fake-editable" tabindex="-1" aria-hidden="true" />
<div class="fake-caret" />
</button>
<input id="dummy-input" class="dummy-input" type="search" />
</div>
<div class="info">
<h1 data-l10n-id="about-private-browsing-info-title"></h1>

Просмотреть файл

@ -453,17 +453,6 @@ var ContentSearch = {
});
},
_onMessageGetEngine(msg, data) {
return this.currentStateObj(msg.target.ownerGlobal).then(state => {
this._reply(msg, "Engine", {
isPrivateWindow: state.isPrivateWindow,
engine: state.isPrivateWindow
? state.currentPrivateEngine
: state.currentEngine,
});
});
},
_onMessageGetStrings(msg, data) {
this._reply(msg, "Strings", this.searchSuggestionUIStrings);
},

Просмотреть файл

@ -163,6 +163,10 @@ p {
width: 1px;
}
.dummy-input {
display: none;
}
.search-banner {
width: 100%;
background-color: var(--in-content-banner-background);