Merge mozilla-inbound and mozilla-central

This commit is contained in:
Marco Bonardo 2011-06-11 11:08:40 +02:00
Родитель 3f4e794b64 23ad77aa47
Коммит 7f0d3f68aa
62 изменённых файлов: 698 добавлений и 1296 удалений

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

@ -57,7 +57,6 @@ EXTRA_JS_MODULES = \
content/openLocationLastURL.jsm \
content/NetworkPrioritizer.jsm \
content/domplate.jsm \
content/stylePanel.jsm \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -250,26 +250,6 @@
accesskey="&inspectButton.accesskey;"
class="toolbarbutton-text"
command="Inspector:Inspect"/>
<toolbarbutton id="inspector-previous-toolbutton"
label="&inspectPreviousButton.label;"
accesskey="&inspectPreviousButton.accesskey;"
class="toolbarbutton-text"
command="Inspector:Previous"/>
<toolbarbutton id="inspector-next-toolbutton"
label="&inspectNextButton.label;"
accesskey="&inspectNextButton.accesskey;"
class="toolbarbutton-text"
command="Inspector:Next"/>
<toolbarbutton id="inspector-style-toolbutton"
label="&inspectStyleButton.label;"
accesskey="&inspectStyleButton.accesskey;"
class="toolbarbutton-text"
oncommand="InspectorUI.toggleStylePanel();"/>
<toolbarbutton id="inspector-dom-toolbutton"
label="&inspectObjectButton.label;"
accesskey="&inspectObjectButton.accesskey;"
class="toolbarbutton-text"
oncommand="InspectorUI.toggleDOMPanel();"/>
</toolbar>
<hbox id="tree-panel-resizer-box" align="end">
<spacer flex="1" />
@ -277,21 +257,6 @@
</hbox>
</panel>
<panel id="inspector-style-panel"
hidden="true"
orient="vertical"
ignorekeys="true"
noautofocus="true"
noautohide="true"
titlebar="normal"
label="&inspectStylePanelTitle.label;">
<listbox id="inspector-style-listbox" flex="1"/>
<hbox align="end">
<spacer flex="1" />
<resizer dir="bottomend"/>
</hbox>
</panel>
<menupopup id="toolbar-context-menu"
onpopupshowing="onViewToolbarsPopupShowing(event);">
<menuseparator/>

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

