Merge cedar with mozilla-central

This commit is contained in:
Boris Zbarsky 2011-05-04 13:58:26 -04:00
Родитель 8f22855b2a 2b85ff7562
Коммит 7f3fe8f1c2
303 изменённых файлов: 24788 добавлений и 6613 удалений

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

@ -38,11 +38,16 @@
-moz-border-image: url(chrome://testpilot-os/skin/notification-tail-up.png) 26 56 22 18 / 26px 56px 22px 18px round stretch;
}
/* tail-down uses the old styling; it doesn't look as good as the new styling,
but the new styling doesn't work on 3.6.
TODO: If someone is using 3.7.* or 4.* but is NOT on the beta channel and
installed Test Pilot from AMO, they should get the new styling, similar
to .tail-up! */
.tail-down {
-moz-border-image: url(chrome://testpilot-os/skin/notification-tail-down.png) 26 56 22 18 / 26px 56px 22px 18px round stretch;
-moz-border-image: url(chrome://testpilot/skin/notification-tail-down.png) 26 50 22 18 / 26px 50px 22px 18px repeat;
color: white;
}
.pilot-notification-popup-container {
-moz-appearance: none;
margin-right: -42px;
@ -172,7 +177,7 @@ image.study-result {
color: white;
font-weight: bold;
padding: 2px;
border-radius: 10000px;
-moz-border-radius: 100%;
margin-right: 25px;
margin-bottom: 13px;
}

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

@ -128,6 +128,7 @@ var TestPilotMenuUtils;
let menuPopup = document.getElementById("pilot-menu-popup");
let menuButton = document.getElementById(attachPointId);
// TODO failing here with "menuPopup is null" for Tracy
if (menuPopup.parentNode != menuButton)
menuButton.appendChild(menuPopup);

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

@ -20,7 +20,20 @@
function reloadAllExperiments() {
Components.utils.import("resource://testpilot/modules/setup.js");
TestPilotSetup.reloadRemoteExperiments();
TestPilotSetup.reloadRemoteExperiments(function(success) {
let errors = TestPilotSetup._remoteExperimentLoader.getLoadErrors();
let str;
if (errors.length > 0) {
str = "<ul>";
for each (let errStr in errors) {
str += "<li>" + errStr + "</li>";
}
str += "</ul>";
} else {
str = "All experiments reloaded, no errors.";
}
document.getElementById("debug").innerHTML = str;
});
}
function runUnitTests() {
@ -81,8 +94,7 @@
var path = codeStore.resolveModule(null, filename);
var textArea = document.getElementById("experiment-code-area");
codeStore.setLocalOverride(path, textArea.value);
reloadAllExperiments(function(success) {
document.getElementById("debug").innerHTML = "Success? " + success;});
reloadAllExperiments();
}
function showMetaData() {

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

@ -405,16 +405,10 @@ var stringBundle;
function onStatusPageLoad() {
setStrings(PAGE_TYPE_STATUS);
/* If an experiment ID (eid) is provided in the url params, show status
* for that experiment. If not, show the main menu with status for all
* installed experiments. */
let eidString = getUrlParam("eid");
if (eidString == "") {
showStatusMenuPage();
} else {
/* An experiment ID (eid) must be provided in the url params. Show status
* for that experiment.*/
loadExperimentPage();
}
}
function setStrings(pageType) {
stringBundle =

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

@ -102,16 +102,16 @@ src: url('chrome://testpilot/skin/fonts/DroidSans-Bold.ttf') format('truetype');
font-size: 16px;
padding: 8px 12px;
color: rgba(0, 0, 0, 0.8);
border-radius: 0.5em;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
box-shadow:
-moz-box-shadow:
inset rgba(0, 0, 0, 0.2) 0 1px 1px,
inset rgba(255, 255, 255, 1) 0 3px 1px,
inset rgba(255, 255, 255, 0.3) 0 16px 0px,
inset rgba(0, 0, 0, 0.2) 0 -1px 1px,
inset rgba(0, 0, 0, 0.1) 0 -2px 1px,
rgba(255, 255, 255, 1) 0 1px,
rgba(133, 153, 166, 0.3) 0px 1px 8.5px;
rgba(133, 153, 166, 0.3) 0px 1px 12px;
background-color: #e7eaec;
//display: inline;
}
@ -122,16 +122,16 @@ src: url('chrome://testpilot/skin/fonts/DroidSans-Bold.ttf') format('truetype');
padding: 8px 12px;
width: 240px;
color: rgba(0, 0, 0, 0.8);
border-radius: 0.5em;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
box-shadow:
-moz-box-shadow:
inset rgba(0, 0, 0, 0.2) 0 1px 1px,
inset rgba(255, 255, 255, 1) 0 3px 1px,
inset rgba(255, 255, 255, 0.3) 0 16px 0px,
inset rgba(0, 0, 0, 0.2) 0 -1px 1px,
inset rgba(0, 0, 0, 0.1) 0 -2px 1px,
rgba(255, 255, 255, 1) 0 1px,
rgba(133, 153, 166, 0.3) 0px 1px 8.5px;
rgba(133, 153, 166, 0.3) 0px 1px 12px;
background-color: #e7eaec;
//display: inline;
}
@ -143,13 +143,13 @@ src: url('chrome://testpilot/skin/fonts/DroidSans-Bold.ttf') format('truetype');
padding: 8px 24px;
margin: 24px auto;
color: rgba(0, 0, 0, 0.8);
border-radius: 0.5em;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/callout.png') no-repeat top center;
box-shadow:
inset rgba(185, 221, 234, 0.2) 0 -10px 8.5px,
-moz-box-shadow:
inset rgba(185, 221, 234, 0.2) 0 -10px 12px,
inset rgba(185, 221, 234, 1) 0 0px 1px,
inset rgba(255, 255, 255, 0.2) 0 10px 8.5px;
inset rgba(255, 255, 255, 0.2) 0 10px 12px;
//display: inline;
}
@ -161,13 +161,13 @@ src: url('chrome://testpilot/skin/fonts/DroidSans-Bold.ttf') format('truetype');
padding: 8px 24px;
margin: 8px auto;
color: rgba(0, 0, 0, 0.8);
border-radius: 0.5em;
-moz-border-radius: 0.5em;
-webkit-border-radius: 0.5em;
background: rgba(220, 240, 247, 0.8) url('chrome://testpilot/skin/callout.png') no-repeat top center;
box-shadow:
inset rgba(185, 221, 234, 0.2) 0 -10px 8.5px,
-moz-box-shadow:
inset rgba(185, 221, 234, 0.2) 0 -10px 12px,
inset rgba(185, 221, 234, 1) 0 0px 1px,
inset rgba(255, 255, 255, 0.2) 0 10px 8.5px;
inset rgba(255, 255, 255, 0.2) 0 10px 12px;
//display: inline;
}
@ -197,7 +197,7 @@ src: url('chrome://testpilot/skin/fonts/DroidSans-Bold.ttf') format('truetype');
padding: 4px 40px;
width: 800px;
text-align: left;
border-radius: 0.25em;
-moz-border-radius: 0.25em;
-webkit-border-radius: 0.25em;
border-top: 1px solid #adb6ba;
border-left: 1px solid #adb6ba;
@ -223,8 +223,8 @@ src: url('chrome://testpilot/skin/fonts/DroidSans-Bold.ttf') format('truetype');
font-size: 14px;
text-shadow: 1px 1px 1px rgba(173, 182, 186, 1);
background-color: rgba(173, 182, 186, 0.3);
box-shadow:
inset rgba(0, 0, 0, 0.2) 0 -10px 8.5px;
-moz-box-shadow:
inset rgba(0, 0, 0, 0.2) 0 -10px 12px;
padding: 9px 8px 8px 8px;
}

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

@ -28,9 +28,7 @@
<div class="home_callout">
<img class="homeIcon"
src="chrome://testpilot/skin/images/home_comments.png">
<a id="comments-and-discussions-link"
onclick="
openLink('http://groups.google.com/group/mozilla-labs-testpilot');">
<a id="comments-and-discussions-link" onclick="openLink('http://groups.google.com/group/mozilla-labs-testpilot');">
</a>
</div><br>
<div class="home_callout">

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

@ -24,6 +24,11 @@
<span id="please-take-text"></span>&nbsp;
<a class="function-link" id="background-survey-text"
onclick="TestPilotWelcomePage.openPilotSurvey();"></a>!</p>
<p class="embiggened">
<a class="function-link" id="privacy-policy-link"
style="text-decoration: underline"
href="http://www.mozilla.com/en-US/privacy-policy.html"></a>
</p>
<p class="embiggened">
<a class="function-link" id="open-studies-window-link"
onclick="TestPilotWindowUtils.openAllStudiesWindow();"></a>
@ -45,8 +50,6 @@
</div>
<div id="footer">
<img class="mozLogo" src="chrome://testpilot/skin/mozilla-logo.png">
<a href="http://www.mozilla.com/en-US/privacy-policy.html"
id="privacy-policy-link"></a> &nbsp; &nbsp;
<a href="http://www.mozilla.com/en-US/about/legal.html"
id="legal-notices-link"></a>
</div>

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

@ -4,7 +4,7 @@
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
<Description about="urn:mozilla:install-manifest">
<em:id>testpilot@labs.mozilla.com</em:id>
<em:version>1.0.9</em:version>
<em:version>1.1.1</em:version>
<em:type>2</em:type>
<!-- Target Application this extension can install into,

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

