From 0515d3805cdb7ca15774cf0b5fd04c74d4310f1c Mon Sep 17 00:00:00 2001 From: Gabriel Luong Date: Tue, 13 Sep 2016 16:35:16 -0400 Subject: [PATCH 1/5] Bug 1302496 - Refactor LayoutView to a Box Model component r=jdescottes --HG-- rename : devtools/client/inspector/layout/layout.js => devtools/client/inspector/components/box-model.js rename : devtools/client/inspector/layout/test/.eslintrc => devtools/client/inspector/components/test/.eslintrc rename : devtools/client/inspector/layout/test/browser.ini => devtools/client/inspector/components/test/browser.ini rename : devtools/client/inspector/layout/test/browser_layout.js => devtools/client/inspector/components/test/browser_boxmodel.js rename : devtools/client/inspector/layout/test/browser_layout_editablemodel.js => devtools/client/inspector/components/test/browser_boxmodel_editablemodel.js rename : devtools/client/inspector/layout/test/browser_layout_editablemodel_allproperties.js => devtools/client/inspector/components/test/browser_boxmodel_editablemodel_allproperties.js rename : devtools/client/inspector/layout/test/browser_layout_editablemodel_bluronclick.js => devtools/client/inspector/components/test/browser_boxmodel_editablemodel_bluronclick.js rename : devtools/client/inspector/layout/test/browser_layout_editablemodel_border.js => devtools/client/inspector/components/test/browser_boxmodel_editablemodel_border.js rename : devtools/client/inspector/layout/test/browser_layout_editablemodel_stylerules.js => devtools/client/inspector/components/test/browser_boxmodel_editablemodel_stylerules.js rename : devtools/client/inspector/layout/test/browser_layout_guides.js => devtools/client/inspector/components/test/browser_boxmodel_guides.js rename : devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js => devtools/client/inspector/components/test/browser_boxmodel_rotate-labels-on-sides.js rename : devtools/client/inspector/layout/test/browser_layout_sync.js => devtools/client/inspector/components/test/browser_boxmodel_sync.js rename : devtools/client/inspector/layout/test/browser_layout_tooltips.js => devtools/client/inspector/components/test/browser_boxmodel_tooltips.js rename : devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js => devtools/client/inspector/components/test/browser_boxmodel_update-after-navigation.js rename : devtools/client/inspector/layout/test/browser_layout_update-after-reload.js => devtools/client/inspector/components/test/browser_boxmodel_update-after-reload.js rename : devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js => devtools/client/inspector/components/test/browser_boxmodel_update-in-iframes.js rename : devtools/client/inspector/layout/test/doc_layout_iframe1.html => devtools/client/inspector/components/test/doc_boxmodel_iframe1.html rename : devtools/client/inspector/layout/test/doc_layout_iframe2.html => devtools/client/inspector/components/test/doc_boxmodel_iframe2.html rename : devtools/client/inspector/layout/test/head.js => devtools/client/inspector/components/test/head.js rename : devtools/client/themes/layout.css => devtools/client/themes/boxmodel.css --- .../layout.js => components/box-model.js} | 84 ++++++------ .../client/inspector/components/moz.build | 3 + .../{layout => components}/test/.eslintrc | 0 .../inspector/components/test/browser.ini | 29 ++++ .../test/browser_boxmodel.js} | 60 ++++---- .../test/browser_boxmodel_editablemodel.js} | 12 +- ...r_boxmodel_editablemodel_allproperties.js} | 10 +- ...ser_boxmodel_editablemodel_bluronclick.js} | 15 +- .../browser_boxmodel_editablemodel_border.js} | 4 +- ...wser_boxmodel_editablemodel_stylerules.js} | 8 +- .../test/browser_boxmodel_guides.js} | 14 +- ...browser_boxmodel_rotate-labels-on-sides.js | 49 +++++++ .../test/browser_boxmodel_sync.js} | 6 +- .../test/browser_boxmodel_tooltips.js} | 20 +-- ...owser_boxmodel_update-after-navigation.js} | 44 +++--- .../browser_boxmodel_update-after-reload.js | 40 ++++++ .../browser_boxmodel_update-in-iframes.js} | 28 ++-- .../test/doc_boxmodel_iframe1.html} | 2 +- .../test/doc_boxmodel_iframe2.html} | 0 .../{layout => components}/test/head.js | 18 +-- .../client/inspector/computed/computed.js | 8 +- .../test/browser_computed_search-filter.js | 4 +- .../browser_computed_search-filter_clear.js | 4 +- devtools/client/inspector/inspector-panel.js | 6 +- devtools/client/inspector/inspector.xul | 62 ++++----- devtools/client/inspector/layout/moz.build | 11 -- .../client/inspector/layout/test/browser.ini | 29 ---- .../browser_layout_rotate-labels-on-sides.js | 49 ------- .../browser_layout_update-after-reload.js | 40 ------ devtools/client/inspector/moz.build | 1 - devtools/client/jar.mn | 3 +- .../themes/{layout.css => boxmodel.css} | 128 +++++++++--------- devtools/server/actors/highlighters.js | 2 +- devtools/server/actors/inspector.js | 2 +- devtools/server/actors/styles.js | 2 +- 35 files changed, 394 insertions(+), 403 deletions(-) rename devtools/client/inspector/{layout/layout.js => components/box-model.js} (91%) rename devtools/client/inspector/{layout => components}/test/.eslintrc (100%) create mode 100644 devtools/client/inspector/components/test/browser.ini rename devtools/client/inspector/{layout/test/browser_layout.js => components/test/browser_boxmodel.js} (59%) rename devtools/client/inspector/{layout/test/browser_layout_editablemodel.js => components/test/browser_boxmodel_editablemodel.js} (94%) rename devtools/client/inspector/{layout/test/browser_layout_editablemodel_allproperties.js => components/test/browser_boxmodel_editablemodel_allproperties.js} (93%) rename devtools/client/inspector/{layout/test/browser_layout_editablemodel_bluronclick.js => components/test/browser_boxmodel_editablemodel_bluronclick.js} (83%) rename devtools/client/inspector/{layout/test/browser_layout_editablemodel_border.js => components/test/browser_boxmodel_editablemodel_border.js} (93%) rename devtools/client/inspector/{layout/test/browser_layout_editablemodel_stylerules.js => components/test/browser_boxmodel_editablemodel_stylerules.js} (93%) rename devtools/client/inspector/{layout/test/browser_layout_guides.js => components/test/browser_boxmodel_guides.js} (81%) create mode 100644 devtools/client/inspector/components/test/browser_boxmodel_rotate-labels-on-sides.js rename devtools/client/inspector/{layout/test/browser_layout_sync.js => components/test/browser_boxmodel_sync.js} (88%) rename devtools/client/inspector/{layout/test/browser_layout_tooltips.js => components/test/browser_boxmodel_tooltips.js} (82%) rename devtools/client/inspector/{layout/test/browser_layout_update-after-navigation.js => components/test/browser_boxmodel_update-after-navigation.js} (53%) create mode 100644 devtools/client/inspector/components/test/browser_boxmodel_update-after-reload.js rename devtools/client/inspector/{layout/test/browser_layout_update-in-iframes.js => components/test/browser_boxmodel_update-in-iframes.js} (73%) rename devtools/client/inspector/{layout/test/doc_layout_iframe1.html => components/test/doc_boxmodel_iframe1.html} (56%) rename devtools/client/inspector/{layout/test/doc_layout_iframe2.html => components/test/doc_boxmodel_iframe2.html} (100%) rename devtools/client/inspector/{layout => components}/test/head.js (85%) delete mode 100644 devtools/client/inspector/layout/moz.build delete mode 100644 devtools/client/inspector/layout/test/browser.ini delete mode 100644 devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js delete mode 100644 devtools/client/inspector/layout/test/browser_layout_update-after-reload.js rename devtools/client/themes/{layout.css => boxmodel.css} (61%) diff --git a/devtools/client/inspector/layout/layout.js b/devtools/client/inspector/components/box-model.js similarity index 91% rename from devtools/client/inspector/layout/layout.js rename to devtools/client/inspector/components/box-model.js index 266f508dbd52..d7d23de94e8c 100644 --- a/devtools/client/inspector/layout/layout.js +++ b/devtools/client/inspector/components/box-model.js @@ -23,7 +23,7 @@ const LONG_TEXT_ROTATE_LIMIT = 3; /** * An instance of EditingSession tracks changes that have been made during the * modification of box model values. All of these changes can be reverted by - * calling revert. The main parameter is the LayoutView that created it. + * calling revert. The main parameter is the BoxModelView that created it. * * @param inspector The inspector panel. * @param doc A DOM document that can be used to test style rules. @@ -183,27 +183,27 @@ EditingSession.prototype = { }; /** - * The layout-view panel + * The box model view * @param {InspectorPanel} inspector * An instance of the inspector-panel currently loaded in the toolbox * @param {Document} document - * The document that will contain the layout view. + * The document that will contain the box model view. */ -function LayoutView(inspector, document) { +function BoxModelView(inspector, document) { this.inspector = inspector; this.doc = document; - this.wrapper = this.doc.getElementById("layout-wrapper"); - this.container = this.doc.getElementById("layout-container"); - this.expander = this.doc.getElementById("layout-expander"); - this.sizeLabel = this.doc.querySelector(".layout-size > span"); - this.sizeHeadingLabel = this.doc.getElementById("layout-element-size"); + this.wrapper = this.doc.getElementById("boxmodel-wrapper"); + this.container = this.doc.getElementById("boxmodel-container"); + this.expander = this.doc.getElementById("boxmodel-expander"); + this.sizeLabel = this.doc.querySelector(".boxmodel-size > span"); + this.sizeHeadingLabel = this.doc.getElementById("boxmodel-element-size"); this._geometryEditorHighlighter = null; this._cssProperties = getCssProperties(inspector.toolbox); this.init(); } -LayoutView.prototype = { +BoxModelView.prototype = { init: function () { this.update = this.update.bind(this); @@ -218,7 +218,7 @@ LayoutView.prototype = { this.onToggleExpander = this.onToggleExpander.bind(this); this.expander.addEventListener("click", this.onToggleExpander); - let header = this.doc.getElementById("layout-header"); + let header = this.doc.getElementById("boxmodel-header"); header.addEventListener("dblclick", this.onToggleExpander); this.onFilterComputedView = this.onFilterComputedView.bind(this); @@ -233,72 +233,72 @@ LayoutView.prototype = { this.initBoxModelHighlighter(); // Store for the different dimensions of the node. - // 'selector' refers to the element that holds the value in view.xhtml; + // 'selector' refers to the element that holds the value; // 'property' is what we are measuring; // 'value' is the computed dimension, computed in update(). this.map = { position: { - selector: "#layout-element-position", + selector: "#boxmodel-element-position", property: "position", value: undefined }, marginTop: { - selector: ".layout-margin.layout-top > span", + selector: ".boxmodel-margin.boxmodel-top > span", property: "margin-top", value: undefined }, marginBottom: { - selector: ".layout-margin.layout-bottom > span", + selector: ".boxmodel-margin.boxmodel-bottom > span", property: "margin-bottom", value: undefined }, marginLeft: { - selector: ".layout-margin.layout-left > span", + selector: ".boxmodel-margin.boxmodel-left > span", property: "margin-left", value: undefined }, marginRight: { - selector: ".layout-margin.layout-right > span", + selector: ".boxmodel-margin.boxmodel-right > span", property: "margin-right", value: undefined }, paddingTop: { - selector: ".layout-padding.layout-top > span", + selector: ".boxmodel-padding.boxmodel-top > span", property: "padding-top", value: undefined }, paddingBottom: { - selector: ".layout-padding.layout-bottom > span", + selector: ".boxmodel-padding.boxmodel-bottom > span", property: "padding-bottom", value: undefined }, paddingLeft: { - selector: ".layout-padding.layout-left > span", + selector: ".boxmodel-padding.boxmodel-left > span", property: "padding-left", value: undefined }, paddingRight: { - selector: ".layout-padding.layout-right > span", + selector: ".boxmodel-padding.boxmodel-right > span", property: "padding-right", value: undefined }, borderTop: { - selector: ".layout-border.layout-top > span", + selector: ".boxmodel-border.boxmodel-top > span", property: "border-top-width", value: undefined }, borderBottom: { - selector: ".layout-border.layout-bottom > span", + selector: ".boxmodel-border.boxmodel-bottom > span", property: "border-bottom-width", value: undefined }, borderLeft: { - selector: ".layout-border.layout-left > span", + selector: ".boxmodel-border.boxmodel-left > span", property: "border-left-width", value: undefined }, borderRight: { - selector: ".layout-border.layout-right > span", + selector: ".boxmodel-border.boxmodel-right > span", property: "border-right-width", value: undefined } @@ -326,7 +326,7 @@ LayoutView.prototype = { }, initBoxModelHighlighter: function () { - let highlightElts = this.doc.querySelectorAll("#layout-container *[title]"); + let highlightElts = this.doc.querySelectorAll("#boxmodel-container *[title]"); this.onHighlightMouseOver = this.onHighlightMouseOver.bind(this); this.onHighlightMouseOut = this.onHighlightMouseOut.bind(this); @@ -367,7 +367,7 @@ LayoutView.prototype = { }, /** - * Called when the user clicks on one of the editable values in the layoutview + * Called when the user clicks on one of the editable values in the box model view */ initEditor: function (element, event, dimension) { let { property } = dimension; @@ -382,7 +382,7 @@ LayoutView.prototype = { name: dimension.property }, start: self => { - self.elt.parentNode.classList.add("layout-editing"); + self.elt.parentNode.classList.add("boxmodel-editing"); }, change: value => { @@ -406,7 +406,7 @@ LayoutView.prototype = { }, done: (value, commit) => { - editor.elt.parentNode.classList.remove("layout-editing"); + editor.elt.parentNode.classList.remove("boxmodel-editing"); if (!commit) { session.revert().then(() => { session.destroy(); @@ -418,7 +418,7 @@ LayoutView.prototype = { }, /** - * Is the layoutview visible in the sidebar. + * Is the BoxModelView visible in the sidebar. * @return {Boolean} */ isViewVisible: function () { @@ -427,7 +427,7 @@ LayoutView.prototype = { }, /** - * Is the layoutview visible in the sidebar and is the current node valid to + * Is the BoxModelView visible in the sidebar and is the current node valid to * be displayed in the view. * @return {Boolean} */ @@ -441,7 +441,7 @@ LayoutView.prototype = { * Destroy the nodes. Remove listeners. */ destroy: function () { - let highlightElts = this.doc.querySelectorAll("#layout-container *[title]"); + let highlightElts = this.doc.querySelectorAll("#boxmodel-container *[title]"); for (let element of highlightElts) { element.removeEventListener("mouseover", this.onHighlightMouseOver, true); @@ -449,7 +449,7 @@ LayoutView.prototype = { } this.expander.removeEventListener("click", this.onToggleExpander); - let header = this.doc.getElementById("layout-header"); + let header = this.doc.getElementById("boxmodel-header"); header.removeEventListener("dblclick", this.onToggleExpander); let nodeGeometry = this.doc.getElementById("layout-geometry-editor"); @@ -458,7 +458,7 @@ LayoutView.prototype = { this.inspector.off("picker-started", this.onPickerStarted); // Inspector Panel will destroy `markup` object on "will-navigate" event, - // therefore we have to check if it's still available in case LayoutView + // therefore we have to check if it's still available in case BoxModelView // is destroyed immediately after. if (this.inspector.markup) { this.inspector.markup.off("leave", this.onMarkupViewLeave); @@ -571,7 +571,7 @@ LayoutView.prototype = { * Event handler that responds to the computed view being filtered * @param {String} reason * @param {Boolean} hidden - * Whether or not to hide the layout wrapper + * Whether or not to hide the box model wrapper */ onFilterComputedView: function (reason, hidden) { this.wrapper.hidden = hidden; @@ -579,7 +579,7 @@ LayoutView.prototype = { /** * Stop tracking reflows and hide all values when no node is selected or the - * layout-view is hidden, otherwise track reflows and show values. + * box model view is hidden, otherwise track reflows and show values. * @param {Boolean} isActive */ setActive: function (isActive) { @@ -604,7 +604,7 @@ LayoutView.prototype = { let lastRequest = Task.spawn((function* () { if (!this.isViewVisibleAndNodeValid()) { this.wrapper.hidden = true; - this.inspector.emit("layoutview-updated"); + this.inspector.emit("boxmodel-view-updated"); return null; } @@ -689,7 +689,7 @@ LayoutView.prototype = { this.wrapper.hidden = false; - this.inspector.emit("layoutview-updated"); + this.inspector.emit("boxmodel-view-updated"); return null; }).bind(this)).catch(console.error); @@ -831,12 +831,12 @@ LayoutView.prototype = { manageOverflowingText: function (span) { let classList = span.parentNode.classList; - if (classList.contains("layout-left") || - classList.contains("layout-right")) { + if (classList.contains("boxmodel-left") || + classList.contains("boxmodel-right")) { let force = span.textContent.length > LONG_TEXT_ROTATE_LIMIT; - classList.toggle("layout-rotate", force); + classList.toggle("boxmodel-rotate", force); } } }; -exports.LayoutView = LayoutView; +exports.BoxModelView = BoxModelView; diff --git a/devtools/client/inspector/components/moz.build b/devtools/client/inspector/components/moz.build index 50556cf26ecf..5e4dd40edc45 100644 --- a/devtools/client/inspector/components/moz.build +++ b/devtools/client/inspector/components/moz.build @@ -5,6 +5,9 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. DevToolsModules( + 'box-model.js', 'inspector-tab-panel.css', 'inspector-tab-panel.js', ) + +BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] diff --git a/devtools/client/inspector/layout/test/.eslintrc b/devtools/client/inspector/components/test/.eslintrc similarity index 100% rename from devtools/client/inspector/layout/test/.eslintrc rename to devtools/client/inspector/components/test/.eslintrc diff --git a/devtools/client/inspector/components/test/browser.ini b/devtools/client/inspector/components/test/browser.ini new file mode 100644 index 000000000000..42eb352d6553 --- /dev/null +++ b/devtools/client/inspector/components/test/browser.ini @@ -0,0 +1,29 @@ +[DEFAULT] +tags = devtools +subsuite = devtools +support-files = + doc_boxmodel_iframe1.html + doc_boxmodel_iframe2.html + head.js + !/devtools/client/commandline/test/helpers.js + !/devtools/client/framework/test/shared-head.js + !/devtools/client/inspector/test/head.js + !/devtools/client/inspector/test/shared-head.js + !/devtools/client/shared/test/test-actor.js + !/devtools/client/shared/test/test-actor-registry.js + +[browser_boxmodel.js] +[browser_boxmodel_editablemodel.js] +# [browser_boxmodel_editablemodel_allproperties.js] +# Disabled for too many intermittent failures (bug 1009322) +[browser_boxmodel_editablemodel_bluronclick.js] +[browser_boxmodel_editablemodel_border.js] +[browser_boxmodel_editablemodel_stylerules.js] +[browser_boxmodel_guides.js] +[browser_boxmodel_rotate-labels-on-sides.js] +[browser_boxmodel_sync.js] +[browser_boxmodel_tooltips.js] +[browser_boxmodel_update-after-navigation.js] +[browser_boxmodel_update-after-reload.js] +# [browser_boxmodel_update-in-iframes.js] +# Bug 1020038 boxmodel-view updates for iframe elements changes diff --git a/devtools/client/inspector/layout/test/browser_layout.js b/devtools/client/inspector/components/test/browser_boxmodel.js similarity index 59% rename from devtools/client/inspector/layout/test/browser_layout.js rename to devtools/client/inspector/components/test/browser_boxmodel.js index 2daebd01271d..f8b87f42133e 100644 --- a/devtools/client/inspector/layout/test/browser_layout.js +++ b/devtools/client/inspector/components/test/browser_boxmodel.js @@ -4,124 +4,124 @@ "use strict"; -// Test that the layout-view displays the right values and that it updates when +// Test that the box model displays the right values and that it updates when // the node's style is changed // Expected values: var res1 = [ { - selector: "#layout-element-size", + selector: "#boxmodel-element-size", value: "160" + "\u00D7" + "160.117" }, { - selector: ".layout-size > span", + selector: ".boxmodel-size > span", value: "100" + "\u00D7" + "100.117" }, { - selector: ".layout-margin.layout-top > span", + selector: ".boxmodel-margin.boxmodel-top > span", value: 30 }, { - selector: ".layout-margin.layout-left > span", + selector: ".boxmodel-margin.boxmodel-left > span", value: "auto" }, { - selector: ".layout-margin.layout-bottom > span", + selector: ".boxmodel-margin.boxmodel-bottom > span", value: 30 }, { - selector: ".layout-margin.layout-right > span", + selector: ".boxmodel-margin.boxmodel-right > span", value: "auto" }, { - selector: ".layout-padding.layout-top > span", + selector: ".boxmodel-padding.boxmodel-top > span", value: 20 }, { - selector: ".layout-padding.layout-left > span", + selector: ".boxmodel-padding.boxmodel-left > span", value: 20 }, { - selector: ".layout-padding.layout-bottom > span", + selector: ".boxmodel-padding.boxmodel-bottom > span", value: 20 }, { - selector: ".layout-padding.layout-right > span", + selector: ".boxmodel-padding.boxmodel-right > span", value: 20 }, { - selector: ".layout-border.layout-top > span", + selector: ".boxmodel-border.boxmodel-top > span", value: 10 }, { - selector: ".layout-border.layout-left > span", + selector: ".boxmodel-border.boxmodel-left > span", value: 10 }, { - selector: ".layout-border.layout-bottom > span", + selector: ".boxmodel-border.boxmodel-bottom > span", value: 10 }, { - selector: ".layout-border.layout-right > span", + selector: ".boxmodel-border.boxmodel-right > span", value: 10 }, ]; var res2 = [ { - selector: "#layout-element-size", + selector: "#boxmodel-element-size", value: "190" + "\u00D7" + "210" }, { - selector: ".layout-size > span", + selector: ".boxmodel-size > span", value: "100" + "\u00D7" + "150" }, { - selector: ".layout-margin.layout-top > span", + selector: ".boxmodel-margin.boxmodel-top > span", value: 30 }, { - selector: ".layout-margin.layout-left > span", + selector: ".boxmodel-margin.boxmodel-left > span", value: "auto" }, { - selector: ".layout-margin.layout-bottom > span", + selector: ".boxmodel-margin.boxmodel-bottom > span", value: 30 }, { - selector: ".layout-margin.layout-right > span", + selector: ".boxmodel-margin.boxmodel-right > span", value: "auto" }, { - selector: ".layout-padding.layout-top > span", + selector: ".boxmodel-padding.boxmodel-top > span", value: 20 }, { - selector: ".layout-padding.layout-left > span", + selector: ".boxmodel-padding.boxmodel-left > span", value: 20 }, { - selector: ".layout-padding.layout-bottom > span", + selector: ".boxmodel-padding.boxmodel-bottom > span", value: 20 }, { - selector: ".layout-padding.layout-right > span", + selector: ".boxmodel-padding.boxmodel-right > span", value: 50 }, { - selector: ".layout-border.layout-top > span", + selector: ".boxmodel-border.boxmodel-top > span", value: 10 }, { - selector: ".layout-border.layout-left > span", + selector: ".boxmodel-border.boxmodel-left > span", value: 10 }, { - selector: ".layout-border.layout-bottom > span", + selector: ".boxmodel-border.boxmodel-bottom > span", value: 10 }, { - selector: ".layout-border.layout-right > span", + selector: ".boxmodel-border.boxmodel-right > span", value: 10 }, ]; @@ -133,7 +133,7 @@ add_task(function* () { let html = "
"; yield addTab("data:text/html," + encodeURIComponent(html)); - let {inspector, view, testActor} = yield openLayoutView(); + let {inspector, view, testActor} = yield openBoxModelView(); yield selectNode("div", inspector); yield testInitialValues(inspector, view); diff --git a/devtools/client/inspector/layout/test/browser_layout_editablemodel.js b/devtools/client/inspector/components/test/browser_boxmodel_editablemodel.js similarity index 94% rename from devtools/client/inspector/layout/test/browser_layout_editablemodel.js rename to devtools/client/inspector/components/test/browser_boxmodel_editablemodel.js index b930f438c334..5c32c2029597 100644 --- a/devtools/client/inspector/layout/test/browser_layout_editablemodel.js +++ b/devtools/client/inspector/components/test/browser_boxmodel_editablemodel.js @@ -19,7 +19,7 @@ const TEST_URI = "", + "
" +].join("")); +const LONG_TEXT_ROTATE_LIMIT = 3; + +add_task(function* () { + yield addTab("data:text/html," + TEST_URI); + let {inspector, view} = yield openBoxModelView(); + yield selectNode("div", inspector); + + for (let i = 0; i < res1.length; i++) { + let elt = view.doc.querySelector(res1[i].selector); + let isLong = elt.textContent.length > LONG_TEXT_ROTATE_LIMIT; + let classList = elt.parentNode.classList; + let canBeRotated = classList.contains("boxmodel-left") || + classList.contains("boxmodel-right"); + let isRotated = classList.contains("boxmodel-rotate"); + + is(canBeRotated && isLong, + isRotated, res1[i].selector + " correctly rotated."); + } +}); diff --git a/devtools/client/inspector/layout/test/browser_layout_sync.js b/devtools/client/inspector/components/test/browser_boxmodel_sync.js similarity index 88% rename from devtools/client/inspector/layout/test/browser_layout_sync.js rename to devtools/client/inspector/components/test/browser_boxmodel_sync.js index 3005f9f1c0d4..a896bfe06b41 100644 --- a/devtools/client/inspector/layout/test/browser_layout_sync.js +++ b/devtools/client/inspector/components/test/browser_boxmodel_sync.js @@ -10,14 +10,14 @@ const TEST_URI = "

hello

"; add_task(function* () { yield addTab("data:text/html," + encodeURIComponent(TEST_URI)); - let {inspector, view} = yield openLayoutView(); + let {inspector, view} = yield openBoxModelView(); info("When a property is edited, it should sync in the rule view"); yield selectNode("p", inspector); - info("Modify padding-bottom in layout view"); - let span = view.doc.querySelector(".layout-padding.layout-bottom > span"); + info("Modify padding-bottom in box model view"); + let span = view.doc.querySelector(".boxmodel-padding.boxmodel-bottom > span"); EventUtils.synthesizeMouseAtCenter(span, {}, view.doc.defaultView); let editor = view.doc.querySelector(".styleinspector-propertyeditor"); diff --git a/devtools/client/inspector/layout/test/browser_layout_tooltips.js b/devtools/client/inspector/components/test/browser_boxmodel_tooltips.js similarity index 82% rename from devtools/client/inspector/layout/test/browser_layout_tooltips.js rename to devtools/client/inspector/components/test/browser_boxmodel_tooltips.js index d9586518edac..b65d2446a33f 100644 --- a/devtools/client/inspector/layout/test/browser_layout_tooltips.js +++ b/devtools/client/inspector/components/test/browser_boxmodel_tooltips.js @@ -4,7 +4,7 @@ "use strict"; -// Test that the regions in the layout-view have tooltips, and that individual +// Test that the regions in the box model view have tooltips, and that individual // values too. Also test that values that are set from a css rule have tooltips // referencing the rule. @@ -72,28 +72,28 @@ const VALUES_TEST_DATA = [{ add_task(function* () { yield addTab("data:text/html;charset=utf-8," + encodeURIComponent(TEST_URI)); - let {inspector, view} = yield openLayoutView(); + let {inspector, view} = yield openBoxModelView(); info("Checking the regions tooltips"); - ok(view.doc.querySelector("#layout-margins").hasAttribute("title"), + ok(view.doc.querySelector("#boxmodel-margins").hasAttribute("title"), "The margin region has a tooltip"); - is(view.doc.querySelector("#layout-margins").getAttribute("title"), "margin", + is(view.doc.querySelector("#boxmodel-margins").getAttribute("title"), "margin", "The margin region has the correct tooltip content"); - ok(view.doc.querySelector("#layout-borders").hasAttribute("title"), + ok(view.doc.querySelector("#boxmodel-borders").hasAttribute("title"), "The border region has a tooltip"); - is(view.doc.querySelector("#layout-borders").getAttribute("title"), "border", + is(view.doc.querySelector("#boxmodel-borders").getAttribute("title"), "border", "The border region has the correct tooltip content"); - ok(view.doc.querySelector("#layout-padding").hasAttribute("title"), + ok(view.doc.querySelector("#boxmodel-padding").hasAttribute("title"), "The padding region has a tooltip"); - is(view.doc.querySelector("#layout-padding").getAttribute("title"), "padding", + is(view.doc.querySelector("#boxmodel-padding").getAttribute("title"), "padding", "The padding region has the correct tooltip content"); - ok(view.doc.querySelector("#layout-content").hasAttribute("title"), + ok(view.doc.querySelector("#boxmodel-content").hasAttribute("title"), "The content region has a tooltip"); - is(view.doc.querySelector("#layout-content").getAttribute("title"), "content", + is(view.doc.querySelector("#boxmodel-content").getAttribute("title"), "content", "The content region has the correct tooltip content"); for (let {selector, values} of VALUES_TEST_DATA) { diff --git a/devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js b/devtools/client/inspector/components/test/browser_boxmodel_update-after-navigation.js similarity index 53% rename from devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js rename to devtools/client/inspector/components/test/browser_boxmodel_update-after-navigation.js index 3d082cddab23..cb59602291da 100644 --- a/devtools/client/inspector/layout/test/browser_layout_update-after-navigation.js +++ b/devtools/client/inspector/components/test/browser_boxmodel_update-after-navigation.js @@ -4,15 +4,15 @@ "use strict"; -// Test that the layout-view continues to work after a page navigation and that +// Test that the box model view continues to work after a page navigation and that // it also works after going back -const IFRAME1 = URL_ROOT + "doc_layout_iframe1.html"; -const IFRAME2 = URL_ROOT + "doc_layout_iframe2.html"; +const IFRAME1 = URL_ROOT + "doc_boxmodel_iframe1.html"; +const IFRAME2 = URL_ROOT + "doc_boxmodel_iframe2.html"; add_task(function* () { yield addTab(IFRAME1); - let {inspector, view, testActor} = yield openLayoutView(); + let {inspector, view, testActor} = yield openBoxModelView(); yield testFirstPage(inspector, view, testActor); @@ -30,62 +30,62 @@ add_task(function* () { }); function* testFirstPage(inspector, view, testActor) { - info("Test that the layout-view works on the first page"); + info("Test that the box model view works on the first page"); info("Selecting the test node"); yield selectNode("p", inspector); - info("Checking that the layout-view shows the right value"); - let paddingElt = view.doc.querySelector(".layout-padding.layout-top > span"); + info("Checking that the box model view shows the right value"); + let paddingElt = view.doc.querySelector(".boxmodel-padding.boxmodel-top > span"); is(paddingElt.textContent, "50"); - info("Listening for layout-view changes and modifying the padding"); + info("Listening for box model view changes and modifying the padding"); let onUpdated = waitForUpdate(inspector); yield setStyle(testActor, "p", "padding", "20px"); yield onUpdated; - ok(true, "Layout-view got updated"); + ok(true, "Box model view got updated"); - info("Checking that the layout-view shows the right value after update"); + info("Checking that the box model view shows the right value after update"); is(paddingElt.textContent, "20"); } function* testSecondPage(inspector, view, testActor) { - info("Test that the layout-view works on the second page"); + info("Test that the box model view works on the second page"); info("Selecting the test node"); yield selectNode("p", inspector); - info("Checking that the layout-view shows the right value"); - let sizeElt = view.doc.querySelector(".layout-size > span"); + info("Checking that the box model view shows the right value"); + let sizeElt = view.doc.querySelector(".boxmodel-size > span"); is(sizeElt.textContent, "100" + "\u00D7" + "100"); - info("Listening for layout-view changes and modifying the size"); + info("Listening for box model view changes and modifying the size"); let onUpdated = waitForUpdate(inspector); yield setStyle(testActor, "p", "width", "200px"); yield onUpdated; - ok(true, "Layout-view got updated"); + ok(true, "Box model view got updated"); - info("Checking that the layout-view shows the right value after update"); + info("Checking that the box model view shows the right value after update"); is(sizeElt.textContent, "200" + "\u00D7" + "100"); } function* testBackToFirstPage(inspector, view, testActor) { - info("Test that the layout-view works on the first page after going back"); + info("Test that the box model view works on the first page after going back"); info("Selecting the test node"); yield selectNode("p", inspector); - info("Checking that the layout-view shows the right value, which is the" + + info("Checking that the box model view shows the right value, which is the" + "modified value from step one because of the bfcache"); - let paddingElt = view.doc.querySelector(".layout-padding.layout-top > span"); + let paddingElt = view.doc.querySelector(".boxmodel-padding.boxmodel-top > span"); is(paddingElt.textContent, "20"); - info("Listening for layout-view changes and modifying the padding"); + info("Listening for box model view changes and modifying the padding"); let onUpdated = waitForUpdate(inspector); yield setStyle(testActor, "p", "padding", "100px"); yield onUpdated; - ok(true, "Layout-view got updated"); + ok(true, "Box model view got updated"); - info("Checking that the layout-view shows the right value after update"); + info("Checking that the box model view shows the right value after update"); is(paddingElt.textContent, "100"); } diff --git a/devtools/client/inspector/components/test/browser_boxmodel_update-after-reload.js b/devtools/client/inspector/components/test/browser_boxmodel_update-after-reload.js new file mode 100644 index 000000000000..7fc09bfa3607 --- /dev/null +++ b/devtools/client/inspector/components/test/browser_boxmodel_update-after-reload.js @@ -0,0 +1,40 @@ +/* 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"; + +// Test that the box model view continues to work after the page is reloaded + +add_task(function* () { + yield addTab(URL_ROOT + "doc_boxmodel_iframe1.html"); + let {inspector, view, testActor} = yield openBoxModelView(); + + info("Test that the box model view works on the first page"); + yield assertBoxModelView(inspector, view, testActor); + + info("Reload the page"); + yield testActor.reload(); + yield inspector.once("markuploaded"); + + info("Test that the box model view works on the reloaded page"); + yield assertBoxModelView(inspector, view, testActor); +}); + +function* assertBoxModelView(inspector, view, testActor) { + info("Selecting the test node"); + yield selectNode("p", inspector); + + info("Checking that the box model view shows the right value"); + let paddingElt = view.doc.querySelector(".boxmodel-padding.boxmodel-top > span"); + is(paddingElt.textContent, "50"); + + info("Listening for box model view changes and modifying the padding"); + let onUpdated = waitForUpdate(inspector); + yield setStyle(testActor, "p", "padding", "20px"); + yield onUpdated; + ok(true, "Box model view got updated"); + + info("Checking that the box model view shows the right value after update"); + is(paddingElt.textContent, "20"); +} diff --git a/devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js b/devtools/client/inspector/components/test/browser_boxmodel_update-in-iframes.js similarity index 73% rename from devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js rename to devtools/client/inspector/components/test/browser_boxmodel_update-in-iframes.js index 1847a38c2a80..50014ad1c741 100644 --- a/devtools/client/inspector/layout/test/browser_layout_update-in-iframes.js +++ b/devtools/client/inspector/components/test/browser_boxmodel_update-in-iframes.js @@ -4,12 +4,12 @@ "use strict"; -// Test that the layout-view for elements within iframes also updates when they +// Test that the box model view for elements within iframes also updates when they // change add_task(function* () { - yield addTab(URL_ROOT + "doc_layout_iframe1.html"); - let {inspector, view, testActor} = yield openLayoutView(); + yield addTab(URL_ROOT + "doc_boxmodel_iframe1.html"); + let {inspector, view, testActor} = yield openBoxModelView(); yield testResizingInIframe(inspector, view, testActor); yield testReflowsAfterIframeDeletion(inspector, view, testActor); @@ -21,22 +21,22 @@ function* testResizingInIframe(inspector, view, testActor) { info("Selecting the nested test node"); yield selectNodeInIframe2("div", inspector); - info("Checking that the layout-view shows the right value"); - let sizeElt = view.doc.querySelector(".layout-size > span"); + info("Checking that the box model view shows the right value"); + let sizeElt = view.doc.querySelector(".boxmodel-size > span"); is(sizeElt.textContent, "400\u00D7200"); - info("Listening for layout-view changes and modifying its size"); + info("Listening for box model view changes and modifying its size"); let onUpdated = waitForUpdate(inspector); yield setStyleInIframe2(testActor, "div", "width", "200px"); yield onUpdated; - ok(true, "Layout-view got updated"); + ok(true, "Box model view got updated"); - info("Checking that the layout-view shows the right value after update"); + info("Checking that the box model view shows the right value after update"); is(sizeElt.textContent, "200\u00D7200"); } function* testReflowsAfterIframeDeletion(inspector, view, testActor) { - info("Test reflows are still sent to the layout-view after deleting an " + + info("Test reflows are still sent to the box model view after deleting an " + "iframe"); info("Deleting the iframe2"); @@ -46,17 +46,17 @@ function* testReflowsAfterIframeDeletion(inspector, view, testActor) { info("Selecting the test node in iframe1"); yield selectNodeInIframe1("p", inspector); - info("Checking that the layout-view shows the right value"); - let sizeElt = view.doc.querySelector(".layout-size > span"); + info("Checking that the box model view shows the right value"); + let sizeElt = view.doc.querySelector(".boxmodel-size > span"); is(sizeElt.textContent, "100\u00D7100"); - info("Listening for layout-view changes and modifying its size"); + info("Listening for box model view changes and modifying its size"); let onUpdated = waitForUpdate(inspector); yield setStyleInIframe1(testActor, "p", "width", "200px"); yield onUpdated; - ok(true, "Layout-view got updated"); + ok(true, "Box model view got updated"); - info("Checking that the layout-view shows the right value after update"); + info("Checking that the box model view shows the right value after update"); is(sizeElt.textContent, "200\u00D7100"); } diff --git a/devtools/client/inspector/layout/test/doc_layout_iframe1.html b/devtools/client/inspector/components/test/doc_boxmodel_iframe1.html similarity index 56% rename from devtools/client/inspector/layout/test/doc_layout_iframe1.html rename to devtools/client/inspector/components/test/doc_boxmodel_iframe1.html index 2d188c106d65..eef48ce07964 100644 --- a/devtools/client/inspector/layout/test/doc_layout_iframe1.html +++ b/devtools/client/inspector/components/test/doc_boxmodel_iframe1.html @@ -1,3 +1,3 @@

Root page

- + diff --git a/devtools/client/inspector/layout/test/doc_layout_iframe2.html b/devtools/client/inspector/components/test/doc_boxmodel_iframe2.html similarity index 100% rename from devtools/client/inspector/layout/test/doc_layout_iframe2.html rename to devtools/client/inspector/components/test/doc_boxmodel_iframe2.html diff --git a/devtools/client/inspector/layout/test/head.js b/devtools/client/inspector/components/test/head.js similarity index 85% rename from devtools/client/inspector/layout/test/head.js rename to devtools/client/inspector/components/test/head.js index a92f1c4fcaf8..a39f4d57d850 100644 --- a/devtools/client/inspector/layout/test/head.js +++ b/devtools/client/inspector/components/test/head.js @@ -20,7 +20,7 @@ registerCleanupFunction(() => { * Simple DOM node accesor function that takes either a node or a string css * selector as argument and returns the corresponding node * FIXME: Delete this function and use inspector/test/head.js' getNode instead, - * and fix all layout-view tests to use nodeFronts instead of CPOWs. + * and fix all box model view tests to use nodeFronts instead of CPOWs. * @param {String|DOMNode} nodeOrSelector * @return {DOMNode} */ @@ -49,14 +49,14 @@ function selectAndHighlightNode(nodeOrSelector, inspector) { } /** - * Open the toolbox, with the inspector tool visible, and the layout-view - * sidebar tab selected. - * @return a promise that resolves when the inspector is ready and the layout + * Open the toolbox, with the inspector tool visible, and the computed view + * sidebar tab selected to display the box model view. + * @return a promise that resolves when the inspector is ready and the box model * view is visible and ready */ -function openLayoutView() { +function openBoxModelView() { return openInspectorSidebarTab("computedview").then(data => { - // The actual highligher show/hide methods are mocked in layoutview tests. + // The actual highligher show/hide methods are mocked in box model tests. // The highlighter is tested in devtools/inspector/test. function mockHighlighter({highlighter}) { highlighter.showBoxModel = function () { @@ -71,18 +71,18 @@ function openLayoutView() { return { toolbox: data.toolbox, inspector: data.inspector, - view: data.inspector.computedview.layoutView, + view: data.inspector.computedview.boxModelView, testActor: data.testActor }; }); } /** - * Wait for the layoutview-updated event. + * Wait for the boxmodel-view-updated event. * @return a promise */ function waitForUpdate(inspector) { - return inspector.once("layoutview-updated"); + return inspector.once("boxmodel-view-updated"); } function getStyle(testActor, selector, propertyName) { diff --git a/devtools/client/inspector/computed/computed.js b/devtools/client/inspector/computed/computed.js index 7d60f6712e0f..f1f04e1e5f70 100644 --- a/devtools/client/inspector/computed/computed.js +++ b/devtools/client/inspector/computed/computed.js @@ -23,7 +23,7 @@ const {getCssProperties} = require("devtools/shared/fronts/css-properties"); const overlays = require("devtools/client/inspector/shared/style-inspector-overlays"); const StyleInspectorMenu = require("devtools/client/inspector/shared/style-inspector-menu"); const {KeyShortcuts} = require("devtools/client/shared/key-shortcuts"); -const {LayoutView} = require("devtools/client/inspector/layout/layout"); +const {BoxModelView} = require("devtools/client/inspector/components/box-model"); const clipboardHelper = require("devtools/shared/platform/clipboard"); const STYLE_INSPECTOR_PROPERTIES = "devtools-shared/locale/styleinspector.properties"; @@ -1394,7 +1394,7 @@ function ComputedViewTool(inspector, window) { this.computedView = new CssComputedView(this.inspector, this.document, this.inspector.pageStyle); - this.layoutView = new LayoutView(this.inspector, this.document); + this.boxModelView = new BoxModelView(this.inspector, this.document); this.onSelected = this.onSelected.bind(this); this.refresh = this.refresh.bind(this); @@ -1503,9 +1503,9 @@ ComputedViewTool.prototype = { } this.computedView.destroy(); - this.layoutView.destroy(); + this.boxModelView.destroy(); - this.computedView = this.layoutView = this.document = this.inspector = null; + this.computedView = this.boxModelView = this.document = this.inspector = null; } }; diff --git a/devtools/client/inspector/computed/test/browser_computed_search-filter.js b/devtools/client/inspector/computed/test/browser_computed_search-filter.js index e79eba338cbf..10ba8229341f 100644 --- a/devtools/client/inspector/computed/test/browser_computed_search-filter.js +++ b/devtools/client/inspector/computed/test/browser_computed_search-filter.js @@ -34,7 +34,7 @@ function* testToggleDefaultStyles(inspector, computedView) { function* testAddTextInFilter(inspector, computedView) { info("setting filter text to \"color\""); let doc = computedView.styleDocument; - let layoutWrapper = doc.querySelector("#layout-wrapper"); + let boxModelWrapper = doc.querySelector("#boxmodel-wrapper"); let searchField = computedView.searchField; let onRefreshed = inspector.once("computed-view-refreshed"); let win = computedView.styleWindow; @@ -53,7 +53,7 @@ function* testAddTextInFilter(inspector, computedView) { synthesizeKeys("color", win); yield onRefreshed; - ok(layoutWrapper.hidden, "Layout view is hidden"); + ok(boxModelWrapper.hidden, "Box model is hidden"); info("check that the correct properties are visible"); diff --git a/devtools/client/inspector/computed/test/browser_computed_search-filter_clear.js b/devtools/client/inspector/computed/test/browser_computed_search-filter_clear.js index 9183b12945ff..bd989854f9f9 100644 --- a/devtools/client/inspector/computed/test/browser_computed_search-filter_clear.js +++ b/devtools/client/inspector/computed/test/browser_computed_search-filter_clear.js @@ -50,7 +50,7 @@ function* testClearSearchFilter(inspector, computedView) { let win = computedView.styleWindow; let doc = computedView.styleDocument; - let layoutWrapper = doc.querySelector("#layout-wrapper"); + let boxModelWrapper = doc.querySelector("#boxmodel-wrapper"); let propertyViews = computedView.propertyViews; let searchField = computedView.searchField; let searchClearButton = computedView.searchClearButton; @@ -59,7 +59,7 @@ function* testClearSearchFilter(inspector, computedView) { EventUtils.synthesizeMouseAtCenter(searchClearButton, {}, win); yield onRefreshed; - ok(!layoutWrapper.hidden, "Layout view is displayed"); + ok(!boxModelWrapper.hidden, "Box model is displayed"); info("Check that the correct properties are visible"); diff --git a/devtools/client/inspector/inspector-panel.js b/devtools/client/inspector/inspector-panel.js index ff7c513bd367..f8f35580405f 100644 --- a/devtools/client/inspector/inspector-panel.js +++ b/devtools/client/inspector/inspector-panel.js @@ -38,7 +38,7 @@ const TOOLBOX_L10N = new LocalizationHelper("devtools/locale/toolbox.properties" /** * Represents an open instance of the Inspector for a tab. * The inspector controls the breadcrumbs, the markup view, and the sidebar - * (computed view, rule view, font view and layout view). + * (computed view, rule view, font view and animation inspector). * * Events: * - ready @@ -52,8 +52,8 @@ const TOOLBOX_L10N = new LocalizationHelper("devtools/locale/toolbox.properties" * Fired when the markup-view frame has loaded * - breadcrumbs-updated * Fired when the breadcrumb widget updates to a new node - * - layoutview-updated - * Fired when the layoutview (box model) updates to a new node + * - boxmodel-view-updated + * Fired when the box model updates to a new node * - markupmutation * Fired after markup mutations have been processed by the markup-view * - computed-view-refreshed diff --git a/devtools/client/inspector/inspector.xul b/devtools/client/inspector/inspector.xul index 8eab10f58170..f0ebb4f61294 100644 --- a/devtools/client/inspector/inspector.xul +++ b/devtools/client/inspector/inspector.xul @@ -9,7 +9,7 @@ - + @@ -116,54 +116,54 @@ - - - + + + &layoutViewTitle; - - - &margin.tooltip; - - &border.tooltip; - - &padding.tooltip; - - + + + &margin.tooltip; + + &border.tooltip; + + &padding.tooltip; + + - - - - + + + + - - - - + + + + - - - - + + + + - + - - - + + + - + - + diff --git a/devtools/client/inspector/layout/moz.build b/devtools/client/inspector/layout/moz.build deleted file mode 100644 index 4cd47df0da42..000000000000 --- a/devtools/client/inspector/layout/moz.build +++ /dev/null @@ -1,11 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -DevToolsModules( - 'layout.js', -) - -BROWSER_CHROME_MANIFESTS += ['test/browser.ini'] diff --git a/devtools/client/inspector/layout/test/browser.ini b/devtools/client/inspector/layout/test/browser.ini deleted file mode 100644 index ea74092aa903..000000000000 --- a/devtools/client/inspector/layout/test/browser.ini +++ /dev/null @@ -1,29 +0,0 @@ -[DEFAULT] -tags = devtools -subsuite = devtools -support-files = - doc_layout_iframe1.html - doc_layout_iframe2.html - head.js - !/devtools/client/commandline/test/helpers.js - !/devtools/client/framework/test/shared-head.js - !/devtools/client/inspector/test/head.js - !/devtools/client/inspector/test/shared-head.js - !/devtools/client/shared/test/test-actor.js - !/devtools/client/shared/test/test-actor-registry.js - -[browser_layout.js] -[browser_layout_editablemodel.js] -# [browser_layout_editablemodel_allproperties.js] -# Disabled for too many intermittent failures (bug 1009322) -[browser_layout_editablemodel_bluronclick.js] -[browser_layout_editablemodel_border.js] -[browser_layout_editablemodel_stylerules.js] -[browser_layout_guides.js] -[browser_layout_rotate-labels-on-sides.js] -[browser_layout_sync.js] -[browser_layout_tooltips.js] -[browser_layout_update-after-navigation.js] -[browser_layout_update-after-reload.js] -# [browser_layout_update-in-iframes.js] -# Bug 1020038 layout-view updates for iframe elements changes diff --git a/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js b/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js deleted file mode 100644 index 5ec5bbff4738..000000000000 --- a/devtools/client/inspector/layout/test/browser_layout_rotate-labels-on-sides.js +++ /dev/null @@ -1,49 +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"; - -// Test that longer values are rotated on the side - -const res1 = [ - {selector: ".layout-margin.layout-top > span", value: 30}, - {selector: ".layout-margin.layout-left > span", value: "auto"}, - {selector: ".layout-margin.layout-bottom > span", value: 30}, - {selector: ".layout-margin.layout-right > span", value: "auto"}, - {selector: ".layout-padding.layout-top > span", value: 20}, - {selector: ".layout-padding.layout-left > span", value: 2000000}, - {selector: ".layout-padding.layout-bottom > span", value: 20}, - {selector: ".layout-padding.layout-right > span", value: 20}, - {selector: ".layout-border.layout-top > span", value: 10}, - {selector: ".layout-border.layout-left > span", value: 10}, - {selector: ".layout-border.layout-bottom > span", value: 10}, - {selector: ".layout-border.layout-right > span", value: 10}, -]; - -const TEST_URI = encodeURIComponent([ - "", - "
" -].join("")); -const LONG_TEXT_ROTATE_LIMIT = 3; - -add_task(function* () { - yield addTab("data:text/html," + TEST_URI); - let {inspector, view} = yield openLayoutView(); - yield selectNode("div", inspector); - - for (let i = 0; i < res1.length; i++) { - let elt = view.doc.querySelector(res1[i].selector); - let isLong = elt.textContent.length > LONG_TEXT_ROTATE_LIMIT; - let classList = elt.parentNode.classList; - let canBeRotated = classList.contains("layout-left") || - classList.contains("layout-right"); - let isRotated = classList.contains("layout-rotate"); - - is(canBeRotated && isLong, - isRotated, res1[i].selector + " correctly rotated."); - } -}); diff --git a/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js b/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js deleted file mode 100644 index 1352445dbc85..000000000000 --- a/devtools/client/inspector/layout/test/browser_layout_update-after-reload.js +++ /dev/null @@ -1,40 +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"; - -// Test that the layout-view continues to work after the page is reloaded - -add_task(function* () { - yield addTab(URL_ROOT + "doc_layout_iframe1.html"); - let {inspector, view, testActor} = yield openLayoutView(); - - info("Test that the layout-view works on the first page"); - yield assertLayoutView(inspector, view, testActor); - - info("Reload the page"); - yield testActor.reload(); - yield inspector.once("markuploaded"); - - info("Test that the layout-view works on the reloaded page"); - yield assertLayoutView(inspector, view, testActor); -}); - -function* assertLayoutView(inspector, view, testActor) { - info("Selecting the test node"); - yield selectNode("p", inspector); - - info("Checking that the layout-view shows the right value"); - let paddingElt = view.doc.querySelector(".layout-padding.layout-top > span"); - is(paddingElt.textContent, "50"); - - info("Listening for layout-view changes and modifying the padding"); - let onUpdated = waitForUpdate(inspector); - yield setStyle(testActor, "p", "padding", "20px"); - yield onUpdated; - ok(true, "Layout-view got updated"); - - info("Checking that the layout-view shows the right value after update"); - is(paddingElt.textContent, "20"); -} diff --git a/devtools/client/inspector/moz.build b/devtools/client/inspector/moz.build index 884fb9a39330..8d2e22b00fbc 100644 --- a/devtools/client/inspector/moz.build +++ b/devtools/client/inspector/moz.build @@ -6,7 +6,6 @@ DIRS += [ 'components', 'computed', 'fonts', - 'layout', 'markup', 'rules', 'shared' diff --git a/devtools/client/jar.mn b/devtools/client/jar.mn index 8f1f1d4d884d..8f19f276b26b 100644 --- a/devtools/client/jar.mn +++ b/devtools/client/jar.mn @@ -26,7 +26,6 @@ devtools.jar: content/styleeditor/styleeditor.xul (styleeditor/styleeditor.xul) content/storage/storage.xul (storage/storage.xul) content/inspector/fonts/fonts.js (inspector/fonts/fonts.js) - content/inspector/layout/layout.js (inspector/layout/layout.js) content/inspector/markup/markup.xhtml (inspector/markup/markup.xhtml) content/animationinspector/animation-controller.js (animationinspector/animation-controller.js) content/animationinspector/animation-panel.js (animationinspector/animation-panel.js) @@ -212,7 +211,7 @@ devtools.jar: skin/images/itemArrow-ltr.svg (themes/images/itemArrow-ltr.svg) skin/images/noise.png (themes/images/noise.png) skin/images/dropmarker.svg (themes/images/dropmarker.svg) - skin/layout.css (themes/layout.css) + skin/boxmodel.css (themes/boxmodel.css) skin/images/geometry-editor.svg (themes/images/geometry-editor.svg) skin/images/pause.svg (themes/images/pause.svg) skin/images/play.svg (themes/images/play.svg) diff --git a/devtools/client/themes/layout.css b/devtools/client/themes/boxmodel.css similarity index 61% rename from devtools/client/themes/layout.css rename to devtools/client/themes/boxmodel.css index 0f3019fe1bfe..5a3289faeda6 100644 --- a/devtools/client/themes/layout.css +++ b/devtools/client/themes/boxmodel.css @@ -2,13 +2,13 @@ * 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/ */ -#layout-wrapper { +#boxmodel-wrapper { border-bottom-style: solid; border-bottom-width: 1px; border-color: var(--theme-splitter-color); } -#layout-container { +#boxmodel-container { /* The view will grow bigger as the window gets resized, until 400px */ max-width: 400px; margin: 0px auto; @@ -17,8 +17,8 @@ /* Header */ -#layout-header, -#layout-info { +#boxmodel-header, +#boxmodel-info { display: flex; align-items: center; padding: 4px 17px; @@ -34,7 +34,7 @@ /* Main: contains the box-model regions */ -#layout-main { +#boxmodel-main { position: relative; box-sizing: border-box; /* The regions are semi-transparent, so the white background is partly @@ -46,192 +46,192 @@ width: calc(100% - 2 * 14px); } -.layout-margin, -.layout-size { +.boxmodel-margin, +.boxmodel-size { color: var(--theme-highlight-blue); } /* Regions are 3 nested elements with wide borders and outlines */ -#layout-content { +#boxmodel-content { height: 18px; } -#layout-margins, -#layout-borders, -#layout-padding { +#boxmodel-margins, +#boxmodel-borders, +#boxmodel-padding { border-color: hsla(210,100%,85%,0.2); border-width: 18px; border-style: solid; outline: dotted 1px hsl(210,100%,85%); } -#layout-margins { +#boxmodel-margins { /* This opacity applies to all of the regions, since they are nested */ opacity: .8; } /* Regions colors */ -#layout-margins { +#boxmodel-margins { border-color: #edff64; } -#layout-borders { +#boxmodel-borders { border-color: #444444; } -#layout-padding { +#boxmodel-padding { border-color: #6a5acd; } -#layout-content { +#boxmodel-content { background-color: #87ceeb; } -.theme-firebug #layout-main, -.theme-firebug #layout-borders, -.theme-firebug #layout-content { +.theme-firebug #boxmodel-main, +.theme-firebug #boxmodel-borders, +.theme-firebug #boxmodel-content { border-style: solid; } -.theme-firebug #layout-main, -.theme-firebug #layout-header { +.theme-firebug #boxmodel-main, +.theme-firebug #boxmodel-header { font-family: var(--proportional-font-family); } -.theme-firebug #layout-main { +.theme-firebug #boxmodel-main { color: var(--theme-body-color); font-size: var(--theme-toolbar-font-size); } -.theme-firebug #layout-header { +.theme-firebug #boxmodel-header { font-size: var(--theme-toolbar-font-size); } /* Editable region sizes are contained in absolutely positioned

*/ -#layout-main > p { +#boxmodel-main > p { position: absolute; pointer-events: none; margin: 0; text-align: center; } -#layout-main > p > span, -#layout-main > p > input { +#boxmodel-main > p > span, +#boxmodel-main > p > input { vertical-align: middle; pointer-events: auto; } /* Coordinates for the region sizes */ -.layout-top, -.layout-bottom { +.boxmodel-top, +.boxmodel-bottom { width: calc(100% - 2px); text-align: center; } -.layout-padding.layout-top { +.boxmodel-padding.boxmodel-top { top: 37px; } -.layout-padding.layout-bottom { +.boxmodel-padding.boxmodel-bottom { bottom: 38px; } -.layout-border.layout-top { +.boxmodel-border.boxmodel-top { top: 19px; } -.layout-border.layout-bottom { +.boxmodel-border.boxmodel-bottom { bottom: 20px; } -.layout-margin.layout-top { +.boxmodel-margin.boxmodel-top { top: 1px; } -.layout-margin.layout-bottom { +.boxmodel-margin.boxmodel-bottom { bottom: 2px; } -.layout-size, -.layout-margin.layout-left, -.layout-margin.layout-right, -.layout-border.layout-left, -.layout-border.layout-right, -.layout-padding.layout-left, -.layout-padding.layout-right { +.boxmodel-size, +.boxmodel-margin.boxmodel-left, +.boxmodel-margin.boxmodel-right, +.boxmodel-border.boxmodel-left, +.boxmodel-border.boxmodel-right, +.boxmodel-padding.boxmodel-left, +.boxmodel-padding.boxmodel-right { top: 22px; line-height: 80px; } -.layout-size { +.boxmodel-size { width: calc(100% - 2px); } -.layout-margin.layout-right, -.layout-margin.layout-left, -.layout-border.layout-left, -.layout-border.layout-right, -.layout-padding.layout-right, -.layout-padding.layout-left { +.boxmodel-margin.boxmodel-right, +.boxmodel-margin.boxmodel-left, +.boxmodel-border.boxmodel-left, +.boxmodel-border.boxmodel-right, +.boxmodel-padding.boxmodel-right, +.boxmodel-padding.boxmodel-left { width: 21px; } -.layout-padding.layout-left { +.boxmodel-padding.boxmodel-left { left: 35px; } -.layout-padding.layout-right { +.boxmodel-padding.boxmodel-right { right: 35px; } -.layout-border.layout-left { +.boxmodel-border.boxmodel-left { left: 16px; } -.layout-border.layout-right { +.boxmodel-border.boxmodel-right { right: 17px; } -.layout-margin.layout-right { +.boxmodel-margin.boxmodel-right { right: 0; } -.layout-margin.layout-left { +.boxmodel-margin.boxmodel-left { left: 0; } -.layout-rotate.layout-left:not(.layout-editing) { +.boxmodel-rotate.boxmodel-left:not(.boxmodel-editing) { transform: rotate(-90deg); } -.layout-rotate.layout-right:not(.layout-editing) { +.boxmodel-rotate.boxmodel-right:not(.boxmodel-editing) { transform: rotate(90deg); } /* Legend: displayed inside regions */ -.layout-legend { +.boxmodel-legend { position: absolute; margin: 2px 6px; z-index: 1; } -.layout-legend[data-box="margin"] { +.boxmodel-legend[data-box="margin"] { color: var(--theme-highlight-blue); } /* Editable fields */ -.layout-editable { +.boxmodel-editable { border: 1px dashed transparent; -moz-user-select: text; } -.layout-editable:hover { +.boxmodel-editable:hover { border-bottom-color: hsl(0, 0%, 50%); } @@ -242,17 +242,17 @@ /* Make sure the content size doesn't appear as editable like the other sizes */ -.layout-size > span { +.boxmodel-size > span { cursor: default; } -/* Layout info: contains the position and size of the element */ +/* Box Model Info: contains the position and size of the element */ -#layout-element-size { +#boxmodel-element-size { flex: 1; } -#layout-position-group { +#boxmodel-position-group { display: flex; align-items: center; } diff --git a/devtools/server/actors/highlighters.js b/devtools/server/actors/highlighters.js index f50e1d4d7e51..3df88f39cae3 100644 --- a/devtools/server/actors/highlighters.js +++ b/devtools/server/actors/highlighters.js @@ -72,7 +72,7 @@ exports.register = register; * The InspectorActor will always return the same instance of * HighlighterActor if asked several times and this instance is used in the * toolbox to highlighter elements's box-model from the markup-view, - * layout-view, console, debugger, ... as well as select elements with the + * box model view, console, debugger, ... as well as select elements with the * pointer (pick). * * Other types of highlighter actors exist and can be accessed via the diff --git a/devtools/server/actors/inspector.js b/devtools/server/actors/inspector.js index 453477641b0c..bf953134c02f 100644 --- a/devtools/server/actors/inspector.js +++ b/devtools/server/actors/inspector.js @@ -2653,7 +2653,7 @@ exports.InspectorActor = protocol.ActorClassWithSpec(inspectorSpec, { * The same instance will always be returned by this method when called * several times. * The highlighter actor returned here is used to highlighter elements's - * box-models from the markup-view, layout-view, console, debugger, ... as + * box-models from the markup-view, box model, console, debugger, ... as * well as select elements with the pointer (pick). * * @param {Boolean} autohide Optionally autohide the highlighter after an diff --git a/devtools/server/actors/styles.js b/devtools/server/actors/styles.js index 4e9bf36c48f5..cdb812882814 100644 --- a/devtools/server/actors/styles.js +++ b/devtools/server/actors/styles.js @@ -760,7 +760,7 @@ var PageStyleActor = protocol.ActorClassWithSpec(pageStyleSpec, { let layout = {}; - // First, we update the first part of the layout view, with + // First, we update the first part of the box model view, with // the size of the element. let clientRect = node.rawNode.getBoundingClientRect(); From 6007ad04a95387a918545145a316c55bcf13a295 Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Sun, 18 Sep 2016 14:07:51 +0800 Subject: [PATCH 2/5] Bug 1303469 - Stub form autofill system extension. r=rhelmer MozReview-Commit-ID: JXbUQdCwXN0 --HG-- rename : browser/extensions/webcompat/bootstrap.js => browser/extensions/formautofill/bootstrap.js rename : browser/extensions/webcompat/install.rdf.in => browser/extensions/formautofill/install.rdf.in rename : browser/extensions/webcompat/moz.build => browser/extensions/formautofill/moz.build rename : browser/extensions/webcompat/test/browser.ini => browser/extensions/formautofill/test/browser/browser.ini rename : browser/extensions/webcompat/test/browser_webcompat_stub_check.js => browser/extensions/formautofill/test/browser/browser_check_installed.js extra : histedit_source : 655db162ef67f733bdf80e5410f75da7dc6e5d36 --- browser/extensions/formautofill/bootstrap.js | 10 ++++++ .../extensions/formautofill/install.rdf.in | 32 +++++++++++++++++++ browser/extensions/formautofill/moz.build | 18 +++++++++++ .../formautofill/test/browser/browser.ini | 3 ++ .../test/browser/browser_check_installed.js | 14 ++++++++ browser/extensions/moz.build | 1 + browser/extensions/webcompat/install.rdf.in | 2 +- .../talos/talos/xtalos/xperf_whitelist.json | 1 + 8 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 browser/extensions/formautofill/bootstrap.js create mode 100644 browser/extensions/formautofill/install.rdf.in create mode 100644 browser/extensions/formautofill/moz.build create mode 100644 browser/extensions/formautofill/test/browser/browser.ini create mode 100644 browser/extensions/formautofill/test/browser/browser_check_installed.js diff --git a/browser/extensions/formautofill/bootstrap.js b/browser/extensions/formautofill/bootstrap.js new file mode 100644 index 000000000000..10b5e6ce6f05 --- /dev/null +++ b/browser/extensions/formautofill/bootstrap.js @@ -0,0 +1,10 @@ +/* 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 startup() {} +function shutdown() {} +function install() {} +function uninstall() {} diff --git a/browser/extensions/formautofill/install.rdf.in b/browser/extensions/formautofill/install.rdf.in new file mode 100644 index 000000000000..5e34051ba022 --- /dev/null +++ b/browser/extensions/formautofill/install.rdf.in @@ -0,0 +1,32 @@ + + + +#filter substitution + + + + + formautofill@mozilla.org + 1.0 + 2 + true + true + + + + + {ec8030f7-c20a-464f-9b0e-13a3a9e97384} + @MOZ_APP_VERSION@ + @MOZ_APP_MAXVERSION@ + + + + + Form Autofill + Autofill forms with saved profiles + + diff --git a/browser/extensions/formautofill/moz.build b/browser/extensions/formautofill/moz.build new file mode 100644 index 000000000000..ebb9a90ea63e --- /dev/null +++ b/browser/extensions/formautofill/moz.build @@ -0,0 +1,18 @@ +# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION'] +DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION'] + +FINAL_TARGET_FILES.features['formautofill@mozilla.org'] += [ + 'bootstrap.js' +] + +FINAL_TARGET_PP_FILES.features['formautofill@mozilla.org'] += [ + 'install.rdf.in' +] + +BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini'] diff --git a/browser/extensions/formautofill/test/browser/browser.ini b/browser/extensions/formautofill/test/browser/browser.ini new file mode 100644 index 000000000000..500224636708 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/browser.ini @@ -0,0 +1,3 @@ +[DEFAULT] + +[browser_check_installed.js] diff --git a/browser/extensions/formautofill/test/browser/browser_check_installed.js b/browser/extensions/formautofill/test/browser/browser_check_installed.js new file mode 100644 index 000000000000..b018c0f71f43 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/browser_check_installed.js @@ -0,0 +1,14 @@ +"use strict"; + +add_task(function* test_enabled() { + let addon = yield new Promise( + resolve => AddonManager.getAddonByID("formautofill@mozilla.org", resolve) + ); + isnot(addon, null, "Check addon exists"); + is(addon.version, "1.0", "Check version"); + is(addon.name, "Form Autofill", "Check name"); + ok(addon.isCompatible, "Check application compatibility"); + ok(!addon.appDisabled, "Check not app disabled"); + ok(addon.isActive, "Check addon is active"); + is(addon.type, "extension", "Check type is 'extension'"); +}); diff --git a/browser/extensions/moz.build b/browser/extensions/moz.build index 41cafd856a67..bac4210020de 100644 --- a/browser/extensions/moz.build +++ b/browser/extensions/moz.build @@ -15,4 +15,5 @@ DIRS += [ if 'a' in CONFIG['GRE_MILESTONE']: DIRS += [ 'flyweb', + 'formautofill', ] diff --git a/browser/extensions/webcompat/install.rdf.in b/browser/extensions/webcompat/install.rdf.in index 2206f401ce03..2c4406f25799 100644 --- a/browser/extensions/webcompat/install.rdf.in +++ b/browser/extensions/webcompat/install.rdf.in @@ -15,7 +15,7 @@ true true - diff --git a/testing/talos/talos/xtalos/xperf_whitelist.json b/testing/talos/talos/xtalos/xperf_whitelist.json index d6c2e7879046..570c3c8bb42b 100644 --- a/testing/talos/talos/xtalos/xperf_whitelist.json +++ b/testing/talos/talos/xtalos/xperf_whitelist.json @@ -8,6 +8,7 @@ "{firefox}\\browser\\omni.ja": {"mincount": 0, "maxcount": 28, "minbytes": 0, "maxbytes": 1835008}, "{firefox}\\browser\\features\\e10srollout@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000}, "{firefox}\\browser\\features\\flyweb@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000}, + "{firefox}\\browser\\features\\formautofill@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000}, "{firefox}\\browser\\features\\loop@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000}, "{firefox}\\browser\\features\\firefox@getpocket.com.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000}, "{firefox}\\browser\\features\\webcompat@mozilla.org.xpi": {"mincount": 0, "maxcount": 100, "minbytes": 0, "maxbytes": 10000000}, From 6e48c96390bc0b30ce6369401532f3336679c8a5 Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Fri, 16 Sep 2016 16:39:51 -0700 Subject: [PATCH 3/5] Bug 1303469 - Initial formautofill .eslintrc. r=rhelmer MozReview-Commit-ID: 8rbFYPksUMi --HG-- rename : toolkit/components/extensions/.eslintrc => browser/extensions/formautofill/.eslintrc extra : histedit_source : 8022a4b4c7f57e6d79e947c3a72f5a7d67aef36f --- browser/extensions/formautofill/.eslintrc | 473 ++++++++++++++++++ browser/extensions/formautofill/bootstrap.js | 2 + .../formautofill/test/browser/.eslintrc | 5 + 3 files changed, 480 insertions(+) create mode 100644 browser/extensions/formautofill/.eslintrc create mode 100644 browser/extensions/formautofill/test/browser/.eslintrc diff --git a/browser/extensions/formautofill/.eslintrc b/browser/extensions/formautofill/.eslintrc new file mode 100644 index 000000000000..cacd9c22ed3d --- /dev/null +++ b/browser/extensions/formautofill/.eslintrc @@ -0,0 +1,473 @@ +{ + "extends": "../../.eslintrc", + + "globals": { + "Components": true, + "dump": true, + "TextDecoder": false, + "TextEncoder": false, + }, + + "rules": { + // Rules from the mozilla plugin + "mozilla/balanced-listeners": 2, + "mozilla/mark-test-function-used": 1, + "mozilla/no-aArgs": 1, + "mozilla/no-cpows-in-tests": 1, + "mozilla/var-only-at-top-level": 1, + + "valid-jsdoc": [2, { + "prefer": { + "return": "returns", + }, + "preferType": { + "Boolean": "boolean", + "Number": "number", + "String": "string", + "bool": "boolean", + }, + "requireParamDescription": false, + "requireReturn": false, + "requireReturnDescription": false, + }], + + // Braces only needed for multi-line arrow function blocks + // "arrow-body-style": [2, "as-needed"], + + // Require spacing around => + "arrow-spacing": 2, + + // Always require spacing around a single line block + "block-spacing": 1, + + // Forbid spaces inside the square brackets of array literals. + "array-bracket-spacing": [2, "never"], + + // Forbid spaces inside the curly brackets of object literals. + "object-curly-spacing": [2, "never"], + + // No space padding in parentheses + "space-in-parens": [2, "never"], + + // Enforce one true brace style (opening brace on the same line) and avoid + // start and end braces on the same line. + "brace-style": [2, "1tbs", {"allowSingleLine": true}], + + // No space before always a space after a comma + "comma-spacing": [2, {"before": false, "after": true}], + + // Commas at the end of the line not the start + "comma-style": 2, + + // Don't require spaces around computed properties + "computed-property-spacing": [1, "never"], + + // Functions are not required to consistently return something or nothing + "consistent-return": 0, + + // Require braces around blocks that start a new line + "curly": [2, "all"], + + // Always require a trailing EOL + "eol-last": 2, + + // Require function* name() + "generator-star-spacing": [2, {"before": false, "after": true}], + + // Two space indent + "indent": [2, 2, {"SwitchCase": 1}], + + // Space after colon not before in property declarations + "key-spacing": [2, {"beforeColon": false, "afterColon": true, "mode": "minimum"}], + + // Require spaces before and after finally, catch, etc. + "keyword-spacing": 2, + + // Unix linebreaks + "linebreak-style": [2, "unix"], + + // Always require parenthesis for new calls + "new-parens": 2, + + // Use [] instead of Array() + "no-array-constructor": 2, + + // No duplicate arguments in function declarations + "no-dupe-args": 2, + + // No duplicate keys in object declarations + "no-dupe-keys": 2, + + // No duplicate cases in switch statements + "no-duplicate-case": 2, + + // If an if block ends with a return no need for an else block + // "no-else-return": 2, + + // Disallow empty statements. This will report an error for: + // try { something(); } catch (e) {} + // but will not report it for: + // try { something(); } catch (e) { /* Silencing the error because ...*/ } + // which is a valid use case. + "no-empty": 2, + + // No empty character classes in regex + "no-empty-character-class": 2, + + // Disallow empty destructuring + "no-empty-pattern": 2, + + // No assiging to exception variable + "no-ex-assign": 2, + + // No using !! where casting to boolean is already happening + "no-extra-boolean-cast": 1, + + // No double semicolon + "no-extra-semi": 2, + + // No overwriting defined functions + "no-func-assign": 2, + + // No invalid regular expresions + "no-invalid-regexp": 2, + + // No odd whitespace characters + "no-irregular-whitespace": 2, + + // No single if block inside an else block + "no-lonely-if": 1, + + // No mixing spaces and tabs in indent + "no-mixed-spaces-and-tabs": [2, "smart-tabs"], + + // Disallow use of multiple spaces (sometimes used to align const values, + // array or object items, etc.). It's hard to maintain and doesn't add that + // much benefit. + "no-multi-spaces": 1, + + // No reassigning native JS objects + "no-native-reassign": 2, + + // No (!foo in bar) + "no-negated-in-lhs": 2, + + // Nested ternary statements are confusing + "no-nested-ternary": 2, + + // Use {} instead of new Object() + "no-new-object": 2, + + // No Math() or JSON() + "no-obj-calls": 2, + + // No octal literals + "no-octal": 2, + + // No redeclaring variables + "no-redeclare": 2, + + // No unnecessary comparisons + "no-self-compare": 2, + + // No spaces between function name and parentheses + "no-spaced-func": 1, + + // No trailing whitespace + "no-trailing-spaces": 2, + + // Error on newline where a semicolon is needed + "no-unexpected-multiline": 2, + + // No unreachable statements + "no-unreachable": 2, + + // No expressions where a statement is expected + "no-unused-expressions": 2, + + // No declaring variables that are never used + "no-unused-vars": [2, {"args": "none", "varsIgnorePattern": "^(Cc|Ci|Cr|Cu|EXPORTED_SYMBOLS)$"}], + + // No using variables before defined + "no-use-before-define": 2, + + // No using with + "no-with": 2, + + // Always require semicolon at end of statement + "semi": [2, "always"], + + // Require space before blocks + "space-before-blocks": 2, + + // Never use spaces before function parentheses + "space-before-function-paren": [2, {"anonymous": "never", "named": "never"}], + + // Require spaces around operators, except for a|0. + "space-infix-ops": [2, {"int32Hint": true}], + + // ++ and -- should not need spacing + "space-unary-ops": [1, {"nonwords": false}], + + // No comparisons to NaN + "use-isnan": 2, + + // Only check typeof against valid results + "valid-typeof": 2, + + // Disallow using variables outside the blocks they are defined (especially + // since only let and const are used, see "no-var"). + "block-scoped-var": 2, + + // Allow trailing commas for easy list extension. Having them does not + // impair readability, but also not required either. + "comma-dangle": [2, "always-multiline"], + + // Warn about cyclomatic complexity in functions. + "complexity": 1, + + // Don't warn for inconsistent naming when capturing this (not so important + // with auto-binding fat arrow functions). + // "consistent-this": [2, "self"], + + // Don't require a default case in switch statements. Avoid being forced to + // add a bogus default when you know all possible cases are handled. + "default-case": 0, + + // Enforce dots on the next line with property name. + "dot-location": [2, "property"], + + // Encourage the use of dot notation whenever possible. + "dot-notation": 2, + + // Allow using == instead of ===, in the interest of landing something since + // the devtools codebase is split on convention here. + "eqeqeq": 0, + + // Don't require function expressions to have a name. + // This makes the code more verbose and hard to read. Our engine already + // does a fantastic job assigning a name to the function, which includes + // the enclosing function name, and worst case you have a line number that + // you can just look up. + "func-names": 0, + + // Allow use of function declarations and expressions. + "func-style": 0, + + // Don't enforce the maximum depth that blocks can be nested. The complexity + // rule is a better rule to check this. + "max-depth": 0, + + // Maximum length of a line. + // Disabled because we exceed this in too many places. + "max-len": [0, 80], + + // Maximum depth callbacks can be nested. + "max-nested-callbacks": [2, 4], + + // Don't limit the number of parameters that can be used in a function. + "max-params": 0, + + // Don't limit the maximum number of statement allowed in a function. We + // already have the complexity rule that's a better measurement. + "max-statements": 0, + + // Don't require a capital letter for constructors, only check if all new + // operators are followed by a capital letter. Don't warn when capitalized + // functions are used without the new operator. + "new-cap": [0, {"capIsNew": false}], + + // Allow use of bitwise operators. + "no-bitwise": 0, + + // Disallow use of arguments.caller or arguments.callee. + "no-caller": 2, + + // Disallow the catch clause parameter name being the same as a variable in + // the outer scope, to avoid confusion. + "no-catch-shadow": 0, + + // Disallow assignment in conditional expressions. + "no-cond-assign": 2, + + // Disallow using the console API. + "no-console": 2, + + // Allow using constant expressions in conditions like while (true) + "no-constant-condition": 0, + + // Allow use of the continue statement. + "no-continue": 0, + + // Disallow control characters in regular expressions. + "no-control-regex": 2, + + // Disallow use of debugger. + "no-debugger": 2, + + // Disallow deletion of variables (deleting properties is fine). + "no-delete-var": 2, + + // Allow division operators explicitly at beginning of regular expression. + "no-div-regex": 0, + + // Disallow use of eval(). We have other APIs to evaluate code in content. + "no-eval": 2, + + // Disallow adding to native types + "no-extend-native": 2, + + // Disallow unnecessary function binding. + "no-extra-bind": 2, + + // Allow unnecessary parentheses, as they may make the code more readable. + "no-extra-parens": 0, + + // Disallow fallthrough of case statements, except if there is a comment. + "no-fallthrough": 2, + + // Allow the use of leading or trailing decimal points in numeric literals. + "no-floating-decimal": 0, + + // Allow comments inline after code. + "no-inline-comments": 0, + + // Disallow use of labels for anything other then loops and switches. + "no-labels": [2, { "allowLoop": true }], + + // Disallow use of multiline strings (use template strings instead). + "no-multi-str": 1, + + // Disallow multiple empty lines. + "no-multiple-empty-lines": [1, {"max": 2}], + + // Allow reassignment of function parameters. + "no-param-reassign": 0, + + // Allow string concatenation with __dirname and __filename (not a node env). + "no-path-concat": 0, + + // Allow use of unary operators, ++ and --. + "no-plusplus": 0, + + // Allow using process.env (not a node environment). + "no-process-env": 0, + + // Allow using process.exit (not a node environment). + "no-process-exit": 0, + + // Disallow usage of __proto__ property. + "no-proto": 2, + + // Disallow multiple spaces in a regular expression literal. + "no-regex-spaces": 2, + + // Allow reserved words being used as object literal keys. + "no-reserved-keys": 0, + + // Don't restrict usage of specified node modules (not a node environment). + "no-restricted-modules": 0, + + // Disallow use of assignment in return statement. It is preferable for a + // single line of code to have only one easily predictable effect. + "no-return-assign": 2, + + // Don't warn about declaration of variables already declared in the outer scope. + "no-shadow": 0, + + // Disallow shadowing of names such as arguments. + "no-shadow-restricted-names": 2, + + // Allow use of synchronous methods (not a node environment). + "no-sync": 0, + + // Allow the use of ternary operators. + "no-ternary": 0, + + // Disallow throwing literals (eg. throw "error" instead of + // throw new Error("error")). + "no-throw-literal": 2, + + // Disallow use of undeclared variables unless mentioned in a /* global */ + // block. Note that globals from head.js are automatically imported in tests + // by the import-headjs-globals rule form the mozilla eslint plugin. + "no-undef": 2, + + // Allow dangling underscores in identifiers (for privates). + "no-underscore-dangle": 0, + + // Allow use of undefined variable. + "no-undefined": 0, + + // Disallow the use of Boolean literals in conditional expressions. + "no-unneeded-ternary": 2, + + // We use var-only-at-top-level instead of no-var as we allow top level + // vars. + "no-var": 0, + + // Allow using TODO/FIXME comments. + "no-warning-comments": 0, + + // Don't require method and property shorthand syntax for object literals. + // We use this in the code a lot, but not consistently, and this seems more + // like something to check at code review time. + "object-shorthand": 0, + + // Allow more than one variable declaration per function. + "one-var": 0, + + // Disallow padding within blocks. + "padded-blocks": [1, "never"], + + // Don't require quotes around object literal property names. + "quote-props": 0, + + // Double quotes should be used. + "quotes": [1, "double", {"avoidEscape": true, "allowTemplateLiterals": true}], + + // Require use of the second argument for parseInt(). + "radix": 2, + + // Enforce spacing after semicolons. + "semi-spacing": [2, {"before": false, "after": true}], + + // Don't require to sort variables within the same declaration block. + // Anyway, one-var is disabled. + "sort-vars": 0, + + // Require a space immediately following the // in a line comment. + "spaced-comment": [2, "always"], + + // Require "use strict" to be defined globally in the script. + "strict": [2, "global"], + + // Allow vars to be declared anywhere in the scope. + "vars-on-top": 0, + + // Don't require immediate function invocation to be wrapped in parentheses. + "wrap-iife": 0, + + // Don't require regex literals to be wrapped in parentheses (which + // supposedly prevent them from being mistaken for division operators). + "wrap-regex": 0, + + // Disallow Yoda conditions (where literal value comes first). + "yoda": 2, + + // disallow use of eval()-like methods + "no-implied-eval": 2, + + // Disallow function or variable declarations in nested blocks + "no-inner-declarations": 2, + + // Disallow usage of __iterator__ property + "no-iterator": 2, + + // Disallow labels that share a name with a variable + "no-label-var": 2, + + // Disallow creating new instances of String, Number, and Boolean + "no-new-wrappers": 2, + } +} diff --git a/browser/extensions/formautofill/bootstrap.js b/browser/extensions/formautofill/bootstrap.js index 10b5e6ce6f05..0b3f355bd499 100644 --- a/browser/extensions/formautofill/bootstrap.js +++ b/browser/extensions/formautofill/bootstrap.js @@ -4,6 +4,8 @@ "use strict"; +/* exported startup, shutdown, install, uninstall */ + function startup() {} function shutdown() {} function install() {} diff --git a/browser/extensions/formautofill/test/browser/.eslintrc b/browser/extensions/formautofill/test/browser/.eslintrc new file mode 100644 index 000000000000..be7c552e0ce0 --- /dev/null +++ b/browser/extensions/formautofill/test/browser/.eslintrc @@ -0,0 +1,5 @@ +{ + "extends": [ + "../../../../../testing/mochitest/browser.eslintrc" + ] +} From 237d452b757012f13c7ada5211dd847768738821 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Sun, 18 Sep 2016 22:54:08 -0400 Subject: [PATCH 4/5] Bug 1303651 - Update pdf.js to version 1.5.476. r=bdahl --- browser/extensions/pdfjs/README.mozilla | 2 +- browser/extensions/pdfjs/content/build/pdf.js | 56 +++++-- .../pdfjs/content/build/pdf.worker.js | 156 +++++++++++++++--- .../extensions/pdfjs/content/web/viewer.css | 22 ++- .../extensions/pdfjs/content/web/viewer.js | 32 +++- 5 files changed, 221 insertions(+), 47 deletions(-) diff --git a/browser/extensions/pdfjs/README.mozilla b/browser/extensions/pdfjs/README.mozilla index ba2f89ea9226..c0ef27918d91 100644 --- a/browser/extensions/pdfjs/README.mozilla +++ b/browser/extensions/pdfjs/README.mozilla @@ -1,3 +1,3 @@ This is the pdf.js project output, https://github.com/mozilla/pdf.js -Current extension version is: 1.5.464 +Current extension version is: 1.5.476 diff --git a/browser/extensions/pdfjs/content/build/pdf.js b/browser/extensions/pdfjs/content/build/pdf.js index b37832906fc0..53b1d56b8e76 100644 --- a/browser/extensions/pdfjs/content/build/pdf.js +++ b/browser/extensions/pdfjs/content/build/pdf.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdf = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.5.464'; -var pdfjsBuild = '834a7ff'; +var pdfjsVersion = '1.5.476'; +var pdfjsBuild = 'c0e82db'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -114,6 +114,28 @@ var AnnotationFlag = { LOCKEDCONTENTS: 0x200 }; +var AnnotationFieldFlag = { + READONLY: 1, + REQUIRED: 2, + NOEXPORT: 3, + MULTILINE: 13, + PASSWORD: 14, + NOTOGGLETOOFF: 15, + RADIO: 16, + PUSHBUTTON: 17, + COMBO: 18, + EDIT: 19, + SORT: 20, + FILESELECT: 21, + MULTISELECT: 22, + DONOTSPELLCHECK: 23, + DONOTSCROLL: 24, + COMB: 25, + RICHTEXT: 26, + RADIOSINUNISON: 26, + COMMITONSELCHANGE: 27, +}; + var AnnotationBorderStyleType = { SOLID: 1, DASHED: 2, @@ -1405,6 +1427,7 @@ exports.OPS = OPS; exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS; exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES; exports.AnnotationBorderStyleType = AnnotationBorderStyleType; +exports.AnnotationFieldFlag = AnnotationFieldFlag; exports.AnnotationFlag = AnnotationFlag; exports.AnnotationType = AnnotationType; exports.FontType = FontType; @@ -2295,7 +2318,9 @@ var TextAnnotationElement = (function TextAnnotationElementClosure() { */ var WidgetAnnotationElement = (function WidgetAnnotationElementClosure() { function WidgetAnnotationElement(parameters) { - AnnotationElement.call(this, parameters, true); + var isRenderable = parameters.renderInteractiveForms || + (!parameters.data.hasAppearance && !!parameters.data.fieldValue); + AnnotationElement.call(this, parameters, isRenderable); } Util.inherit(WidgetAnnotationElement, AnnotationElement, { @@ -2340,9 +2365,15 @@ var TextWidgetAnnotationElement = ( var element = null; if (this.renderInteractiveForms) { - element = document.createElement('input'); - element.type = 'text'; + if (this.data.multiLine) { + element = document.createElement('textarea'); + } else { + element = document.createElement('input'); + element.type = 'text'; + } + element.value = this.data.fieldValue; + element.disabled = this.data.readOnly; if (this.data.maxLen !== null) { element.maxLength = this.data.maxLen; @@ -7270,6 +7301,9 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { * calling of PDFPage.getViewport method. * @property {string} intent - Rendering intent, can be 'display' or 'print' * (default value is 'display'). + * @property {boolean} renderInteractiveForms - (optional) Whether or not + * interactive form elements are rendered in the display + * layer. If so, we do not render them on canvas as well. * @property {Array} transform - (optional) Additional transform, applied * just before viewport transform. * @property {Object} imageLayer - (optional) An object that has beginLayout, @@ -7378,6 +7412,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { this.pendingCleanup = false; var renderingIntent = (params.intent === 'print' ? 'print' : 'display'); + var renderInteractiveForms = (params.renderInteractiveForms === true ? + true : /* Default */ false); if (!this.intentStates[renderingIntent]) { this.intentStates[renderingIntent] = Object.create(null); @@ -7398,7 +7434,8 @@ var PDFPageProxy = (function PDFPageProxyClosure() { this.stats.time('Page Request'); this.transport.messageHandler.send('RenderPageRequest', { pageIndex: this.pageNumber - 1, - intent: renderingIntent + intent: renderingIntent, + renderInteractiveForms: renderInteractiveForms, }); } @@ -8932,13 +8969,6 @@ exports._UnsupportedManager = _UnsupportedManager; PDFJS.isEvalSupported = (PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported); - /** - * Renders interactive form elements. - * @var {boolean} - */ - PDFJS.renderInteractiveForms = (PDFJS.renderInteractiveForms === undefined ? - false : PDFJS.renderInteractiveForms); - PDFJS.getDocument = displayAPI.getDocument; PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport; diff --git a/browser/extensions/pdfjs/content/build/pdf.worker.js b/browser/extensions/pdfjs/content/build/pdf.worker.js index 5063532420ea..5f04e0955159 100644 --- a/browser/extensions/pdfjs/content/build/pdf.worker.js +++ b/browser/extensions/pdfjs/content/build/pdf.worker.js @@ -28,8 +28,8 @@ factory((root.pdfjsDistBuildPdfWorker = {})); // Use strict in our context only - users might not want it 'use strict'; -var pdfjsVersion = '1.5.464'; -var pdfjsBuild = '834a7ff'; +var pdfjsVersion = '1.5.476'; +var pdfjsBuild = 'c0e82db'; var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? @@ -1100,6 +1100,28 @@ var AnnotationFlag = { LOCKEDCONTENTS: 0x200 }; +var AnnotationFieldFlag = { + READONLY: 1, + REQUIRED: 2, + NOEXPORT: 3, + MULTILINE: 13, + PASSWORD: 14, + NOTOGGLETOOFF: 15, + RADIO: 16, + PUSHBUTTON: 17, + COMBO: 18, + EDIT: 19, + SORT: 20, + FILESELECT: 21, + MULTISELECT: 22, + DONOTSPELLCHECK: 23, + DONOTSCROLL: 24, + COMB: 25, + RICHTEXT: 26, + RADIOSINUNISON: 26, + COMMITONSELCHANGE: 27, +}; + var AnnotationBorderStyleType = { SOLID: 1, DASHED: 2, @@ -2391,6 +2413,7 @@ exports.OPS = OPS; exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS; exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES; exports.AnnotationBorderStyleType = AnnotationBorderStyleType; +exports.AnnotationFieldFlag = AnnotationFieldFlag; exports.AnnotationFlag = AnnotationFlag; exports.AnnotationType = AnnotationType; exports.FontType = FontType; @@ -27015,6 +27038,30 @@ function adjustWidths(properties) { properties.defaultWidth *= scale; } +function adjustToUnicode(properties, builtInEncoding) { + if (properties.hasIncludedToUnicodeMap) { + return; // The font dictionary has a `ToUnicode` entry. + } + if (properties.hasEncoding) { + return; // The font dictionary has an `Encoding` entry. + } + if (builtInEncoding === properties.defaultEncoding) { + return; // No point in trying to adjust `toUnicode` if the encodings match. + } + if (properties.toUnicode instanceof IdentityToUnicodeMap) { + return; + } + var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode(); + for (var charCode in builtInEncoding) { + var glyphName = builtInEncoding[charCode]; + var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap); + if (unicode !== -1) { + toUnicode[charCode] = String.fromCharCode(unicode); + } + } + properties.toUnicode.amend(toUnicode); +} + function getFontType(type, subtype) { switch (type) { case 'Type1': @@ -27113,7 +27160,13 @@ var ToUnicodeMap = (function ToUnicodeMapClosure() { charCodeOf: function(v) { return this._map.indexOf(v); - } + }, + + amend: function (map) { + for (var charCode in map) { + this._map[charCode] = map[charCode]; + } + }, }; return ToUnicodeMap; @@ -27149,7 +27202,11 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() { charCodeOf: function (v) { return (isInt(v) && v >= this.firstChar && v <= this.lastChar) ? v : -1; - } + }, + + amend: function (map) { + error('Should not call amend()'); + }, }; return IdentityToUnicodeMap; @@ -27550,6 +27607,7 @@ var Font = (function FontClosure() { this.fontMatrix = properties.fontMatrix; this.widths = properties.widths; this.defaultWidth = properties.defaultWidth; + this.toUnicode = properties.toUnicode; this.encoding = properties.baseEncoding; this.seacMap = properties.seacMap; @@ -29171,10 +29229,8 @@ var Font = (function FontClosure() { } else { // Most of the following logic in this code branch is based on the // 9.6.6.4 of the PDF spec. - var hasEncoding = - properties.differences.length > 0 || !!properties.baseEncodingName; - var cmapTable = - readCmapTable(tables['cmap'], font, this.isSymbolicFont, hasEncoding); + var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, + properties.hasEncoding); var cmapPlatformId = cmapTable.platformId; var cmapEncodingId = cmapTable.encodingId; var cmapMappings = cmapTable.mappings; @@ -29183,7 +29239,7 @@ var Font = (function FontClosure() { // The spec seems to imply that if the font is symbolic the encoding // should be ignored, this doesn't appear to work for 'preistabelle.pdf' // where the the font is symbolic and it has an encoding. - if (hasEncoding && + if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || (cmapPlatformId === -1 && cmapEncodingId === -1 && // Temporary hack @@ -29347,6 +29403,12 @@ var Font = (function FontClosure() { // TODO: Check the charstring widths to determine this. properties.fixedPitch = false; + if (properties.builtInEncoding) { + // For Type1 fonts that do not include either `ToUnicode` or `Encoding` + // data, attempt to use the `builtInEncoding` to improve text selection. + adjustToUnicode(properties, properties.builtInEncoding); + } + var mapping = font.getGlyphMapping(properties); var newMapping = adjustMapping(mapping, properties); this.toFontChar = newMapping.toFontChar; @@ -37623,6 +37685,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { properties.differences = differences; properties.baseEncodingName = baseEncodingName; + properties.hasEncoding = !!baseEncodingName || differences.length > 0; properties.dict = dict; return toUnicodePromise.then(function(toUnicode) { properties.toUnicode = toUnicode; @@ -37640,8 +37703,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { * {ToUnicodeMap|IdentityToUnicodeMap} object. */ buildToUnicode: function PartialEvaluator_buildToUnicode(properties) { + properties.hasIncludedToUnicodeMap = + !!properties.toUnicode && properties.toUnicode.length > 0; // Section 9.10.2 Mapping Character Codes to Unicode Values - if (properties.toUnicode && properties.toUnicode.length !== 0) { + if (properties.hasIncludedToUnicodeMap) { return Promise.resolve(properties.toUnicode); } // According to the spec if the font is a simple font we should only map @@ -39186,6 +39251,7 @@ exports.PartialEvaluator = PartialEvaluator; coreColorSpace, coreObj, coreEvaluator) { var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType; +var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag; var AnnotationFlag = sharedUtil.AnnotationFlag; var AnnotationType = sharedUtil.AnnotationType; var OPS = sharedUtil.OPS; @@ -39218,10 +39284,14 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { /** * @param {XRef} xref * @param {Object} ref + * @param {string} uniquePrefix + * @param {Object} idCounters + * @param {boolean} renderInteractiveForms * @returns {Annotation} */ create: function AnnotationFactory_create(xref, ref, - uniquePrefix, idCounters) { + uniquePrefix, idCounters, + renderInteractiveForms) { var dict = xref.fetchIfRef(ref); if (!isDict(dict)) { return; @@ -39240,6 +39310,7 @@ AnnotationFactory.prototype = /** @lends AnnotationFactory.prototype */ { ref: isRef(ref) ? ref : null, subtype: subtype, id: id, + renderInteractiveForms: renderInteractiveForms, }; switch (subtype) { @@ -39774,9 +39845,13 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() { data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || ''; var fieldType = Util.getInheritableProperty(dict, 'FT'); data.fieldType = isName(fieldType) ? fieldType.name : null; - data.fieldFlags = Util.getInheritableProperty(dict, 'Ff') || 0; this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty; + data.fieldFlags = Util.getInheritableProperty(dict, 'Ff'); + if (!isInt(data.fieldFlags) || data.fieldFlags < 0) { + data.fieldFlags = 0; + } + // Hide signatures because we cannot validate them. if (data.fieldType === 'Sig') { this.setFlags(AnnotationFlag.HIDDEN); @@ -39815,7 +39890,22 @@ var WidgetAnnotation = (function WidgetAnnotationClosure() { data.fullName = fieldName.join('.'); } - Util.inherit(WidgetAnnotation, Annotation, {}); + Util.inherit(WidgetAnnotation, Annotation, { + /** + * Check if a provided field flag is set. + * + * @public + * @memberof WidgetAnnotation + * @param {number} flag - Bit position, numbered from one instead of + * zero, to check + * @return {boolean} + * @see {@link shared/util.js} + */ + hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) { + var mask = 1 << (flag - 1); + return !!(this.data.fieldFlags & mask); + }, + }); return WidgetAnnotation; })(); @@ -39824,6 +39914,8 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { function TextWidgetAnnotation(params) { WidgetAnnotation.call(this, params); + this.renderInteractiveForms = params.renderInteractiveForms; + // Determine the alignment of text in the field. var alignment = Util.getInheritableProperty(params.dict, 'Q'); if (!isInt(alignment) || alignment < 0 || alignment > 2) { @@ -39837,29 +39929,38 @@ var TextWidgetAnnotation = (function TextWidgetAnnotationClosure() { maximumLength = null; } this.data.maxLen = maximumLength; + + // Process field flags for the display layer. + this.data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY); + this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE); } Util.inherit(TextWidgetAnnotation, WidgetAnnotation, { getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task) { + var operatorList = new OperatorList(); + + // Do not render form elements on the canvas when interactive forms are + // enabled. The display layer is responsible for rendering them instead. + if (this.renderInteractiveForms) { + return Promise.resolve(operatorList); + } + if (this.appearance) { return Annotation.prototype.getOperatorList.call(this, evaluator, task); } - var opList = new OperatorList(); - var data = this.data; - // Even if there is an appearance stream, ignore it. This is the // behaviour used by Adobe Reader. - if (!data.defaultAppearance) { - return Promise.resolve(opList); + if (!this.data.defaultAppearance) { + return Promise.resolve(operatorList); } - var stream = new Stream(stringToBytes(data.defaultAppearance)); - return evaluator.getOperatorList(stream, task, - this.fieldResources, opList). + var stream = new Stream(stringToBytes(this.data.defaultAppearance)); + return evaluator.getOperatorList(stream, task, this.fieldResources, + operatorList). then(function () { - return opList; + return operatorList; }); } }); @@ -40306,7 +40407,8 @@ var Page = (function PageClosure() { }.bind(this)); }, - getOperatorList: function Page_getOperatorList(handler, task, intent) { + getOperatorList: function Page_getOperatorList(handler, task, intent, + renderInteractiveForms) { var self = this; var pdfManager = this.pdfManager; @@ -40346,6 +40448,8 @@ var Page = (function PageClosure() { }); }); + this.renderInteractiveForms = renderInteractiveForms; + var annotationsPromise = pdfManager.ensure(this, 'annotations'); return Promise.all([pageListPromise, annotationsPromise]).then( function(datas) { @@ -40429,7 +40533,8 @@ var Page = (function PageClosure() { var annotationRef = annotationRefs[i]; var annotation = annotationFactory.create(this.xref, annotationRef, this.uniquePrefix, - this.idCounters); + this.idCounters, + this.renderInteractiveForms); if (annotation) { annotations.push(annotation); } @@ -41616,7 +41721,8 @@ var WorkerMessageHandler = { var pageNum = pageIndex + 1; var start = Date.now(); // Pre compile the pdf page and fetch the fonts/images. - page.getOperatorList(handler, task, data.intent).then( + page.getOperatorList(handler, task, data.intent, + data.renderInteractiveForms).then( function(operatorList) { finishWorkerTask(task); diff --git a/browser/extensions/pdfjs/content/web/viewer.css b/browser/extensions/pdfjs/content/web/viewer.css index 07d9d3b2fe80..53a94e72c224 100644 --- a/browser/extensions/pdfjs/content/web/viewer.css +++ b/browser/extensions/pdfjs/content/web/viewer.css @@ -101,7 +101,8 @@ cursor: pointer; } -.annotationLayer .textWidgetAnnotation input { +.annotationLayer .textWidgetAnnotation input, +.annotationLayer .textWidgetAnnotation textarea { background-color: rgba(0, 54, 255, 0.13); border: 1px solid transparent; box-sizing: border-box; @@ -112,11 +113,26 @@ width: 100%; } -.annotationLayer .textWidgetAnnotation input:hover { +.annotationLayer .textWidgetAnnotation textarea { + font: message-box; + font-size: 9px; + resize: none; +} + +.annotationLayer .textWidgetAnnotation input[disabled], +.annotationLayer .textWidgetAnnotation textarea[disabled] { + background: none; + border: 1px solid transparent; + cursor: not-allowed; +} + +.annotationLayer .textWidgetAnnotation input:hover, +.annotationLayer .textWidgetAnnotation textarea:hover { border: 1px solid #000; } -.annotationLayer .textWidgetAnnotation input:focus { +.annotationLayer .textWidgetAnnotation input:focus, +.annotationLayer .textWidgetAnnotation textarea:focus { background: none; border: 1px solid transparent; } diff --git a/browser/extensions/pdfjs/content/web/viewer.js b/browser/extensions/pdfjs/content/web/viewer.js index 481ed351773e..df9cdb1f0214 100644 --- a/browser/extensions/pdfjs/content/web/viewer.js +++ b/browser/extensions/pdfjs/content/web/viewer.js @@ -5054,6 +5054,8 @@ var TEXT_LAYER_RENDER_DELAY = 200; // ms * @property {IPDFAnnotationLayerFactory} annotationLayerFactory * @property {boolean} enhanceTextSelection - Turns on the text selection * enhancement. The default is `false`. + * @property {boolean} renderInteractiveForms - Turns on rendering of + * interactive form elements. The default is `false`. */ /** @@ -5074,6 +5076,7 @@ var PDFPageView = (function PDFPageViewClosure() { var textLayerFactory = options.textLayerFactory; var annotationLayerFactory = options.annotationLayerFactory; var enhanceTextSelection = options.enhanceTextSelection || false; + var renderInteractiveForms = options.renderInteractiveForms || false; this.id = id; this.renderingId = 'page' + id; @@ -5084,6 +5087,7 @@ var PDFPageView = (function PDFPageViewClosure() { this.pdfPageRotate = defaultViewport.rotation; this.hasRestrictedScaling = false; this.enhanceTextSelection = enhanceTextSelection; + this.renderInteractiveForms = renderInteractiveForms; this.eventBus = options.eventBus || domEvents.getGlobalEventBus(); this.renderingQueue = renderingQueue; @@ -5498,6 +5502,7 @@ var PDFPageView = (function PDFPageViewClosure() { canvasContext: ctx, transform: transform, viewport: this.viewport, + renderInteractiveForms: this.renderInteractiveForms, // intent: 'default', // === 'display' }; var renderTask = this.renderTask = this.pdfPage.render(renderContext); @@ -5523,7 +5528,8 @@ var PDFPageView = (function PDFPageViewClosure() { if (this.annotationLayerFactory) { if (!this.annotationLayer) { this.annotationLayer = this.annotationLayerFactory. - createAnnotationLayerBuilder(div, this.pdfPage); + createAnnotationLayerBuilder(div, this.pdfPage, + this.renderInteractiveForms); } this.annotationLayer.render(this.viewport, 'display'); } @@ -6164,6 +6170,7 @@ var SimpleLinkService = pdfLinkService.SimpleLinkService; * @typedef {Object} AnnotationLayerBuilderOptions * @property {HTMLDivElement} pageDiv * @property {PDFPage} pdfPage + * @property {boolean} renderInteractiveForms * @property {IPDFLinkService} linkService * @property {DownloadManager} downloadManager */ @@ -6179,6 +6186,7 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() { function AnnotationLayerBuilder(options) { this.pageDiv = options.pageDiv; this.pdfPage = options.pdfPage; + this.renderInteractiveForms = options.renderInteractiveForms; this.linkService = options.linkService; this.downloadManager = options.downloadManager; @@ -6205,9 +6213,9 @@ var AnnotationLayerBuilder = (function AnnotationLayerBuilderClosure() { div: self.div, annotations: annotations, page: self.pdfPage, + renderInteractiveForms: self.renderInteractiveForms, linkService: self.linkService, downloadManager: self.downloadManager, - renderInteractiveForms: pdfjsLib.PDFJS.renderInteractiveForms, }; if (self.div) { @@ -6254,12 +6262,15 @@ DefaultAnnotationLayerFactory.prototype = { /** * @param {HTMLDivElement} pageDiv * @param {PDFPage} pdfPage + * @param {boolean} renderInteractiveForms * @returns {AnnotationLayerBuilder} */ - createAnnotationLayerBuilder: function (pageDiv, pdfPage) { + createAnnotationLayerBuilder: function (pageDiv, pdfPage, + renderInteractiveForms) { return new AnnotationLayerBuilder({ pageDiv: pageDiv, pdfPage: pdfPage, + renderInteractiveForms: renderInteractiveForms, linkService: new SimpleLinkService(), }); } @@ -6321,6 +6332,8 @@ var DEFAULT_CACHE_SIZE = 10; * around the pages. The default is false. * @property {boolean} enhanceTextSelection - (optional) Enables the improved * text selection behaviour. The default is `false`. + * @property {boolean} renderInteractiveForms - (optional) Enables rendering of + * interactive form elements. The default is `false`. */ /** @@ -6373,6 +6386,7 @@ var PDFViewer = (function pdfViewer() { this.downloadManager = options.downloadManager || null; this.removePageBorders = options.removePageBorders || false; this.enhanceTextSelection = options.enhanceTextSelection || false; + this.renderInteractiveForms = options.renderInteractiveForms || false; this.defaultRenderingQueue = !options.renderingQueue; if (this.defaultRenderingQueue) { @@ -6600,6 +6614,7 @@ var PDFViewer = (function pdfViewer() { textLayerFactory: textLayerFactory, annotationLayerFactory: this, enhanceTextSelection: this.enhanceTextSelection, + renderInteractiveForms: this.renderInteractiveForms, }); bindOnAfterAndBeforeDraw(pageView); this._pages.push(pageView); @@ -7086,12 +7101,15 @@ var PDFViewer = (function pdfViewer() { /** * @param {HTMLDivElement} pageDiv * @param {PDFPage} pdfPage + * @param {boolean} renderInteractiveForms * @returns {AnnotationLayerBuilder} */ - createAnnotationLayerBuilder: function (pageDiv, pdfPage) { + createAnnotationLayerBuilder: function (pageDiv, pdfPage, + renderInteractiveForms) { return new AnnotationLayerBuilder({ pageDiv: pageDiv, pdfPage: pdfPage, + renderInteractiveForms: renderInteractiveForms, linkService: this.linkService, downloadManager: this.downloadManager }); @@ -7272,6 +7290,7 @@ var PDFViewerApplication = { linkService: pdfLinkService, downloadManager: downloadManager, enhanceTextSelection: false, + renderInteractiveForms: false, }); pdfRenderingQueue.setViewer(this.pdfViewer); pdfLinkService.setViewer(this.pdfViewer); @@ -7432,7 +7451,10 @@ var PDFViewerApplication = { PDFJS.externalLinkTarget = value; }), Preferences.get('renderInteractiveForms').then(function resolved(value) { - PDFJS.renderInteractiveForms = value; + // TODO: Like the `enhanceTextSelection` preference, move the + // initialization and fetching of `Preferences` to occur + // before the various viewer components are initialized. + self.pdfViewer.renderInteractiveForms = value; }), // TODO move more preferences and other async stuff here ]).catch(function (reason) { }); From f6383735e1c306b727767ba4eb76014486ea88fd Mon Sep 17 00:00:00 2001 From: MDTsai Date: Mon, 12 Sep 2016 20:57:00 -0400 Subject: [PATCH 5/5] Bug 1301619 - Update Firefox android User Agent override. r=miket Remove following domains from ua-update.json.in: auctions.yahoo.co.jp news.yahoo.co.jp shopping.yahoo.co.jp travel.yahoo.co.jp sports.yahoo.co.jp mixi.jp Update bug number inline --- mobile/android/app/ua-update.json.in | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/mobile/android/app/ua-update.json.in b/mobile/android/app/ua-update.json.in index 15952cdcfaa7..6b9108e4f20f 100644 --- a/mobile/android/app/ua-update.json.in +++ b/mobile/android/app/ua-update.json.in @@ -3,23 +3,16 @@ // Send these sites a custom user-agent. Bugs should be included with an entry. // NOTE: trailing commas are not valid JSON and will prevent the CDN from syncing. { - // bug 117898, yahoo.co.jp properties + // bug 1177298, yahoo.co.jp properties "www.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", // send override to m. in addition to www. to prevent infinite 302 loop "m.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - "auctions.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", "finance.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - "news.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - "shopping.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - "sports.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - "travel.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", "weather.yahoo.co.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - // bug 117898, lohaco.jp + // bug 1177298, lohaco.jp "lohaco.jp": "Mozilla/5.0 (Linux; Android 5.0.2; Galaxy Nexus Build/IMM76B) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.93 Mobile Safari/537.36", - // bug 117898, www.nhk.or.jp + // bug 1177298, www.nhk.or.jp "nhk.or.jp": "\\)\\s# AppleWebKit ", // bug 1177298, uniqlo.com - "uniqlo.com": "\\)\\s#) Mobile Safari ", - // bug 1177298, mixi.jp - "mixi.jp": "\\)\\s#) Mobile Safari " + "uniqlo.com": "\\)\\s#) Mobile Safari " }