@ -366,37 +366,6 @@ var InspectorUI = {
}
},
/**
* Toggle the style panel. Invoked from the toolbar's Style button.
*/
toggleStylePanel: function IUI_toggleStylePanel()
{
if (this.isStylePanelOpen) {
this.stylePanel.hidePopup();
} else {
this.openStylePanel();
if (this.selection) {
this.updateStylePanel(this.selection);
}
}
},
/**
* Toggle the DOM panel. Invoked from the toolbar's DOM button.
*/
toggleDOMPanel: function IUI_toggleDOMPanel()
{
if (this.isDOMPanelOpen) {
this.domPanel.hidePopup();
} else {
this.clearDOMPanel();
this.openDOMPanel();
if (this.selection) {
this.updateDOMPanel(this.selection);
}
}
},
/**
* Is the tree panel open?
*
@ -407,26 +376,6 @@ var InspectorUI = {
return this.treePanel && this.treePanel.state == "open";
},
/**
* Is the style panel open?
*
* @returns boolean
*/
get isStylePanelOpen()
{
return this.stylePanel && this.stylePanel.state == "open";
},
/**
* Is the DOM panel open?
*
* @returns boolean
*/
get isDOMPanelOpen()
{
return this.domPanel && this.domPanel.state == "open";
},
/**
* Return the default selection element for the inspected document.
*/
@ -445,10 +394,17 @@ var InspectorUI = {
this.ioBox = new InsideOutBox(this, this.treePanelDiv);
this.ioBox.createObjectBox(this.win.document.documentElement);
this.treeLoaded = true;
if (this.isTreePanelOpen && this.isStylePanelOpen &&
this.isDOMPanelOpen && this.treeLoaded) {
// setup highlighter and start inspecting
this.initializeHighlighter();
// Setup the InspectorStore or restore state
this.initializeStore();
if (InspectorStore.getValue(this.winID, "inspecting"))
this.startInspecting();
this.notifyReady();
}
},
/**
@ -472,25 +428,39 @@ var InspectorUI = {
this.treeIFrame = this.treePanel.insertBefore(this.treeIFrame, resizerBox);
}
const panelWidthRatio = 7 / 8;
const panelHeightRatio = 1 / 5;
this.treePanel.openPopup(this.browser, "overlap", 80, this.win.innerHeight,
false, false);
this.treePanel.sizeTo(this.win.outerWidth * panelWidthRatio,
this.win.outerHeight * panelHeightRatio);
this.treePanel.addEventListener("popupshown", function treePanelShown() {
InspectorUI.treePanel.removeEventListener("popupshown",
treePanelShown, false);
let src = this.treeIFrame.getAttribute("src");
if (src != "chrome://browser/content/inspector.html") {
let self = this;
this.treeIFrame.addEventListener("DOMContentLoaded", function() {
self.treeIFrame.removeEventListener("DOMContentLoaded", arguments.callee, true);
self.initializeTreePanel();
InspectorUI.treeIFrame.addEventListener("load",
function loadedInitializeTreePanel() {
InspectorUI.treeIFrame.removeEventListener("load",
loadedInitializeTreePanel, true);
InspectorUI.initializeTreePanel();
}, true);
this.treeIFrame.setAttribute("src", "chrome://browser/content/inspector.html");
let src = InspectorUI.treeIFrame.getAttribute("src");
if (src != "chrome://browser/content/inspector.html") {
InspectorUI.treeIFrame.setAttribute("src",
"chrome://browser/content/inspector.html");
} else {
this.initializeTreePanel();
InspectorUI.treeIFrame.contentWindow.location.reload();
}
}, false);
const panelWidthRatio = 7 / 8;
const panelHeightRatio = 1 / 5;
let width = parseInt(this.win.outerWidth * panelWidthRatio);
let height = parseInt(this.win.outerHeight * panelHeightRatio);
let y = Math.min(window.screen.availHeight - height, this.win.innerHeight);
this.treePanel.openPopup(this.browser, "overlap", 0, 0,
false, false);
this.treePanel.moveTo(80, y);
this.treePanel.sizeTo(width, height);
},
createObjectBox: function IUI_createObjectBox(object, isRoot)
@ -600,55 +570,8 @@ var InspectorUI = {
},
/**
* Open the style panel if not already onscreen.
*/
openStylePanel: function IUI_openStylePanel()
{
if (!this.stylePanel)
this.stylePanel = document.getElementById("inspector-style-panel");
if (!this.isStylePanelOpen) {
this.stylePanel.hidden = false;
// open at top right of browser panel, offset by 20px from top.
this.stylePanel.openPopup(this.browser, "end_before", 0, 20, false, false);
// size panel to 200px wide by half browser height - 60.
this.stylePanel.sizeTo(200, this.win.outerHeight / 2 - 60);
}
},
/**
* Open the DOM panel if not already onscreen.
*/
openDOMPanel: function IUI_openDOMPanel()
{
if (!this.isDOMPanelOpen) {
this.domPanel.hidden = false;
// open at middle right of browser panel, offset by 20px from middle.
this.domPanel.openPopup(this.browser, "end_before", 0,
this.win.outerHeight / 2 - 20, false, false);
// size panel to 200px wide by half browser height - 60.
this.domPanel.sizeTo(200, this.win.outerHeight / 2 - 60);
}
},
/**
* Toggle the dimmed (semi-transparent) state for a panel by setting or
* removing a dimmed attribute.
*
* @param aDim
* The panel to be dimmed.
*/
toggleDimForPanel: function IUI_toggleDimForPanel(aDim)
{
if (aDim.hasAttribute("dimmed")) {
aDim.removeAttribute("dimmed");
} else {
aDim.setAttribute("dimmed", "true");
}
},
/**
* Open inspector UI. tree, style and DOM panels if enabled. Add listeners for
* document scrolling, resize, tabContainer.TabSelect and others.
* Open inspector UI. tree. Add listeners for document scrolling,
* resize, tabContainer.TabSelect and others.
*/
openInspectorUI: function IUI_openInspectorUI()
{
@ -661,44 +584,12 @@ var InspectorUI = {
this.domplateUtils.setDOM(window);
}
// DOM panel initialization and loading (via PropertyPanel.jsm)
let objectPanelTitle = this.strings.
GetStringFromName("object.objectPanelTitle");
let parent = document.getElementById("inspector-style-panel").parentNode;
this.propertyPanel = new (this.PropertyPanel)(parent, document,
objectPanelTitle, {});
// additional DOM panel setup needed for unittest identification and use
this.domPanel = this.propertyPanel.panel;
this.domPanel.setAttribute("id", "inspector-dom-panel");
this.domBox = this.propertyPanel.tree;
this.domTreeView = this.propertyPanel.treeView;
// open inspector UI
this.openTreePanel();
// style panel setup and activation
this.styleBox = document.getElementById("inspector-style-listbox");
this.clearStylePanel();
this.openStylePanel();
// DOM panel setup and activation
this.clearDOMPanel();
this.openDOMPanel();
// setup highlighter and start inspecting
this.initializeHighlighter();
// Setup the InspectorStore or restore state
this.initializeStore();
if (InspectorStore.getValue(this.winID, "inspecting"))
this.startInspecting();
this.win.document.addEventListener("scroll", this, false);
this.win.addEventListener("resize", this, false);
this.inspectCmd.setAttribute("checked", true);
document.addEventListener("popupshown", this, false);
},
/**
@ -774,8 +665,6 @@ var InspectorUI = {
this.highlighter.unhighlight();
}
if (this.isTreePanelOpen)
this.treePanel.hidePopup();
if (this.treePanelDiv) {
this.treePanelDiv.ownerPanel = null;
let parent = this.treePanelDiv.parentNode;
@ -795,21 +684,19 @@ var InspectorUI = {
delete this.domplateUtils;
}
if (this.isStylePanelOpen) {
this.stylePanel.hidePopup();
}
if (this.domPanel) {
this.domPanel.hidePopup();
this.domBox = null;
this.domTreeView = null;
}
this.inspectCmd.setAttribute("checked", false);
this.browser = this.win = null; // null out references to browser and window
this.winID = null;
this.selection = null;
this.treeLoaded = false;
this.closing = false;
this.treePanel.addEventListener("popuphidden", function treePanelHidden() {
InspectorUI.closing = false;
Services.obs.notifyObservers(null, "inspector-closed", null);
}, false);
this.treePanel.hidePopup();
delete this.treePanel;
},
/**
@ -820,8 +707,6 @@ var InspectorUI = {
{
this.attachPageListeners();
this.inspecting = true;
this.toggleDimForPanel(this.stylePanel);
this.toggleDimForPanel(this.domPanel);
},
/**
@ -834,8 +719,6 @@ var InspectorUI = {
return;
this.detachPageListeners();
this.inspecting = false;
this.toggleDimForPanel(this.stylePanel);
this.toggleDimForPanel(this.domPanel);
if (this.highlighter.node) {
this.select(this.highlighter.node, true, true);
}
@ -860,148 +743,16 @@ var InspectorUI = {
let box = this.ioBox.createObjectBox(this.selection);
if (!this.inspecting) {
this.highlighter.highlightNode(this.selection);
this.updateStylePanel(this.selection);
this.updateDOMPanel(this.selection);
}
this.ioBox.select(aNode, true, true, aScroll);
}
},
/////////////////////////////////////////////////////////////////////////
//// Model Creation Methods
/**
* Add a new item to the style panel listbox.
*
* @param aLabel
* A bit of text to put in the listitem's label attribute.
* @param aType
* The type of item.
* @param content
* Text content or value of the listitem.
*/
addStyleItem: function IUI_addStyleItem(aLabel, aType, aContent)
{
let itemLabelString = this.strings.GetStringFromName("style.styleItemLabel");
let item = document.createElement("listitem");
// Do not localize these strings
let label = aLabel;
item.className = "style-" + aType;
if (aContent) {
label = itemLabelString.replace("#1", aLabel);
label = label.replace("#2", aContent);
}
item.setAttribute("label", label);
this.styleBox.appendChild(item);
},
/**
* Create items for each rule included in the given array.
*
* @param aRules
* an array of rule objects
*/
createStyleRuleItems: function IUI_createStyleRuleItems(aRules)
{
let selectorLabel = this.strings.GetStringFromName("style.selectorLabel");
aRules.forEach(function(rule) {
this.addStyleItem(selectorLabel, "selector", rule.id);
rule.properties.forEach(function(property) {
if (property.overridden)
return; // property marked overridden elsewhere
// Do not localize the strings below this line
let important = "";
if (property.important)
important += " !important";
this.addStyleItem(property.name, "property", property.value + important);
}, this);
}, this);
},
/**
* Create rule items for each section as well as the element's style rules,
* if any.
*
* @param aRules
* Array of rules corresponding to the element's style object.
* @param aSections
* Array of sections encapsulating the inherited rules for selectors
* and elements.
*/
createStyleItems: function IUI_createStyleItems(aRules, aSections)
{
this.createStyleRuleItems(aRules);
let inheritedString =
this.strings.GetStringFromName("style.inheritedFrom");
aSections.forEach(function(section) {
let sectionTitle = section.element.tagName;
if (section.element.id)
sectionTitle += "#" + section.element.id;
let replacedString = inheritedString.replace("#1", sectionTitle);
this.addStyleItem(replacedString, "section");
this.createStyleRuleItems(section.rules);
}, this);
},
/**
* Remove all items from the Style Panel's listbox.
*/
clearStylePanel: function IUI_clearStylePanel()
{
for (let i = this.styleBox.childElementCount; i >= 0; --i)
this.styleBox.removeItemAt(i);
},
/**
* Remove all items from the DOM Panel's listbox.
*/
clearDOMPanel: function IUI_clearStylePanel()
{
this.domTreeView.data = {};
},
/**
* Update the contents of the style panel with styles for the currently
* inspected node.
*
* @param aNode
* The highlighted node to get styles for.
*/
updateStylePanel: function IUI_updateStylePanel(aNode)
{
if (this.inspecting || !this.isStylePanelOpen) {
return;
}
let rules = [], styleSections = [], usedProperties = {};
this.style.getInheritedRules(aNode, styleSections, usedProperties);
this.style.getElementRules(aNode, rules, usedProperties);
this.clearStylePanel();
this.createStyleItems(rules, styleSections);
},
/**
* Update the contents of the DOM panel with name/value pairs for the
* currently-inspected node.
*/
updateDOMPanel: function IUI_updateDOMPanel(aNode)
{
if (this.inspecting || !this.isDOMPanelOpen) {
return;
}
this.domTreeView.data = aNode;
},
/////////////////////////////////////////////////////////////////////////
//// Event Handling
notifyReady: function IUI_notifyReady()
{
document.removeEventListener("popupshowing", this, false);
Services.obs.notifyObservers(null, "inspector-opened", null);
},
@ -1018,15 +769,6 @@ var InspectorUI = {
let inspectorClosed = false;
switch (event.type) {
case "popupshown":
if (event.target.id == "inspector-tree-panel" ||
event.target.id == "inspector-style-panel" ||
event.target.id == "inspector-dom-panel")
if (this.isTreePanelOpen && this.isStylePanelOpen &&
this.isDOMPanelOpen && this.treeLoaded) {
this.notifyReady();
}
break;
case "TabSelect":
winID = this.getWindowID(gBrowser.selectedBrowser.contentWindow);
if (this.isTreePanelOpen && winID != this.winID) {
@ -1036,13 +778,17 @@ var InspectorUI = {
if (winID && InspectorStore.hasID(winID)) {
if (inspectorClosed && this.closing) {
Services.obs.addObserver(function () {
Services.obs.addObserver(function reopenInspectorForTab() {
Services.obs.removeObserver(reopenInspectorForTab,
"inspector-closed", false);
InspectorUI.openInspectorUI();
}, "inspector-closed", false);
} else {
this.openInspectorUI();
}
} else if (InspectorStore.isEmpty()) {
}
if (InspectorStore.isEmpty()) {
gBrowser.tabContainer.removeEventListener("TabSelect", this, false);
}
break;
@ -1151,8 +897,6 @@ var InspectorUI = {
this.selectEventsSuppressed = true;
this.select(aNode, true, true);
this.selectEventsSuppressed = false;
this.updateStylePanel(aNode);
this.updateDOMPanel(aNode);
},
/**
@ -1284,6 +1028,25 @@ var InspectorUI = {
{
Services.console.logStringMessage(msg);
},
/**
* Debugging function.
* @param msg
* text to show with the stack trace.
*/
_trace: function TRACE(msg)
{
this._log("TRACE: " + msg);
let frame = Components.stack.caller;
while (frame = frame.caller) {
if (frame.language == Ci.nsIProgrammingLanguage.JAVASCRIPT ||
frame.language == Ci.nsIProgrammingLanguage.JAVASCRIPT2) {
this._log("filename: " + frame.filename + " lineNumber: " + frame.lineNumber +
" functionName: " + frame.name);
}
}
this._log("END TRACE");
},
}
/**
@ -1420,26 +1183,3 @@ XPCOMUtils.defineLazyGetter(InspectorUI, "inspectCmd", function () {
return document.getElementById("Tools:Inspect");
});
XPCOMUtils.defineLazyGetter(InspectorUI, "strings", function () {
return Services.strings.createBundle("chrome://browser/locale/inspector.properties");
});
XPCOMUtils.defineLazyGetter(InspectorUI, "PropertyTreeView", function () {
var obj = {};
Cu.import("resource:///modules/PropertyPanel.jsm", obj);
return obj.PropertyTreeView;
});
XPCOMUtils.defineLazyGetter(InspectorUI, "PropertyPanel", function () {
var obj = {};
Cu.import("resource:///modules/PropertyPanel.jsm", obj);
return obj.PropertyPanel;
});
XPCOMUtils.defineLazyGetter(InspectorUI, "style", function () {
var obj = {};
Cu.import("resource:///modules/stylePanel.jsm", obj);
obj.style.initialize();
return obj.style;
});

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

@ -1,315 +0,0 @@
/*
* Software License Agreement (BSD License)
*
* Copyright (c) 2007, Parakey Inc.
* All rights reserved.
*
* Redistribution and use of this software in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above
* copyright notice, this list of conditions and the
* following disclaimer.
*
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* * Neither the name of Parakey Inc. nor the names of its
* contributors may be used to endorse or promote products
* derived from this software without specific prior
* written permission of Parakey Inc.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
* IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Creator:
* Joe Hewitt
* Contributors
* John J. Barton (IBM Almaden)
* Jan Odvarko (Mozilla Corp.)
* Max Stepanov (Aptana Inc.)
* Rob Campbell (Mozilla Corp.)
* Hans Hillen (Paciello Group, Mozilla)
* Curtis Bartley (Mozilla Corp.)
* Mike Collins (IBM Almaden)
* Kevin Decker
* Mike Ratcliffe (Comartis AG)
* Hernan Rodríguez Colmeiro
* Austin Andrews
* Christoph Dorn
* Steven Roussey (AppCenter Inc, Network54)
*/
var EXPORTED_SYMBOLS = ["style"];
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
var style = {
/**
* initialize domUtils
*/
initialize: function CSS_initialize()
{
this.domUtils = Cc["@mozilla.org/inspector/dom-utils;1"].
getService(Ci["inIDOMUtils"]);
},
/**
* Is the given property sheet a system (user agent) stylesheet?
*
* @param aSheet
* a stylesheet
*/
isSystemStyleSheet: function CSS_isSystemStyleSheet(aSheet)
{
if (!aSheet)
return true;
let url = aSheet.href;
if (!url)
return false;
if (url.length == 0)
return true;
if (url[0] == 'h')
return false;
if (url.substr(0, 9) == "resource:")
return true;
if (url.substr(0, 7) == "chrome:")
return true;
if (url == "XPCSafeJSObjectWrapper.cpp")
return true;
if (url.substr(0, 6) == "about:")
return true;
return false;
},
/**
* Parse properties from a given style object.
* Borrowed from Firebug's css.js.
*
* @param aStyle
* a style object
*/
parseCSSProperties: function CSS_parseCSSProps(aStyle)
{
let properties = [];
let lines = aStyle.cssText.match(/(?:[^;\(]*(?:\([^\)]*?\))?[^;\(]*)*;?/g);
let propRE = /\s*([^:\s]*)\s*:\s*(.*?)\s*(! important)?;?$/;
let line, i = 0;
while(line = lines[i++]) {
let match = propRE.exec(line);
if (!match)
continue;
let name = match[1];
let value = match[2];
let important = !!match[3]; // true if match[3] is non-empty
properties.unshift({name: name, value: value, important: important});
}
return properties;
},
/**
* Mark properties overridden further up the hierarchy.
*
* @param aProps
* Array of properties.
* @param aUsedProps
* Object of arrays keyed by property name.
* @param aInherit
* Boolean of whether or not we are in inherited mode.
*/
markOverriddenProperties: function CSS_markOverriddenProperties(aProps, aUsedProps, aInherit)
{
for (let i = 0; i < aProps.length; ++i) {
let prop = aProps[i];
if (aUsedProps.hasOwnProperty(prop.name)) {
// all previous occurrences of this property
let deadProps = aUsedProps[prop.name];
for (let j = 0; j < deadProps.length; ++j) {
let deadProp = deadProps[j];
if (!deadProp.disabled && !deadProp.wasInherited &&
deadProp.important && !prop.important) {
prop.overridden = true; // new occurrence overridden
} else if (!prop.disabled) {
deadProp.overridden = true; // previous occurrences overridden
} else {
aUsedProps[prop.name] = [];
}
prop.wasInherited = aInherit ? true : false;
// all occurrences of a property seen so far, by name
aUsedProps[prop.name].push(prop);
}
}
}
},
/**
* Sort given properties in lexical order by name.
*
* @param properties
* An array of properties.
* @returns sorted array.
*/
sortProperties: function CSS_sortProperties(properties)
{
properties.sort(function(a, b)
{
if (a.name < b.name) {
return -1;
}
if (a.name > b.name) {
return 1;
}
return 0;
});
},
/**
* Get properties for a given element and push them to the rules array.
*
* @param aNode
* a DOM node
* @param rules
* An array of rules to add properties to.
* @param usedProps
* Object of arrays keyed by property name.
* @param inherit
* boolean determining whether or not we're in inherit mode
*/
getStyleProperties: function CSS_getStyleProperties(aNode, aRules, aUsedProps, aInherit)
{
let properties = this.parseCSSProperties(aNode.style, aInherit);
this.sortProperties(properties);
this.markOverriddenProperties(properties, aUsedProps, aInherit);
if (properties.length) {
aRules.push({rule: aNode, selector: "element.style",
properties: properties, inherited: aInherit});
}
},
/**
* Get properties for a given rule.
*
* @param aRule
* A Rule from a stylesheet.
*/
getRuleProperties: function CSS_getRuleProperties(aRule)
{
let style = aRule.style;
return this.parseCSSProperties(style);
},
/**
* Recursively get rules for an element's parents and add them to the
* sections array.
*
* @param aNode
* an element in a DOM tree.
* @param sections
* an array of sections
* @param usedProps
* Object of arrays keyed by property name.
*/
getInheritedRules: function CSS_getInheritedRules(aNode, aSections, aUsedProps)
{
let parent = aNode.parentNode;
if (parent && parent.nodeType == 1) {
this.getInheritedRules(parent, aSections, aUsedProps);
let rules = [];
this.getElementRules(parent, rules, aUsedProps, true);
if (rules.length) {
aSections.unshift({element: parent, rules: rules});
}
}
},
/**
* Get the CSS style rules for a given node in the DOM and append them to the
* rules array.
*
* @param aNode
* an element in the DOM tree.
* @param aRules
* an array of rules.
* @param aUsedProps
* Object of arrays keyed by property name.
* @param aInherit
* boolean indicating whether we are in an inherited mode or not
*/
getElementRules: function CSS_getElementRules(aNode, aRules, aUsedProps, aInherit)
{
let inspectedRules;
try {
inspectedRules = this.domUtils.getCSSStyleRules(aNode);
} catch (ex) {
Services.console.logStringMessage(ex);
}
if (!inspectedRules)
return;
for (let i = 0; i < inspectedRules.Count(); ++i) {
let rule = inspectedRules.GetElementAt(i);
let href = rule.parentStyleSheet.href;
if (!href) {
// Null href means inline style.
href = aNode.ownerDocument.location.href;
}
let isSystemSheet = this.isSystemStyleSheet(rule.parentStyleSheet);
if (isSystemSheet)
continue;
let properties = this.getRuleProperties(rule, aInherit);
if (aInherit && !properties.length)
continue;
let line = this.domUtils.getRuleLine(rule);
let ruleId = rule.selectorText + " " + href + " (" + line + ")";
let sourceLink = "view-source:" + href + "#" + line;
this.markOverriddenProperties(properties, aUsedProps, aInherit);
aRules.unshift(
{rule: rule,
id: ruleId,
selector: rule.selectorText,
properties: properties,
inherited: aInherit,
sourceLink: sourceLink,
isSystemSheet: isSystemSheet});
}
if (aNode.style) {
this.getStyleProperties(aNode, aRules, aUsedProps, aInherit);
}
},
};

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

@ -186,8 +186,6 @@ _BROWSER_FILES = \
browser_inspector_initialization.js \
browser_inspector_treeSelection.js \
browser_inspector_highlighter.js \
browser_inspector_stylePanel.js \
browser_inspector_domPanel.js \
browser_inspector_iframeTest.js \
browser_inspector_scrolling.js \
browser_inspector_store.js \

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

@ -1,171 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Inspector DOM Panel Tests.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Rob Campbell <rcampbell@mozilla.com>
* Mihai Șucan <mihai.sucan@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
let doc;
let testGen;
let newProperty;
function createDocument()
{
doc.body.innerHTML = '<div id="first" style="{ margin: 10em; ' +
'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA}">\n' +
'<h1>Some header text</h1>\n' +
'<p id="salutation" style="{font-size: 12pt}">hi.</p>\n' +
'<p id="body" style="{font-size: 12pt}">I am a test-case. This text exists ' +
'solely to provide some things to <span style="{color: yellow}">' +
'highlight</span> and <span style="{font-weight: bold}">count</span> ' +
'DOM list-items in the box at right. If you are reading this, ' +
'you should go do something else instead. Maybe read a book. Or better ' +
'yet, write some test-cases for another bit of code. ' +
'<span style="{font-style: italic}">Maybe more inspector test-cases!</span></p>\n' +
'<p id="closing">end transmission</p>\n' +
'</div>';
doc.title = "Inspector DOM Test";
Services.obs.addObserver(runDOMTests, "inspector-opened", false);
InspectorUI.openInspectorUI();
}
function nodeGenerator()
{
let body = doc.body;
newProperty = "rand" + Date.now();
body[newProperty] = Math.round(Math.random() * 100);
InspectorUI.inspectNode(body);
yield;
let h1 = doc.querySelector("h1");
newProperty = "rand2" + Date.now();
h1[newProperty] = "test" + Math.random();
InspectorUI.inspectNode(h1);
yield;
let first = doc.getElementById("first");
newProperty = "rand3" + Date.now();
first[newProperty] = null;
InspectorUI.inspectNode(first);
yield;
let closing = doc.getElementById("closing");
newProperty = "bazbaz" + Date.now();
closing[newProperty] = false;
InspectorUI.inspectNode(closing);
yield;
}
function runDOMTests()
{
InspectorUI._log("runDOMtests");
Services.obs.removeObserver(runDOMTests, "inspector-opened", false);
document.addEventListener("popupshown", performTestComparisons, false);
InspectorUI.stopInspecting();
testGen = nodeGenerator();
testGen.next();
}
function findInDOMPanel(aString)
{
let treeView = InspectorUI.domTreeView;
let row;
for (let i = 0, n = treeView.rowCount; i < n; i++) {
row = treeView.getCellText(i, 0);
if (row && row.indexOf(aString) != -1) {
return true;
}
}
return false;
}
function performTestComparisons(evt)
{
InspectorUI._log("performTestComparisons");
if (evt.target.id != "highlighter-panel")
return true;
let selection = InspectorUI.selection;
ok(selection, "selection");
ok(InspectorUI.isDOMPanelOpen, "DOM panel is open?");
ok(InspectorUI.highlighter.isHighlighting, "panel is highlighting");
let value = selection[newProperty];
if (typeof value == "string") {
value = '"' + value + '"';
}
ok(findInDOMPanel(newProperty + ': ' + value),
"domPanel shows the correct value for " + newProperty);
ok(findInDOMPanel('tagName: "' + selection.tagName + '"'),
"domPanel shows the correct tagName");
if (selection.id) {
ok(findInDOMPanel('id: "' + selection.id + '"'),
"domPanel shows the correct id");
}
try {
testGen.next();
} catch(StopIteration) {
document.removeEventListener("popupshown", performTestComparisons, false);
finishUp();
}
}
function finishUp() {
InspectorUI.closeInspectorUI();
gBrowser.removeCurrentTab();
finish();
}
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
doc = content.document;
waitForFocus(createDocument, content);
}, true);
content.location = "data:text/html,basic tests for inspector";
}

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

@ -97,11 +97,16 @@ function performTestComparisons(evt)
is(h1, InspectorUI.selection, "selection matches node");
ok(InspectorUI.highlighter.isHighlighting, "panel is highlighting");
is(InspectorUI.highlighter.highlitNode, h1, "highlighter matches selection");
executeSoon(finishUp);
Services.obs.addObserver(finishUp, "inspector-closed", false);
InspectorUI.closeInspectorUI();
}
function finishUp() {
InspectorUI.closeInspectorUI();
Services.obs.removeObserver(finishUp, "inspector-closed", false);
ok(!InspectorUI.highlighter.isHighlighting, "panel is not highlighting");
doc = h1 = null;
gBrowser.removeCurrentTab();
finish();
}

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

@ -54,16 +54,12 @@ function runInspectorTests()
is(InspectorUI.treeIFrame, iframe, "Inspector IFrame matches");
ok(InspectorUI.inspecting, "Inspector is highlighting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
ok(InspectorUI.isStylePanelOpen, "Inspector Style Panel is open");
ok(InspectorUI.isDOMPanelOpen, "Inspector DOM Panel is open");
InspectorUI.closeInspectorUI();
}
function finishInspectorTests()
{
Services.obs.removeObserver(finishInspectorTests, "inspector-closed", false);
ok(!InspectorUI.isDOMPanelOpen, "Inspector DOM Panel is closed");
ok(!InspectorUI.isStylePanelOpen, "Inspector Style Panel is closed");
ok(!InspectorUI.isTreePanelOpen, "Inspector Tree Panel is closed");
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
gBrowser.removeCurrentTab();

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

@ -1,124 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Inspector Style Panel Tests.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Rob Campbell <rcampbell@mozilla.com> (original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
let doc;
let spans;
let testGen;
function createDocument()
{
doc.body.innerHTML = '<div id="first" style="{ margin: 10em; ' +
'font-size: 14pt; font-family: helvetica, sans-serif; color: #AAA}">\n' +
'<h1>Some header text</h1>\n' +
'<p id="salutation" style="{font-size: 12pt}">hi.</p>\n' +
'<p id="body" style="{font-size: 12pt}">I am a test-case. This text exists ' +
'solely to provide some things to <span style="{color: yellow}">' +
'highlight</span> and <span style="{font-weight: bold}">count</span> ' +
'style list-items in the box at right. If you are reading this, ' +
'you should go do something else instead. Maybe read a book. Or better ' +
'yet, write some test-cases for another bit of code. ' +
'<span style="{font-style: italic}">Maybe more inspector test-cases!</span></p>\n' +
'<p id="closing">end transmission</p>\n' +
'</div>';
doc.title = "Inspector Style Test";
setupStyleTests();
}
function setupStyleTests()
{
spans = doc.querySelectorAll("span");
ok(spans, "captain, we have the spans");
Services.obs.addObserver(runStyleTests, "inspector-opened", false);
InspectorUI.openInspectorUI();
}
function spanGenerator()
{
for (var i = 0; i < spans.length; ++i) {
InspectorUI.inspectNode(spans[i]);
yield;
}
}
function runStyleTests()
{
Services.obs.removeObserver(runStyleTests, "inspector-opened", false);
document.addEventListener("popupshown", performTestComparisons, false);
InspectorUI.stopInspecting();
testGen = spanGenerator();
testGen.next();
}
function performTestComparisons(evt)
{
if (evt.target.id != "highlighter-panel")
return true;
ok(InspectorUI.selection, "selection");
ok(InspectorUI.isStylePanelOpen, "style panel is open?");
ok(InspectorUI.highlighter.isHighlighting, "panel is highlighting");
ok(InspectorUI.styleBox.itemCount > 0, "styleBox has items");
try {
testGen.next();
} catch(StopIteration) {
document.removeEventListener("popupshown", performTestComparisons, false);
finishUp();
}
}
function finishUp() {
InspectorUI.closeInspectorUI();
gBrowser.removeCurrentTab();
finish();
}
function test()
{
waitForExplicitFinish();
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function() {
gBrowser.selectedBrowser.removeEventListener("load", arguments.callee, true);
doc = content.document;
waitForFocus(createDocument, content);
}, true);
content.location = "data:text/html,basic tests for inspector";
}

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

@ -60,7 +60,6 @@ function inspectorUIOpen1()
// Make sure the inspector is open.
ok(InspectorUI.inspecting, "Inspector is highlighting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
ok(InspectorUI.isStylePanelOpen, "Inspector Style Panel is open");
ok(!InspectorStore.isEmpty(), "InspectorStore is not empty");
is(InspectorStore.length, 1, "InspectorStore.length = 1");
@ -72,6 +71,7 @@ function inspectorUIOpen1()
// Open the second tab.
tab2 = gBrowser.addTab();
gBrowser.selectedTab = tab2;
gBrowser.selectedBrowser.addEventListener("load", function(evt) {
gBrowser.selectedBrowser.removeEventListener(evt.type, arguments.callee,
true);
@ -86,12 +86,13 @@ function inspectorTabOpen2()
// Make sure the inspector is closed.
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
ok(!InspectorUI.isPanelOpen, "Inspector Tree Panel is closed");
ok(!InspectorUI.isStylePanelOpen, "Inspector Style Panel is closed");
is(InspectorStore.length, 1, "InspectorStore.length = 1");
// Activate the inspector again.
executeSoon(function() {
Services.obs.addObserver(inspectorUIOpen2, "inspector-opened", false);
InspectorUI.openInspectorUI();
});
}
function inspectorUIOpen2()
@ -101,7 +102,6 @@ function inspectorUIOpen2()
// Make sure the inspector is open.
ok(InspectorUI.inspecting, "Inspector is highlighting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
ok(InspectorUI.isStylePanelOpen, "Inspector Style Panel is open");
is(InspectorStore.length, 2, "InspectorStore.length = 2");
// Disable highlighting.
@ -109,8 +109,10 @@ function inspectorUIOpen2()
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
// Switch back to tab 1.
executeSoon(function() {
Services.obs.addObserver(inspectorFocusTab1, "inspector-opened", false);
gBrowser.selectedTab = tab1;
});
}
function inspectorFocusTab1()
@ -120,7 +122,6 @@ function inspectorFocusTab1()
// Make sure the inspector is still open.
ok(InspectorUI.inspecting, "Inspector is highlighting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
ok(InspectorUI.isStylePanelOpen, "Inspector Style Panel is open");
is(InspectorStore.length, 2, "InspectorStore.length = 2");
is(InspectorUI.selection, div, "selection matches the div element");
@ -136,7 +137,6 @@ function inspectorFocusTab2()
// Make sure the inspector is still open.
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
ok(InspectorUI.isStylePanelOpen, "Inspector Style Panel is open");
is(InspectorStore.length, 2, "InspectorStore.length = 2");
isnot(InspectorUI.selection, div, "selection does not match the div element");
@ -154,7 +154,6 @@ function inspectorTabUnload1(evt)
// Make sure the Inspector is still open and that the state is correct.
ok(!InspectorUI.inspecting, "Inspector is not highlighting");
ok(InspectorUI.isTreePanelOpen, "Inspector Tree Panel is open");
ok(InspectorUI.isStylePanelOpen, "Inspector Style Panel is open");
is(InspectorStore.length, 1, "InspectorStore.length = 1");
InspectorUI.closeInspectorUI();

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

@ -36,8 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
const TEST_URL_BASES = [
"http://example.org/browser/browser/base/content/test/dummy_page.html#tabmatch",
"http://example.org/browser/browser/base/content/test/moz.png#tabmatch"

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

@ -11,8 +11,6 @@ const PAGE_URL = BASE_URL + "/framedPage.html";
const LEFT_URL = BASE_URL + "/frameLeft.html";
const RIGHT_URL = BASE_URL + "/frameRight.html";
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
let gTabLoaded = false;
let gLeftFrameVisited = false;

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

@ -1,7 +1,6 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");

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

@ -212,19 +212,6 @@ can reach it easily. -->
<!ENTITY inspectPanelTitle.label "HTML">
<!ENTITY inspectButton.label "Inspect">
<!ENTITY inspectButton.accesskey "I">
<!ENTITY inspectNextButton.label "Next">
<!ENTITY inspectNextButton.accesskey "N">
<!ENTITY inspectPreviousButton.label "Previous">
<!ENTITY inspectPreviousButton.accesskey "P">
<!ENTITY inspectStyleButton.label "Style">
<!ENTITY inspectStyleButton.accesskey "S">
<!ENTITY inspectStylePanelTitle.label "Style">
<!-- LOCALIZATION NOTE (inspectObjectButton.label): This button label
- appears on the Inspector's toolbar. It is used to open and close the Object
- panel. There is also a label in inspector.properties for the panel
- titlebar: object.objectPanelTitle. -->
<!ENTITY inspectObjectButton.label "Object">
<!ENTITY inspectObjectButton.accesskey "O">
<!ENTITY getMoreDevtoolsCmd.label "Get More Tools">
<!ENTITY getMoreDevtoolsCmd.accesskey "M">

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

@ -1,16 +0,0 @@
# LOCALIZATION NOTE (style.selectorLabel): Used in the Inspector style panel
# to label a CSS Selector.
style.selectorLabel=Selector
# LOCALIZATION NOTE (style.inheritedFrom): used in Style panel in
# inspector. Describes which tagname[#id] the properties are inherited from.
style.inheritedFrom=Inherited from: #1
# LOCALIZATION NOTE (style.styleItemLabel): used in Style panel in inspector.
# Used for construction of list items, #1 = label, #2 = content.
style.styleItemLabel=#1: #2
# LOCALIZATION NOTE (object.objectPanelTitle): used in the Object Panel in the
# Inspector tool. There's also inspectObjectButton in browser.dtd for the
# toolbar button which allows users to open/close the Object panel.
object.objectPanelTitle=Object

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

@ -14,7 +14,6 @@
* locale/browser/browser.dtd (%chrome/browser/browser.dtd)
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
locale/browser/browser.properties (%chrome/browser/browser.properties)
locale/browser/inspector.properties (%chrome/browser/inspector.properties)
locale/browser/scratchpad.properties (%chrome/browser/scratchpad.properties)
locale/browser/scratchpad.dtd (%chrome/browser/scratchpad.dtd)
locale/browser/openLocation.dtd (%chrome/browser/openLocation.dtd)

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

@ -54,7 +54,7 @@ from automationutils import getDebuggerInfo, addCommonOptions
PORT = 8888
PROFILE_DIRECTORY = os.path.abspath(os.path.join(SCRIPT_DIR, "./pgoprofile"))
MOZ_JAR_LOG_DIR = os.path.abspath(os.path.join(os.getenv("OBJDIR"), "jarlog"))
MOZ_JAR_LOG_DIR = os.path.abspath(os.getenv("JARLOG_DIR"))
os.chdir(SCRIPT_DIR)
class EasyServer(SocketServer.TCPServer):

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

@ -211,7 +211,7 @@ endif
profiledbuild::
$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_GENERATE=1
$(MAKE) -C $(PGO_OBJDIR) package
OBJDIR=${PGO_OBJDIR} $(PROFILE_GEN_SCRIPT)
OBJDIR=${PGO_OBJDIR} JARLOG_DIR=${PGO_OBJDIR}/jarlog/en-US $(PROFILE_GEN_SCRIPT)
$(MAKE) -f $(TOPSRCDIR)/client.mk maybe_clobber_profiledbuild
$(MAKE) -f $(TOPSRCDIR)/client.mk realbuild MOZ_PROFILE_USE=1

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

@ -2028,6 +2028,9 @@ nsCanvasRenderingContext2D::FillRect(float x, float y, float w, float h)
NS_IMETHODIMP
nsCanvasRenderingContext2D::StrokeRect(float x, float y, float w, float h)
{
if (w == 0.f && h == 0.f) {
return NS_OK;
}
return DrawRect(gfxRect(x, y, w, h), STYLE_STROKE);
}
@ -3291,8 +3294,14 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
return NS_ERROR_DOM_TYPE_MISMATCH_ERR;
}
double sx,sy,sw,sh;
double dx,dy,dw,dh;
nsCOMPtr<nsIContent> content = do_QueryInterface(imgElt);
nsHTMLCanvasElement* canvas = nsHTMLCanvasElement::FromContent(content);
if (canvas) {
nsIntSize size = canvas->GetSize();
if (size.width == 0 || size.height == 0) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
}
gfxMatrix matrix;
nsRefPtr<gfxPattern> pattern;
@ -3334,6 +3343,8 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
}
}
double sx,sy,sw,sh;
double dx,dy,dw,dh;
if (optional_argc == 0) {
dx = a1;
dy = a2;

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

@ -79,6 +79,7 @@ _TEST_FILES_0 = \
test_2d.composite.uncovered.image.destination-in.html \
test_2d.composite.uncovered.image.source-in.html \
test_2d.composite.uncovered.image.source-out.html \
test_2d.drawImage.zerocanvas.html \
test_toDataURL_lowercase_ascii.html \
test_toDataURL_parameters.html \
test_mozGetAsFile.html \

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

@ -0,0 +1,56 @@
<!DOCTYPE HTML>
<title>Canvas test: 2d.drawImage.zerocanvas</title>
<script src="/MochiKit/MochiKit.js"></script>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
<body>
<canvas id="c" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
<script>
function isPixel(ctx, x,y, r,g,b,a, pos, colour, d) {
var pixel = ctx.getImageData(x, y, 1, 1);
var pr = pixel.data[0],
pg = pixel.data[1],
pb = pixel.data[2],
pa = pixel.data[3];
ok(r-d <= pr && pr <= r+d &&
g-d <= pg && pg <= g+d &&
b-d <= pb && pb <= b+d &&
a-d <= pa && pa <= a+d,
"pixel "+pos+" is "+pr+","+pg+","+pb+","+pa+"; expected "+colour+" +/- "+d);
}
SimpleTest.waitForExplicitFinish();
MochiKit.DOM.addLoadEvent(function () {
var canvas = document.getElementById('c');
var ctx = canvas.getContext('2d');
ctx.fillStyle = '#0f0';
ctx.fillRect(0, 0, 100, 50);
var canvas2 = document.createElement('canvas');
canvas2.width = 0;
canvas2.height = 10;
var _thrown = undefined; try {
ctx.drawImage(canvas2, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw INVALID_STATE_ERR");
canvas2.width = 10;
canvas2.height = 0;
var _thrown = undefined; try {
ctx.drawImage(canvas2, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw INVALID_STATE_ERR");
canvas2.width = 0;
canvas2.height = 0;
var _thrown = undefined; try {
ctx.drawImage(canvas2, 0, 0);
} catch (e) { _thrown = e }; ok(_thrown && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw INVALID_STATE_ERR");
isPixel(ctx, 50,25, 0,255,0,255, "50,25", "0,255,0,255", 2);
SimpleTest.finish();
});
</script>

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

@ -18395,7 +18395,7 @@ ctx.lineWidth = 250;
ctx.lineCap = 'round';
ctx.lineJoin = 'round';
ctx.strokeRect(50, 25, 0, 0);
todo_isPixel(ctx, 50,25, 0,0,0,0, 0);
isPixel(ctx, 50,25, 0,0,0,0, 0);
}

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

@ -68,6 +68,13 @@ public:
nsHTMLCanvasElement(already_AddRefed<nsINodeInfo> aNodeInfo);
virtual ~nsHTMLCanvasElement();
static nsHTMLCanvasElement* FromContent(nsIContent* aPossibleCanvas)
{
if (!aPossibleCanvas || !aPossibleCanvas->IsHTML(nsGkAtoms::canvas)) {
return nsnull;
}
return static_cast<nsHTMLCanvasElement*>(aPossibleCanvas);
}
// nsISupports
NS_DECL_ISUPPORTS_INHERITED

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

@ -36,8 +36,8 @@
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsITextControlElement.h"
#include "nsIDOMNSEditableElement.h"
#include "nsIControllers.h"
@ -90,7 +90,6 @@ static NS_DEFINE_CID(kXULControllersCID, NS_XULCONTROLLERS_CID);
class nsHTMLTextAreaElement : public nsGenericHTMLFormElement,
public nsIDOMHTMLTextAreaElement,
public nsIDOMNSHTMLTextAreaElement,
public nsITextControlElement,
public nsIDOMNSEditableElement,
public nsStubMutationObserver,
@ -117,9 +116,6 @@ public:
// nsIDOMHTMLTextAreaElement
NS_DECL_NSIDOMHTMLTEXTAREAELEMENT
// nsIDOMNSHTMLTextAreaElement
NS_DECL_NSIDOMNSHTMLTEXTAREAELEMENT
// nsIDOMNSEditableElement
NS_IMETHOD GetEditor(nsIEditor** aEditor)
{
@ -352,9 +348,8 @@ DOMCI_NODE_DATA(HTMLTextAreaElement, nsHTMLTextAreaElement)
// QueryInterface implementation for nsHTMLTextAreaElement
NS_INTERFACE_TABLE_HEAD_CYCLE_COLLECTION_INHERITED(nsHTMLTextAreaElement)
NS_HTML_CONTENT_INTERFACE_TABLE6(nsHTMLTextAreaElement,
NS_HTML_CONTENT_INTERFACE_TABLE5(nsHTMLTextAreaElement,
nsIDOMHTMLTextAreaElement,
nsIDOMNSHTMLTextAreaElement,
nsITextControlElement,
nsIDOMNSEditableElement,
nsIMutationObserver,

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

@ -49,7 +49,7 @@
#include "nsTextControlFrame.h"
#include "nsIControllers.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsITransactionManager.h"
#include "nsIControllerContext.h"
#include "nsAttrValue.h"
@ -782,7 +782,7 @@ DoCommandCallback(const char *aCommand, void *aData)
if (input) {
input->GetControllers(getter_AddRefs(controllers));
} else {
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> textArea =
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea =
do_QueryInterface(content);
if (textArea) {
@ -1249,7 +1249,7 @@ nsTextEditorState::PrepareEditor(const nsAString *aValue)
if (inputElement) {
rv = inputElement->GetControllers(getter_AddRefs(controllers));
} else {
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> textAreaElement =
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement =
do_QueryInterface(mTextCtrlElement);
if (!textAreaElement)
@ -1460,7 +1460,7 @@ nsTextEditorState::UnbindFromFrame(nsTextControlFrame* aFrame)
inputElement->GetControllers(getter_AddRefs(controllers));
else
{
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> textAreaElement =
nsCOMPtr<nsIDOMHTMLTextAreaElement> textAreaElement =
do_QueryInterface(mTextCtrlElement);
if (textAreaElement) {
textAreaElement->GetControllers(getter_AddRefs(controllers));

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

@ -54,7 +54,7 @@
#include "nsIDOMXULElement.h"
#include "nsIDOMNSUIEvent.h"
#include "nsIURI.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMText.h"
#include "nsFocusManager.h"
@ -558,7 +558,7 @@ nsXBLPrototypeHandler::GetController(nsPIDOMEventTarget* aTarget)
xulElement->GetControllers(getter_AddRefs(controllers));
if (!controllers) {
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> htmlTextArea(do_QueryInterface(aTarget));
nsCOMPtr<nsIDOMHTMLTextAreaElement> htmlTextArea(do_QueryInterface(aTarget));
if (htmlTextArea)
htmlTextArea->GetControllers(getter_AddRefs(controllers));
}

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

@ -50,7 +50,6 @@
#include "nsIDOMXULDocument.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMWindowInternal.h"
#include "nsIDOMXULElement.h"
#include "nsIDocument.h"

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

@ -308,7 +308,6 @@
#include "nsIDOMHTMLTableRowElement.h"
#include "nsIDOMHTMLTableSectionElem.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMHTMLTitleElement.h"
#include "nsIDOMHTMLUListElement.h"
#include "nsIDOMHTMLUnknownElement.h"
@ -2936,7 +2935,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_BEGIN(HTMLTextAreaElement, nsIDOMHTMLTextAreaElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHTMLTextAreaElement)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHTMLTextAreaElement)
DOM_CLASSINFO_GENERIC_HTML_MAP_ENTRIES
DOM_CLASSINFO_MAP_END

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

@ -56,7 +56,7 @@
#include "nsGlobalWindow.h"
#include "nsFocusManager.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIDOMHTMLTextAreaElement.h"
#include "nsIControllers.h"
#include "nsCycleCollectionParticipant.h"
@ -286,7 +286,7 @@ nsWindowRoot::GetControllers(nsIControllers** aResult)
return xulElement->GetControllers(aResult);
#endif
nsCOMPtr<nsIDOMNSHTMLTextAreaElement> htmlTextArea =
nsCOMPtr<nsIDOMHTMLTextAreaElement> htmlTextArea =
do_QueryInterface(focusedContent);
if (htmlTextArea)
return htmlTextArea->GetControllers(aResult);

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

@ -123,7 +123,6 @@ XPIDLSRCS = \
nsIDOMNSHTMLElement.idl \
nsIDOMNSHTMLFrameElement.idl \
nsIDOMNSHTMLOptionCollectn.idl \
nsIDOMNSHTMLTextAreaElement.idl \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -39,6 +39,9 @@
#include "nsIDOMHTMLElement.idl"
interface nsIControllers;
interface nsIDOMValidityState;
/**
* The nsIDOMHTMLTextAreaElement interface is the interface to a
* [X]HTML textarea element.
@ -53,16 +56,45 @@
[scriptable, uuid(905edd3e-c0b3-4d54-8a2c-0eaab6ccb3cf)]
interface nsIDOMHTMLTextAreaElement : nsIDOMHTMLElement
{
// Modified in DOM Level 2:
attribute DOMString defaultValue;
readonly attribute nsIDOMHTMLFormElement form;
attribute boolean autofocus;
attribute unsigned long cols;
attribute boolean disabled;
readonly attribute nsIDOMHTMLFormElement form;
attribute long maxLength;
attribute DOMString name;
attribute DOMString placeholder;
attribute boolean readOnly;
attribute boolean required;
attribute unsigned long rows;
attribute long tabIndex;
/**
* Reflects the wrap content attribute. Possible values are "soft", "hard" and
* "off". "soft" is the default.
*/
[Null(Stringify)]
attribute DOMString wrap;
readonly attribute DOMString type;
attribute DOMString defaultValue;
attribute DOMString value;
readonly attribute long textLength;
// The following lines are part of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
void select();
attribute long selectionStart;
attribute long selectionEnd;
void setSelectionRange(in long selectionStart, in long selectionEnd);
// Defined on HTMLElement in the specification.
attribute long tabIndex;
// Mozilla extensions
readonly attribute nsIControllers controllers;
};

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

@ -1,74 +0,0 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Vidur Apparao <vidur@netscape.com> (original author)
* Johnny Stenback <jst@netscape.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either of the GNU General Public License Version 2 or later (the "GPL"),
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "domstubs.idl"
interface nsIControllers;
interface nsIDOMValidityState;
[scriptable, uuid(df5dc23d-cf90-443e-bf56-cd3af021ebc7)]
interface nsIDOMNSHTMLTextAreaElement : nsISupports
{
attribute boolean autofocus;
readonly attribute nsIControllers controllers;
readonly attribute long textLength;
attribute long selectionStart;
attribute long selectionEnd;
attribute long maxLength;
attribute DOMString placeholder;
attribute boolean required;
/**
* Reflects the wrap content attribute. Possible values are "soft, "hard" and
* "off". "soft" is the default.
*/
[Null(Stringify)] attribute DOMString wrap;
// The following lines are parte of the constraint validation API, see:
// http://www.whatwg.org/specs/web-apps/current-work/#the-constraint-validation-api
readonly attribute boolean willValidate;
readonly attribute nsIDOMValidityState validity;
readonly attribute DOMString validationMessage;
boolean checkValidity();
void setCustomValidity(in DOMString error);
void setSelectionRange(in long selectionStart,
in long selectionEnd);
};

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

@ -333,6 +333,11 @@ members = [
'nsIDOMHTMLTextAreaElement.value',
'nsIDOMHTMLTextAreaElement.type',
'nsIDOMHTMLTextAreaElement.select',
'nsIDOMHTMLTextAreaElement.setSelectionRange',
'nsIDOMHTMLTextAreaElement.selectionStart',
'nsIDOMHTMLTextAreaElement.selectionEnd',
'nsIDOMHTMLTextAreaElement.textLength',
'nsIDOMHTMLTextAreaElement.wrap',
'nsIDOMHTMLTitleElement.text',
'nsIDOMHTMLCanvasElement.width',
'nsIDOMHTMLCanvasElement.height',
@ -350,11 +355,6 @@ members = [
'nsIDOMNSHTMLFrameElement.contentWindow',
'nsIDOMNSHTMLOptionCollection.selectedIndex',
'nsIDOMNSHTMLOptionCollection.add',
'nsIDOMNSHTMLTextAreaElement.setSelectionRange',
'nsIDOMNSHTMLTextAreaElement.selectionStart',
'nsIDOMNSHTMLTextAreaElement.selectionEnd',
'nsIDOMNSHTMLTextAreaElement.textLength',
'nsIDOMNSHTMLTextAreaElement.wrap',
# dom/interfaces/json - None.
# All 4 methods of nsIJSON call GetCurrentNativeCallContext.

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

@ -113,7 +113,6 @@
#include "nsIParser.h"
#include "nsParserCIID.h"
#include "nsFrameSelection.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsViewsCID.h"
#include "nsPresArena.h"
#include "nsFrameManager.h"

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

@ -563,7 +563,12 @@ nsFileControlFrame::BrowseMouseListener::HandleEvent(nsIDOMEvent* aEvent)
nsCOMPtr<nsIDOMFileList> fileList;
dataTransfer->GetFiles(getter_AddRefs(fileList));
PRBool oldState = mFrame->mTextFrame->GetFireChangeEventState();
mFrame->mTextFrame->SetFireChangeEventState(PR_TRUE);
inputElement->SetFiles(fileList, true);
mFrame->mTextFrame->SetFireChangeEventState(oldState);
mFrame->mTextFrame->CheckFireOnChange();
}
return NS_OK;

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

@ -36,11 +36,9 @@
*
* ***** END LICENSE BLOCK ***** */
#include "nsCOMPtr.h"
#include "nsTextControlFrame.h"
#include "nsIDocument.h"
#include "nsIDOMNSHTMLTextAreaElement.h"
#include "nsIFormControl.h"
#include "nsIServiceManager.h"
#include "nsFrameSelection.h"

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

@ -199,8 +199,43 @@ static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
#endif /* PR_LOGGING */
#if defined(XP_MACOSX) && !defined(NP_NO_CARBON)
#define MAC_CARBON_PLUGINS
#endif
// The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7
// and up (though the QuickDraw APIs defined in them are still present) -- so
// we need to supply the relevant parts of their contents here. It's likely
// that Apple will eventually remove the APIs themselves (probably in OS X
// 10.8), so we need to make them weak imports, and test for their presence
// before using them.
extern "C" {
#if !defined(__QUICKDRAWAPI__)
extern void SetRect(
Rect * r,
short left,
short top,
short right,
short bottom)
__attribute__((weak_import));
#endif /* __QUICKDRAWAPI__ */
#if !defined(__QDOFFSCREEN__)
extern QDErr NewGWorldFromPtr(
GWorldPtr * offscreenGWorld,
UInt32 PixelFormat,
const Rect * boundsRect,
CTabHandle cTable, /* can be NULL */
GDHandle aGDevice, /* can be NULL */
GWorldFlags flags,
Ptr newBuffer,
SInt32 rowBytes)
__attribute__((weak_import));
extern void DisposeGWorld(GWorldPtr offscreenGWorld)
__attribute__((weak_import));
#endif /* __QDOFFSCREEN__ */
}
#endif /* #if defined(XP_MACOSX) && !defined(NP_NO_CARBON) */
using namespace mozilla;
using namespace mozilla::plugins;
@ -1272,6 +1307,13 @@ nsObjectFrame::PrintPlugin(nsRenderingContext& aRenderingContext,
// platform specific printing code
#ifdef MAC_CARBON_PLUGINS
// Don't use this code if any of the QuickDraw APIs it currently requires
// are missing (as they probably will be on OS X 10.8 and up).
if (!::SetRect || !::NewGWorldFromPtr || !::DisposeGWorld) {
NS_WARNING("Cannot print plugin -- required QuickDraw APIs are missing!");
return;
}
nsSize contentSize = GetContentRectRelativeToSelf().Size();
window.x = 0;
window.y = 0;

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

@ -1,7 +1,3 @@
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
const RELATIVE_DIR = "modules/libpr0n/test/browser/";
const TESTROOT = "http://example.com/browser/" + RELATIVE_DIR;
const TESTROOT2 = "http://example.org/browser/" + RELATIVE_DIR;
@ -9,8 +5,6 @@ const TESTROOT2 = "http://example.org/browser/" + RELATIVE_DIR;
var chrome_root = getRootDirectory(gTestPath);
const CHROMEROOT = chrome_root;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function getImageLoading(doc, id) {
var htmlImg = doc.getElementById(id);
return htmlImg.QueryInterface(Ci.nsIImageLoadingContent);

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

@ -45,10 +45,6 @@
*
* ***** END LICENSE BLOCK ***** */
#ifdef MOZ_IPC
#include "base/basictypes.h"
#endif
#include "nsHttpChannel.h"
#include "nsHttpHandler.h"
#include "nsIApplicationCacheService.h"

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

@ -5655,6 +5655,13 @@ ConsoleUtils = {
// Make the location clickable.
locationNode.addEventListener("click", function() {
if (aSourceURL == "Scratchpad") {
let win = Services.wm.getMostRecentWindow("devtools:scratchpad");
if (win) {
win.focus();
}
return;
}
let viewSourceUtils = aDocument.defaultView.gViewSourceUtils;
viewSourceUtils.viewSource(aSourceURL, null, aDocument, aSourceLine);
}, true);

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

@ -36,22 +36,7 @@
*
* ***** END LICENSE BLOCK ***** */
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "HUDService", function () {
Cu.import("resource:///modules/HUDService.jsm");
try {
return HUDService;
}
catch (ex) {
dump(ex + "\n");
}
});
Cu.import("resource://gre/modules/HUDService.jsm");
function log(aMsg)
{

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

@ -36,8 +36,6 @@
*
* ***** END LICENSE BLOCK ***** */
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
gBrowser.selectedTab = gBrowser.addTab();
function test() {

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

@ -3,8 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
gBrowser.selectedTab = gBrowser.addTab();
function finishAndCleanUp()

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

@ -3,8 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
gBrowser.selectedTab = gBrowser.addTab();
function finishAndCleanUp()

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

@ -3,9 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const INITIAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html";
const FINAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/final.html";

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

@ -3,9 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
const INITIAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/begin.html";
const FINAL_URL = "http://example.com/tests/toolkit/components/places/tests/browser/final.html";

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

@ -139,7 +139,9 @@ endif
repackage-zip: UNPACKAGE="$(ZIP_IN)"
repackage-zip: libs-$(AB_CD)
# Adjust jar logs with the new locale (can't use sed -i because of bug 373784)
-$(PERL) -pi.old -e "s/en-US/$(AB_CD)/g" $(JARLOG_DIR)/*.jar.log
mkdir -p $(JARLOG_DIR_AB_CD)
-cp -r $(JARLOG_DIR)/en-US/*.jar.log $(JARLOG_DIR_AB_CD)
-$(PERL) -pi.old -e "s/en-US/$(AB_CD)/g" $(JARLOG_DIR_AB_CD)/*.jar.log
# call a hook for apps to put their uninstall helper.exe into the package
$(UNINSTALLER_PACKAGE_HOOK)
# copy xpi-stage over, but not install.rdf and chrome.manifest,

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

@ -2181,7 +2181,8 @@ var XPIProvider = {
* When performing recovery after startup this will be an array of
* persistent descriptors of add-ons that are known to be active,
* otherwise it will be null
* @return true if a change requiring a restart was detected
* @return a boolean indicating if a change requiring flushing the caches was
* detected
*/
processFileChanges: function XPI_processFileChanges(aState, aManifests,
aUpdateCompatibility,
@ -2205,7 +2206,7 @@ var XPIProvider = {
* ran
* @param aAddonState
* The new state of the add-on
* @return true if restarting the application is required to complete
* @return a boolean indicating if flushing caches is required to complete
* changing this add-on
*/
function updateMetadata(aInstallLocation, aOldAddon, aAddonState) {
@ -2276,6 +2277,37 @@ var XPIProvider = {
return false;
}
/**
* Updates an add-on's descriptor for when the add-on has moved in the
* filesystem but hasn't changed in any other way.
*
* @param aInstallLocation
* The install location containing the add-on
* @param aOldAddon
* The AddonInternal as it appeared the last time the application
* ran
* @param aAddonState
* The new state of the add-on
* @return a boolean indicating if flushing caches is required to complete
* changing this add-on
*/
function updateDescriptor(aInstallLocation, aOldAddon, aAddonState) {
LOG("Add-on " + aOldAddon.id + " moved to " + aAddonState.descriptor);
aOldAddon._descriptor = aAddonState.descriptor;
aOldAddon.visible = !(aOldAddon.id in visibleAddons);
// Update the database
XPIDatabase.setAddonDescriptor(aOldAddon, aAddonState.descriptor);
if (aOldAddon.visible) {
visibleAddons[aOldAddon.id] = aOldAddon;
return true;
}
return false;
}
/**
* Called when no change has been detected for an add-on's metadata. The
* add-on may have become visible due to other add-ons being removed or
@ -2289,8 +2321,8 @@ var XPIProvider = {
* ran
* @param aAddonState
* The new state of the add-on
* @return a boolean indicating if restarting the application is required
* to complete changing this add-on
* @return a boolean indicating if flushing caches is required to complete
* changing this add-on
*/
function updateVisibilityAndCompatibility(aInstallLocation, aOldAddon,
aAddonState) {
@ -2399,8 +2431,8 @@ var XPIProvider = {
* @param aOldAddon
* The AddonInternal as it appeared the last time the application
* ran
* @return a boolean indicating if restarting the application is required
* to complete changing this add-on
* @return a boolean indicating if flushing caches is required to complete
* changing this add-on
*/
function removeMetadata(aInstallLocation, aOldAddon) {
// This add-on has disappeared
@ -2433,8 +2465,8 @@ var XPIProvider = {
* @param aMigrateData
* If during startup the database had to be upgraded this will
* contain data that used to be held about this add-on
* @return a boolean indicating if restarting the application is required
* to complete changing this add-on
* @return a boolean indicating if flushing caches is required to complete
* changing this add-on
*/
function addMetadata(aInstallLocation, aId, aAddonState, aMigrateData) {
LOG("New add-on " + aId + " installed in " + aInstallLocation.name);
@ -2606,17 +2638,19 @@ var XPIProvider = {
XPIProvider.inactiveAddonIDs.push(aOldAddon.id);
// The add-on has changed if the modification time has changed, or
// the directory it is installed in has changed or we have an
// updated manifest for it. Also reload the metadata for add-ons
// in the application directory when the application version has
// changed
// we have an updated manifest for it. Also reload the metadata for
// add-ons in the application directory when the application version
// has changed
if (aOldAddon.id in aManifests[installLocation.name] ||
aOldAddon.updateDate != addonState.mtime ||
aOldAddon._descriptor != addonState.descriptor ||
(aUpdateCompatibility && installLocation.name == KEY_APP_GLOBAL)) {
changed = updateMetadata(installLocation, aOldAddon, addonState) ||
changed;
}
else if (aOldAddon._descriptor != addonState.descriptor) {
changed = updateDescriptor(installLocation, aOldAddon, addonState) ||
changed;
}
else {
changed = updateVisibilityAndCompatibility(installLocation,
aOldAddon, addonState) ||
@ -3882,6 +3916,8 @@ var XPIDatabase = {
"pendingUninstall=:pendingUninstall, " +
"applyBackgroundUpdates=:applyBackgroundUpdates WHERE " +
"internal_id=:internal_id",
setAddonDescriptor: "UPDATE addon SET descriptor=:descriptor WHERE " +
"internal_id=:internal_id",
updateTargetApplications: "UPDATE targetApplication SET " +
"minVersion=:minVersion, maxVersion=:maxVersion " +
"WHERE addon_internal_id=:internal_id AND id=:id",
@ -5129,7 +5165,23 @@ var XPIDatabase = {
},
/**
* Synchronously pdates an add-on's active flag in the database.
* Synchronously sets the file descriptor for an add-on.
*
* @param aAddon
* The DBAddonInternal being updated
* @param aProperties
* A dictionary of properties to set
*/
setAddonDescriptor: function XPIDB_setAddonDescriptor(aAddon, aDescriptor) {
let stmt = this.getStatement("setAddonDescriptor");
stmt.params.internal_id = aAddon._internal_id;
stmt.params.descriptor = aDescriptor;
executeStatement(stmt);
},
/**
* Synchronously updates an add-on's active flag in the database.
*
* @param aAddon
* The DBAddonInternal to update

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

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>addon1@tests.mozilla.org</em:id>
<em:version>1.0</em:version>
<em:name>Test 1</em:name>
<em:updateURL>http://localhost:4444/data/test_bug655254.rdf</em:updateURL>
<em:targetApplication>
<Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>1</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
</RDF>

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

@ -3,8 +3,6 @@
const URI_BLOCKLIST_DIALOG = "chrome://mozapps/content/extensions/blocklist.xul";
Components.utils.import("resource://gre/modules/Services.jsm");
// This tests that the blocklist dialog still affects soft-blocked add-ons
// if the user clicks the "Restart Later" button. It also ensures that the
// "Cancel" button is correctly renamed (to "Restart Later").

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

@ -3,7 +3,6 @@
*/
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/NetUtil.jsm");
var pathParts = gTestPath.split("/");

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

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<RDF:Description about="urn:mozilla:extension:addon1@tests.mozilla.org">
<em:updates>
<RDF:Seq>
<RDF:li>
<RDF:Description>
<em:version>1</em:version>
<em:targetApplication>
<RDF:Description>
<em:id>xpcshell@tests.mozilla.org</em:id>
<em:minVersion>1</em:minVersion>
<em:maxVersion>2</em:maxVersion>
</RDF:Description>
</em:targetApplication>
</RDF:Description>
</RDF:li>
</RDF:Seq>
</em:updates>
</RDF:Description>
</RDF:RDF>

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

@ -0,0 +1,101 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// This verifies that moving an extension in the filesystem without any other
// change still keeps updated compatibility information
// The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
// Enable loading extensions from the user and system scopes
Services.prefs.setIntPref("extensions.enabledScopes",
AddonManager.SCOPE_PROFILE + AddonManager.SCOPE_USER);
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2", "1.9.2");
do_load_httpd_js();
var testserver;
var userDir = gProfD.clone();
userDir.append("extensions2");
userDir.append(gAppInfo.ID);
var dirProvider = {
getFile: function(aProp, aPersistent) {
aPersistent.value = false;
if (aProp == "XREUSysExt")
return userDir.parent;
return null;
},
QueryInterface: XPCOMUtils.generateQI([AM_Ci.nsIDirectoryServiceProvider,
AM_Ci.nsISupports])
};
Services.dirsvc.registerProvider(dirProvider);
var addon1 = {
id: "addon1@tests.mozilla.org",
version: "1.0",
name: "Test 1",
updateURL: "http://localhost:4444/data/test_bug655254.rdf",
targetApplications: [{
id: "xpcshell@tests.mozilla.org",
minVersion: "1",
maxVersion: "1"
}]
};
// Set up the profile
function run_test() {
do_test_pending();
// Create and configure the HTTP server.
testserver = new nsHttpServer();
testserver.registerDirectory("/data/", do_get_file("data"));
testserver.start(4444);
var time = Date.now();
var dir = writeInstallRDFForExtension(addon1, userDir);
setExtensionModifiedTime(dir, time);
startupManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_true(a1.appDisabled);
do_check_false(a1.isActive);
do_check_false(isExtensionInAddonsList(userDir, a1.id));
a1.findUpdates({
onUpdateFinished: function() {
restartManager();
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_false(a1.appDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(userDir, a1.id));
shutdownManager();
userDir.parent.moveTo(gProfD, "extensions3");
userDir = gProfD.clone();
userDir.append("extensions3");
userDir.append(gAppInfo.ID);
do_check_true(userDir.exists());
startupManager(false);
AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
do_check_neq(a1, null);
do_check_false(a1.appDisabled);
do_check_true(a1.isActive);
do_check_true(isExtensionInAddonsList(userDir, a1.id));
testserver.stop(do_test_finished);
});
});
}
}, AddonManager.UPDATE_WHEN_USER_REQUESTED);
});
}

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

@ -54,6 +54,7 @@ tail =
[test_bug616841.js]
[test_bug619730.js]
[test_bug620837.js]
[test_bug655254.js]
[test_cacheflush.js]
[test_checkcompatibility.js]
[test_corrupt.js]

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

@ -27,7 +27,6 @@ function extractChromeRoot(path) {
}
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
/**
* This is a test harness designed to handle responding to UI during the process

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

@ -85,6 +85,7 @@ SDK = $(SDK_PATH)$(PKG_BASENAME).sdk$(SDK_SUFFIX)
MAKE_PACKAGE = $(error What is a $(MOZ_PKG_FORMAT) package format?);
_ABS_DIST = $(call core_abspath,$(DIST))
JARLOG_DIR = $(call core_abspath,$(DEPTH)/jarlog/)
JARLOG_DIR_AB_CD = $(JARLOG_DIR)/$(AB_CD)
CREATE_FINAL_TAR = $(TAR) -c --owner=0 --group=0 --numeric-owner \
--mode="go-w" -f
@ -392,11 +393,11 @@ PACK_OMNIJAR = \
mv components.manifest components && \
zip -r9m omni.jar $(OMNIJAR_FILES) -x $(NON_OMNIJAR_FILES) && \
$(GENERATE_CACHE) && \
$(OPTIMIZE_JARS_CMD) --optimize $(JARLOG_DIR) ./ ./ && \
$(OPTIMIZE_JARS_CMD) --optimize $(JARLOG_DIR_AB_CD) ./ ./ && \
mv binary.manifest components && \
printf "manifest components/binary.manifest\n" > chrome.manifest
UNPACK_OMNIJAR = \
$(OPTIMIZE_JARS_CMD) --deoptimize $(JARLOG_DIR) ./ ./ && \
$(OPTIMIZE_JARS_CMD) --deoptimize $(JARLOG_DIR_AB_CD) ./ ./ && \
unzip -o omni.jar && \
rm -f components/binary.manifest && \
sed -e 's/^\#binary-component/binary-component/' components/components.manifest > components.manifest && \
@ -619,7 +620,7 @@ else
endif # DMG
endif # MOZ_PKG_MANIFEST
endif # UNIVERSAL_BINARY
$(OPTIMIZE_JARS_CMD) --optimize $(JARLOG_DIR) $(DIST)/bin/chrome $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/chrome
$(OPTIMIZE_JARS_CMD) --optimize $(JARLOG_DIR_AB_CD) $(DIST)/bin/chrome $(DIST)/$(STAGEPATH)$(MOZ_PKG_DIR)$(_BINPATH)/chrome
ifndef PKG_SKIP_STRIP
ifeq ($(OS_ARCH),OS2)
@echo "Stripping package directory..."

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

@ -69,9 +69,12 @@
margin-bottom: 0;
}
.webconsole-msg-icon {
.hud-msg-node {
list-style-image: url(chrome://global/skin/icons/webconsole.png);
-moz-image-region: rect(0, 1px, 0, 0);
}
.webconsole-msg-icon {
margin: 3px 4px;
width: 8px;
height: 8px;
@ -167,7 +170,7 @@
-moz-border-start: solid #000 6px;
}
.webconsole-msg-network.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-network.webconsole-msg-error {
-moz-image-region: rect(0, 16px, 8px, 8px);
}
@ -180,11 +183,11 @@
-moz-border-start: solid #00b6f0 6px;
}
.webconsole-msg-cssparser.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-cssparser.webconsole-msg-error {
-moz-image-region: rect(8px, 16px, 16px, 8px);
}
.webconsole-msg-cssparser.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-cssparser.webconsole-msg-warn {
-moz-image-region: rect(8px, 24px, 16px, 16px);
}
@ -197,11 +200,11 @@
-moz-border-start: solid #fb9500 6px;
}
.webconsole-msg-exception.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-exception.webconsole-msg-error {
-moz-image-region: rect(16px, 16px, 24px, 8px);
}
.webconsole-msg-exception.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-exception.webconsole-msg-warn {
-moz-image-region: rect(16px, 24px, 24px, 16px);
}
@ -214,16 +217,16 @@
-moz-border-start: solid #cbcbcb 6px;
}
.webconsole-msg-console.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon,
.webconsole-msg-output.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-error,
.webconsole-msg-output.webconsole-msg-error {
-moz-image-region: rect(24px, 16px, 32px, 8px);
}
.webconsole-msg-console.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-warn {
-moz-image-region: rect(24px, 24px, 32px, 16px);
}
.webconsole-msg-console.webconsole-msg-info > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-info {
-moz-image-region: rect(24px, 32px, 32px, 24px);
}
@ -233,11 +236,11 @@
border-left: solid #808080 6px;
}
.webconsole-msg-input > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-input {
-moz-image-region: rect(24px, 40px, 32px, 32px);
}
.webconsole-msg-output > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-output {
-moz-image-region: rect(24px, 48px, 32px, 40px);
}

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

@ -72,9 +72,12 @@
margin-bottom: 0;
}
.webconsole-msg-icon {
.hud-msg-node {
list-style-image: url(chrome://global/skin/icons/webconsole.png);
-moz-image-region: rect(0, 1px, 0, 0);
}
.webconsole-msg-icon {
margin: 3px 4px;
width: 8px;
height: 8px;
@ -225,7 +228,7 @@
-moz-border-start: solid #000 6px;
}
.webconsole-msg-network.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-network.webconsole-msg-error {
-moz-image-region: rect(0, 16px, 8px, 8px);
}
@ -238,11 +241,11 @@
-moz-border-start: solid #00b6f0 6px;
}
.webconsole-msg-cssparser.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-cssparser.webconsole-msg-error {
-moz-image-region: rect(8px, 16px, 16px, 8px);
}
.webconsole-msg-cssparser.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-cssparser.webconsole-msg-warn {
-moz-image-region: rect(8px, 24px, 16px, 16px);
}
@ -255,11 +258,11 @@
-moz-border-start: solid #fb9500 6px;
}
.webconsole-msg-exception.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-exception.webconsole-msg-error {
-moz-image-region: rect(16px, 16px, 24px, 8px);
}
.webconsole-msg-exception.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-exception.webconsole-msg-warn {
-moz-image-region: rect(16px, 24px, 24px, 16px);
}
@ -272,16 +275,16 @@
-moz-border-start: solid #cbcbcb 6px;
}
.webconsole-msg-console.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon,
.webconsole-msg-output.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-error,
.webconsole-msg-output.webconsole-msg-error {
-moz-image-region: rect(24px, 16px, 32px, 8px);
}
.webconsole-msg-console.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-warn {
-moz-image-region: rect(24px, 24px, 32px, 16px);
}
.webconsole-msg-console.webconsole-msg-info > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-info {
-moz-image-region: rect(24px, 32px, 32px, 24px);
}
@ -291,11 +294,11 @@
border-left: solid #808080 6px;
}
.webconsole-msg-input.webconsole-msg-log > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-input {
-moz-image-region: rect(24px, 40px, 32px, 32px);
}
.webconsole-msg-output.webconsole-msg-log > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-output {
-moz-image-region: rect(24px, 48px, 32px, 40px);
}

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

@ -68,9 +68,12 @@
margin-bottom: 0;
}
.webconsole-msg-icon {
.hud-msg-node {
list-style-image: url(chrome://global/skin/icons/webconsole.png);
-moz-image-region: rect(0, 1px, 0, 0);
}
.webconsole-msg-icon {
margin: 3px 4px;
width: 8px;
height: 8px;
@ -165,7 +168,7 @@
-moz-border-start: solid #000 6px;
}
.webconsole-msg-network.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-network.webconsole-msg-error {
-moz-image-region: rect(0, 16px, 8px, 8px);
}
@ -178,11 +181,11 @@
-moz-border-start: solid #00b6f0 6px;
}
.webconsole-msg-cssparser.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-cssparser.webconsole-msg-error {
-moz-image-region: rect(8px, 16px, 16px, 8px);
}
.webconsole-msg-cssparser.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-cssparser.webconsole-msg-warn {
-moz-image-region: rect(8px, 24px, 16px, 16px);
}
@ -195,11 +198,11 @@
-moz-border-start: solid #fb9500 6px;
}
.webconsole-msg-exception.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-exception.webconsole-msg-error {
-moz-image-region: rect(16px, 16px, 24px, 8px);
}
.webconsole-msg-exception.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-exception.webconsole-msg-warn {
-moz-image-region: rect(16px, 24px, 24px, 16px);
}
@ -212,16 +215,16 @@
-moz-border-start: solid #cbcbcb 6px;
}
.webconsole-msg-console.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon,
.webconsole-msg-output.webconsole-msg-error > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-error,
.webconsole-msg-output.webconsole-msg-error {
-moz-image-region: rect(24px, 16px, 32px, 8px);
}
.webconsole-msg-console.webconsole-msg-warn > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-warn {
-moz-image-region: rect(24px, 24px, 32px, 16px);
}
.webconsole-msg-console.webconsole-msg-info > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-console.webconsole-msg-info {
-moz-image-region: rect(24px, 32px, 32px, 24px);
}
@ -231,11 +234,11 @@
border-left: solid #808080 6px;
}
.webconsole-msg-input > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-input {
-moz-image-region: rect(24px, 40px, 32px, 32px);
}
.webconsole-msg-output > .webconsole-msg-icon-container > .webconsole-msg-icon {
.webconsole-msg-output {
-moz-image-region: rect(24px, 48px, 32px, 40px);
}

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

@ -66,6 +66,52 @@
#import <Cocoa/Cocoa.h>
#import <AppKit/NSOpenGL.h>
// The header files QuickdrawAPI.h and QDOffscreen.h are missing on OS X 10.7
// and up (though the QuickDraw APIs defined in them are still present) -- so
// we need to supply the relevant parts of their contents here. It's likely
// that Apple will eventually remove the APIs themselves (probably in OS X
// 10.8), so we need to make them weak imports, and test for their presence
// before using them.
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(__QUICKDRAWAPI__)
extern void SetPort(GrafPtr port)
__attribute__((weak_import));
extern void SetOrigin(short h, short v)
__attribute__((weak_import));
extern RgnHandle NewRgn(void)
__attribute__((weak_import));
extern void DisposeRgn(RgnHandle rgn)
__attribute__((weak_import));
extern void RectRgn(RgnHandle rgn, const Rect * r)
__attribute__((weak_import));
extern GDHandle GetMainDevice(void)
__attribute__((weak_import));
extern Boolean IsPortOffscreen(CGrafPtr port)
__attribute__((weak_import));
extern void SetPortVisibleRegion(CGrafPtr port, RgnHandle visRgn)
__attribute__((weak_import));
extern void SetPortClipRegion(CGrafPtr port, RgnHandle clipRgn)
__attribute__((weak_import));
extern CGrafPtr GetQDGlobalsThePort(void)
__attribute__((weak_import));
#endif /* __QUICKDRAWAPI__ */
#if !defined(__QDOFFSCREEN__)
extern void GetGWorld(CGrafPtr * port, GDHandle * gdh)
__attribute__((weak_import));
extern void SetGWorld(CGrafPtr port, GDHandle gdh)
__attribute__((weak_import));
#endif /* __QDOFFSCREEN__ */
#ifdef __cplusplus
}
#endif
class gfxASurface;
class nsChildView;
class nsCocoaWindow;

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

@ -1229,6 +1229,12 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
// visible region to be the entire port every time. It is necessary to set up our
// window's port even for CoreGraphics plugins, because they may still use Carbon
// internally (see bug #420527 for details).
//
// Don't use this code if any of the QuickDraw APIs it currently requires are
// missing (as they probably will be on OS X 10.8 and up).
if (::NewRgn && ::GetQDGlobalsThePort && ::GetGWorld && ::SetGWorld &&
::IsPortOffscreen && ::GetMainDevice && ::SetOrigin && ::RectRgn &&
::SetPortVisibleRegion && ::SetPortClipRegion && ::DisposeRgn) {
CGrafPtr port = ::GetWindowPort(WindowRef([window windowRef]));
if (isQDPlugin) {
port = mPluginQDPort.port;
@ -1236,7 +1242,7 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
RgnHandle pluginRegion = ::NewRgn();
if (pluginRegion) {
PRBool portChanged = (port != CGrafPtr(GetQDGlobalsThePort()));
PRBool portChanged = (port != CGrafPtr(::GetQDGlobalsThePort()));
CGrafPtr oldPort;
GDHandle oldDevice;
@ -1265,9 +1271,13 @@ NS_IMETHODIMP nsChildView::StartDrawPlugin()
::DisposeRgn(pluginRegion);
if (portChanged)
if (portChanged) {
::SetGWorld(oldPort, oldDevice);
}
}
} else {
NS_WARNING("Cannot set plugin's visible region -- required QuickDraw APIs are missing!");
}
#endif
mPluginDrawing = PR_TRUE;
@ -2332,7 +2342,11 @@ NSEvent* gLastDragMouseDownEvent = nil;
#ifndef NP_NO_QUICKDRAW
// This sets the current port to _savePort.
// todo: Only do if a Quickdraw plugin is present in the hierarchy!
// Check if ::SetPort() is available -- it probably won't be on
// OS X 10.8 and up.
if (::SetPort) {
::SetPort(NULL);
}
#endif
NS_OBJC_END_TRY_ABORT_BLOCK;
@ -2642,7 +2656,10 @@ NSEvent* gLastDragMouseDownEvent = nil;
// Set the current GrafPort to a "safe" port before calling [NSQuickDrawView lockFocus],
// so that the NSQuickDrawView stashes a pointer to this known-good port internally.
// It will set the port back to this port on destruction.
// Check if ::SetPort() is available -- it probably won't be on OS X 10.8 and up.
if (::SetPort) {
::SetPort(NULL); // todo: only do if a Quickdraw plugin is present in the hierarchy!
}
#endif
[super lockFocus];

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

@ -469,9 +469,10 @@ struct PtrInfo
PRUint32 mColor : 2;
PRUint32 mInternalRefs : 30;
PRUint32 mRefCount;
EdgePool::Iterator mFirstChild; // first
EdgePool::Iterator mLastChild; // one after last
private:
EdgePool::Iterator mFirstChild;
public:
#ifdef DEBUG_CC
size_t mBytes;
char *mName;
@ -498,8 +499,7 @@ struct PtrInfo
mColor(grey),
mInternalRefs(0),
mRefCount(0),
mFirstChild(),
mLastChild()
mFirstChild()
#ifdef DEBUG_CC
, mBytes(0),
mName(nsnull),
@ -523,6 +523,28 @@ struct PtrInfo
PtrInfo() {
NS_NOTREACHED("should never be called");
}
EdgePool::Iterator FirstChild()
{
return mFirstChild;
}
// this PtrInfo must be part of a NodePool
EdgePool::Iterator LastChild()
{
return (this + 1)->mFirstChild;
}
void SetFirstChild(EdgePool::Iterator aFirstChild)
{
mFirstChild = aFirstChild;
}
// this PtrInfo must be part of a NodePool
void SetLastChild(EdgePool::Iterator aLastChild)
{
(this + 1)->mFirstChild = aLastChild;
}
};
/**
@ -542,7 +564,7 @@ private:
~Block() { NS_NOTREACHED("should never be called"); }
Block* mNext;
PtrInfo mEntries[BlockSize];
PtrInfo mEntries[BlockSize + 1]; // +1 to store last child of last node
};
public:
@ -632,6 +654,11 @@ public:
return mNext == mLast;
}
PRBool AtBlockEnd() const
{
return mNext == mBlockEnd;
}
PtrInfo* GetNext()
{
NS_ASSERTION(!IsDone(), "calling GetNext when done");
@ -1169,7 +1196,8 @@ Fault(const char *msg, PtrInfo *pi)
NodePool::Enumerator queue(sCollector->mGraph.mNodes);
while (!queue.IsDone()) {
PtrInfo *ppi = queue.GetNext();
for (EdgePool::Iterator e = ppi->mFirstChild, e_end = ppi->mLastChild;
for (EdgePool::Iterator e = ppi->FirstChild(),
e_end = ppi->LastChild();
e != e_end; ++e) {
if (*e == pi) {
printf(" %p %s\n", ppi->mPointer, ppi->mName);
@ -1264,8 +1292,8 @@ GraphWalker<Visitor>::DoWalk(nsDeque &aQueue)
if (mVisitor.ShouldVisitNode(pi)) {
mVisitor.VisitNode(pi);
for (EdgePool::Iterator child = pi->mFirstChild,
child_end = pi->mLastChild;
for (EdgePool::Iterator child = pi->FirstChild(),
child_end = pi->LastChild();
child != child_end; ++child) {
aQueue.Push(*child);
}
@ -1429,6 +1457,7 @@ public:
}
#endif
void Traverse(PtrInfo* aPtrInfo);
void SetLastChild();
// nsCycleCollectionTraversalCallback methods.
NS_IMETHOD_(void) NoteXPCOMRoot(nsISupports *root);
@ -1519,14 +1548,18 @@ GCGraphBuilder::Traverse(PtrInfo* aPtrInfo)
}
#endif
mCurrPi->mFirstChild = mEdgeBuilder.Mark();
mCurrPi->SetFirstChild(mEdgeBuilder.Mark());
nsresult rv = aPtrInfo->mParticipant->Traverse(aPtrInfo->mPointer, *this);
if (NS_FAILED(rv)) {
Fault("script pointer traversal failed", aPtrInfo);
}
}
mCurrPi->mLastChild = mEdgeBuilder.Mark();
void
GCGraphBuilder::SetLastChild()
{
mCurrPi->SetLastChild(mEdgeBuilder.Mark());
}
NS_IMETHODIMP_(void)
@ -1771,7 +1804,11 @@ nsCycleCollector::MarkRoots(GCGraphBuilder &builder)
while (!queue.IsDone()) {
PtrInfo *pi = queue.GetNext();
builder.Traverse(pi);
if (queue.AtBlockEnd())
builder.SetLastChild();
}
if (mGraph.mRootCount > 0)
builder.SetLastChild();
}
@ -3027,8 +3064,8 @@ nsCycleCollector::ExplainLiveExpectedGarbage()
PtrInfo *pi = (PtrInfo*)stack.Peek();
if (pi->mSCCIndex == INDEX_UNREACHED) {
pi->mSCCIndex = INDEX_TRAVERSING;
for (EdgePool::Iterator child = pi->mFirstChild,
child_end = pi->mLastChild;
for (EdgePool::Iterator child = pi->FirstChild(),
child_end = pi->LastChild();
child != child_end; ++child) {
stack.Push(*child);
}
@ -3071,8 +3108,8 @@ nsCycleCollector::ExplainLiveExpectedGarbage()
PtrInfo *pi = queue.GetNext();
if (pi->mColor != white)
continue;
for (EdgePool::Iterator child = pi->mFirstChild,
child_end = pi->mLastChild;
for (EdgePool::Iterator child = pi->FirstChild(),
child_end = pi->LastChild();
child != child_end; ++child) {
if ((*child)->mSCCIndex != pi->mSCCIndex) {
GraphWalker<SetNonRootGreyVisitor>(SetNonRootGreyVisitor()).Walk(*child);
@ -3134,7 +3171,7 @@ nsCycleCollector::CreateReversedEdges()
NodePool::Enumerator countQueue(mGraph.mNodes);
while (!countQueue.IsDone()) {
PtrInfo *pi = countQueue.GetNext();
for (EdgePool::Iterator e = pi->mFirstChild, e_end = pi->mLastChild;
for (EdgePool::Iterator e = pi->FirstChild(), e_end = pi->LastChild();
e != e_end; ++e, ++edgeCount) {
}
}
@ -3152,7 +3189,7 @@ nsCycleCollector::CreateReversedEdges()
while (!buildQueue.IsDone()) {
PtrInfo *pi = buildQueue.GetNext();
PRInt32 i = 0;
for (EdgePool::Iterator e = pi->mFirstChild, e_end = pi->mLastChild;
for (EdgePool::Iterator e = pi->FirstChild(), e_end = pi->LastChild();
e != e_end; ++e) {
current->mTarget = pi;
current->mEdgeName = &pi->mEdgeNames[i];