@ -75,9 +75,9 @@ DbUtils.createTable = function createTable(connection, tableName, schema){
logger.debug("File is " + file + "\n");
try{
if(!connection.tableExists(tableName)){
// TODO why don't we use connection.createTable here??
connection.executeSimpleSQL(schema);
}
else{
} else{
logger.debug("database table: " + tableName + " already exists\n");
}
}

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

@ -54,6 +54,8 @@ const TYPE_INT_32 = 0;
const TYPE_DOUBLE = 1;
const TYPE_STRING = 2;
const EXCEPTION_TABLE_NAME = "exceptions";
function ExperimentDataStore(fileName, tableName, columns) {
this._init(fileName, tableName, columns);
}
@ -87,9 +89,17 @@ ExperimentDataStore.prototype = {
+ schemaClauses.join(", ") + ");";
// CreateTable creates the table only if it does not already exist:
try {
this._connection = DbUtils.createTable(this._connection,
this._tableName,
schema);
DbUtils.createTable(this._connection, this._tableName, schema);
} catch(e) {
logger.warn("Error in createTable: " + e + "\n");
}
// Create a second table for storing exceptions for this study. It has a fixed
// name and schema:
let exceptionTableSchema = "CREATE TABLE " + EXCEPTION_TABLE_NAME +
" (time INTEGER, trace TEXT);";
try {
DbUtils.createTable(this._connection, "exceptions", exceptionTableSchema);
} catch(e) {
logger.warn("Error in createTable: " + e + "\n");
}
@ -150,7 +160,20 @@ ExperimentDataStore.prototype = {
insStmt.finalize();
},
logException: function EDS_logException(exception) {
let insertSql = "INSERT INTO " + EXCEPTION_TABLE_NAME + " VALUES (?1, ?2);";
let insStmt = this._createStatement(insertSql);
// Even though the SQL says ?1 and ?2, the param indices count from 0.
insStmt.params[0] = Date.now();
let txt = exception.message ? exception.message : exception.toString();
insStmt.params[1] = txt;
insStmt.executeAsync();
insStmt.finalize(); // TODO Is this the right thing to do when calling asynchronously?
},
getJSONRows: function EDS_getJSONRows(callback) {
// TODO why do both this function and getAllDataAsJSON exist when they both do
// the same thing?
let selectSql = "SELECT * FROM " + this._tableName;
let selStmt = this._createStatement(selectSql);
let records = [];
@ -255,33 +278,61 @@ ExperimentDataStore.prototype = {
selStmt.finalize();
},
wipeAllData: function EDS_wipeAllData(callback) {
let logger = Log4Moz.repository.getLogger("TestPilot.Database");
logger.trace("ExperimentDataStore.wipeAllData called.\n");
let wipeSql = "DELETE FROM " + this._tableName;
let wipeStmt = this._createStatement(wipeSql);
wipeStmt.executeAsync({
getExceptionsAsJson: function(callback) {
let selectSql = "SELECT * FROM " + EXCEPTION_TABLE_NAME;
let selStmt = this._createStatement(selectSql);
let records = [];
let self = this;
selStmt.executeAsync({
handleResult: function(aResultSet) {
},
handleError: function(aError) {
if (callback) {
callback(false);
for (let row = aResultSet.getNextRow(); row;
row = aResultSet.getNextRow()) {
records.push({ time: row.getDouble(0),
exception: row.getString(1)});
}
},
handleError: function(aError) {
callback(records);
},
handleCompletion: function(aReason) {
callback(records);
}
});
},
wipeAllData: function EDS_wipeAllData(callback) {
// Wipe both the data table and the exception table; call callback when both
// are wiped.
let logger = Log4Moz.repository.getLogger("TestPilot.Database");
logger.trace("ExperimentDataStore.wipeAllData called.\n");
let wipeDataStmt = this._createStatement("DELETE FROM " + this._tableName);
let wipeExcpStmt = this._createStatement("DELETE FROM " + EXCEPTION_TABLE_NAME);
let numberWiped = 0;
let onComplete = function() {
numberWiped ++;
if (numberWiped == 2 && callback) {
callback();
}
};
wipeDataStmt.executeAsync({
handleResult: function(aResultSet) {},
handleError: function(aError) { onComplete(); },
handleCompletion: function(aReason) {
if (aReason == Ci.mozIStorageStatementCallback.REASON_FINISHED) {
logger.trace("ExperimentDataStore.wipeAllData complete.\n");
if (callback) {
callback(true);
}
} else {
if (callback) {
callback(false);
}
}
onComplete();
}
});
wipeStmt.finalize();
wipeExcpStmt.executeAsync({
handleResult: function(aResultSet) {},
handleError: function(aError) { onComplete(); },
handleCompletion: function(aReason) { onComplete(); }
});
wipeDataStmt.finalize();
wipeExcpStmt.finalize();
},
nukeTable: function EDS_nukeTable() {

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

@ -219,6 +219,7 @@ exports.RemoteExperimentLoader.prototype = {
this._studyResults = [];
this._legacyStudies = [];
this._experimentFileNames = [];
this._loadErrors = [];
},
getLocalizedStudyInfo: function(studiesIndex) {
@ -504,12 +505,20 @@ exports.RemoteExperimentLoader.prototype = {
* the module name and value = the module object. */
this._logger.trace("GetExperiments called.");
let remoteExperiments = {};
this._loadErrors = [];
for each (filename in this._experimentFileNames) {
this._logger.debug("GetExperiments is loading " + filename);
try {
remoteExperiments[filename] = this._loader.require(filename);
this._logger.info("Loaded " + filename + " OK.");
} catch(e) {
/* Turn the load-time errors into strings and store them, so we can display
* them on a debug page or include them with a data upload! (Don't store
* exception objects directly as that causes garbage collector problems-
* aka bug 646122) */
let errStr = e.name + " on line " + e.lineNumber + " of file " +
e.fileName + ": " + e.message;
this._loadErrors.push(errStr);
this._logger.warn("Error loading " + filename);
this._logger.warn(e);
}
@ -523,6 +532,10 @@ exports.RemoteExperimentLoader.prototype = {
getLegacyStudies: function() {
return this._legacyStudies;
},
getLoadErrors: function() {
return this._loadErrors;
}
};

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

@ -259,13 +259,13 @@ let TestPilotSetup = {
if (currVersion != self.version) {
if(!self._isBetaChannel()) {
// Don't show first run page in ffx4 beta version.
self._prefs.setValue(VERSION_PREF, self.version);
let browser = self._getFrontBrowserWindow().getBrowser();
let url = self._prefs.getValue(FIRST_RUN_PREF, "");
let tab = browser.addTab(url);
browser.selectedTab = tab;
}
// Don't show first run page in ffx4 beta version.
}
// Install tasks. (This requires knowing the version, so it is

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

@ -487,29 +487,44 @@ TestPilotExperiment.prototype = {
onNewWindow: function TestPilotExperiment_onNewWindow(window) {
this._logger.trace("Experiment.onNewWindow called.");
if (this.experimentIsRunning()) {
try {
this._handlers.onNewWindow(window);
} catch(e) {
this._dataStore.logException("onNewWindow: " + e);
}
}
},
onWindowClosed: function TestPilotExperiment_onWindowClosed(window) {
this._logger.trace("Experiment.onWindowClosed called.");
if (this.experimentIsRunning()) {
try {
this._handlers.onWindowClosed(window);
} catch(e) {
this._dataStore.logException("onWindowClosed: " + e);
}
}
},
onAppStartup: function TestPilotExperiment_onAppStartup() {
this._logger.trace("Experiment.onAppStartup called.");
if (this.experimentIsRunning()) {
try {
this._handlers.onAppStartup();
} catch(e) {
this._dataStore.logException("onAppStartup: " + e);
}
}
},
onAppShutdown: function TestPilotExperiment_onAppShutdown() {
this._logger.trace("Experiment.onAppShutdown called.");
// TODO the caller for this is not yet implemented
if (this.experimentIsRunning()) {
try {
this._handlers.onAppShutdown();
} catch(e) {
this._dataStore.logException("onAppShutdown: " + e);
}
}
},
@ -518,7 +533,11 @@ TestPilotExperiment.prototype = {
// Make sure not to call this if it's already been called:
if (this.experimentIsRunning() && !this._startedUpHandlers) {
this._logger.trace(" ... starting up handlers!");
try {
this._handlers.onExperimentStartup(this._dataStore);
} catch(e) {
this._dataStore.logException("onExperimentStartup: " + e);
}
this._startedUpHandlers = true;
}
},
@ -526,7 +545,11 @@ TestPilotExperiment.prototype = {
onExperimentShutdown: function TestPilotExperiment_onShutdown() {
this._logger.trace("Experiment.onExperimentShutdown called.");
if (this.experimentIsRunning() && this._startedUpHandlers) {
try {
this._handlers.onExperimentShutdown();
} catch(e) {
this._dataStore.logException("onExperimentShutdown: " + e);
}
this._startedUpHandlers = false;
}
},
@ -534,21 +557,33 @@ TestPilotExperiment.prototype = {
doExperimentCleanup: function TestPilotExperiment_doExperimentCleanup() {
if (this._handlers.doExperimentCleanup) {
this._logger.trace("Doing experiment cleanup.");
try {
this._handlers.doExperimentCleanup();
} catch(e) {
this._dataStore.logException("doExperimentCleanup: " + e);
}
}
},
onEnterPrivateBrowsing: function TestPilotExperiment_onEnterPrivate() {
this._logger.trace("Task is entering private browsing.");
if (this.experimentIsRunning()) {
try {
this._handlers.onEnterPrivateBrowsing();
} catch(e) {
this._dataStore.logException("onEnterPrivateBrowsing: " + e);
}
}
},
onExitPrivateBrowsing: function TestPilotExperiment_onExitPrivate() {
this._logger.trace("Task is exiting private browsing.");
if (this.experimentIsRunning()) {
try {
this._handlers.onExitPrivateBrowsing();
} catch(e) {
this._dataStore.logException("onExitPrivateBrowsing: " + e);
}
}
},
@ -779,9 +814,12 @@ TestPilotExperiment.prototype = {
}
self._dataStore.getJSONRows(function(rows) {
json.events = rows;
self._dataStore.getExceptionsAsJson(function(errs) {
json.exceptions = errs;
callback( JSON.stringify(json) );
});
});
});
},
// Note: When we have multiple experiments running, the uploads

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

@ -299,6 +299,8 @@ pref("browser.urlbar.match.url", "@");
// 2 = only bookmarks, 3 = visited bookmarks, 1+16 = history matching in the url
pref("browser.urlbar.default.behavior", 0);
pref("browser.urlbar.formatting.enabled", true);
// Number of milliseconds to wait for the http headers (and thus
// the Content-Disposition filename) before giving up and falling back to
// picking a filename without that info in hand so that the user sees some

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

@ -597,6 +597,8 @@ var gChannelSelector = {
selectChannel: function(aSelectedItem) {
document.getElementById("channelDescriptionDeck").selectedPanel =
document.getElementById(aSelectedItem.value + "Description");
document.getElementById("channelMenulist").setAttribute("aria-describedby",
aSelectedItem.value + "Description");
},
cancel: function() {

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

@ -67,6 +67,7 @@
#else
title="&aboutDialog.title;"
#endif
aria-describedby="version distribution distributionId"
>
<script type="application/javascript" src="chrome://browser/content/aboutDialog.js"/>
@ -82,7 +83,7 @@
<!-- Make sure the selectedIndex attribute is always set so that the CSS
selectors for transitions work -->
<deck id="contentDeck" selectedIndex="0">
<vbox id="detailsBox">
<vbox id="detailsBox" aria-describedby="communityDesc contributeDesc">
<vbox id="updateBox">
#ifdef MOZ_UPDATER
<deck id="updateDeck" orient="vertical">
@ -119,10 +120,10 @@
<description class="text-blurb" id="currentChannelText" hidden="true">
&channel.description.start;<label id="currentChannel"/>&channel.description.end;<label id="channelChangeLink" class="text-link" onclick="gChannelSelector.show();">&channel.change;</label>
</description>
<description class="text-blurb">
<description class="text-blurb" id="communityDesc">
&community.start2;<label class="text-link" href="http://www.mozilla.org/">&community.mozillaLink;</label>&community.middle2;<label class="text-link" href="about:credits">&community.creditsLink;</label>&community.end2;
</description>
<description class="text-blurb">
<description class="text-blurb" id="contributeDesc">
&contribute.start;<label class="text-link" href="http://www.mozilla.org/contribute/">&contribute.getInvolvedLink;</label>&contribute.end;
</description>
</vbox>
@ -130,7 +131,7 @@
<vbox id="channelSelector">
<hbox pack="start" align="center">
<label id="channelSelectorStart">&channel.selector.start;</label>
<menulist id="channelMenulist" onselect="gChannelSelector.selectChannel(this.selectedItem);">
<menulist id="channelMenulist" onselect="gChannelSelector.selectChannel(this.selectedItem);" aria-labelledby="channelSelectorStart channelMenulist channelSelectorEnd">
<menupopup>
<menuitem id="releaseMenuitem" label="Release" value="release"/>
<menuitem id="betaMenuitem" label="Beta" value="beta"/>
@ -138,7 +139,7 @@
<menuitem id="auroraMenuitem" label="Aurora" value="aurora"/>
</menupopup>
</menulist>
<label>&channel.selector.end;</label>
<label id="channelSelectorEnd">&channel.selector.end;</label>
</hbox>
<deck id="channelDescriptionDeck" selectedIndex="0">

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

@ -2688,6 +2688,11 @@ function BrowserOnClick(event) {
gBrowser.loadURIWithFlags(content.location.href,
nsIWebNavigation.LOAD_FLAGS_BYPASS_CLASSIFIER,
null, null, null);
Services.perms.add(makeURI(content.location.href), "safe-browsing",
Ci.nsIPermissionManager.ALLOW_ACTION,
Ci.nsIPermissionManager.EXPIRE_SESSION);
let buttons = [{
label: gNavigatorBundle.getString("safebrowsing.getMeOutOfHereButton.label"),
accessKey: gNavigatorBundle.getString("safebrowsing.getMeOutOfHereButton.accessKey"),

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

@ -77,11 +77,11 @@
value="&addDevice.showMeHow.label;"
href="https://services.mozilla.com/sync/help/add-device"/>
</description>
<spacer flex="1"/>
<separator class="groove-thin"/>
<description>
&addDevice.dialog.enterCode.label;
</description>
<spacer flex="1"/>
<separator class="groove-thin"/>
<vbox align="center">
<textbox id="pin1"
class="pin"
@ -99,7 +99,7 @@
onfocus="this.select();"
/>
</vbox>
<spacer flex="1"/>
<separator class="groove-thin"/>
<vbox id="add-device-throbber" align="center" hidden="true">
<image/>
</vbox>

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

@ -111,7 +111,7 @@ let Change = {
pp = Weave.Utils.hyphenatePassphrase(pp);
this._passphraseBox.value = pp;
this._passphraseBox.focus();
document.title = this._str("change.synckey.title");
document.title = this._str("change.synckey2.title");
introText.textContent = this._str("change.synckey.introText2");
warningText.textContent = this._str("change.synckey2.warningText");
this._dialog.getButton("finish").label

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

@ -100,7 +100,7 @@
<spacer flex="1"/>
<label id="generatePassphraseButton"
hidden="true"
value="&syncKeyGenerate.label;"
value="&syncGenerateNewKey.label;"
class="text-link inline-link"
onclick="event.stopPropagation();
Change.doGeneratePassphrase();"/>

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

@ -56,6 +56,11 @@ const OPTIONS_PAGE = 6;
const OPTIONS_CONFIRM_PAGE = 7;
const SETUP_SUCCESS_PAGE = 8;
// Broader than we'd like, but after this changed from api-secure.recaptcha.net
// we had no choice. At least we only do this for the duration of setup.
// See discussion in Bugs 508112 and 653307.
const RECAPTCHA_DOMAIN = "https://www.google.com";
Cu.import("resource://services-sync/main.js");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource://gre/modules/Services.jsm");
@ -69,7 +74,6 @@ var gSyncSetup = {
captchaBrowser: null,
wizard: null,
_disabledSites: [],
_remoteSites: [Weave.Service.serverURL, "https://api-secure.recaptcha.net"],
status: {
password: false,
@ -77,6 +81,8 @@ var gSyncSetup = {
server: false
},
get _remoteSites() [Weave.Service.serverURL, RECAPTCHA_DOMAIN],
get _usingMainServers() {
if (this._settingUpNew)
return document.getElementById("server").selectedIndex == 0;

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

@ -35,7 +35,7 @@
}
tabpanels {
background-color: white;
background-color: transparent;
}
.tab-drop-indicator {

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

@ -2456,6 +2456,11 @@
this.mTabListeners[0] = tabListener;
this.mTabFilters[0] = filter;
this.init();
this.style.backgroundColor =
Services.prefs.getBoolPref("browser.display.use_system_colors") ?
"-moz-default-background-color" :
Services.prefs.getCharPref("browser.display.background_color");
]]>
</constructor>

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

@ -215,6 +215,7 @@ _BROWSER_FILES = \
browser_tabfocus.js \
browser_tabs_isActive.js \
browser_tabs_owner.js \
browser_urlHighlight.js \
browser_visibleFindSelection.js \
browser_visibleTabs.js \
browser_visibleTabs_contextMenu.js \

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

@ -0,0 +1,58 @@
function testVal(aExpected) {
gURLBar.value = aExpected.replace(/[<>]/g, "");
let selectionController = gURLBar.editor.selectionController;
let selection = selectionController.getSelection(selectionController.SELECTION_URLSECONDARY);
let value = gURLBar.editor.rootElement.textContent;
let result = "";
for (let i = 0; i < selection.rangeCount; i++) {
let range = selection.getRangeAt(i).toString();
let pos = value.indexOf(range);
result += value.substring(0, pos) + "<" + range + ">";
value = value.substring(pos + range.length);
}
result += value;
is(result, aExpected);
}
function test() {
const prefname = "browser.urlbar.formatting.enabled";
registerCleanupFunction(function () {
Services.prefs.clearUserPref(prefname);
URLBarSetURI();
});
Services.prefs.setBoolPref(prefname, true);
testVal("<http://>mozilla.org");
testVal("<http://>mozilla.org</>");
testVal("<http://>mözilla.org</>");
testVal("<http://>mozilla.imaginatory</>");
testVal("<http://www.>mozilla.org</>");
testVal("<http://sub.>mozilla.org</>");
testVal("<http://sub1.sub2.sub3.>mozilla.org</>");
testVal("<http://ftp.>mozilla.org</>");
testVal("<ftp://ftp.>mozilla.org</>");
testVal("<https://sub.>mozilla.org</>");
testVal("<https://sub1.sub2.sub3.>mozilla.org</>");
testVal("<https://user:pass@sub1.sub2.sub3.>mozilla.org</>");
testVal("<https://user:pass@>mozilla.org</>");
testVal("<http://>mozilla.org</file.ext>");
testVal("<http://>mozilla.org</sub/file.ext>");
testVal("<http://>mozilla.org</sub/file.ext?foo>");
testVal("<http://>mozilla.org</sub/file.ext?foo&bar>");
testVal("<http://>mozilla.org</sub/file.ext?foo&bar#top>");
testVal("<http://sub.>mozilla.org<:666/file.ext>");
testVal("mailto:admin@mozilla.org");
testVal("gopher://mozilla.org/");
testVal("about:config");
Services.prefs.setBoolPref(prefname, false);
testVal("http://mozilla.org/");
}

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

@ -90,6 +90,7 @@
this.doubleClickSelectsAll = this._prefs.getBoolPref("doubleClickSelectsAll");
this.completeDefaultIndex = this._prefs.getBoolPref("autoFill");
this.timeout = this._prefs.getIntPref("delay");
this._formattingEnabled = this._prefs.getBoolPref("formatting.enabled");
this._urlTooltip = document.getElementById("urlTooltip");
@ -179,6 +180,46 @@
]]></body>
</method>
<field name="_formattingEnabled">true</field>
<method name="formatValue">
<body><![CDATA[
if (!this._formattingEnabled)
return;
let controller = this.editor.selectionController;
let selection = controller.getSelection(controller.SELECTION_URLSECONDARY);
selection.removeAllRanges();
let textNode = this.editor.rootElement.firstChild;
let value = textNode.textContent;
let matchedURL = value.match(/^((?:http|https|ftp):\/\/(?:[^\/]+@)?)([^\/:]+)/);
if (!matchedURL)
return;
let [, preDomain, domain] = matchedURL;
let baseDomain = domain;
try {
baseDomain = Services.eTLD.getBaseDomainFromHost(domain);
} catch (e) {}
let segments = function (s) s.replace(/[^.]*/g, "").length + 1;
let subSegments = segments(domain) - segments(baseDomain);
let subDomain = domain.match(new RegExp("(?:[^.]*\.){" + subSegments + "}"))[0];
let range = document.createRange();
range.setStart(textNode, 0);
range.setEnd(textNode, preDomain.length + subDomain.length);
selection.addRange(range);
let startRest = preDomain.length + domain.length;
if (startRest < value.length) {
range = document.createRange();
range.setStart(textNode, startRest);
range.setEnd(textNode, value.length);
selection.addRange(range);
}
]]></body>
</method>
<method name="handleRevert">
<body><![CDATA[
var isScrolling = this.popupOpen;
@ -494,6 +535,9 @@
case "delay":
this.timeout = this._prefs.getIntPref(aData);
break;
case "formatting.enabled":
this._formattingEnabled = this._prefs.getBoolPref(aData);
break;
}
}
]]></body>

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

@ -110,7 +110,8 @@ let gSyncPane = {
startOver: function (showDialog) {
if (showDialog) {
let flags = Services.prompt.BUTTON_POS_0 * Services.prompt.BUTTON_TITLE_IS_STRING +
Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL;
Services.prompt.BUTTON_POS_1 * Services.prompt.BUTTON_TITLE_CANCEL +
Services.prompt.BUTTON_POS_1_DEFAULT;
let buttonChoice =
Services.prompt.confirmEx(window,
this._stringBundle.GetStringFromName("stopUsingAccount.title"),

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

@ -36,6 +36,7 @@
@BINPATH@/update.locale
@BINPATH@/updater.ini
@BINPATH@/dictionaries/*
@BINPATH@/hyphenation/*
#ifdef XP_WIN32
@BINPATH@/uninstall/helper.exe
#endif

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

@ -186,6 +186,7 @@ libs-%:
@$(MAKE) -C ../../toolkit/locales libs-$* BOTH_MANIFESTS=1
@$(MAKE) -C ../../services/sync/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
@$(MAKE) -C ../../extensions/spellcheck/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
@$(MAKE) -C ../../intl/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
@$(MAKE) libs AB_CD=$* XPI_NAME=locale-$* PREF_DIR=defaults/pref BOTH_MANIFESTS=1
@$(MAKE) -C $(DEPTH)/$(MOZ_BRANDING_DIRECTORY)/locales AB_CD=$* XPI_NAME=locale-$* BOTH_MANIFESTS=1
@ -217,6 +218,7 @@ clobber-zip:
$(STAGEDIST)/defaults/pref/firefox-l10n.js
$(RM) -rf $(STAGEDIST)/searchplugins \
$(STAGEDIST)/dictionaries \
$(STAGEDIST)/hyphenation \
$(STAGEDIST)/defaults/profile \
$(STAGEDIST)/chrome/$(AB_CD)

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

@ -8,7 +8,7 @@ change.password.status.error = There was an error changing your password.
change.password2.introText = Your password must be at least 8 characters long. It cannot be the same as either your user name or your Sync Key.
change.password.warningText = Note: All of your other devices will be unable to connect to your account once you change this password.
change.synckey.title = Change your Sync Key
change.synckey2.title = My Sync Key
change.synckey.acceptButton = Change Sync Key
change.synckey.label = Changing Sync Key and uploading local data, please wait…
change.synckey2.error = There was an error while changing your Sync Key!

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

@ -43,7 +43,7 @@
<!ENTITY setup.newSyncKeyPage.description.label "To ensure your total privacy, all of your data is encrypted prior to being uploaded. The Sync Key which is necessary to decrypt your data is not uploaded.">
<!ENTITY syncKeyEntry.label "Your Sync Key">
<!ENTITY syncKeyEntry.accesskey "K">
<!ENTITY syncKeyGenerate.label "Generate">
<!ENTITY syncGenerateNewKey.label "Generate a new key">
<!ENTITY syncKeyBackup.description "Your Sync Key is required to access &syncBrand.fullName.label; on other machines. Please create a backup copy. We cannot help you recover your Sync Key.">
<!ENTITY button.syncKeyBackup.print.label "Print…">

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

@ -54,10 +54,19 @@ namespace std {
#if (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5)
/* Instantiate these templates to avoid GLIBCXX_3.4.14 symbol versions
* in debug builds */
template char *basic_string<char, char_traits<char>, allocator<char> >::_S_construct_aux_2(size_type, char, allocator<char> const&);
template wchar_t *basic_string<wchar_t, char_traits<wchar_t>, allocator<wchar_t> >::_S_construct_aux_2(size_type, wchar_t, allocator<wchar_t> const&);
#endif
#endif
template char *string::_S_construct_aux_2(size_type, char, allocator<char> const&);
#ifdef _GLIBCXX_USE_WCHAR_T
template wchar_t *wstring::_S_construct_aux_2(size_type, wchar_t, allocator<wchar_t> const&);
#endif /* _GLIBCXX_USE_WCHAR_T */
#ifdef __GXX_EXPERIMENTAL_CXX0X__
template string::basic_string(string&&);
template string& string::operator=(string&&);
template wstring::basic_string(wstring&&);
template wstring& wstring::operator=(wstring&&);
template wstring& wstring::assign(wstring&&);
#endif /* __GXX_EXPERIMENTAL_CXX0X__ */
#endif /* (__GNUC__ == 4) && (__GNUC_MINOR__ >= 5) */
#endif /* DEBUG */
}
namespace std __attribute__((visibility("default"))) {

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

@ -2963,6 +2963,11 @@ fi
AC_LANG_CPLUSPLUS
if test "$GNU_CXX"; then
_SAVE_CXXFLAGS=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -std=gnu++0x"
fi
dnl Check for usable char16_t (2 bytes, unsigned)
dnl (we might not need the unsignedness check anymore)
AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
@ -2978,6 +2983,8 @@ AC_CACHE_CHECK(for usable char16_t (2 bytes, unsigned),
if test "$ac_cv_have_usable_char16_t" = "yes"; then
AC_DEFINE(HAVE_CPP_CHAR16_T)
HAVE_CPP_CHAR16_T=1
elif test "$GNU_CXX"; then
CXXFLAGS="$_SAVE_CXXFLAGS"
fi
dnl Check for usable wchar_t (2 bytes, unsigned)

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

@ -51,7 +51,7 @@ interface nsIDOMNode;
interface nsISelection;
interface nsISelectionDisplay;
[scriptable, uuid(ff11fa25-788f-444f-8f69-dcdf14348fb3)]
[scriptable, uuid(e0dd9365-470b-4ee8-b644-54add1c4c73f)]
interface nsISelectionController : nsISelectionDisplay
{
const short SELECTION_NONE=0;
@ -63,7 +63,8 @@ interface nsISelectionController : nsISelectionDisplay
const short SELECTION_IME_SELECTEDCONVERTEDTEXT=32;
const short SELECTION_ACCESSIBILITY=64; // For accessibility API usage
const short SELECTION_FIND=128;
const short NUM_SELECTIONTYPES=9;
const short SELECTION_URLSECONDARY=256;
const short NUM_SELECTIONTYPES=10;
const short SELECTION_ANCHOR_REGION = 0;
const short SELECTION_FOCUS_REGION = 1;

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

@ -43,6 +43,7 @@
#include "nsILineBreaker.h"
class nsIAtom;
class nsHyphenator;
/**
* A receiver of line break data.
@ -55,8 +56,12 @@ public:
* will cover the entire text chunk. Substrings may overlap (i.e., we may
* set the break-before state of a character more than once).
* @param aBreakBefore the break-before states for the characters in the substring.
* These are enum values from gfxTextRun::CompressedGlyph:
* FLAG_BREAK_TYPE_NONE - no linebreak is allowed here
* FLAG_BREAK_TYPE_NORMAL - a normal (whitespace) linebreak
* FLAG_BREAK_TYPE_HYPHEN - a hyphenation point
*/
virtual void SetBreaks(PRUint32 aStart, PRUint32 aLength, PRPackedBool* aBreakBefore) = 0;
virtual void SetBreaks(PRUint32 aStart, PRUint32 aLength, PRUint8* aBreakBefore) = 0;
/**
* Indicates which characters should be capitalized. Only called if
@ -153,7 +158,12 @@ public:
* We need to be notified of characters that should be capitalized
* (as in text-transform:capitalize) in this chunk of text.
*/
BREAK_NEED_CAPITALIZATION = 0x08
BREAK_NEED_CAPITALIZATION = 0x08,
/**
* Auto-hyphenation is enabled, so we need to get a hyphenator
* (if available) and use it to find breakpoints.
*/
BREAK_USE_AUTO_HYPHENATION = 0x10
};
/**
@ -214,9 +224,18 @@ private:
// appropriate sink(s). Then we clear the current word state.
nsresult FlushCurrentWord();
void UpdateCurrentWordLangGroup(nsIAtom *aLangGroup);
void FindHyphenationPoints(nsHyphenator *aHyphenator,
const PRUnichar *aTextStart,
const PRUnichar *aTextLimit,
PRPackedBool *aBreakState);
nsAutoTArray<PRUnichar,100> mCurrentWord;
// All the items that contribute to mCurrentWord
nsAutoTArray<TextItem,2> mTextItems;
nsIAtom* mCurrentWordLangGroup;
PRPackedBool mCurrentWordContainsMixedLang;
PRPackedBool mCurrentWordContainsComplexChar;
// True if the previous character was breakable whitespace

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

@ -287,6 +287,9 @@ nsContentSink::Init(nsIDocument* aDoc,
mDocumentURI = aURI;
mDocShell = do_QueryInterface(aContainer);
mScriptLoader = mDocument->ScriptLoader();
if (!mFragmentMode) {
if (mDocShell) {
PRUint32 loadType = 0;
mDocShell->GetLoadType(&loadType);
@ -299,12 +302,12 @@ nsContentSink::Init(nsIDocument* aDoc,
new nsScriptLoaderObserverProxy(this);
NS_ENSURE_TRUE(proxy, NS_ERROR_OUT_OF_MEMORY);
mScriptLoader = mDocument->ScriptLoader();
mScriptLoader->AddObserver(proxy);
mCSSLoader = aDoc->CSSLoader();
ProcessHTTPHeaders(aChannel);
}
mCSSLoader = aDoc->CSSLoader();
mNodeInfoManager = aDoc->NodeInfoManager();
@ -315,10 +318,11 @@ nsContentSink::Init(nsIDocument* aDoc,
FavorPerformanceHint(!mDynamicLowerValue, 0);
}
mCanInterruptParser = sCanInterruptParser;
// prevent DropParserAndPerfHint from unblocking onload in the fragment
// case
mCanInterruptParser = !mFragmentMode && sCanInterruptParser;
return NS_OK;
}
NS_IMETHODIMP

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

@ -343,6 +343,8 @@ protected:
// shouldn't be performing any more content model notifications,
// since we're not longer updating our child counts.
PRUint8 mIsDocumentObserver : 1;
// True if this is a fragment parser
PRUint8 mFragmentMode : 1;
//
// -- Can interrupt parsing members --

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

@ -6292,7 +6292,7 @@ nsDocument::AddEventListener(const nsAString& aType,
PRBool aUseCapture, PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
NS_ASSERTION(!aWantsUntrusted || optional_argc > 0,
NS_ASSERTION(!aWantsUntrusted || optional_argc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
"explicit by making optional_argc non-zero.");
@ -6303,7 +6303,7 @@ nsDocument::AddEventListener(const nsAString& aType,
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted ||
(optional_argc == 0 && !nsContentUtils::IsChromeDoc(this))) {
(optional_argc < 2 && !nsContentUtils::IsChromeDoc(this))) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}

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

@ -2085,7 +2085,7 @@ nsDOMEventRTTearoff::AddEventListener(const nsAString& aType,
PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
NS_ASSERTION(!aWantsUntrusted || optional_argc > 0,
NS_ASSERTION(!aWantsUntrusted || optional_argc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
"explicit by making optional_argc non-zero.");
@ -2097,7 +2097,7 @@ nsDOMEventRTTearoff::AddEventListener(const nsAString& aType,
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted ||
(optional_argc == 0 &&
(optional_argc < 2 &&
!nsContentUtils::IsChromeDoc(mNode->GetOwnerDoc()))) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}

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

@ -39,9 +39,14 @@
#include "nsLineBreaker.h"
#include "nsContentUtils.h"
#include "nsILineBreaker.h"
#include "gfxFont.h" // for the gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_* values
#include "nsHyphenationManager.h"
#include "nsHyphenator.h"
nsLineBreaker::nsLineBreaker()
: mCurrentWordContainsComplexChar(PR_FALSE),
: mCurrentWordLangGroup(nsnull),
mCurrentWordContainsMixedLang(PR_FALSE),
mCurrentWordContainsComplexChar(PR_FALSE),
mAfterBreakableSpace(PR_FALSE), mBreakHere(PR_FALSE)
{
}
@ -74,7 +79,7 @@ nsresult
nsLineBreaker::FlushCurrentWord()
{
PRUint32 length = mCurrentWord.Length();
nsAutoTArray<PRPackedBool,4000> breakState;
nsAutoTArray<PRUint8,4000> breakState;
if (!breakState.AppendElements(length))
return NS_ERROR_OUT_OF_MEMORY;
@ -82,25 +87,47 @@ nsLineBreaker::FlushCurrentWord()
if (!mCurrentWordContainsComplexChar) {
// Just set everything internal to "no break"!
memset(breakState.Elements(), PR_FALSE, length*sizeof(PRPackedBool));
memset(breakState.Elements(),
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NONE,
length*sizeof(PRUint8));
} else {
nsContentUtils::LineBreaker()->
GetJISx4051Breaks(mCurrentWord.Elements(), length, breakState.Elements());
}
PRBool autoHyphenate = mCurrentWordLangGroup &&
!mCurrentWordContainsMixedLang;
PRUint32 i;
for (i = 0; autoHyphenate && i < mTextItems.Length(); ++i) {
TextItem* ti = &mTextItems[i];
if (!(ti->mFlags & BREAK_USE_AUTO_HYPHENATION)) {
autoHyphenate = PR_FALSE;
}
}
if (autoHyphenate) {
nsRefPtr<nsHyphenator> hyphenator =
nsHyphenationManager::Instance()->GetHyphenator(mCurrentWordLangGroup);
if (hyphenator) {
FindHyphenationPoints(hyphenator,
mCurrentWord.Elements(),
mCurrentWord.Elements() + length,
breakState.Elements());
}
}
PRUint32 offset = 0;
for (i = 0; i < mTextItems.Length(); ++i) {
TextItem* ti = &mTextItems[i];
NS_ASSERTION(ti->mLength > 0, "Zero length word contribution?");
if ((ti->mFlags & BREAK_SUPPRESS_INITIAL) && ti->mSinkOffset == 0) {
breakState[offset] = PR_FALSE;
breakState[offset] = gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NONE;
}
if (ti->mFlags & BREAK_SUPPRESS_INSIDE) {
PRUint32 exclude = ti->mSinkOffset == 0 ? 1 : 0;
memset(breakState.Elements() + offset + exclude, PR_FALSE,
(ti->mLength - exclude)*sizeof(PRPackedBool));
memset(breakState.Elements() + offset + exclude,
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NONE,
(ti->mLength - exclude)*sizeof(PRUint8));
}
// Don't set the break state for the first character of the word, because
@ -130,6 +157,8 @@ nsLineBreaker::FlushCurrentWord()
mCurrentWord.Clear();
mTextItems.Clear();
mCurrentWordContainsComplexChar = PR_FALSE;
mCurrentWordContainsMixedLang = PR_FALSE;
mCurrentWordLangGroup = nsnull;
return NS_OK;
}
@ -150,6 +179,7 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUnichar* aText, PRUint32
if (!mCurrentWordContainsComplexChar && IsComplexChar(aText[offset])) {
mCurrentWordContainsComplexChar = PR_TRUE;
}
UpdateCurrentWordLangGroup(aLangGroup);
++offset;
}
@ -166,7 +196,7 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUnichar* aText, PRUint32
return rv;
}
nsAutoTArray<PRPackedBool,4000> breakState;
nsAutoTArray<PRUint8,4000> breakState;
if (aSink) {
if (!breakState.AppendElements(aLength))
return NS_ERROR_OUT_OF_MEMORY;
@ -198,28 +228,43 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUnichar* aText, PRUint32
PRUint32 wordStart = offset;
PRBool wordHasComplexChar = PR_FALSE;
nsRefPtr<nsHyphenator> hyphenator;
if ((aFlags & BREAK_USE_AUTO_HYPHENATION) && !(aFlags & BREAK_SUPPRESS_INSIDE)) {
hyphenator = nsHyphenationManager::Instance()->GetHyphenator(aLangGroup);
}
for (;;) {
PRUnichar ch = aText[offset];
PRBool isSpace = IsSpace(ch);
PRBool isBreakableSpace = isSpace && !(aFlags & BREAK_SUPPRESS_INSIDE);
if (aSink) {
breakState[offset] = mBreakHere || (mAfterBreakableSpace && !isBreakableSpace);
breakState[offset] =
mBreakHere || (mAfterBreakableSpace && !isBreakableSpace) ?
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NORMAL :
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NONE;
}
mBreakHere = PR_FALSE;
mAfterBreakableSpace = isBreakableSpace;
if (isSpace) {
if (offset > wordStart && aSink) {
if (wordHasComplexChar && !(aFlags & BREAK_SUPPRESS_INSIDE)) {
if (!(aFlags & BREAK_SUPPRESS_INSIDE)) {
if (wordHasComplexChar) {
// Save current start-of-word state because GetJISx4051Breaks will
// set it to false
PRPackedBool currentStart = breakState[wordStart];
PRUint8 currentStart = breakState[wordStart];
nsContentUtils::LineBreaker()->
GetJISx4051Breaks(aText + wordStart, offset - wordStart,
breakState.Elements() + wordStart);
breakState[wordStart] = currentStart;
}
if (hyphenator) {
FindHyphenationPoints(hyphenator,
aText + wordStart, aText + offset,
breakState.Elements() + wordStart);
}
}
if (aFlags & BREAK_NEED_CAPITALIZATION) {
SetupCapitalization(aText + wordStart, offset - wordStart,
capitalizationState.Elements() + wordStart);
@ -246,6 +291,7 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUnichar* aText, PRUint32
mTextItems.AppendElement(TextItem(aSink, wordStart, len, aFlags));
// Ensure that the break-before for this word is written out
offset = wordStart + 1;
UpdateCurrentWordLangGroup(aLangGroup);
break;
}
}
@ -262,17 +308,35 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUnichar* aText, PRUint32
return NS_OK;
}
void
nsLineBreaker::FindHyphenationPoints(nsHyphenator *aHyphenator,
const PRUnichar *aTextStart,
const PRUnichar *aTextLimit,
PRPackedBool *aBreakState)
{
nsDependentSubstring string(aTextStart, aTextLimit);
nsAutoTArray<PRPackedBool,200> hyphens;
if (NS_SUCCEEDED(aHyphenator->Hyphenate(string, hyphens))) {
for (PRUint32 i = 0; i + 1 < string.Length(); ++i) {
if (hyphens[i]) {
aBreakState[i + 1] =
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_HYPHEN;
}
}
}
}
nsresult
nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUint8* aText, PRUint32 aLength,
PRUint32 aFlags, nsILineBreakSink* aSink)
{
NS_ASSERTION(aLength > 0, "Appending empty text...");
if (aFlags & BREAK_NEED_CAPITALIZATION) {
// Defer to the Unicode path if capitalization is required
if (aFlags & (BREAK_NEED_CAPITALIZATION | BREAK_USE_AUTO_HYPHENATION)) {
// Defer to the Unicode path if capitalization or hyphenation is required
nsAutoString str;
CopyASCIItoUTF16(nsDependentCString(reinterpret_cast<const char*>(aText), aLength),
str);
const char* cp = reinterpret_cast<const char*>(aText);
CopyASCIItoUTF16(nsDependentCSubstring(cp, cp + aLength), str);
return AppendText(aLangGroup, str.get(), aLength, aFlags, aSink);
}
@ -306,7 +370,7 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUint8* aText, PRUint32 aL
return rv;
}
nsAutoTArray<PRPackedBool,4000> breakState;
nsAutoTArray<PRUint8,4000> breakState;
if (aSink) {
if (!breakState.AppendElements(aLength))
return NS_ERROR_OUT_OF_MEMORY;
@ -337,7 +401,10 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUint8* aText, PRUint32 aL
PRBool isBreakableSpace = isSpace && !(aFlags & BREAK_SUPPRESS_INSIDE);
if (aSink) {
breakState[offset] = mBreakHere || (mAfterBreakableSpace && !isBreakableSpace);
breakState[offset] =
mBreakHere || (mAfterBreakableSpace && !isBreakableSpace) ?
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NORMAL :
gfxTextRun::CompressedGlyph::FLAG_BREAK_TYPE_NONE;
}
mBreakHere = PR_FALSE;
mAfterBreakableSpace = isBreakableSpace;
@ -390,6 +457,16 @@ nsLineBreaker::AppendText(nsIAtom* aLangGroup, const PRUint8* aText, PRUint32 aL
return NS_OK;
}
void
nsLineBreaker::UpdateCurrentWordLangGroup(nsIAtom *aLangGroup)
{
if (mCurrentWordLangGroup && mCurrentWordLangGroup != aLangGroup) {
mCurrentWordContainsMixedLang = PR_TRUE;
} else {
mCurrentWordLangGroup = aLangGroup;
}
}
nsresult
nsLineBreaker::AppendInvisibleWhitespace(PRUint32 aFlags)
{

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

@ -173,8 +173,9 @@ static PRInt64 GetCanvasMemoryUsed(void *) {
}
NS_MEMORY_REPORTER_IMPLEMENT(CanvasMemory,
"content/canvas/2d_pixel_bytes",
"Total memory used by 2D canvas (width * height * 4)",
"heap-used/content/canvas/2d-pixel-bytes",
"Memory used by 2D canvases. Each canvas "
"requires (width * height * 4) bytes.",
GetCanvasMemoryUsed,
NULL)
@ -3228,105 +3229,6 @@ nsCanvasRenderingContext2D::IsPointInPath(float x, float y, PRBool *retVal)
return NS_OK;
}
#ifdef WINCE
/* A simple bitblt for self copies that ensures that we don't overwrite any
* area before we've read from it. */
static void
bitblt(gfxImageSurface *s, int src_x, int src_y, int width, int height,
int dest_x, int dest_y) {
unsigned char *data = s->Data();
int stride = s->Stride()/4;
int x, y;
unsigned int *dest = (unsigned int *)data;
unsigned int *src = (unsigned int *)data;
int surface_width = s->Width();
int surface_height = s->Height();
/* clip to the surface size */
if (src_x < 0) {
dest_x += -src_x;
width -= -src_x;
src_x = 0;
}
if (src_y < 0) {
dest_y += -src_y;
height -= -src_y;
src_y = 0;
}
if (dest_x < 0) {
src_x += -dest_x;
width -= -dest_x;
dest_x = 0;
}
if (dest_y < 0) {
src_y += -dest_y;
height -= -dest_y;
dest_y = 0;
}
/*XXX: we might want to check for overflow? */
if (src_x + width > surface_width)
width = surface_width - src_x;
if (dest_x + width > surface_width)
width = surface_width - dest_x;
if (src_y + height > surface_height)
height = surface_height - src_y;
if (dest_y + height > surface_height)
height = surface_height - dest_y;
if (dest_x < src_x) {
if (dest_y < src_y) {
dest = dest + dest_y*stride + dest_x;
src = src + src_y*stride + src_x;
/* copy right to left, top to bottom */
for (y=0; y<height; y++) {
for (x=0; x<width; x++) {
*dest++ = *src++;
}
dest += stride - width;
src += stride - width;
}
} else {
dest = dest + (dest_y+height-1)*stride + dest_x;
src = src + (src_y +height-1)*stride + src_x;
/* copy right to left, bottom to top */
for (y=0; y<height; y++) {
for (x=0; x<width; x++) {
*dest++ = *src++;
}
dest += -stride - width;
src += -stride - width;
}
}
} else {
if (dest_y < src_y) {
dest = dest + dest_y*stride + (dest_x+width-1);
src = src + src_y*stride + (src_x +width-1);
/* copy left to right, top to bottom */
for (y=0; y<height; y++) {
for (x=0; x<width; x++) {
*dest-- = *src--;
}
dest += stride + width;
src += stride + width;
}
} else {
dest = dest + (dest_y+height-1)*stride + (dest_x+width-1);
src = src + (src_y +height-1)*stride + (src_x +width-1);
/* copy left to right, bottom to top */
for (y=0; y<height; y++) {
for (x=0; x<width; x++) {
*dest-- = *src--;
}
dest += -stride + width;
src += -stride + width;
}
}
}
}
#endif
//
// image
//
@ -3368,8 +3270,7 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
return res.mIsStillLoading ? NS_OK : NS_ERROR_NOT_AVAILABLE;
}
#ifndef WINCE
// On non-CE, force a copy if we're using drawImage with our destination
// Force a copy if we're using drawImage with our destination
// as a source to work around some Cairo self-copy semantics issues.
if (res.mSurface == mSurface) {
sfeFlags |= nsLayoutUtils::SFE_WANT_NEW_SURFACE;
@ -3377,7 +3278,6 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
if (!res.mSurface)
return NS_ERROR_NOT_AVAILABLE;
}
#endif
imgsurf = res.mSurface.forget();
imgSize = res.mSize;
@ -3466,34 +3366,6 @@ nsCanvasRenderingContext2D::DrawImage(nsIDOMElement *imgElt, float a1,
matrix.Translate(gfxPoint(sx, sy));
matrix.Scale(sw/dw, sh/dh);
#ifdef WINCE
/* cairo doesn't have consistent semantics for drawing a surface onto
* itself. Specifically, pixman will not preserve the contents when doing
* the copy. So to get the desired semantics a temporary copy would be needed.
* Instead we optimize opaque self copies here */
{
nsRefPtr<gfxASurface> csurf = mThebes->CurrentSurface();
if (csurf == imgsurf) {
if (imgsurf->GetType() == gfxASurface::SurfaceTypeImage) {
gfxImageSurface *surf = static_cast<gfxImageSurface*>(imgsurf.get());
gfxContext::GraphicsOperator op = mThebes->CurrentOperator();
PRBool opaque, unscaled;
opaque = surf->Format() == gfxASurface::ImageFormatARGB32 &&
(op == gfxContext::OPERATOR_SOURCE);
opaque |= surf->Format() == gfxASurface::ImageFormatRGB24 &&
(op == gfxContext::OPERATOR_SOURCE || op == gfxContext::OPERATOR_OVER);
unscaled = sw == dw && sh == dh;
if (opaque && unscaled) {
bitblt(surf, sx, sy, sw, sh, dx, dy);
return NS_OK;
}
}
}
}
#endif
pattern = new gfxPattern(imgsurf);
pattern->SetMatrix(matrix);

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

@ -95,7 +95,7 @@ nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
@ -119,7 +119,7 @@ nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,
PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
NS_ASSERTION(!aWantsUntrusted || optional_argc > 0,
NS_ASSERTION(!aWantsUntrusted || optional_argc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
"explicit by making optional_argc non-zero.");
@ -128,7 +128,7 @@ nsDOMEventTargetHelper::AddEventListener(const nsAString& aType,
NS_ENSURE_STATE(elm);
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (optional_argc == 0) {
if (optional_argc < 2) {
nsresult rv;
nsIScriptContext* context = GetContextForEventHandlers(&rv);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -97,6 +97,7 @@ _TEST_FILES = \
test_bug593959.html \
test_bug591815.html \
test_bug605242.html \
test_bug613634.html \
test_bug607464.html \
test_bug624127.html \
test_bug641477.html \

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

@ -0,0 +1,91 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=613634
-->
<head>
<title>Test for Bug 613634</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=613634">Mozilla Bug 613634</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 613634 **/
var eventCount = 0;
function l(e) {
if (e.eventPhase != Event.CAPTURING_PHASE) {
++eventCount;
} else {
ok(false, "Listener shouldn't be called!");
}
}
var d1 = document.createElement("div");
var d2 = document.createElement("div");
d1.appendChild(d2);
var x = new XMLHttpRequest();
try {
d1.addEventListener("foo", l);
document.addEventListener("foo", l);
window.addEventListener("foo", l);
x.addEventListener("foo", l);
} catch(ex) {
ok(false, "Shouldn't throw " + ex);
}
var ev = document.createEvent("Event");
ev.initEvent("foo", true, true);
d2.dispatchEvent(ev);
is(eventCount, 1, "Event listener should have been called!");
ev = document.createEvent("Event");
ev.initEvent("foo", false, false);
d2.dispatchEvent(ev);
is(eventCount, 1, "Event listener shouldn't have been called!");
d1.removeEventListener("foo", l);
ev = document.createEvent("Event");
ev.initEvent("foo", true, true);
d2.dispatchEvent(ev);
is(eventCount, 1, "Event listener shouldn't have been called!");
ev = document.createEvent("Event");
ev.initEvent("foo", true, true);
document.body.dispatchEvent(ev);
is(eventCount, 3, "Event listener should have been called on document and window!");
document.removeEventListener("foo", l);
window.removeEventListener("foo", l, false);
ev = document.createEvent("Event");
ev.initEvent("foo", true, true);
document.body.dispatchEvent(ev);
is(eventCount, 3, "Event listener shouldn't have been called on document and window!");
ev = document.createEvent("Event");
ev.initEvent("foo", true, true);
x.dispatchEvent(ev);
is(eventCount, 4, "Event listener should have been called on XMLHttpRequest!");
x.removeEventListener("foo", l);
ev = document.createEvent("Event");
ev.initEvent("foo", true, true);
x.dispatchEvent(ev);
is(eventCount, 4, "Event listener shouldn't have been called on XMLHttpRequest!");
</script>
</pre>
</body>
</html>

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

@ -254,7 +254,8 @@ class nsHTMLMediaElement::MediaLoadListener : public nsIStreamListener,
public:
MediaLoadListener(nsHTMLMediaElement* aElement)
: mElement(aElement)
: mElement(aElement),
mLoadID(aElement->GetCurrentLoadID())
{
NS_ABORT_IF_FALSE(mElement, "Must pass an element to call back");
}
@ -262,6 +263,7 @@ public:
private:
nsRefPtr<nsHTMLMediaElement> mElement;
nsCOMPtr<nsIStreamListener> mNextListener;
PRUint32 mLoadID;
};
NS_IMPL_ISUPPORTS5(nsHTMLMediaElement::MediaLoadListener, nsIRequestObserver,
@ -288,6 +290,13 @@ NS_IMETHODIMP nsHTMLMediaElement::MediaLoadListener::OnStartRequest(nsIRequest*
nsRefPtr<nsHTMLMediaElement> element;
element.swap(mElement);
if (mLoadID != element->GetCurrentLoadID()) {
// The channel has been cancelled before we had a chance to create
// a decoder. Abort, don't dispatch an "error" event, as the new load
// may not be in an error state.
return NS_BINDING_ABORTED;
}
// Don't continue to load if the request failed or has been canceled.
nsresult rv;
nsresult status;

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

@ -179,15 +179,16 @@ public:
{}
SVGNumberListAndInfo(nsSVGElement *aElement)
: mElement(aElement)
: mElement(do_GetWeakReference(static_cast<nsINode*>(aElement)))
{}
void SetInfo(nsSVGElement *aElement) {
mElement = aElement;
mElement = do_GetWeakReference(static_cast<nsINode*>(aElement));
}
nsSVGElement* Element() const {
return mElement; // .get();
nsCOMPtr<nsIContent> e = do_QueryReferent(mElement);
return static_cast<nsSVGElement*>(e.get());
}
nsresult CopyFrom(const SVGNumberListAndInfo& rhs) {
@ -218,10 +219,11 @@ public:
}
private:
// We must keep a strong reference to our element because we may belong to a
// We must keep a weak reference to our element because we may belong to a
// cached baseVal nsSMILValue. See the comments starting at:
// https://bugzilla.mozilla.org/show_bug.cgi?id=515116#c15
nsRefPtr<nsSVGElement> mElement;
// See also https://bugzilla.mozilla.org/show_bug.cgi?id=653497
nsWeakPtr mElement;
};
} // namespace mozilla

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

@ -72,10 +72,8 @@
#if defined(XP_WIN)
// Prevent Windows redefining LoadImage
#ifndef WINCE
#undef LoadImage
#endif
#endif
#define NUM_ENTRIES_IN_4x5_MATRIX 20

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

@ -42,7 +42,7 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
ifneq (,$(filter OS2 WINNT WINCE,$(OS_ARCH)))
ifneq (,$(filter OS2 WINNT,$(OS_ARCH)))
DIRS = win
else
ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))

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

@ -248,10 +248,6 @@ static txEXSLTFunctionDescriptor descriptTable[] =
};
#ifdef WINCE // WINCE defines this.
#undef DIFFERENCE
#endif
class txEXSLTFunctionCall : public FunctionCall
{
public:

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

@ -908,8 +908,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(CSSStyleDeclaration, nsCSSStyleDeclSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ComputedCSSStyleDeclaration, nsCSSStyleDeclSH,
ARRAY_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(ROCSSPrimitiveValue, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
@ -3004,12 +3002,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSS2Properties)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ComputedCSSStyleDeclaration,
nsIDOMCSSStyleDeclaration)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSStyleDeclaration)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSS2Properties)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN_NO_CLASS_IF(ROCSSPrimitiveValue,
nsIDOMCSSPrimitiveValue)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMCSSPrimitiveValue)

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

@ -156,7 +156,6 @@ DOMCI_CLASS(MediaList)
DOMCI_CLASS(StyleSheetList)
DOMCI_CLASS(CSSStyleSheet)
DOMCI_CLASS(CSSStyleDeclaration)
DOMCI_CLASS(ComputedCSSStyleDeclaration)
DOMCI_CLASS(ROCSSPrimitiveValue)
// Range classes

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

@ -63,6 +63,7 @@
#include "prmem.h"
#include "jsapi.h" // for JSAutoRequest
#include "jsdbgapi.h" // for JS_ClearWatchPointsForObject
#include "jsfriendapi.h" // for JS_GetFrameScopeChainRaw
#include "nsReadableUtils.h"
#include "nsDOMClassInfo.h"
#include "nsJSEnvironment.h"
@ -5797,13 +5798,13 @@ nsGlobalWindow::CallerInnerWindow()
JSStackFrame *fp = nsnull;
JS_FrameIterator(cx, &fp);
if (fp) {
while (fp->isDummyFrame()) {
while (!JS_IsScriptFrame(cx, fp)) {
if (!JS_FrameIterator(cx, &fp))
break;
}
if (fp)
scope = &fp->scopeChain();
scope = JS_GetFrameScopeChainRaw(fp);
}
if (!scope)
@ -7079,7 +7080,7 @@ nsGlobalWindow::AddEventListener(const nsAString& aType,
FORWARD_TO_INNER_CREATE(AddEventListener, (aType, aListener, aUseCapture),
NS_ERROR_NOT_AVAILABLE);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
@ -7173,7 +7174,7 @@ nsGlobalWindow::AddEventListener(const nsAString& aType,
PRBool aUseCapture, PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
NS_ASSERTION(!aWantsUntrusted || optional_argc > 0,
NS_ASSERTION(!aWantsUntrusted || optional_argc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
"explicit by making optional_argc non-zero.");
@ -7189,7 +7190,7 @@ nsGlobalWindow::AddEventListener(const nsAString& aType,
PRInt32 flags = aUseCapture ? NS_EVENT_FLAG_CAPTURE : NS_EVENT_FLAG_BUBBLE;
if (aWantsUntrusted ||
(optional_argc == 0 && !nsContentUtils::IsChromeDoc(mDoc))) {
(optional_argc < 2 && !nsContentUtils::IsChromeDoc(mDoc))) {
flags |= NS_PRIV_EVENT_UNTRUSTED_PERMITTED;
}

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

@ -116,6 +116,8 @@
#include "mozilla/FunctionTimer.h"
using namespace mozilla;
const size_t gStackSize = 8192;
#ifdef PR_LOGGING
@ -1884,8 +1886,8 @@ nsJSContext::CallEventHandler(nsISupports* aTarget, void *aScope, void *aHandler
return NS_ERROR_FAILURE;
}
js::LazilyConstructed<nsAutoPoolRelease> poolRelease;
js::LazilyConstructed<js::AutoArrayRooter> tvr;
Maybe<nsAutoPoolRelease> poolRelease;
Maybe<js::AutoArrayRooter> tvr;
// Use |target| as the scope for wrapping the arguments, since aScope is
// the safe scope in many cases, which isn't very useful. Wrapping aTarget
@ -2373,8 +2375,8 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg
JSAutoRequest ar(mContext);
js::LazilyConstructed<nsAutoPoolRelease> poolRelease;
js::LazilyConstructed<js::AutoArrayRooter> tvr;
Maybe<nsAutoPoolRelease> poolRelease;
Maybe<js::AutoArrayRooter> tvr;
nsresult rv;
rv = ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc,
@ -2414,8 +2416,8 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
void *aScope,
PRUint32 *aArgc,
jsval **aArgv,
js::LazilyConstructed<nsAutoPoolRelease> &aPoolRelease,
js::LazilyConstructed<js::AutoArrayRooter> &aRooter)
Maybe<nsAutoPoolRelease> &aPoolRelease,
Maybe<js::AutoArrayRooter> &aRooter)
{
nsresult rv = NS_OK;

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

@ -51,7 +51,9 @@ class nsIXPConnectJSObjectHolder;
class nsAutoPoolRelease;
namespace js {
class AutoArrayRooter;
template <class> class LazilyConstructed;
}
namespace mozilla {
template <class> class Maybe;
}
class nsJSContext : public nsIScriptContext,
@ -205,8 +207,8 @@ protected:
void *aScope,
PRUint32 *aArgc,
jsval **aArgv,
js::LazilyConstructed<nsAutoPoolRelease> &aPoolRelease,
js::LazilyConstructed<js::AutoArrayRooter> &aRooter);
mozilla::Maybe<nsAutoPoolRelease> &aPoolRelease,
mozilla::Maybe<js::AutoArrayRooter> &aRooter);
nsresult AddSupportsPrimitiveTojsvals(nsISupports *aArg, jsval *aArgv);

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

@ -97,7 +97,7 @@ NS_IMPL_CYCLE_COLLECTING_RELEASE(nsWindowRoot)
NS_IMETHODIMP
nsWindowRoot::AddEventListener(const nsAString& aType, nsIDOMEventListener* aListener, PRBool aUseCapture)
{
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
@ -167,7 +167,7 @@ nsWindowRoot::AddEventListener(const nsAString& aType,
PRBool aUseCapture, PRBool aWantsUntrusted,
PRUint8 optional_argc)
{
NS_ASSERTION(!aWantsUntrusted || optional_argc > 0,
NS_ASSERTION(!aWantsUntrusted || optional_argc > 1,
"Won't check if this is chrome, you want to set "
"aWantsUntrusted to PR_FALSE or make the aWantsUntrusted "
"explicit by making optional_argc non-zero.");

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

@ -50,7 +50,7 @@
* http://www.w3.org/TR/DOM-Level-2-Style
*/
[scriptable, uuid(35c15ba1-932d-4a95-8f08-ddcdd50c041a)]
[scriptable, uuid(249755DF-EEFE-4AF4-8127-BE3D6BDAED2D)]
interface nsIDOMCSS2Properties : nsISupports
{
attribute DOMString background;
@ -665,6 +665,9 @@ interface nsIDOMCSS2Properties : nsISupports
attribute DOMString wordWrap;
// raises(DOMException) on setting
attribute DOMString MozHyphens;
// raises(DOMException) on setting
attribute DOMString MozTransform;
// raises(DOMException) on setting

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

@ -101,7 +101,7 @@ interface nsIDOMEventTarget : nsISupports
*/
void removeEventListener(in DOMString type,
in nsIDOMEventListener listener,
in boolean useCapture);
[optional] in boolean useCapture);
/**
* This method allows the dispatch of events into the implementations

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

@ -66,7 +66,7 @@ interface nsIDOMNSEventTarget : nsISupports
*/
[optional_argc] void addEventListener(in DOMString type,
in nsIDOMEventListener listener,
in boolean useCapture,
[optional] in boolean useCapture,
[optional] in boolean wantsUntrusted);
/**

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

@ -319,7 +319,9 @@ ContentChild::RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* chi
report->GetDescription(getter_Copies(desc));
report->GetMemoryUsed(&memoryUsed);
MemoryReport memreport(nsPrintfCString("Content Process - %d - ", getpid()),
static const int maxLength = 31; // big enough; pid is only a few chars
MemoryReport memreport(nsPrintfCString(maxLength, "Content (%d)",
getpid()),
path,
desc,
memoryUsed);

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

@ -874,7 +874,7 @@ nsresult nsPluginStreamListenerPeer::ServeStreamAsFile(nsIRequest *request,
window->window = widget->GetNativeData(NS_NATIVE_PLUGIN_PORT);
}
#endif
mOwner->SetWindow();
owner->SetWindow();
}
mSeekable = PR_FALSE;

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

@ -1164,7 +1164,7 @@ nsDOMWorkerScope::AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
NS_IMETHODIMP
@ -2569,7 +2569,7 @@ nsDOMWorker::AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
NS_IMETHODIMP

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

@ -254,7 +254,7 @@ nsDOMWorkerMessageHandler::AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
/**
@ -347,7 +347,7 @@ nsDOMWorkerMessageHandler::AddEventListener(const nsAString& aType,
PRUint8 optional_argc)
{
// We don't support aWantsUntrusted yet.
NS_ENSURE_TRUE(optional_argc == 0, NS_ERROR_NOT_IMPLEMENTED);
NS_ENSURE_TRUE(optional_argc < 2, NS_ERROR_NOT_IMPLEMENTED);
ListenerCollection* collection =
const_cast<ListenerCollection*>(GetListenerCollection(aType));

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

@ -286,7 +286,7 @@ nsDOMWorkerXHRUpload::AddEventListener(const nsAString& aType,
nsIDOMEventListener* aListener,
PRBool aUseCapture)
{
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 0);
return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
}
NS_IMETHODIMP

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

@ -242,9 +242,9 @@ nsWebBrowserPersist::nsWebBrowserPersist() :
mSerializingOutput(PR_FALSE),
mPersistFlags(kDefaultPersistFlags),
mPersistResult(NS_OK),
mWrapColumn(72),
mTotalCurrentProgress(0),
mTotalMaxProgress(0),
mWrapColumn(72),
mEncodingFlags(0)
{
}

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

@ -166,18 +166,9 @@ int main(int argc, char *argv[])
LoadString(ghInstanceApp, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
MyRegisterClass(ghInstanceApp);
// Find the GRE (libxul). We are only using frozen interfaces, so we
// should be compatible all the way up to (but not including) mozilla 2.0
static const GREVersionRange vr = {
"1.8a1",
PR_TRUE,
"2.0",
PR_FALSE
};
char path[_MAX_PATH];
GetModuleFileName(ghInstanceApp, self, sizeof(self));
lastslash = ns_strrpbrk(xpcomPath, "/\\");
GetModuleFileName(ghInstanceApp, path, sizeof(path));
char* lastslash = ns_strrpbrk(path, "/\\");
if (!lastslash)
return 7;

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

@ -40,6 +40,7 @@
#include "nsBoundingMetrics.h"
#include "nsRenderingContext.h"
#include "nsDeviceContext.h"
#include "nsStyleConsts.h"
#include "gfxTextRunCache.h"
namespace {
@ -80,6 +81,10 @@ public:
PRPackedBool* aBreakBefore) {
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
}
virtual PRInt8 GetHyphensOption() {
NS_ERROR("This shouldn't be called because we never call BreakAndMeasureText");
return NS_STYLE_HYPHENS_NONE;
}
virtual gfxFloat GetHyphenWidth() {
NS_ERROR("This shouldn't be called because we never enable hyphens");
return 0;

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

@ -521,30 +521,30 @@ gfxASurface::MovePixels(const nsIntRect& aSourceRect,
/** Memory reporting **/
static const char *sSurfaceNamesForSurfaceType[] = {
"gfx/surface/image",
"gfx/surface/pdf",
"gfx/surface/ps",
"gfx/surface/xlib",
"gfx/surface/xcb",
"gfx/surface/glitz",
"gfx/surface/quartz",
"gfx/surface/win32",
"gfx/surface/beos",
"gfx/surface/directfb",
"gfx/surface/svg",
"gfx/surface/os2",
"gfx/surface/win32printing",
"gfx/surface/quartzimage",
"gfx/surface/script",
"gfx/surface/qpainter",
"gfx/surface/recording",
"gfx/surface/vg",
"gfx/surface/gl",
"gfx/surface/drm",
"gfx/surface/tee",
"gfx/surface/xml",
"gfx/surface/skia",
"gfx/surface/d2d"
"heap-used/gfx/surface/image",
"heap-used/gfx/surface/pdf",
"heap-used/gfx/surface/ps",
"heap-used/gfx/surface/xlib",
"heap-used/gfx/surface/xcb",
"heap-used/gfx/surface/glitz",
"heap-used/gfx/surface/quartz",
"heap-used/gfx/surface/win32",
"heap-used/gfx/surface/beos",
"heap-used/gfx/surface/directfb",
"heap-used/gfx/surface/svg",
"heap-used/gfx/surface/os2",
"heap-used/gfx/surface/win32printing",
"heap-used/gfx/surface/quartzimage",
"heap-used/gfx/surface/script",
"heap-used/gfx/surface/qpainter",
"heap-used/gfx/surface/recording",
"heap-used/gfx/surface/vg",
"heap-used/gfx/surface/gl",
"heap-used/gfx/surface/drm",
"heap-used/gfx/surface/tee",
"heap-used/gfx/surface/xml",
"heap-used/gfx/surface/skia",
"heap-used/gfx/surface/d2d"
};
PR_STATIC_ASSERT(NS_ARRAY_LENGTH(sSurfaceNamesForSurfaceType) == gfxASurface::SurfaceTypeMax);
@ -558,7 +558,7 @@ SurfaceMemoryReporterPathForType(gfxASurface::gfxSurfaceType aType)
{
if (aType < 0 ||
aType >= gfxASurface::SurfaceTypeMax)
return "gfx/surface/unknown";
return "heap-used/gfx/surface/unknown";
return sSurfaceNamesForSurfaceType[aType];
}

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

@ -65,6 +65,7 @@
#include "nsBidiUtils.h"
#include "nsUnicodeRange.h"
#include "nsCompressedCharMap.h"
#include "nsStyleConsts.h"
#include "cairo.h"
#include "gfxFontTest.h"
@ -3120,7 +3121,7 @@ gfxTextRun::~gfxTextRun()
PRBool
gfxTextRun::SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
PRPackedBool *aBreakBefore,
PRUint8 *aBreakBefore,
gfxContext *aRefContext)
{
NS_ASSERTION(aStart + aLength <= mCharacterCount, "Overflow");
@ -3130,12 +3131,12 @@ gfxTextRun::SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
PRUint32 changed = 0;
PRUint32 i;
for (i = 0; i < aLength; ++i) {
PRBool canBreak = aBreakBefore[i];
PRUint8 canBreak = aBreakBefore[i];
if (canBreak && !mCharacterGlyphs[aStart + i].IsClusterStart()) {
// This can happen ... there is no guarantee that our linebreaking rules
// align with the platform's idea of what constitutes a cluster.
NS_WARNING("Break suggested inside cluster!");
canBreak = PR_FALSE;
canBreak = CompressedGlyph::FLAG_BREAK_TYPE_NONE;
}
changed |= mCharacterGlyphs[aStart + i].SetCanBreakBefore(canBreak);
}
@ -3722,7 +3723,9 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
}
PRPackedBool hyphenBuffer[MEASUREMENT_BUFFER_SIZE];
PRBool haveHyphenation = aProvider &&
(mFlags & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0;
(aProvider->GetHyphensOption() == NS_STYLE_HYPHENS_AUTO ||
(aProvider->GetHyphensOption() == NS_STYLE_HYPHENS_MANUAL &&
(mFlags & gfxTextRunFactory::TEXT_ENABLE_HYPHEN_BREAKS) != 0));
if (haveHyphenation) {
aProvider->GetHyphenationBreaks(bufferStart, bufferLength,
hyphenBuffer);
@ -3766,7 +3769,7 @@ gfxTextRun::BreakAndMeasureText(PRUint32 aStart, PRUint32 aMaxLength,
// could be the first and last break opportunity on the line, and that
// would trigger an infinite loop.
if (!aSuppressInitialBreak || i > aStart) {
PRBool lineBreakHere = mCharacterGlyphs[i].CanBreakBefore();
PRBool lineBreakHere = mCharacterGlyphs[i].CanBreakBefore() == 1;
PRBool hyphenation = haveHyphenation && hyphenBuffer[i - bufferStart];
PRBool wordWrapping = aCanWordWrap && *aBreakPriority <= eWordWrapBreak;

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

@ -1407,7 +1407,13 @@ public:
}
PRBool CanBreakLineBefore(PRUint32 aPos) {
NS_ASSERTION(0 <= aPos && aPos < mCharacterCount, "aPos out of range");
return mCharacterGlyphs[aPos].CanBreakBefore();
return mCharacterGlyphs[aPos].CanBreakBefore() ==
CompressedGlyph::FLAG_BREAK_TYPE_NORMAL;
}
PRBool CanHyphenateBefore(PRUint32 aPos) {
NS_ASSERTION(0 <= aPos && aPos < mCharacterCount, "aPos out of range");
return mCharacterGlyphs[aPos].CanBreakBefore() ==
CompressedGlyph::FLAG_BREAK_TYPE_HYPHEN;
}
PRUint32 GetLength() { return mCharacterCount; }
@ -1431,7 +1437,7 @@ public:
* breaks are the same as the old
*/
virtual PRBool SetPotentialLineBreaks(PRUint32 aStart, PRUint32 aLength,
PRPackedBool *aBreakBefore,
PRUint8 *aBreakBefore,
gfxContext *aRefContext);
/**
@ -1451,6 +1457,11 @@ public:
virtual void GetHyphenationBreaks(PRUint32 aStart, PRUint32 aLength,
PRPackedBool *aBreakBefore) = 0;
// Returns the provider's hyphenation setting, so callers can decide
// whether it is necessary to call GetHyphenationBreaks.
// Result is an NS_STYLE_HYPHENS_* value.
virtual PRInt8 GetHyphensOption() = 0;
// Returns the extra width that will be consumed by a hyphen. This should
// be constant for a given textrun.
virtual gfxFloat GetHyphenWidth() = 0;
@ -1722,14 +1733,22 @@ public:
// Indicates that a cluster and ligature group starts at this
// character; this character has a single glyph with a reasonable
// advance and zero offsets. A "reasonable" advance
// is one that fits in the available bits (currently 14) (specified
// is one that fits in the available bits (currently 13) (specified
// in appunits).
FLAG_IS_SIMPLE_GLYPH = 0x80000000U,
// Indicates that a linebreak is allowed before this character
FLAG_CAN_BREAK_BEFORE = 0x40000000U,
// Indicates whether a linebreak is allowed before this character;
// this is a two-bit field that holds a FLAG_BREAK_TYPE_xxx value
// indicating the kind of linebreak (if any) allowed here.
FLAGS_CAN_BREAK_BEFORE = 0x60000000U,
FLAGS_CAN_BREAK_SHIFT = 29,
FLAG_BREAK_TYPE_NONE = 0,
FLAG_BREAK_TYPE_NORMAL = 1,
FLAG_BREAK_TYPE_HYPHEN = 2,
// The advance is stored in appunits
ADVANCE_MASK = 0x3FFF0000U,
ADVANCE_MASK = 0x1FFF0000U,
ADVANCE_SHIFT = 16,
GLYPH_MASK = 0x0000FFFFU,
@ -1783,13 +1802,15 @@ public:
(FLAG_NOT_LIGATURE_GROUP_START | FLAG_NOT_MISSING);
}
PRBool CanBreakBefore() const { return (mValue & FLAG_CAN_BREAK_BEFORE) != 0; }
// Returns FLAG_CAN_BREAK_BEFORE if the setting changed, 0 otherwise
PRUint32 SetCanBreakBefore(PRBool aCanBreakBefore) {
NS_ASSERTION(aCanBreakBefore == PR_FALSE || aCanBreakBefore == PR_TRUE,
PRUint8 CanBreakBefore() const {
return (mValue & FLAGS_CAN_BREAK_BEFORE) >> FLAGS_CAN_BREAK_SHIFT;
}
// Returns FLAGS_CAN_BREAK_BEFORE if the setting changed, 0 otherwise
PRUint32 SetCanBreakBefore(PRUint8 aCanBreakBefore) {
NS_ASSERTION(aCanBreakBefore <= 2,
"Bogus break-before value!");
PRUint32 breakMask = aCanBreakBefore*FLAG_CAN_BREAK_BEFORE;
PRUint32 toggle = breakMask ^ (mValue & FLAG_CAN_BREAK_BEFORE);
PRUint32 breakMask = (PRUint32(aCanBreakBefore) << FLAGS_CAN_BREAK_SHIFT);
PRUint32 toggle = breakMask ^ (mValue & FLAGS_CAN_BREAK_BEFORE);
mValue ^= toggle;
return toggle;
}
@ -1797,13 +1818,15 @@ public:
CompressedGlyph& SetSimpleGlyph(PRUint32 aAdvanceAppUnits, PRUint32 aGlyph) {
NS_ASSERTION(IsSimpleAdvance(aAdvanceAppUnits), "Advance overflow");
NS_ASSERTION(IsSimpleGlyphID(aGlyph), "Glyph overflow");
mValue = (mValue & FLAG_CAN_BREAK_BEFORE) | FLAG_IS_SIMPLE_GLYPH |
mValue = (mValue & FLAGS_CAN_BREAK_BEFORE) |
FLAG_IS_SIMPLE_GLYPH |
(aAdvanceAppUnits << ADVANCE_SHIFT) | aGlyph;
return *this;
}
CompressedGlyph& SetComplex(PRBool aClusterStart, PRBool aLigatureStart,
PRUint32 aGlyphCount) {
mValue = (mValue & FLAG_CAN_BREAK_BEFORE) | FLAG_NOT_MISSING |
mValue = (mValue & FLAGS_CAN_BREAK_BEFORE) |
FLAG_NOT_MISSING |
(aClusterStart ? 0 : FLAG_NOT_CLUSTER_START) |
(aLigatureStart ? 0 : FLAG_NOT_LIGATURE_GROUP_START) |
(aGlyphCount << GLYPH_COUNT_SHIFT);
@ -1814,7 +1837,7 @@ public:
* the cluster-start flag (see bugs 618870 and 619286).
*/
CompressedGlyph& SetMissing(PRUint32 aGlyphCount) {
mValue = (mValue & (FLAG_CAN_BREAK_BEFORE | FLAG_NOT_CLUSTER_START)) |
mValue = (mValue & (FLAGS_CAN_BREAK_BEFORE | FLAG_NOT_CLUSTER_START)) |
(aGlyphCount << GLYPH_COUNT_SHIFT);
return *this;
}

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

@ -96,12 +96,12 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetPath(char **memoryPath) {
*memoryPath = strdup("gfx/d2d/surfacecache");
*memoryPath = strdup("gfx-d2d-surfacecache");
return NS_OK;
}
NS_IMETHOD GetDescription(char **desc) {
*desc = strdup("Memory used by Direct2D internal surface cache.");
*desc = strdup("Memory used by the Direct2D internal surface cache.");
return NS_OK;
}
@ -123,7 +123,7 @@ public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetPath(char **memoryPath) {
*memoryPath = strdup("gfx/d2d/surfacevram");
*memoryPath = strdup("gfx-d2d-surfacevram");
return NS_OK;
}

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

@ -43,7 +43,9 @@ VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
PARALLEL_DIRS = \
hyphenation \
locale \
locales \
lwbrk \
strres \
unicharutil \

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

@ -79,6 +79,7 @@ SHARED_LIBRARY_LIBS = \
../strres/src/$(LIB_PREFIX)strres_s.$(LIB_SUFFIX) \
../locale/src/$(LIB_PREFIX)nslocale_s.$(LIB_SUFFIX) \
../locale/src/$(LOCALE_DIR)/$(LIB_PREFIX)platlocale_s.$(LIB_SUFFIX) \
../hyphenation/src/$(HYPHENATION_DIR)/$(LIB_PREFIX)hyphenation_s.$(LIB_SUFFIX) \
$(NULL)
EXTRA_DSO_LDOPTS = \

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

@ -0,0 +1,48 @@
# ***** 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 Hyphenation Service.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Jonathan Kew <jfkthame@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 *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = hyphenation
DIRS = public src
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,53 @@
# ***** 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 Hyphenation Service.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Jonathan Kew <jfkthame@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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = hyphenation
EXPORTS = \
nsHyphenationManager.h \
nsHyphenator.h \
$(NULL)
include $(topsrcdir)/config/rules.mk

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

@ -0,0 +1,74 @@
/* ***** 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 Hyphenation Service.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Kew <jfkthame@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 ***** */
#ifndef nsHyphenationManager_h__
#define nsHyphenationManager_h__
#include "nsInterfaceHashtable.h"
#include "nsRefPtrHashtable.h"
#include "nsHashKeys.h"
class nsHyphenator;
class nsIAtom;
class nsHyphenationManager
{
public:
nsHyphenationManager();
already_AddRefed<nsHyphenator> GetHyphenator(nsIAtom *aLocale);
static nsHyphenationManager *Instance();
static void Shutdown();
private:
~nsHyphenationManager();
protected:
void LoadPatternList();
void LoadPatternListFromDir(nsIFile *aDir);
void LoadAliases();
nsInterfaceHashtable<nsISupportsHashKey,nsIAtom> mHyphAliases;
nsInterfaceHashtable<nsISupportsHashKey,nsIFile> mPatternFiles;
nsRefPtrHashtable<nsISupportsHashKey,nsHyphenator> mHyphenators;
static nsHyphenationManager *sInstance;
};
#endif // nsHyphenationManager_h__

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

@ -0,0 +1,66 @@
/* ***** 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 Hyphenation Service.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Kew <jfkthame@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 ***** */
#ifndef nsHyphenator_h__
#define nsHyphenator_h__
#include "nsCOMPtr.h"
#include "nsString.h"
#include "nsTArray.h"
class nsIUGenCategory;
class nsHyphenator
{
public:
nsHyphenator(nsIFile *aFile);
NS_INLINE_DECL_REFCOUNTING(nsHyphenator)
PRBool IsValid();
nsresult Hyphenate(const nsAString& aText, nsTArray<PRPackedBool>& aHyphens);
private:
~nsHyphenator();
protected:
void *mDict;
nsCOMPtr<nsIUGenCategory> mCategories;
};
#endif // nsHyphenator_h__

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

@ -0,0 +1,17 @@
GPL 2.0/LGPL 2.1/MPL 1.1 tri-license
The contents of this software may be used under the terms 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",
see COPYING.LGPL) or the Mozilla Public License Version 1.1 or later
(the "MPL", see COPYING.MPL).
The Plain TeX hyphenation tables "hyphen.tex" by Donald E. Knuth
has a non MPL/LGPL compatible license, but freely redistributable:
"Unlimited copying and redistribution of this file are permitted as long
as this file is not modified. Modifications are permitted, but only if
the resulting file is not named hyphen.tex."
Software distributed under these licenses is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the licences
for the specific language governing rights and limitations under the licenses.

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

@ -0,0 +1,515 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations
below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
^L
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
^L
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control
compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
^L
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
^L
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
^L
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
^L
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply, and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding those
countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
^L
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS
^L
How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms
of the ordinary General Public License).
To apply these terms, attach the following notices to the library.
It is safest to attach them to the start of each source file to most
effectively convey the exclusion of warranty; and each file should
have at least the "copyright" line and a pointer to where the full
notice is found.
<one line to give the library's name and a brief idea of what it
does.>
Copyright (C) <year> <name of author>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper
mail.
You should also get your employer (if you work as a programmer) or
your
school, if any, to sign a "copyright disclaimer" for the library, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
library `Frob' (a library for tweaking knobs) written by James
Random Hacker.
<signature of Ty Coon>, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

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

@ -0,0 +1,470 @@
MOZILLA PUBLIC LICENSE
Version 1.1
---------------
1. Definitions.
1.0.1. "Commercial Use" means distribution or otherwise making the
Covered Code available to a third party.
1.1. "Contributor" means each entity that creates or contributes to
the creation of Modifications.
1.2. "Contributor Version" means the combination of the Original
Code, prior Modifications used by a Contributor, and the Modifications
made by that particular Contributor.
1.3. "Covered Code" means the Original Code or Modifications or the
combination of the Original Code and Modifications, in each case
including portions thereof.
1.4. "Electronic Distribution Mechanism" means a mechanism generally
accepted in the software development community for the electronic
transfer of data.
1.5. "Executable" means Covered Code in any form other than Source
Code.
1.6. "Initial Developer" means the individual or entity identified
as the Initial Developer in the Source Code notice required by Exhibit
A.
1.7. "Larger Work" means a work which combines Covered Code or
portions thereof with code not governed by the terms of this License.
1.8. "License" means this document.
1.8.1. "Licensable" means having the right to grant, to the maximum
extent possible, whether at the time of the initial grant or
subsequently acquired, any and all of the rights conveyed herein.
1.9. "Modifications" means any addition to or deletion from the
substance or structure of either the Original Code or any previous
Modifications. When Covered Code is released as a series of files, a
Modification is:
A. Any addition to or deletion from the contents of a file
containing Original Code or previous Modifications.
B. Any new file that contains any part of the Original Code or
previous Modifications.
1.10. "Original Code" means Source Code of computer software code
which is described in the Source Code notice required by Exhibit A as
Original Code, and which, at the time of its release under this
License is not already Covered Code governed by this License.
1.10.1. "Patent Claims" means any patent claim(s), now owned or
hereafter acquired, including without limitation, method, process,
and apparatus claims, in any patent Licensable by grantor.
1.11. "Source Code" means the preferred form of the Covered Code for
making modifications to it, including all modules it contains, plus
any associated interface definition files, scripts used to control
compilation and installation of an Executable, or source code
differential comparisons against either the Original Code or another
well known, available Covered Code of the Contributor's choice. The
Source Code can be in a compressed or archival form, provided the
appropriate decompression or de-archiving software is widely available
for no charge.
1.12. "You" (or "Your") means an individual or a legal entity
exercising rights under, and complying with all of the terms of, this
License or a future version of this License issued under Section 6.1.
For legal entities, "You" includes any entity which controls, is
controlled by, or is under common control with You. For purposes of
this definition, "control" means (a) the power, direct or indirect,
to cause the direction or management of such entity, whether by
contract or otherwise, or (b) ownership of more than fifty percent
(50%) of the outstanding shares or beneficial ownership of such
entity.
2. Source Code License.
2.1. The Initial Developer Grant.
The Initial Developer hereby grants You a world-wide, royalty-free,
non-exclusive license, subject to third party intellectual property
claims:
(a) under intellectual property rights (other than patent or
trademark) Licensable by Initial Developer to use, reproduce,
modify, display, perform, sublicense and distribute the Original
Code (or portions thereof) with or without Modifications, and/or
as part of a Larger Work; and
(b) under Patents Claims infringed by the making, using or
selling of Original Code, to make, have made, use, practice,
sell, and offer for sale, and/or otherwise dispose of the
Original Code (or portions thereof).
(c) the licenses granted in this Section 2.1(a) and (b) are
effective on the date Initial Developer first distributes
Original Code under the terms of this License.
(d) Notwithstanding Section 2.1(b) above, no patent license is
granted: 1) for code that You delete from the Original Code; 2)
separate from the Original Code; or 3) for infringements caused
by: i) the modification of the Original Code or ii) the
combination of the Original Code with other software or devices.
2.2. Contributor Grant.
Subject to third party intellectual property claims, each Contributor
hereby grants You a world-wide, royalty-free, non-exclusive license
(a) under intellectual property rights (other than patent or
trademark) Licensable by Contributor, to use, reproduce, modify,
display, perform, sublicense and distribute the Modifications
created by such Contributor (or portions thereof) either on an
unmodified basis, with other Modifications, as Covered Code
and/or as part of a Larger Work; and
(b) under Patent Claims infringed by the making, using, or
selling of Modifications made by that Contributor either alone
and/or in combination with its Contributor Version (or portions
of such combination), to make, use, sell, offer for sale, have
made, and/or otherwise dispose of: 1) Modifications made by that
Contributor (or portions thereof); and 2) the combination of
Modifications made by that Contributor with its Contributor
Version (or portions of such combination).
(c) the licenses granted in Sections 2.2(a) and 2.2(b) are
effective on the date Contributor first makes Commercial Use of
the Covered Code.
(d) Notwithstanding Section 2.2(b) above, no patent license is
granted: 1) for any code that Contributor has deleted from the
Contributor Version; 2) separate from the Contributor Version;
3) for infringements caused by: i) third party modifications of
Contributor Version or ii) the combination of Modifications made
by that Contributor with other software (except as part of the
Contributor Version) or other devices; or 4) under Patent Claims
infringed by Covered Code in the absence of Modifications made by
that Contributor.
3. Distribution Obligations.
3.1. Application of License.
The Modifications which You create or to which You contribute are
governed by the terms of this License, including without limitation
Section 2.2. The Source Code version of Covered Code may be
distributed only under the terms of this License or a future version
of this License released under Section 6.1, and You must include a
copy of this License with every copy of the Source Code You
distribute. You may not offer or impose any terms on any Source Code
version that alters or restricts the applicable version of this
License or the recipients' rights hereunder. However, You may include
an additional document offering the additional rights described in
Section 3.5.
3.2. Availability of Source Code.
Any Modification which You create or to which You contribute must be
made available in Source Code form under the terms of this License
either on the same media as an Executable version or via an accepted
Electronic Distribution Mechanism to anyone to whom you made an
Executable version available; and if made available via Electronic
Distribution Mechanism, must remain available for at least twelve (12)
months after the date it initially became available, or at least six
(6) months after a subsequent version of that particular Modification
has been made available to such recipients. You are responsible for
ensuring that the Source Code version remains available even if the
Electronic Distribution Mechanism is maintained by a third party.
3.3. Description of Modifications.
You must cause all Covered Code to which You contribute to contain a
file documenting the changes You made to create that Covered Code and
the date of any change. You must include a prominent statement that
the Modification is derived, directly or indirectly, from Original
Code provided by the Initial Developer and including the name of the
Initial Developer in (a) the Source Code, and (b) in any notice in an
Executable version or related documentation in which You describe the
origin or ownership of the Covered Code.
3.4. Intellectual Property Matters
(a) Third Party Claims.
If Contributor has knowledge that a license under a third party's
intellectual property rights is required to exercise the rights
granted by such Contributor under Sections 2.1 or 2.2,
Contributor must include a text file with the Source Code
distribution titled "LEGAL" which describes the claim and the
party making the claim in sufficient detail that a recipient will
know whom to contact. If Contributor obtains such knowledge after
the Modification is made available as described in Section 3.2,
Contributor shall promptly modify the LEGAL file in all copies
Contributor makes available thereafter and shall take other steps
(such as notifying appropriate mailing lists or newsgroups)
reasonably calculated to inform those who received the Covered
Code that new knowledge has been obtained.
(b) Contributor APIs.
If Contributor's Modifications include an application programming
interface and Contributor has knowledge of patent licenses which
are reasonably necessary to implement that API, Contributor must
also include this information in the LEGAL file.
(c) Representations.
Contributor represents that, except as disclosed pursuant to
Section 3.4(a) above, Contributor believes that Contributor's
Modifications are Contributor's original creation(s) and/or
Contributor has sufficient rights to grant the rights conveyed by
this License.
3.5. Required Notices.
You must duplicate the notice in Exhibit A in each file of the Source
Code. If it is not possible to put such notice in a particular Source
Code file due to its structure, then You must include such notice in a
location (such as a relevant directory) where a user would be likely
to look for such a notice. If You created one or more Modification(s)
You may add your name as a Contributor to the notice described in
Exhibit A. You must also duplicate this License in any documentation
for the Source Code where You describe recipients' rights or ownership
rights relating to Covered Code. You may choose to offer, and to
charge a fee for, warranty, support, indemnity or liability
obligations to one or more recipients of Covered Code. However, You
may do so only on Your own behalf, and not on behalf of the Initial
Developer or any Contributor. You must make it absolutely clear than
any such warranty, support, indemnity or liability obligation is
offered by You alone, and You hereby agree to indemnify the Initial
Developer and every Contributor for any liability incurred by the
Initial Developer or such Contributor as a result of warranty,
support, indemnity or liability terms You offer.
3.6. Distribution of Executable Versions.
You may distribute Covered Code in Executable form only if the
requirements of Section 3.1-3.5 have been met for that Covered Code,
and if You include a notice stating that the Source Code version of
the Covered Code is available under the terms of this License,
including a description of how and where You have fulfilled the
obligations of Section 3.2. The notice must be conspicuously included
in any notice in an Executable version, related documentation or
collateral in which You describe recipients' rights relating to the
Covered Code. You may distribute the Executable version of Covered
Code or ownership rights under a license of Your choice, which may
contain terms different from this License, provided that You are in
compliance with the terms of this License and that the license for the
Executable version does not attempt to limit or alter the recipient's
rights in the Source Code version from the rights set forth in this
License. If You distribute the Executable version under a different
license You must make it absolutely clear that any terms which differ
from this License are offered by You alone, not by the Initial
Developer or any Contributor. You hereby agree to indemnify the
Initial Developer and every Contributor for any liability incurred by
the Initial Developer or such Contributor as a result of any such
terms You offer.
3.7. Larger Works.
You may create a Larger Work by combining Covered Code with other code
not governed by the terms of this License and distribute the Larger
Work as a single product. In such a case, You must make sure the
requirements of this License are fulfilled for the Covered Code.
4. Inability to Comply Due to Statute or Regulation.
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Code due to
statute, judicial order, or regulation then You must: (a) comply with
the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description
must be included in the LEGAL file described in Section 3.4 and must
be included with all distributions of the Source Code. Except to the
extent prohibited by statute or regulation, such description must be
sufficiently detailed for a recipient of ordinary skill to be able to
understand it.
5. Application of this License.
This License applies to code to which the Initial Developer has
attached the notice in Exhibit A and to related Covered Code.
6. Versions of the License.
6.1. New Versions.
Netscape Communications Corporation ("Netscape") may publish revised
and/or new versions of the License from time to time. Each version
will be given a distinguishing version number.
6.2. Effect of New Versions.
Once Covered Code has been published under a particular version of the
License, You may always continue to use it under the terms of that
version. You may also choose to use such Covered Code under the terms
of any subsequent version of the License published by Netscape. No one
other than Netscape has the right to modify the terms applicable to
Covered Code created under this License.
6.3. Derivative Works.
If You create or use a modified version of this License (which you may
only do in order to apply it to code which is not already Covered Code
governed by this License), You must (a) rename Your license so that
the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
"MPL", "NPL" or any confusingly similar phrase do not appear in your
license (except to note that your license differs from this License)
and (b) otherwise make it clear that Your version of the license
contains terms which differ from the Mozilla Public License and
Netscape Public License. (Filling in the name of the Initial
Developer, Original Code or Contributor in the notice described in
Exhibit A shall not of themselves be deemed to be modifications of
this License.)
7. DISCLAIMER OF WARRANTY.
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
8. TERMINATION.
8.1. This License and the rights granted hereunder will terminate
automatically if You fail to comply with terms herein and fail to cure
such breach within 30 days of becoming aware of the breach. All
sublicenses to the Covered Code which are properly granted shall
survive any termination of this License. Provisions which, by their
nature, must remain in effect beyond the termination of this License
shall survive.
8.2. If You initiate litigation by asserting a patent infringement
claim (excluding declatory judgment actions) against Initial Developer
or a Contributor (the Initial Developer or Contributor against whom
You file such action is referred to as "Participant") alleging that:
(a) such Participant's Contributor Version directly or indirectly
infringes any patent, then any and all rights granted by such
Participant to You under Sections 2.1 and/or 2.2 of this License
shall, upon 60 days notice from Participant terminate prospectively,
unless if within 60 days after receipt of notice You either: (i)
agree in writing to pay Participant a mutually agreeable reasonable
royalty for Your past and future use of Modifications made by such
Participant, or (ii) withdraw Your litigation claim with respect to
the Contributor Version against such Participant. If within 60 days
of notice, a reasonable royalty and payment arrangement are not
mutually agreed upon in writing by the parties or the litigation claim
is not withdrawn, the rights granted by Participant to You under
Sections 2.1 and/or 2.2 automatically terminate at the expiration of
the 60 day notice period specified above.
(b) any software, hardware, or device, other than such Participant's
Contributor Version, directly or indirectly infringes any patent, then
any rights granted to You by such Participant under Sections 2.1(b)
and 2.2(b) are revoked effective as of the date You first made, used,
sold, distributed, or had made, Modifications made by that
Participant.
8.3. If You assert a patent infringement claim against Participant
alleging that such Participant's Contributor Version directly or
indirectly infringes any patent where such claim is resolved (such as
by license or settlement) prior to the initiation of patent
infringement litigation, then the reasonable value of the licenses
granted by such Participant under Sections 2.1 or 2.2 shall be taken
into account in determining the amount or value of any payment or
license.
8.4. In the event of termination under Sections 8.1 or 8.2 above,
all end user license agreements (excluding distributors and resellers)
which have been validly granted by You or any distributor hereunder
prior to termination shall survive termination.
9. LIMITATION OF LIABILITY.
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
(INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
10. U.S. GOVERNMENT END USERS.
The Covered Code is a "commercial item," as that term is defined in
48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
software" and "commercial computer software documentation," as such
terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
all U.S. Government End Users acquire Covered Code with only those
rights set forth herein.
11. MISCELLANEOUS.
This License represents the complete agreement concerning subject
matter hereof. If any provision of this License is held to be
unenforceable, such provision shall be reformed only to the extent
necessary to make it enforceable. This License shall be governed by
California law provisions (except to the extent applicable law, if
any, provides otherwise), excluding its conflict-of-law provisions.
With respect to disputes in which at least one party is a citizen of,
or an entity chartered or registered to do business in the United
States of America, any litigation relating to this License shall be
subject to the jurisdiction of the Federal Courts of the Northern
District of California, with venue lying in Santa Clara County,
California, with the losing party responsible for costs, including
without limitation, court costs and reasonable attorneys' fees and
expenses. The application of the United Nations Convention on
Contracts for the International Sale of Goods is expressly excluded.
Any law or regulation which provides that the language of a contract
shall be construed against the drafter shall not apply to this
License.
12. RESPONSIBILITY FOR CLAIMS.
As between Initial Developer and the Contributors, each party is
responsible for claims and damages arising, directly or indirectly,
out of its utilization of rights under this License and You agree to
work with Initial Developer and Contributors to distribute such
responsibility on an equitable basis. Nothing herein is intended or
shall be deemed to constitute any admission of liability.
13. MULTIPLE-LICENSED CODE.
Initial Developer may designate portions of the Covered Code as
"Multiple-Licensed". "Multiple-Licensed" means that the Initial
Developer permits you to utilize portions of the Covered Code under
Your choice of the NPL or the alternative licenses, if any, specified
by the Initial Developer in the file described in Exhibit A.
EXHIBIT A -Mozilla Public License.
``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 ______________________________________.
The Initial Developer of the Original Code is ________________________.
Portions created by ______________________ are Copyright (C) ______
_______________________. All Rights Reserved.
Contributor(s): ______________________________________.
Alternatively, the contents of this file may be used under the terms
of the _____ license (the "[___] License"), in which case the
provisions of [______] License are applicable instead of those
above. If you wish to allow use of your version of this file only
under the terms of the [____] License and not to allow others to use
your version of this file under the MPL, indicate your decision by
deleting the provisions above and replace them with the notice and
other provisions required by the [___] License. If you do not delete
the provisions above, a recipient may use your version of this file
under either the MPL or the [___] License."
[NOTE: The text of this Exhibit A may differ slightly from the text of
the notices in the Source Code files of the Original Code. You should
use the text of this Exhibit A rather than the text found in the
Original Code Source Code for Your Modifications.]

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

@ -0,0 +1,56 @@
# ***** 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 Hyphenation Service.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Jonathan Kew <jfkthame@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 *****
DEPTH = ../../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
include $(DEPTH)/config/autoconf.mk
MODULE = hyphenation
LIBRARY_NAME = hyphenation_s
LIBXUL_LIBRARY = 1
CSRCS = hyphen.c \
$(NULL)
CPPSRCS = nsHyphenator.cpp \
nsHyphenationManager.cpp \
$(NULL)
include $(topsrcdir)/config/rules.mk

127
intl/hyphenation/src/README Normal file
Просмотреть файл

@ -0,0 +1,127 @@
Hyphen - hyphenation library to use converted TeX hyphenation patterns
(C) 1998 Raph Levien
(C) 2001 ALTLinux, Moscow
(C) 2006, 2007, 2008, 2010 László Németh
This was part of libHnj library by Raph Levien.
Peter Novodvorsky from ALTLinux cut hyphenation part from libHnj
to use it in OpenOffice.org.
Compound word and non-standard hyphenation support by László Németh.
License is the original LibHnj license:
LibHnj is dual licensed under LGPL and MPL (see also README.libhnj).
Because LGPL allows GPL relicensing, COPYING contains now
LGPL/GPL/MPL tri-license for explicit Mozilla source compatibility.
Original Libhnj source with OOo's patches are managed by Rene Engelhard
and Chris Halls at Debian:
http://packages.debian.org/stable/libdevel/libhnj-dev
and http://packages.debian.org/unstable/source/libhnj
OTHER FILES
This distribution is the source of the en_US hyphenation patterns
"hyph_en_US.dic", too. See README_hyph_en_US.txt.
Source files of hyph_en_US.dic in the distribution:
hyphen.tex (en_US hyphenation patterns from plain TeX)
Source: http://tug.ctan.org/text-archive/macros/plain/base/hyphen.tex
tbhyphext.tex: hyphenation exception log from TugBoat archive
Source of the hyphenation exception list:
http://www.ctan.org/tex-archive/info/digests/tugboat/tb0hyf.tex
Generated with the hyphenex script
(http://www.ctan.org/tex-archive/info/digests/tugboat/hyphenex.sh)
sh hyphenex.sh <tb0hyf.tex >tbhyphext.tex
INSTALLATION
./configure
make
make install
UNIT TESTS (WITH VALGRIND DEBUGGER)
make check
VALGRIND=memcheck make check
USAGE
./example hyph_en_US.dic mywords.txt
or (under Linux)
echo example | ./example hyph_en_US.dic /dev/stdin
NOTE: In the case of Unicode encoded input, convert your words
to lowercase before hyphenation (under UTF-8 console environment):
cat mywords.txt | awk '{print tolower($0)}' >mywordslow.txt
DEVELOPMENT
See README.hyphen for hyphenation algorithm, README.nonstandard
and doc/tb87nemeth.pdf for non-standard hyphenation,
README.compound for compound word hyphenation, and tests/*.
Description of the dictionary format:
First line contains the character encoding (ISO8859-x, UTF-8).
Possible options in the following lines:
LEFTHYPHENMIN num minimal hyphenation distance from the left word end
RIGHTHYPHENMIN num minimal hyphation distance from the right word end
COMPOUNDLEFTHYPHENMIN num min. hyph. dist. from the left compound word boundary
COMPOUNDRIGHTHYPHENMIN num min. hyph. dist. from the right comp. word boundary
hyphenation patterns see README.* files
NEXTWORD separate the two compound sets (see README.compound)
Default values:
Without explicite declarations, hyphenmin fields of dict struct
are zeroes, but in this case the lefthyphenmin and righthyphenmin
will be the default 2 under the hyphenation (for backward compatibility).
Comments
Use percent sign at the beginning of the lines to add comments to your
hpyhenation patterns (after the character encoding in the first line):
% comment
*****************************************************************************
* Warning! Correct working of Libhnj *needs* prepared hyphenation patterns. *
For example, generating hyph_en_US.dic from "hyphen.us" TeX patterns:
perl substrings.pl hyphen.us hyph_en_US.dic ISO8859-1
or with default LEFTHYPHENMIN and RIGHTHYPHENMIN values:
perl substrings.pl hyphen.us hyph_en_US.dic ISO8859-1 2 3
perl substrings.pl hyphen.gb hyph_en_GB.dic ISO8859-1 3 3
****************************************************************************
OTHERS
Java hyphenation: Peter B. West (Folio project) implements a hyphenator with
non standard hyphenation facilities based on extended Libhnj. The HyFo module
is released in binary form as jar files and in source form as zip files.
See http://sourceforge.net/project/showfiles.php?group_id=119136
László Németh
<nemeth (at) openoffice (dot) org>

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

@ -0,0 +1,77 @@
New option of Libhyphen 2.7: NOHYPHEN
Hyphen, apostrophe and other characters may be word boundary characters,
but they don't need (extra) hyphenation. With NOHYPHEN option
it's possible to hyphenate the words parts correctly.
Example:
ISO8859-1
NOHYPHEN -,'
1-1
1'1
NEXTLEVEL
Description:
1-1 and 1'1 declare hyphen and apostrophe as word boundary characters
and NOHYPHEN with the comma separated character (or character sequence)
list forbid the (extra) hyphens at the hyphen and apostrophe characters.
Compound word hyphenation
Hyphen library supports better compound word hyphenation and special
rules of compound word hyphenation of German languages and other
languages with arbitrary number of compound words. The new options,
COMPOUNDLEFTHYPHENMIN and COMPOUNDRIGHTHYPHENMIN help to set the right
style for the hyphenation of compound words.
Algorithm
The algorithm is an extension of the original pattern based hyphenation
algorithm. It uses two hyphenation pattern sets, defined in the same
pattern file and separated by the NEXTLEVEL keyword. First pattern
set is for hyphenation only at compound word boundaries, the second one
is for hyphenation within words or word parts.
Recursive compound level hyphenation
The algorithm is recursive: every word parts of a successful
first (compound) level hyphenation will be rehyphenated
by the same (first) pattern set.
Finally, when first level hyphenation is not possible, Hyphen uses
the second level hyphenation for the word or the word parts.
Word endings and word parts
Patterns for word endings (patterns with ellipses) match the
word parts, too.
Options
COMPOUNDLEFTHYPHENMIN: min. hyph. dist. from the left compound word boundary
COMPOUNDRIGHTHYPHENMIN: min. hyph. dist. from the right comp. word boundary
NEXTLEVEL: sign second level hyphenation patterns
Default hyphenmin values
Default values of COMPOUNDLEFTHYPHENMIN and COMPOUNDRIGHTHYPHENMIN are 0,
and 0 under the hyphenation, too. ("0" values of
LEFTHYPHENMIN and RIGHTHYPHENMIN mean the default "2" under the hyphenation.)
Examples
See tests/compound* test files.
Preparation of hyphenation patterns
It hasn't been special pattern generator tool for compound hyphenation
patterns, yet. It is possible to use PATGEN to generate both of
pattern sets, concatenate it manually and set the requested HYPHENMIN values.
(But don't forget the preprocessing steps by substrings.pl before
concatenation.) One of the disadvantage of this method, that PATGEN
doesn't know recursive compound hyphenation of Hyphen.
László Németh
<nemeth (at) openoffice.org>

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

@ -0,0 +1,108 @@
Brief explanation of the hyphenation algorithm herein.[1]
Raph Levien <raph@acm.org>
4 Aug 1998
The hyphenation algorithm is basically the same as Knuth's TeX
algorithm. However, the implementation is quite a bit faster.
The hyphenation files from TeX can almost be used directly. There
is a preprocessing step, however. If you don't do the preprocessing
step, you'll get bad hyphenations (i.e. a silent failure).
Start with a file such as hyphen.us. This is the TeX ushyph1.tex
file, with the exception dictionary encoded using the same rules as
the main portion of the file. Any line beginning with % is a comment.
Each other line should contain exactly one rule.
Then, do the preprocessing - "perl substrings.pl hyphen.us". The
resulting file is hyphen.mashed. It's in Perl, and it's fairly slow
(it uses brute force algorithms; about 17 seconds on a P100), but it
could probably be redone in C with clever algorithms. This would be
valuable, for example, if it was handle user-supplied exception
dictionaries by integrating them into the rule table.[2]
Once the rules are preprocessed, loading them is quite quick -
about 200ms on a P100. It then hyphenates at about 40,000 words per
second on a P100. I haven't benchmarked it against other
implementations (both TeX and groff contain essentially the same
algorithm), but expect that it runs quite a bit faster than any of
them.
Knuth's algorithm
This section contains a brief explanation of Knuth's algorithm, in
case you missed it from the TeX books. We'll use the semi-word
"example" as our running example.
Since the beginning and end of a word are special, the algorithm is
actually run over the prepared word (prep_word in the source)
".example.". Knuths algorithm basically just does pattern matches from
the rule set, then applies the matches. The patterns in this case that
match are "xa", "xam", "mp", and "pl". These are actually stored as
"x1a", "xam3", "4m1p", and "1p2l2". Whenever numbers appear between
the letters, they are added in. If two (or more) patterns have numbers
in the same place, the highest number wins. Here's the example:
. e x a m p l e .
x1a
x a m3
4m1p
1p2l2
-----------------
. e x1a4m3p2l2e .
Finally, hyphens are placed wherever odd numbers appear. They are,
however, suppressed after the first letter and before the last letter
of the word (TeX actually suppresses them before the next-to-last, as
well). So, it's "ex-am-ple", which is correct.
Knuth uses a trie to implement this. I.e. he stores each rule in a
trie structure. For each position in the word, he searches the trie,
searching for a match. Most patterns are short, so efficiency should
be quite good.
Theory of the algorithm
The algorithm works as a slightly modified finite state machine.
There are two kinds of transitions: those that consume one letter of
input (which work just like your regular finite state machine), and
"fallback" transitions, which don't consume any input. If no
transition matching the next letter is found, the fallback is used.
One way of looking at this is a form of compression of the transition
tables - i.e. it behaves the same as a completely vanilla state
machine in which the actual transition table of a node is made up of
the union of transition tables of the node itself, plus its fallbacks.
Each state is represented by a string. Thus, if the current state
is "am" and the next letter is "p", then the next state is "amp".
Fallback transitions go to states which chop off one or (sometimes)
more letters from the beginning. For example, if none of the
transitions from "amp" match the next letter, then it will fall back
to "mp". Similarly, if none of the transitions from "mp" match the
next letter, it will fall back to "m".
Each state is also associated with a (possibly null) "match"
string. This represents the union of all patterns which are
right-justified substrings of the match string. I.e. the pattern "mp"
is a right-justified substring of the state "amp", so it's numbers get
added in. The actual calculation of this union is done by the
Perl preprocessing script, but could probably be done in C just about
as easily.
Because each state transition either consumes one input character
or shortens the state string by one character, the total number of
state transitions is linear in the length of the word.
[1] Documentations:
Franklin M. Liang: Word Hy-phen-a-tion by Com-put-er.
Stanford University, 1983. http://www.tug.org/docs/liang.
László Németh: Automatic non-standard hyphenation in OpenOffice.org,
TUGboat (27), 2006. No. 2., http://hunspell.sourceforge.net/tb87nemeth.pdf
[2] There is the C version of pattern converter "substrings.c"
in the distribution written by Nanning Buitenhuis. Unfortunatelly,
this version hasn't handled the non standard extension of the
algorithm, yet.

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

@ -0,0 +1,122 @@
Non-standard hyphenation
------------------------
Some languages use non-standard hyphenation; `discretionary'
character changes at hyphenation points. For example,
Catalan: paral·lel -> paral-lel,
Dutch: omaatje -> oma-tje,
German (before the new orthography): Schiffahrt -> Schiff-fahrt,
Hungarian: asszonnyal -> asz-szony-nyal (multiple occurance!)
Swedish: tillata -> till-lata.
Using this extended library, you can define
non-standard hyphenation patterns. For example:
l·1l/l=l
a1atje./a=t,1,3
.schif1fahrt/ff=f,5,2
.as3szon/sz=sz,2,3
n1nyal./ny=ny,1,3
.til1lata./ll=l,3,2
or with narrow boundaries:
l·1l/l=,1,2
a1atje./a=,1,1
.schif1fahrt/ff=,5,1
.as3szon/sz=,2,1
n1nyal./ny=,1,1
.til1lata./ll=,3,1
Note: Libhnj uses modified patterns by preparing substrings.pl.
Unfortunatelly, now the conversion step can generate bad non-standard
patterns (non-standard -> standard pattern conversion), so using
narrow boundaries may be better for recent Libhnj. For example,
substrings.pl generates a few bad patterns for Hungarian hyphenation
patterns resulting bad non-standard hyphenation in a few cases. Using narrow
boundaries solves this problem. Java HyFo module can check this problem.
Syntax of the non-standard hyphenation patterns
------------------------------------------------
pat1tern/change[,start,cut]
If this pattern matches the word, and this pattern win (see README.hyphen)
in the change region of the pattern, then pattern[start, start + cut - 1]
substring will be replaced with the "change".
For example, a German ff -> ff-f hyphenation:
f1f/ff=f
or with expansion
f1f/ff=f,1,2
will change every "ff" with "ff=f" at hyphenation.
A more real example:
% simple ff -> f-f hyphenation
f1f
% Schiffahrt -> Schiff-fahrt hyphenation
%
schif3fahrt/ff=f,5,2
Specification
- Pattern: matching patterns of the original Liang's algorithm
- patterns must contain only one hyphenation point at change region
signed with an one-digit odd number (1, 3, 5, 7 or 9).
These point may be at subregion boundaries: schif3fahrt/ff=,5,1
- only the greater value guarantees the win (don't mix non-standard and
non-standard patterns with the same value, for example
instead of f3f and schif3fahrt/ff=f,5,2 use f3f and schif5fahrt/ff=f,5,2)
- Change: new characters.
Arbitrary character sequence. Equal sign (=) signs hyphenation points
for OpenOffice.org (like in the example). (In a possible German LaTeX
preprocessor, ff could be replaced with "ff, for a Hungarian one, ssz
with `ssz, according to the German and Hungarian Babel settings.)
- Start: starting position of the change region.
- begins with 1 (not 0): schif3fahrt/ff=f,5,2
- start dot doesn't matter: .schif3fahrt/ff=f,5,2
- numbers don't matter: .s2c2h2i2f3f2ahrt/ff=f,5,2
- In UTF-8 encoding, use Unicode character positions: össze/sz=sz,2,3
("össze" looks "össze" in an ISO 8859-1 8-bit editor).
- Cut: length of the removed character sequence in the original word.
- In UTF-8 encoding, use Unicode character length: paral·1lel/l=l,5,3
("paral·lel" looks "paral·1lel" in an ISO 8859-1 8-bit editor).
Dictionary developing
---------------------
There hasn't been extended PatGen pattern generator for non-standard
hyphenation patterns, yet.
Fortunatelly, non-standard hyphenation points are forbidden in the PatGen
generated hyphenation patterns, so with a little patch can be develop
non-standard hyphenation patterns also in this case.
Warning: If you use UTF-8 Unicode encoding in your patterns, call
substrings.pl with UTF-8 parameter to calculate right
character positions for non-standard hyphenation:
./substrings.pl input output UTF-8
Programming
-----------
Use hyphenate2() or hyphenate3() to handle non-standard hyphenation.
See hyphen.h for the documentation of the hyphenate*() functions.
See example.c for processing the output of the hyphenate*() functions.
Warning: change characters are lower cased in the source, so you may need
case conversion of the change characters based on input word case detection.
For example, see OpenOffice.org source
(lingucomponent/source/hyphenator/altlinuxhyph/hyphen/hyphenimp.cxx).
László Németh
<nemeth (at) openoffice.org>

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

@ -0,0 +1,50 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** 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 Foundation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2005-2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Kew <jfkthame@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 ***** */
/*
* Simple replacement for hnjalloc.h from libhyphen-2.x, to use moz_x* memory
* allocation functions. Note that the hyphen.c code does *NOT* check for
* NULL from memory (re)allocation, so it is essential that we use the
* "infallible" moz_x* variants here.
*/
#include "mozilla/mozalloc.h"
#define hnj_malloc(size) moz_xmalloc(size)
#define hnj_realloc(p, size) moz_xrealloc(p, size)
#define hnj_free(p) moz_free(p)

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -0,0 +1,172 @@
/* Hyphen - hyphenation library using converted TeX hyphenation patterns
*
* (C) 1998 Raph Levien
* (C) 2001 ALTLinux, Moscow
* (C) 2006, 2007, 2008 László Németh
*
* This was part of libHnj library by Raph Levien.
*
* Peter Novodvorsky from ALTLinux cut hyphenation part from libHnj
* to use it in OpenOffice.org.
*
* Non-standard and compound word hyphenation support by László Németh.
*
* License is the original LibHnj license:
*
* LibHnj is dual licensed under LGPL and MPL. Boilerplate for both
* licenses follows.
*/
/* LibHnj - a library for high quality hyphenation and justification
* Copyright (C) 1998 Raph Levien
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307 USA.
*/
/*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "MPL"); you may not use this file except in
* compliance with the MPL. You may obtain a copy of the MPL at
* http://www.mozilla.org/MPL/
*
* Software distributed under the MPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the MPL
* for the specific language governing rights and limitations under the
* MPL.
*
*/
#ifndef __HYPHEN_H__
#define __HYPHEN_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
typedef struct _HyphenDict HyphenDict;
typedef struct _HyphenState HyphenState;
typedef struct _HyphenTrans HyphenTrans;
#define MAX_CHARS 100
#define MAX_NAME 20
struct _HyphenDict {
/* user options */
char lhmin; /* lefthyphenmin: min. hyph. distance from the left side */
char rhmin; /* righthyphenmin: min. hyph. distance from the right side */
char clhmin; /* min. hyph. distance from the left compound boundary */
char crhmin; /* min. hyph. distance from the right compound boundary */
char * nohyphen; /* comma separated list of characters or character
sequences with forbidden hyphenation */
int nohyphenl; /* count of elements in nohyphen */
/* system variables */
int num_states;
char cset[MAX_NAME];
int utf8;
HyphenState *states;
HyphenDict *nextlevel;
};
struct _HyphenState {
char *match;
char *repl;
signed char replindex;
signed char replcut;
int fallback_state;
int num_trans;
HyphenTrans *trans;
};
struct _HyphenTrans {
char ch;
int new_state;
};
HyphenDict *hnj_hyphen_load (const char *fn);
void hnj_hyphen_free (HyphenDict *dict);
/* obsolete, use hnj_hyphen_hyphenate2() or *hyphenate3() functions) */
int hnj_hyphen_hyphenate (HyphenDict *dict,
const char *word, int word_size,
char *hyphens);
/*
int hnj_hyphen_hyphenate2(): non-standard hyphenation.
(It supports Catalan, Dutch, German, Hungarian, Norwegian, Swedish
etc. orthography, see documentation.)
input data:
word: input word
word_size: byte length of the input word
hyphens: allocated character buffer (size = word_size + 5)
hyphenated_word: allocated character buffer (size ~ word_size * 2) or NULL
rep, pos, cut: pointers (point to the allocated and _zeroed_ buffers
(size=word_size) or with NULL value) or NULL
output data:
hyphens: hyphenation vector (hyphenation points signed with odd numbers)
hyphenated_word: hyphenated input word (hyphens signed with `='),
optional (NULL input)
rep: NULL (only standard hyph.), or replacements (hyphenation points
signed with `=' in replacements);
pos: NULL, or difference of the actual position and the beginning
positions of the change in input words;
cut: NULL, or counts of the removed characters of the original words
at hyphenation,
Note: rep, pos, cut are complementary arrays to the hyphens, indexed with the
character positions of the input word.
For example:
Schiffahrt -> Schiff=fahrt,
pattern: f1f/ff=f,1,2
output: rep[5]="ff=f", pos[5] = 1, cut[5] = 2
Note: hnj_hyphen_hyphenate2() can allocate rep, pos, cut (word_size
length arrays):
char ** rep = NULL;
int * pos = NULL;
int * cut = NULL;
char hyphens[MAXWORDLEN];
hnj_hyphen_hyphenate2(dict, "example", 7, hyphens, NULL, &rep, &pos, &cut);
See example in the source distribution.
*/
int hnj_hyphen_hyphenate2 (HyphenDict *dict,
const char *word, int word_size, char * hyphens,
char *hyphenated_word, char *** rep, int ** pos, int ** cut);
/* like hnj_hyphen_hyphenate2, but with hyphenmin parameters */
/* lhmin: lefthyphenmin
* rhmin: righthyphenmin
* clhmin: compoundlefthyphemin
* crhmin: compoundrighthyphenmin
* (see documentation) */
int hnj_hyphen_hyphenate3 (HyphenDict *dict,
const char *word, int word_size, char * hyphens,
char *hyphword, char *** rep, int ** pos, int ** cut,
int lhmin, int rhmin, int clhmin, int crhmin);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __HYPHEN_H__ */

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

@ -0,0 +1,256 @@
/* ***** 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 Hyphenation Service.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Kew <jfkthame@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 ***** */
#include "nsHyphenationManager.h"
#include "nsHyphenator.h"
#include "nsIAtom.h"
#include "nsIFile.h"
#include "nsIProperties.h"
#include "nsISimpleEnumerator.h"
#include "nsIDirectoryEnumerator.h"
#include "nsDirectoryServiceDefs.h"
#include "nsUnicharUtils.h"
#include "nsIPrefService.h"
#include "nsIPrefBranch.h"
#define INTL_HYPHENATIONALIAS_PREFIX "intl.hyphenation-alias."
nsHyphenationManager *nsHyphenationManager::sInstance = nsnull;
nsHyphenationManager*
nsHyphenationManager::Instance()
{
if (sInstance == nsnull) {
sInstance = new nsHyphenationManager();
}
return sInstance;
}
void
nsHyphenationManager::Shutdown()
{
delete sInstance;
}
nsHyphenationManager::nsHyphenationManager()
{
mHyphAliases.Init();
mPatternFiles.Init();
mHyphenators.Init();
LoadPatternList();
LoadAliases();
}
nsHyphenationManager::~nsHyphenationManager()
{
sInstance = nsnull;
}
already_AddRefed<nsHyphenator>
nsHyphenationManager::GetHyphenator(nsIAtom *aLocale)
{
nsRefPtr<nsHyphenator> hyph;
mHyphenators.Get(aLocale, getter_AddRefs(hyph));
if (hyph) {
return hyph.forget();
}
nsCOMPtr<nsIFile> file = mPatternFiles.Get(aLocale);
if (!file) {
nsCOMPtr<nsIAtom> alias = mHyphAliases.Get(aLocale);
if (alias) {
mHyphenators.Get(alias, getter_AddRefs(hyph));
if (hyph) {
return hyph.forget();
}
file = mPatternFiles.Get(alias);
if (file) {
aLocale = alias;
}
}
if (!file) {
// In the case of a locale such as "de-DE-1996", we try replacing
// successive trailing subtags with "-*" to find fallback patterns,
// so "de-DE-1996" -> "de-DE-*" (and then recursively -> "de-*")
nsAtomCString localeStr(aLocale);
if (StringEndsWith(localeStr, NS_LITERAL_CSTRING("-*"))) {
localeStr.Truncate(localeStr.Length() - 2);
}
PRInt32 i = localeStr.RFindChar('-');
if (i > 1) {
localeStr.Replace(i, localeStr.Length() - i, "-*");
nsCOMPtr<nsIAtom> fuzzyLocale = do_GetAtom(localeStr);
return GetHyphenator(fuzzyLocale);
} else {
return nsnull;
}
}
}
hyph = new nsHyphenator(file);
if (hyph->IsValid()) {
mHyphenators.Put(aLocale, hyph);
return hyph.forget();
}
#ifdef DEBUG
nsCString msg;
file->GetNativePath(msg);
msg.Insert("failed to load patterns from ", 0);
NS_WARNING(msg.get());
#endif
mPatternFiles.Remove(aLocale);
return nsnull;
}
void
nsHyphenationManager::LoadPatternList()
{
mPatternFiles.Clear();
mHyphenators.Clear();
nsresult rv;
nsCOMPtr<nsIProperties> dirSvc =
do_GetService(NS_DIRECTORY_SERVICE_CONTRACTID);
if (!dirSvc) {
return;
}
nsCOMPtr<nsIFile> greDir;
rv = dirSvc->Get(NS_GRE_DIR,
NS_GET_IID(nsIFile), getter_AddRefs(greDir));
if (NS_SUCCEEDED(rv)) {
greDir->AppendNative(NS_LITERAL_CSTRING("hyphenation"));
LoadPatternListFromDir(greDir);
}
nsCOMPtr<nsIFile> appDir;
rv = dirSvc->Get(NS_XPCOM_CURRENT_PROCESS_DIR,
NS_GET_IID(nsIFile), getter_AddRefs(appDir));
if (NS_SUCCEEDED(rv)) {
appDir->AppendNative(NS_LITERAL_CSTRING("hyphenation"));
PRBool equals;
if (NS_SUCCEEDED(appDir->Equals(greDir, &equals)) && !equals) {
LoadPatternListFromDir(appDir);
}
}
}
void
nsHyphenationManager::LoadPatternListFromDir(nsIFile *aDir)
{
nsresult rv;
PRBool check = PR_FALSE;
rv = aDir->Exists(&check);
if (NS_FAILED(rv) || !check) {
return;
}
rv = aDir->IsDirectory(&check);
if (NS_FAILED(rv) || !check) {
return;
}
nsCOMPtr<nsISimpleEnumerator> e;
rv = aDir->GetDirectoryEntries(getter_AddRefs(e));
if (NS_FAILED(rv)) {
return;
}
nsCOMPtr<nsIDirectoryEnumerator> files(do_QueryInterface(e));
if (!files) {
return;
}
nsCOMPtr<nsIFile> file;
while (NS_SUCCEEDED(files->GetNextFile(getter_AddRefs(file))) && file){
nsAutoString dictName;
file->GetLeafName(dictName);
NS_ConvertUTF16toUTF8 locale(dictName);
ToLowerCase(locale);
if (!StringEndsWith(locale, NS_LITERAL_CSTRING(".dic"))) {
continue;
}
if (StringBeginsWith(locale, NS_LITERAL_CSTRING("hyph_"))) {
locale.Cut(0, 5);
}
locale.SetLength(locale.Length() - 4); // strip ".dic"
for (PRUint32 i = 0; i < locale.Length(); ++i) {
if (locale[i] == '_') {
locale.Replace(i, 1, '-');
}
}
#ifdef DEBUG
printf("adding hyphenation patterns for %s: %s\n", locale.get(),
NS_ConvertUTF16toUTF8(dictName).get());
#endif
nsCOMPtr<nsIAtom> localeAtom = do_GetAtom(locale);
mPatternFiles.Put(localeAtom, file);
}
}
void
nsHyphenationManager::LoadAliases()
{
nsresult rv;
nsCOMPtr<nsIPrefBranch> prefBranch =
do_GetService(NS_PREFSERVICE_CONTRACTID, &rv);
if (NS_FAILED(rv)) {
return;
}
PRUint32 prefCount;
char **prefNames;
rv = prefBranch->GetChildList(INTL_HYPHENATIONALIAS_PREFIX,
&prefCount, &prefNames);
if (NS_SUCCEEDED(rv) && prefCount > 0) {
for (PRUint32 i = 0; i < prefCount; ++i) {
char *prefValue;
rv = prefBranch->GetCharPref(prefNames[i], &prefValue);
if (NS_SUCCEEDED(rv)) {
nsCAutoString alias(prefNames[i]);
alias.Cut(0, strlen(INTL_HYPHENATIONALIAS_PREFIX));
ToLowerCase(alias);
nsCAutoString value(prefValue);
ToLowerCase(value);
nsCOMPtr<nsIAtom> aliasAtom = do_GetAtom(alias);
nsCOMPtr<nsIAtom> valueAtom = do_GetAtom(value);
mHyphAliases.Put(aliasAtom, valueAtom);
NS_Free(prefValue);
}
}
NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(prefCount, prefNames);
}
}

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

@ -0,0 +1,147 @@
/* ***** 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 Hyphenation Service.
*
* The Initial Developer of the Original Code is
* Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Jonathan Kew <jfkthame@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 ***** */
#include "nsHyphenator.h"
#include "nsIFile.h"
#include "nsUTF8Utils.h"
#include "nsIUGenCategory.h"
#include "nsUnicharUtilCIID.h"
#include "hyphen.h"
nsHyphenator::nsHyphenator(nsIFile *aFile)
: mDict(nsnull)
{
nsCString path;
aFile->GetNativePath(path);
mDict = hnj_hyphen_load(path.get());
#ifdef DEBUG
if (mDict) {
printf("loaded hyphenation patterns from %s\n", path.get());
}
#endif
nsresult rv;
mCategories =
do_GetService(NS_UNICHARCATEGORY_CONTRACTID, &rv);
NS_ASSERTION(NS_SUCCEEDED(rv), "failed to get category service");
}
nsHyphenator::~nsHyphenator()
{
if (mDict != nsnull) {
hnj_hyphen_free((HyphenDict*)mDict);
mDict = nsnull;
}
}
PRBool
nsHyphenator::IsValid()
{
return (mDict != nsnull) && (mCategories != nsnull);
}
nsresult
nsHyphenator::Hyphenate(const nsAString& aString,
nsTArray<PRPackedBool>& aHyphens)
{
if (!aHyphens.SetLength(aString.Length())) {
return NS_ERROR_OUT_OF_MEMORY;
}
memset(aHyphens.Elements(), PR_FALSE, aHyphens.Length());
PRBool inWord = PR_FALSE;
PRUint32 wordStart = 0, wordLimit = 0;
for (PRUint32 i = 0; i < aString.Length(); i++) {
PRUnichar ch = aString[i];
nsIUGenCategory::nsUGenCategory cat = mCategories->Get(ch);
if (cat == nsIUGenCategory::kLetter || cat == nsIUGenCategory::kMark) {
if (!inWord) {
inWord = PR_TRUE;
wordStart = i;
}
wordLimit = i + 1;
if (i < aString.Length() - 1) {
continue;
}
}
if (inWord) {
NS_ConvertUTF16toUTF8 utf8(aString.BeginReading() + wordStart,
wordLimit - wordStart);
nsAutoTArray<char,200> utf8hyphens;
utf8hyphens.SetLength(utf8.Length() + 5);
char **rep = nsnull;
int *pos = nsnull;
int *cut = nsnull;
int err = hnj_hyphen_hyphenate2((HyphenDict*)mDict,
utf8.BeginReading(), utf8.Length(),
utf8hyphens.Elements(), nsnull,
&rep, &pos, &cut);
if (!err) {
PRUint32 utf16offset = wordStart;
const char *cp = utf8.BeginReading();
while (cp < utf8.EndReading()) {
if (UTF8traits::isASCII(*cp)) { // single-byte utf8 char
cp++;
utf16offset++;
} else if (UTF8traits::is2byte(*cp)) { // 2-byte sequence
cp += 2;
utf16offset++;
} else if (UTF8traits::is3byte(*cp)) { // 3-byte sequence
cp += 3;
utf16offset++;
} else { // must be a 4-byte sequence (no need to check validity,
// as this was just created with NS_ConvertUTF16toUTF8)
NS_ASSERTION(UTF8traits::is4byte(*cp), "unexpected utf8 byte");
cp += 4;
utf16offset += 2;
}
NS_ASSERTION(cp <= utf8.EndReading(), "incomplete utf8 string?");
NS_ASSERTION(utf16offset <= aString.Length(), "length mismatch?");
if (utf8hyphens[cp - utf8.BeginReading() - 1] & 0x01) {
aHyphens[utf16offset - 1] = PR_TRUE;
}
}
}
}
inWord = PR_FALSE;
}
return NS_OK;
}

61
intl/locales/Makefile.in Normal file
Просмотреть файл

@ -0,0 +1,61 @@
# ***** 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 Hyphenation Component.
#
# The Initial Developer of the Original Code is
# Mozilla Foundation.
# Portions created by the Initial Developer are Copyright (C) 2011
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
# Jonathan Kew <jfkthame@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 *****
DEPTH = ../..
topsrcdir = @top_srcdir@
srcdir = @srcdir@
VPATH = @srcdir@
relativesrcdir = intl/locales
include $(DEPTH)/config/autoconf.mk
DEFINES += -DAB_CD=$(AB_CD)
include $(topsrcdir)/config/rules.mk
PATTERN_FILES = $(strip $(wildcard $(LOCALE_SRCDIR)/hyphenation/*.dic))
ifneq ($(AB_CD),en-US)
PATTERN_FILES += $(strip $(wildcard $(srcdir)/en-US/hyphenation/*.dic))
endif
ifneq (,$(PATTERN_FILES))
libs::
$(INSTALL) $(PATTERN_FILES) $(FINAL_TARGET)/hyphenation
install::
$(SYSINSTALL) $(IFLAGS1) $(PATTERN_FILES) $(DESTDIR)$(mozappdir)/hyphenation
endif

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

@ -0,0 +1,53 @@
hyph_en_US.dic - American English hyphenation patterns for OpenOffice.org
version 2010-02-23
Changes
- set correct LEFTHYPHENMIN = 2, RIGHTHYPHENMIN = 3
- handle apostrophes (forbid *o'=clock etc.)
- set COMPOUNDLEFTHYPHENMIN, COMPOUNDRIGHTHYPHENMIN values
- UTF-8 encoding
- Unicode ligature support
License
BSD-style. Unlimited copying, redistribution and modification of this file
is permitted with this copyright and license information.
See original license in this file.
Conversion and modifications by László Németh (nemeth at OOo).
Based on the plain TeX hyphenation table
(http://tug.ctan.org/text-archive/macros/plain/base/hyphen.tex) and
the TugBoat hyphenation exceptions log in
http://www.ctan.org/tex-archive/info/digests/tugboat/tb0hyf.tex, processed
by the hyphenex.sh script (see in the same directory).
Originally developed and distributed with the Hyphen hyphenation library,
see http://hunspell.sourceforge.net/ for the source files and the conversion
scripts.
Licenses
hyphen.tex:
% The Plain TeX hyphenation tables [NOT TO BE CHANGED IN ANY WAY!]
% Unlimited copying and redistribution of this file are permitted as long
% as this file is not modified. Modifications are permitted, but only if
% the resulting file is not named hyphen.tex.
output of hyphenex.sh:
% Hyphenation exceptions for US English, based on hyphenation exception
% log articles in TUGboat.
%
% Copyright 2007 TeX Users Group.
% You may freely use, modify and/or distribute this file.
%
% This is an automatically generated file. Do not edit!
%
% Please contact the TUGboat editorial staff <tugboat@tug.org>
% for corrections and omissions.
hyph_en_US.txt:
See the previous licenses.

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -52,13 +52,15 @@ static PRInt64 GetShmemAllocated(void*) { return gShmemAllocated; }
static PRInt64 GetShmemMapped(void*) { return gShmemMapped; }
NS_MEMORY_REPORTER_IMPLEMENT(ShmemAllocated,
"shmem/allocated",
"Shmem bytes accessible (not necessarily mapped)",
"shmem-allocated",
"Memory shared with other processes that is "
"accessible (but not necessarily mapped).",
GetShmemAllocated,
nsnull)
NS_MEMORY_REPORTER_IMPLEMENT(ShmemMapped,
"shmem/mapped",
"Shmem bytes mapped into address space",
"shmem-mapped",
"Memory shared with other processes that is "
"mapped into the address space.",
GetShmemMapped,
nsnull)

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

@ -46,8 +46,6 @@
#include "base/basictypes.h"
#include "jsapi.h"
#include "jscntxt.h"
#include "jsdbgapi.h"
#include "jsprf.h"
#include "xpcpublic.h"
@ -406,13 +404,14 @@ GC(JSContext *cx,
jsval *vp)
{
JSRuntime *rt;
uint32 preBytes;
uint32 preBytes, postBytes;
rt = cx->runtime;
preBytes = rt->gcBytes;
rt = JS_GetRuntime(cx);
preBytes = JS_GetGCParameter(rt, JSGC_BYTES);
JS_GC(cx);
postBytes = JS_GetGCParameter(rt, JSGC_BYTES);
fprintf(stdout, "before %lu, after %lu, break %08lx\n",
(unsigned long)preBytes, (unsigned long)rt->gcBytes,
(unsigned long)preBytes, (unsigned long)postBytes,
#ifdef XP_UNIX
(unsigned long)sbrk(0)
#else

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

@ -40,7 +40,6 @@
#include "jscntxt.h"
#include "jsapi.h"
#include "jstl.h"
#include "jshashtable.h"
#include "mozilla/jetpack/JetpackActorCommon.h"
@ -51,15 +50,7 @@
#include "nsJSUtils.h"
using mozilla::jetpack::JetpackActorCommon;
using mozilla::jetpack::PHandleParent;
using mozilla::jetpack::HandleParent;
using mozilla::jetpack::PHandleChild;
using mozilla::jetpack::HandleChild;
using mozilla::jetpack::KeyValue;
using mozilla::jetpack::PrimVariant;
using mozilla::jetpack::CompVariant;
using mozilla::jetpack::Variant;
using namespace mozilla::jetpack;
class JetpackActorCommon::OpaqueSeenType
{
@ -176,7 +167,7 @@ JetpackActorCommon::jsval_to_CompVariant(JSContext* cx, JSType type, jsval from,
if (type != JSTYPE_OBJECT)
return false;
js::LazilyConstructed<OpaqueSeenType> lost;
Maybe<OpaqueSeenType> lost;
if (!seen) {
lost.construct();
seen = lost.addr();
@ -337,7 +328,7 @@ JetpackActorCommon::jsval_from_CompVariant(JSContext* cx,
jsval* to,
OpaqueSeenType* seen)
{
js::LazilyConstructed<OpaqueSeenType> lost;
Maybe<OpaqueSeenType> lost;
if (!seen) {
lost.construct();
seen = lost.addr();

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

@ -181,6 +181,7 @@ CPPSRCS = \
jsxml.cpp \
prmjtime.cpp \
sharkctl.cpp \
Stack.cpp \
$(NULL)
INSTALLED_HEADERS = \
@ -267,6 +268,20 @@ INSTALLED_HEADERS = \
prmjtime.h \
$(NULL)
###############################################
# BEGIN include sources for the vm subdirectory
#
VPATH += \
$(srcdir)/vm \
$(NULL)
EXPORTS_NAMESPACES = vm
EXPORTS_vm = \
Stack.h \
StringObject.h \
$(NULL)
###############################################
# BEGIN include sources for low-level code shared with Gecko
#
@ -274,9 +289,10 @@ VPATH += \
$(srcdir)/../../mfbt \
$(NULL)
EXPORTS_NAMESPACES = mozilla
EXPORTS_NAMESPACES += mozilla
EXPORTS_mozilla = \
Types.h \
Util.h \
$(NULL)
@ -636,7 +652,7 @@ check-malloc-function-usage: $(filter-out %jsalloc.h %jscntxt.h %jsutil.h, $(ALL
# We desire these numbers to go down, not up. See "User guide to memory
# management within SpiderMonkey" in jsutil.h.
$(srcdir)/config/check_source_count.py OffTheBooks:: 53 \
$(srcdir)/config/check_source_count.py OffTheBooks:: 52 \
"in Makefile.in" "{cx,rt}->{new_,new_array,malloc_,calloc_,realloc_}" $^
# This should go to zero, if possible.
$(srcdir)/config/check_source_count.py UnwantedForeground:: 34 \
@ -713,6 +729,11 @@ export::
DEFINES += -DEXPORT_JS_API
# mfbt is always packed with us, so if we're building a shared object,
# we need to declare "exported" mfbt symbols on its behalf when we use
# its headers.
DEFINES += -DIMPL_MFBT
# Some platforms that have stdint.h include it in system headers. So
# to reliably get limit macros defined, we'd always have to define the
# one below before including any header, but that's obscure and

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

@ -32,6 +32,22 @@ namespace JSC {
size_t ExecutableAllocator::pageSize = 0;
size_t ExecutableAllocator::largeAllocSize = 0;
ExecutablePool::~ExecutablePool()
{
m_allocator->releasePoolPages(this);
}
size_t
ExecutableAllocator::getCodeSize() const
{
size_t n = 0;
for (ExecPoolHashSet::Range r = m_pools.all(); !r.empty(); r.popFront()) {
ExecutablePool* pool = r.front();
n += pool->m_allocation.size;
}
return n;
}
}
#endif // HAVE(ASSEMBLER)

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

@ -31,6 +31,7 @@
#include "assembler/wtf/Assertions.h"
#include "jsapi.h"
#include "jshashtable.h"
#include "jsprvtd.h"
#include "jsvector.h"
#include "jslock.h"
@ -78,6 +79,8 @@ extern "C" void sync_instruction_memory(caddr_t v, u_int len);
namespace JSC {
class ExecutableAllocator;
// These are reference-counted. A new one starts with a count of 1.
class ExecutablePool {
@ -92,6 +95,7 @@ private:
#endif
};
ExecutableAllocator* m_allocator;
char* m_freePtr;
char* m_end;
Allocation m_allocation;
@ -126,17 +130,12 @@ private:
++m_refCount;
}
private:
ExecutablePool(Allocation a)
: m_freePtr(a.pages), m_end(m_freePtr + a.size), m_allocation(a), m_refCount(1),
m_destroy(false), m_gcNumber(0)
ExecutablePool(ExecutableAllocator* allocator, Allocation a)
: m_allocator(allocator), m_freePtr(a.pages), m_end(m_freePtr + a.size), m_allocation(a),
m_refCount(1), m_destroy(false), m_gcNumber(0)
{ }
~ExecutablePool()
{
if (m_allocation.pages)
ExecutablePool::systemRelease(m_allocation);
}
~ExecutablePool();
void* alloc(size_t n)
{
@ -150,14 +149,10 @@ private:
JS_ASSERT(m_end >= m_freePtr);
return m_end - m_freePtr;
}
// On OOM, this will return an Allocation where pages is NULL.
static Allocation systemAlloc(size_t n);
static void systemRelease(const Allocation& alloc);
};
class ExecutableAllocator {
enum ProtectionSeting { Writable, Executable };
enum ProtectionSetting { Writable, Executable };
public:
ExecutableAllocator()
@ -175,13 +170,14 @@ public:
largeAllocSize = pageSize * 16;
}
JS_ASSERT(m_smallAllocationPools.empty());
JS_ASSERT(m_smallPools.empty());
}
~ExecutableAllocator()
{
for (size_t i = 0; i < m_smallAllocationPools.length(); i++)
m_smallAllocationPools[i]->release(/* willDestroy = */true);
for (size_t i = 0; i < m_smallPools.length(); i++)
m_smallPools[i]->release(/* willDestroy = */true);
JS_ASSERT(m_pools.empty()); // if this asserts we have a pool leak
}
// alloc() returns a pointer to some memory, and also (by reference) a
@ -209,6 +205,14 @@ public:
return result;
}
void releasePoolPages(ExecutablePool *pool) {
JS_ASSERT(pool->m_allocation.pages);
systemRelease(pool->m_allocation);
m_pools.remove(m_pools.lookup(pool)); // this asserts if |pool| is not in m_pools
}
size_t getCodeSize() const;
private:
static size_t pageSize;
static size_t largeAllocSize;
@ -233,20 +237,34 @@ private:
return size;
}
// On OOM, this will return an Allocation where pages is NULL.
static ExecutablePool::Allocation systemAlloc(size_t n);
static void systemRelease(const ExecutablePool::Allocation& alloc);
ExecutablePool* createPool(size_t n)
{
size_t allocSize = roundUpAllocationSize(n, pageSize);
if (allocSize == OVERSIZE_ALLOCATION)
return NULL;
if (!m_pools.initialized() && !m_pools.init())
return NULL;
#ifdef DEBUG_STRESS_JSC_ALLOCATOR
ExecutablePool::Allocation a = ExecutablePool::systemAlloc(size_t(4294967291));
ExecutablePool::Allocation a = systemAlloc(size_t(4294967291));
#else
ExecutablePool::Allocation a = ExecutablePool::systemAlloc(allocSize);
ExecutablePool::Allocation a = systemAlloc(allocSize);
#endif
if (!a.pages)
return NULL;
return js::OffTheBooks::new_<ExecutablePool>(a);
ExecutablePool *pool = js::OffTheBooks::new_<ExecutablePool>(this, a);
if (!pool) {
systemRelease(a);
return NULL;
}
m_pools.put(pool);
return pool;
}
ExecutablePool* poolForSize(size_t n)
@ -258,8 +276,8 @@ private:
// allocation fitting in a small pool, and (b) it minimizes the
// potential waste when a small pool is next abandoned.
ExecutablePool *minPool = NULL;
for (size_t i = 0; i < m_smallAllocationPools.length(); i++) {
ExecutablePool *pool = m_smallAllocationPools[i];
for (size_t i = 0; i < m_smallPools.length(); i++) {
ExecutablePool *pool = m_smallPools[i];
if (n <= pool->available() && (!minPool || pool->available() < minPool->available()))
minPool = pool;
}
@ -279,26 +297,26 @@ private:
return NULL;
// At this point, local |pool| is the owner.
if (m_smallAllocationPools.length() < maxSmallPools) {
if (m_smallPools.length() < maxSmallPools) {
// We haven't hit the maximum number of live pools; add the new pool.
m_smallAllocationPools.append(pool);
m_smallPools.append(pool);
pool->addRef();
} else {
// Find the pool with the least space.
int iMin = 0;
for (size_t i = 1; i < m_smallAllocationPools.length(); i++)
if (m_smallAllocationPools[i]->available() <
m_smallAllocationPools[iMin]->available())
for (size_t i = 1; i < m_smallPools.length(); i++)
if (m_smallPools[i]->available() <
m_smallPools[iMin]->available())
{
iMin = i;
}
// If the new allocator will result in more free space than the small
// pool with the least space, then we will use it instead
ExecutablePool *minPool = m_smallAllocationPools[iMin];
ExecutablePool *minPool = m_smallPools[iMin];
if ((pool->available() - n) > minPool->available()) {
minPool->release();
m_smallAllocationPools[iMin] = pool;
m_smallPools[iMin] = pool;
pool->addRef();
}
}
@ -411,12 +429,21 @@ public:
private:
#if ENABLE_ASSEMBLER_WX_EXCLUSIVE
static void reprotectRegion(void*, size_t, ProtectionSeting);
static void reprotectRegion(void*, size_t, ProtectionSetting);
#endif
// These are strong references; they keep pools alive.
static const size_t maxSmallPools = 4;
typedef js::Vector<ExecutablePool *, maxSmallPools, js::SystemAllocPolicy> SmallExecPoolVector;
SmallExecPoolVector m_smallAllocationPools;
SmallExecPoolVector m_smallPools;
// All live pools are recorded here, just for stats purposes. These are
// weak references; they don't keep pools alive. When a pool is destroyed
// its reference is removed from m_pools.
typedef js::HashSet<ExecutablePool *, js::DefaultHasher<ExecutablePool *>, js::SystemAllocPolicy>
ExecPoolHashSet;
ExecPoolHashSet m_pools; // All pools, just for stats purposes.
static size_t determinePageSize();
};

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

@ -38,7 +38,7 @@ size_t ExecutableAllocator::determinePageSize()
return 4096u;
}
ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n)
ExecutablePool::Allocation ExecutableAllocator::systemAlloc(size_t n)
{
void* allocation = NULL;
if (DosAllocMem(&allocation, n, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) &&
@ -48,7 +48,7 @@ ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n)
return alloc;
}
void ExecutablePool::systemRelease(const ExecutablePool::Allocation& alloc)
void ExecutableAllocator::systemRelease(const ExecutablePool::Allocation& alloc)
{
DosFreeMem(alloc.pages);
}

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

@ -38,7 +38,7 @@ size_t ExecutableAllocator::determinePageSize()
return getpagesize();
}
ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n)
ExecutablePool::Allocation ExecutableAllocator::systemAlloc(size_t n)
{
void* allocation = mmap(NULL, n, INITIAL_PROTECTION_FLAGS, MAP_PRIVATE | MAP_ANON, VM_TAG_FOR_EXECUTABLEALLOCATOR_MEMORY, 0);
if (allocation == MAP_FAILED)
@ -47,14 +47,14 @@ ExecutablePool::Allocation ExecutablePool::systemAlloc(size_t n)
return alloc;
}
void ExecutablePool::systemRelease(const ExecutablePool::Allocation& alloc)
void ExecutableAllocator::systemRelease(const ExecutablePool::Allocation& alloc)
{
int result = munmap(alloc.pages, alloc.size);
ASSERT_UNUSED(result, !result);
}
#if WTF_ENABLE_ASSEMBLER_WX_EXCLUSIVE
void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSeting setting)
void ExecutableAllocator::reprotectRegion(void* start, size_t size, ProtectionSetting setting)
{
if (!pageSize)
intializePageSize();

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше