src/core/font.js in webfontloader-1.0.31 vs src/core/font.js in webfontloader-1.1.0
- old
+ new
@@ -1,13 +1,16 @@
/**
+ * @param {Window} mainWindow The main application window containing
+ * webfontloader.js.
+ * @param {webfont.FontModuleLoader} fontModuleLoader A loader instance to use.
+ * @param {function(function(), number=)} asyncCall An async function to use.
+ * @param {webfont.UserAgent} userAgent The detected user agent to load for.
* @constructor
*/
-webfont.WebFont = function(domHelper, fontModuleLoader, htmlElement, asyncCall,
- userAgent) {
- this.domHelper_ = domHelper;
+webfont.WebFont = function(mainWindow, fontModuleLoader, asyncCall, userAgent) {
+ this.mainWindow_ = mainWindow;
this.fontModuleLoader_ = fontModuleLoader;
- this.htmlElement_ = htmlElement;
this.asyncCall_ = asyncCall;
this.userAgent_ = userAgent;
this.moduleLoading_ = 0;
this.moduleFailedLoading_ = 0;
};
@@ -15,12 +18,15 @@
webfont.WebFont.prototype.addModule = function(name, factory) {
this.fontModuleLoader_.addModuleFactory(name, factory);
};
webfont.WebFont.prototype.load = function(configuration) {
+ var context = configuration['context'] || this.mainWindow_;
+ this.domHelper_ = new webfont.DomHelper(this.mainWindow_, context);
+
var eventDispatcher = new webfont.EventDispatcher(
- this.domHelper_, this.htmlElement_, configuration);
+ this.domHelper_, context.document.documentElement, configuration);
if (this.userAgent_.isSupportingWebFont()) {
this.load_(eventDispatcher, configuration);
} else {
eventDispatcher.dispatchInactive();
@@ -64,10 +70,10 @@
}, fontWatcher, fontFamilies, opt_fontDescriptions, opt_fontTestStrings,
fontWatchRunnerCtor, allModulesLoaded));
};
webfont.WebFont.prototype.load_ = function(eventDispatcher, configuration) {
- var modules = this.fontModuleLoader_.getModules(configuration),
+ var modules = this.fontModuleLoader_.getModules(configuration, this.domHelper_),
self = this;
this.moduleFailedLoading_ = this.moduleLoading_ = modules.length;
var fontWatcher = new webfont.FontWatcher(this.domHelper_,