Backed out changeset 82f89fcfaa82 (bug 1465500) For failing L10N by request of flod a=backout

This commit is contained in:
arthur.iakab 2018-06-23 16:25:51 +03:00
parent f2ab613f5d
commit 9a3f8590f8
8 changed files with 8 additions and 94 deletions

View File

@ -14,7 +14,7 @@ const FontSize = createFactory(require("./FontSize"));
const FontStyle = createFactory(require("./FontStyle"));
const FontWeight = createFactory(require("./FontWeight"));
const { getStr, getFormatStr } = require("../utils/l10n");
const { getStr } = require("../utils/l10n");
const Types = require("../types");
class FontEditor extends PureComponent {
@ -79,45 +79,16 @@ class FontEditor extends PureComponent {
});
});
}
renderFamilesNotUsed(familiesNotUsed = []) {
if (!familiesNotUsed.length) {
return null;
}
const familiesList = familiesNotUsed.map(family => {
return dom.div(
{
className: "font-family-unused",
},
family
);
});
return dom.details(
{},
dom.summary(
{
className: "font-family-unused-header",
},
getFormatStr("fontinspector.familiesNotUsedLabel", familiesNotUsed.length)
),
familiesList
);
}
/**
* Render font family, font name, and metadata for all fonts used on selected node.
*
* @param {Array} fonts
* Fonts used on selected node.
* @param {Array} families
* Font familes declared on selected node.
* @param {Function} onToggleFontHighlight
* Callback to trigger in-context highlighting of text that uses a font.
* @return {DOMNode}
*/
renderFontFamily(fonts, families, onToggleFontHighlight) {
renderFontFamily(fonts, onToggleFontHighlight) {
if (!fonts.length) {
return null;
}
@ -148,8 +119,7 @@ class FontEditor extends PureComponent {
{
className: "font-control-box",
},
fontList,
this.renderFamilesNotUsed(families.notUsed)
fontList
)
);
}
@ -245,7 +215,7 @@ class FontEditor extends PureComponent {
render() {
const { fontEditor, onToggleFontHighlight } = this.props;
const { fonts, families, axes, instance, properties } = fontEditor;
const { fonts, axes, instance, properties } = fontEditor;
// Pick the first font to show editor controls regardless of how many fonts are used.
const font = fonts[0];
const hasFontAxes = font && font.variationAxes;
@ -267,7 +237,7 @@ class FontEditor extends PureComponent {
// Render empty state message for nodes that don't have font properties.
!hasWeight && this.renderWarning(),
// Always render UI for font family, format and font file URL.
this.renderFontFamily(fonts, families, onToggleFontHighlight),
this.renderFontFamily(fonts, onToggleFontHighlight),
// Render UI for font variation instances if they are defined.
hasFontInstances && this.renderInstances(font.variationInstances, instance),
// Always render UI for font size.

View File

@ -411,7 +411,8 @@ class FontInspector {
const familiesUsedLowercase = families.used.map(family => family.toLowerCase());
// Font family names declared but not used.
families.notUsed = fontFamilies
.filter(family => !familiesUsedLowercase.includes(family.toLowerCase()));
.map(family => family.toLowerCase())
.filter(family => !familiesUsedLowercase.includes(family));
return families;
}

View File

@ -21,7 +21,6 @@ skip-if = !e10s # too slow on !e10s, logging fully serialized actors (Bug 144659
subsuite = clipboard
[browser_fontinspector_edit-previews.js]
[browser_fontinspector_expand-css-code.js]
[browser_fontinspector_family-unused.js]
[browser_fontinspector_other-fonts.js]
[browser_fontinspector_reveal-in-page.js]
[browser_fontinspector_theme-change.js]

View File

@ -27,7 +27,7 @@
}
div {
font-family:Arial;
font-family:bar, "Missing Family", sans-serif;
font-family:bar;
}
.normal-text {
font-family: barnormal;

View File

@ -1,39 +0,0 @@
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_URI = URL_ROOT + "browser_fontinspector.html";
// Test that unused font families show up in the font editor.
add_task(async function() {
await pushPref("devtools.inspector.fonteditor.enabled", true);
const { inspector, view } = await openFontInspectorForURL(TEST_URI);
const viewDoc = view.document;
await testFamiliesUnused(inspector, viewDoc);
await testZeroFamiliesUnused(inspector, viewDoc);
});
function getUnusedFontFamilies(viewDoc) {
return [...viewDoc.querySelectorAll("#font-editor .font-family-unused")]
.map(el => el.textContent);
}
async function testFamiliesUnused(inspector, viewDoc) {
await selectNode("div", inspector);
const unused = getUnusedFontFamilies(viewDoc);
is(unused.length, 2, "Two font families were not used");
is(unused[0], "Missing Family", "First unused family is correct");
is(unused[1], "sans-serif", "Second unused family is correct");
}
async function testZeroFamiliesUnused(inspector, viewDoc) {
await selectNode(".normal-text", inspector);
const unused = getUnusedFontFamilies(viewDoc);
const header = viewDoc.querySelector("#font-editor .font-family-unused-header");
is(unused.length, 0, "All font families were used");
is(header, null, "Container for unused font families was not rendered");
}

View File

@ -8,6 +8,5 @@ const { LocalizationHelper } = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/font-inspector.properties");
module.exports = {
getFormatStr: (...args) => L10N.getFormatStr(...args),
getStr: (...args) => L10N.getStr(...args),
};

View File

@ -55,8 +55,3 @@ fontinspector.fontWeightLabel=Weight
# LOCALIZATION NOTE (fontinspector.fontItalicLabel): This label is shown next to the UI
# in the font editor which allows the user to change the style of the font to italic.
fontinspector.fontItalicLabel=Italic
# LOCALIZATION NOTE (fontinspector.familiesNotUsedLabel): This label is shown at the top
# of the list of unused font families. %S is the number of unused font families. It is
# always a positive integer larger than zero.
fontinspector.familiesNotUsedLabel=%S not used

View File

@ -156,17 +156,6 @@
-moz-user-select: none;
}
.font-family-unused-header {
-moz-user-select: none;
margin-bottom: .7em;
cursor: pointer;
}
.font-family-unused {
margin-bottom: .3em;
color: var(--grey-50);
}
.font-instance-select:active{
outline: none;
}