Skip to content

Commit

Permalink
Add type info and other annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean McBride committed Nov 9, 2010
1 parent 5fe9ee5 commit 9d4d4ae
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/core/fontwatcher.js
@@ -1,5 +1,10 @@
/**
* @constructor
* @param {webfont.DomHelper} domHelper
* @param {webfont.EventDispatcher} eventDispatcher
* @param {Object.<string, function(Object): number>} fontSizer
* @param {function(function(), number=)} asyncCall
* @param {function(): number} getTime
*/
webfont.FontWatcher = function(domHelper, eventDispatcher, fontSizer,
asyncCall, getTime) {
Expand Down Expand Up @@ -60,12 +65,22 @@ webfont.FontWatcher.prototype.watch = function(fontFamilies, fontDescriptions,
}
};

/**
* Called by a FontWatchRunner when a font has been detected as active.
* @param {string} fontFamily
* @param {string} fontDescription
*/
webfont.FontWatcher.prototype.fontActive = function(fontFamily, fontDescription) {
this.eventDispatcher_.dispatchFontActive(fontFamily, fontDescription);
this.success_ = true;
this.decreaseCurrentlyWatched_();
};

/**
* Called by a FontWatchRunner when a font has been detected as inactive.
* @param {string} fontFamily
* @param {string} fontDescription
*/
webfont.FontWatcher.prototype.fontInactive = function(fontFamily, fontDescription) {
this.eventDispatcher_.dispatchFontInactive(fontFamily, fontDescription);
this.decreaseCurrentlyWatched_();
Expand Down
13 changes: 13 additions & 0 deletions src/core/fontwatchrunner.js
@@ -1,5 +1,13 @@
/**
* @constructor
* @param {webfont.FontWatcher} fontWatcher
* @param {webfont.DomHelper} domHelper
* @param {Object.<string, function(Object): number>} fontSizer
* @param {function(function(), number=)} asyncCall
* @param {function(): number} getTime
* @param {string} fontFamily
* @param {string} fontDescription
* @param {string=} opt_fontTestString
*/
webfont.FontWatchRunner = function(fontWatcher, domHelper, fontSizer, asyncCall,
getTime, fontFamily, fontDescription, opt_fontTestString) {
Expand Down Expand Up @@ -60,6 +68,7 @@ webfont.FontWatchRunner.DEFAULT_TEST_STRING = 'BESs';

/**
* @private
* @param {boolean=} opt_first
*/
webfont.FontWatchRunner.prototype.check_ = function(opt_first) {
var sizeA = this.fontSizer_.getWidth(this.requestedFontA_);
Expand Down Expand Up @@ -87,6 +96,7 @@ webfont.FontWatchRunner.prototype.asyncCheck_ = function() {

/**
* @private
* @param {boolean} active
*/
webfont.FontWatchRunner.prototype.finish_ = function(active) {
this.domHelper_.removeElement(this.requestedFontA_);
Expand All @@ -100,6 +110,7 @@ webfont.FontWatchRunner.prototype.finish_ = function(active) {

/**
* @private
* @param {string} defaultFonts
*/
webfont.FontWatchRunner.prototype.getDefaultFontSize_ = function(defaultFonts) {
var defaultFont = this.createHiddenElementWithFont_(defaultFonts, true);
Expand All @@ -111,6 +122,8 @@ webfont.FontWatchRunner.prototype.getDefaultFontSize_ = function(defaultFonts) {

/**
* @private
* @param {string} defaultFonts
* @param {boolean=} opt_withoutFontFamily
*/
webfont.FontWatchRunner.prototype.createHiddenElementWithFont_ = function(
defaultFonts, opt_withoutFontFamily) {
Expand Down

0 comments on commit 9d4d4ae

Please sign in to comment.