зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1305007 - set dir attribute value only if document.hasAttribute("dir");r=bgrins
MozReview-Commit-ID: EnDi7iuoJ5P --HG-- extra : rebase_source : 424145bc6f7aab39730c674318a02bc2ee0fd243
This commit is contained in:
Родитель
0caae84558
Коммит
7c08035837
|
@ -1263,21 +1263,15 @@ Toolbox.prototype = {
|
|||
// Prevent flicker while loading by waiting to make visible until now.
|
||||
iframe.style.visibility = "visible";
|
||||
|
||||
// Try to set the dir attribute as early as possible.
|
||||
this.setIframeDocumentDir(iframe);
|
||||
|
||||
// The build method should return a panel instance, so events can
|
||||
// be fired with the panel as an argument. However, in order to keep
|
||||
// backward compatibility with existing extensions do a check
|
||||
// for a promise return value.
|
||||
let built = definition.build(iframe.contentWindow, this);
|
||||
|
||||
// Set the dir attribute on the documents of panels using HTML.
|
||||
let docEl = iframe.contentWindow && iframe.contentWindow.document.documentElement;
|
||||
if (docEl && docEl.namespaceURI === HTML_NS) {
|
||||
let top = this.win.top;
|
||||
let topDocEl = top.document.documentElement;
|
||||
let isRtl = top.getComputedStyle(topDocEl).direction === "rtl";
|
||||
docEl.setAttribute("dir", isRtl ? "rtl" : "ltr");
|
||||
}
|
||||
|
||||
if (!(typeof built.then == "function")) {
|
||||
let panel = built;
|
||||
iframe.panel = panel;
|
||||
|
@ -1350,6 +1344,28 @@ Toolbox.prototype = {
|
|||
return deferred.promise;
|
||||
},
|
||||
|
||||
/**
|
||||
* Set the dir attribute on the content document element of the provided iframe.
|
||||
*
|
||||
* @param {IFrameElement} iframe
|
||||
*/
|
||||
setIframeDocumentDir: function (iframe) {
|
||||
let docEl = iframe.contentWindow && iframe.contentWindow.document.documentElement;
|
||||
if (!docEl || docEl.namespaceURI !== HTML_NS) {
|
||||
// Bail out if the content window or document is not ready or if the document is not
|
||||
// HTML.
|
||||
return;
|
||||
}
|
||||
|
||||
if (docEl.hasAttribute("dir")) {
|
||||
// Set the dir attribute value only if dir is already present on the document.
|
||||
let top = this.win.top;
|
||||
let topDocEl = top.document.documentElement;
|
||||
let isRtl = top.getComputedStyle(topDocEl).direction === "rtl";
|
||||
docEl.setAttribute("dir", isRtl ? "rtl" : "ltr");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Mark all in collection as unselected; and id as selected
|
||||
* @param {string} collection
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
<!DOCTYPE html>
|
||||
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
<script type="application/javascript;version=1.8"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
<!-- 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/. -->
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="">
|
||||
<head>
|
||||
<link rel="stylesheet" href="chrome://devtools/skin/widgets.css" type="text/css"/>
|
||||
<link rel="stylesheet" href="chrome://devtools/skin/memory.css" type="text/css"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче