diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2015-12-15 18:52:00 +0100 |
---|---|---|
committer | Marco Cecchetti <mrcekets@gmail.com> | 2015-12-19 19:25:10 +0000 |
commit | 84dc88a0d5316802998bbcccfdd0e5c87652bfed (patch) | |
tree | ecc373e5fcee7544b9ee2a8cb9e0adf936109bd8 | |
parent | 98d108811a078aa3b49013d20612f35047741047 (diff) |
svg export: presentation engine: source code clean up
Change-Id: I83f6d524feb21197ad930180f36224feae565ab0
Reviewed-on: https://gerrit.libreoffice.org/20808
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Marco Cecchetti <mrcekets@gmail.com>
-rw-r--r-- | filter/source/svg/presentation_engine.js | 293 |
1 files changed, 135 insertions, 158 deletions
diff --git a/filter/source/svg/presentation_engine.js b/filter/source/svg/presentation_engine.js index 66509c6a3df6..56fec95c8885 100644 --- a/filter/source/svg/presentation_engine.js +++ b/filter/source/svg/presentation_engine.js @@ -75,25 +75,25 @@ * @param node element of the document * @param name attribute name * - * @returns an array containing all the elements of the tree with root + * @returns Array array containing all the elements of the tree with root * 'node' that own the property 'name' */ function getElementsByProperty( node, name ) { - var elems = new Array(); + var elements = []; if( node.getAttribute( name ) ) - elems.push( node ); + elements.push( node ); for( var counter = 0; counter < node.childNodes.length; ++counter ) { if( node.childNodes[counter].nodeType == 1 ) { - var subElems = getElementsByProperty( node.childNodes[counter], name ); - elems = elems.concat( subElems ); + var subElements = getElementsByProperty( node.childNodes[counter], name ); + elements = elements.concat( subElements ); } } - return elems; + return elements; } /** Event handler for key press. @@ -141,14 +141,14 @@ function onKeyPress( aEvt ) /** Function to supply the default key code dictionary. * - * @returns default key code dictionary + * @returns Object default key code dictionary */ function getDefaultKeyCodeDictionary() { - var keyCodeDict = new Object(); + var keyCodeDict = {}; - keyCodeDict[SLIDE_MODE] = new Object(); - keyCodeDict[INDEX_MODE] = new Object(); + keyCodeDict[SLIDE_MODE] = {}; + keyCodeDict[INDEX_MODE] = {}; // slide mode keyCodeDict[SLIDE_MODE][LEFT_KEY] @@ -199,14 +199,14 @@ function getDefaultKeyCodeDictionary() /** Function to supply the default char code dictionary. * - * @returns default char code dictionary + * @returns Object char code dictionary */ function getDefaultCharCodeDictionary() { - var charCodeDict = new Object(); + var charCodeDict = {}; - charCodeDict[SLIDE_MODE] = new Object(); - charCodeDict[INDEX_MODE] = new Object(); + charCodeDict[SLIDE_MODE] = {}; + charCodeDict[INDEX_MODE] = {}; // slide mode charCodeDict[SLIDE_MODE]['i'] @@ -390,14 +390,14 @@ function mouseClickHelper( aEvt ) /** Function to supply the default mouse handler dictionary. * - * @returns default mouse handler dictionary + * @returns Object default mouse handler dictionary */ function getDefaultMouseHandlerDictionary() { - var mouseHandlerDict = new Object(); + var mouseHandlerDict = {}; - mouseHandlerDict[SLIDE_MODE] = new Object(); - mouseHandlerDict[INDEX_MODE] = new Object(); + mouseHandlerDict[SLIDE_MODE] = {}; + mouseHandlerDict[INDEX_MODE] = {}; // slide mode mouseHandlerDict[SLIDE_MODE][MOUSE_UP] @@ -548,7 +548,7 @@ function configureDetectionTools() dav = n.appVersion, tv = parseFloat(dav); - has.add('air', dua.indexOf('AdobeAIR') >= 0), + has.add('air', dua.indexOf('AdobeAIR') >= 0); has.add('khtml', dav.indexOf('Konqueror') >= 0 ? tv : undefined); has.add('webkit', parseFloat(dua.split('WebKit/')[1]) || undefined); has.add('chrome', parseFloat(dua.split('Chrome/')[1]) || undefined); @@ -584,7 +584,7 @@ function configureDetectionTools() //Make sure isIE reflects the desired version. //document.documentMode of 5 means quirks mode. //Only switch the value if documentMode's major version - //is different from isIE's major version. + //is different from isIE major version. var mode = document.documentMode; if(mode && mode != 5 && Math.floor(isIE) != mode){ isIE = mode; @@ -720,7 +720,7 @@ function configureDetectionTools() * Several parts of the following code are the result of the porting, * started on August 2011, of the C++ code included in the source * files placed under the folder '/slideshow/source' and - * subfolders. This got later rebased onto the AL2-licensed versions + * sub-folders. This got later rebased onto the AL2-licensed versions * of those files in early 2013. * @source http://cgit.freedesktop.org/libreoffice/core/tree/slideshow/source * @@ -770,7 +770,7 @@ var aFooterClassName = 'Footer'; var aHeaderClassName = 'Header'; // Creating a namespace dictionary. -var NSS = new Object(); +var NSS = {}; NSS['svg']='http://www.w3.org/2000/svg'; NSS['rdf']='http://www.w3.org/1999/02/22-rdf-syntax-ns#'; NSS['xlink']='http://www.w3.org/1999/xlink'; @@ -790,7 +790,7 @@ var MOUSE_DOWN = 2; var MOUSE_MOVE = 3; var MOUSE_WHEEL = 4; -// Keycodes. +// Key-codes. var LEFT_KEY = 37; // cursor left keycode var UP_KEY = 38; // cursor up keycode var RIGHT_KEY = 39; // cursor right keycode @@ -874,7 +874,7 @@ function extend( aSubType, aSuperType ) function instantiate( TemplateClass, BaseType ) { if( !TemplateClass.instanceSet ) - TemplateClass.instanceSet = new Array(); + TemplateClass.instanceSet = []; var nSize = TemplateClass.instanceSet.length; @@ -884,7 +884,7 @@ function instantiate( TemplateClass, BaseType ) return TemplateClass.instanceSet[i].instance; } - TemplateClass.instanceSet[ nSize ] = new Object(); + TemplateClass.instanceSet[ nSize ] = {}; TemplateClass.instanceSet[ nSize ].base = BaseType; TemplateClass.instanceSet[ nSize ].instance = TemplateClass( BaseType ); @@ -985,7 +985,7 @@ function checkElemAndSetAttribute( aElem, sAttrName, aValue ) function getElementsByClassName( aElem, sClassName ) { - var aElementSet = new Array(); + var aElementSet = []; // not all browsers support the 'getElementsByClassName' method if( 'getElementsByClassName' in aElem ) { @@ -1215,16 +1215,16 @@ function MetaDocument() // The collections for handling properties of each slide, svg elements // related to master pages and content and properties of text fields. - this.aMetaSlideSet = new Array(); - this.aMasterPageSet = new Object(); - this.aTextFieldHandlerSet = new Object(); - this.aTextFieldContentProviderSet = new Array(); + this.aMetaSlideSet = []; + this.aMasterPageSet = {}; + this.aTextFieldHandlerSet = {}; + this.aTextFieldContentProviderSet = []; this.aSlideNumberProvider = new SlideNumberProvider( this.nStartSlideNumber + 1, this.sPageNumberingType ); // We create a map with key an id and value the svg element containing // the animations performed on the slide with such an id. this.bIsAnimated = false; - this.aSlideAnimationsMap = new Object(); + this.aSlideAnimationsMap = {}; this.initSlideAnimationsMap(); // We initialize dummy slide - used as leaving slide for transition on the first slide @@ -1386,7 +1386,7 @@ function MetaSlide( sMetaSlideId, aMetaDoc ) this.bIsDateTimeVariable = undefined; // We initialize the objects responsible to provide the content to text field. - this.aTextFieldContentProviderSet = new Object(); + this.aTextFieldContentProviderSet = {}; this.aTextFieldContentProviderSet[aSlideNumberClassName] = this.initSlideNumberFieldContentProvider(); this.aTextFieldContentProviderSet[aDateTimeClassName] = this.initDateTimeFieldContentProvider( aOOOAttrDateTimeField ); this.aTextFieldContentProviderSet[aFooterClassName] = this.initFixedTextFieldContentProvider( aOOOAttrFooterField ); @@ -1471,7 +1471,7 @@ initMasterPage : function() // We initialize aTextFieldHandlerSet[ sMasterPageId ] to an empty // collection. - this.theMetaDoc.aTextFieldHandlerSet[ sMasterPageId ] = new Object(); + this.theMetaDoc.aTextFieldHandlerSet[ sMasterPageId ] = {}; } return this.theMetaDoc.aMasterPageSet[ sMasterPageId ]; }, @@ -1549,7 +1549,7 @@ initFixedTextFieldContentProvider : function( aOOOAttribute ) collectTextShapes : function() { - var aTextShapeSet = new Array(); + var aTextShapeSet = []; var aTextShapeIndexElem = getElementByClassName( document, 'TextShapeIndex' ); if( aTextShapeIndexElem ) { @@ -1588,7 +1588,7 @@ collectTextShapes : function() initHyperlinks : function() { - var aHyperlinkSet = new Object(); + var aHyperlinkSet = {}; var i; for( i = 0; i < this.aTextShapeSet.length; ++i ) { @@ -1655,6 +1655,8 @@ getSlideAnimationsRoot : function() * @param sMasterPageId * A string representing the value of the id attribute of the master page * element to be handled. + * @param aMetaSlide + * A meta slide having as master page the one with the passed id. */ function MasterPage( sMasterPageId, aMetaSlide ) { @@ -1695,7 +1697,7 @@ function MasterPage( sMasterPageId, aMetaSlide ) var nSubGroupId = 1; var sClass; var sId = ''; - this.aBackgroundObjectSubGroupIdList = new Array(); + this.aBackgroundObjectSubGroupIdList = []; var i = 0; for( ; i < aBackgroundObjectList.length; ++i ) { @@ -1735,7 +1737,7 @@ function MasterPage( sMasterPageId, aMetaSlide ) } // We populate the collection of placeholders. - this.aPlaceholderShapeSet = new Object(); + this.aPlaceholderShapeSet = {}; this.initPlaceholderShapes(); } @@ -1978,7 +1980,7 @@ MasterPageView.prototype.createElement = function() // clone and initialize text field elements var aBackgroundObjectSubGroupIdList = this.aMasterPage.aBackgroundObjectSubGroupIdList; - this.aBackgroundSubGroupElementSet = new Array(); + this.aBackgroundSubGroupElementSet = []; var aPlaceholderShapeSet = this.aMasterPage.aPlaceholderShapeSet; var aTextFieldContentProviderSet = this.aMetaSlide.aTextFieldContentProviderSet; // where cloned elements are appended @@ -3069,17 +3071,6 @@ function bind2( aFunction ) return aResultFunction; } -//function concat3( s1, s2, s3 ) -//{ -// log( s1 + s2 + s3 ); -//} -// -//var bound1 = bind2( concat3, 'Qui' ); -//bound1( 'Quo', 'Qua' ); -// -//var bound2 = bind2( concat3, 'Qui', 'Quo' ); -//bound2( 'Qua' ); - function getCurrentSystemTime() { return ( new Date() ).getTime(); @@ -3096,11 +3087,12 @@ function getSlideAnimationsRoot( sSlideId ) * * @param aElement any XML element * - * @returns an array that contains all children elements + * @returns Array + * an array that contains all children elements */ function getElementChildren( aElement ) { - var aChildrenArray = new Array(); + var aChildrenArray = []; var nSize = aElement.childNodes.length; @@ -3119,8 +3111,8 @@ function removeWhiteSpaces( str ) return ''; var re = / */; - var aSplittedString = str.split( re ); - return aSplittedString.join(''); + var aSplitString = str.split( re ); + return aSplitString.join(''); } function clamp( nValue, nMinimum, nMaximum ) @@ -3805,7 +3797,7 @@ function SVGPathMatrixTransform( aPath, aSVGMatrix ) function PriorityQueue( aCompareFunc ) { - this.aSequence = new Array(); + this.aSequence = []; this.aCompareFunc = aCompareFunc; } @@ -3844,7 +3836,7 @@ PriorityQueue.prototype.push = function( aValue ) PriorityQueue.prototype.clear = function() { - this.aSequence = new Array(); + this.aSequence = []; }; PriorityQueue.prototype.pop = function() @@ -4148,7 +4140,7 @@ PINWHEELWIPE_TRANSITION = 6; // 23 PUSHWIPE_TRANSITION = 7; // 35 SLIDEWIPE_TRANSITION = 8; // 36 FADE_TRANSITION = 9; // 37 -RANDOMBARWIPE_TRANSITION = 10 // 38 +RANDOMBARWIPE_TRANSITION = 10; // 38 CHECKERBOARDWIPE_TRANSITION = 11; // 39 DISSOLVE_TRANSITION = 12; // 40 @@ -4180,7 +4172,7 @@ CORNERSIN_TRANS_SUBTYPE = 3; // 11 CORNERSOUT_TRANS_SUBTYPE = 4; VERTICAL_TRANS_SUBTYPE = 5; HORIZONTAL_TRANS_SUBTYPE = 6; // 14 -DOWN_TRANS_SUBTYPE = 7 // 19 +DOWN_TRANS_SUBTYPE = 7; // 19 CIRCLE_TRANS_SUBTYPE = 8; // 27 CLOCKWISETWELVE_TRANS_SUBTYPE = 9; // 33 CLOCKWISETHREE_TRANS_SUBTYPE = 10; @@ -4535,15 +4527,14 @@ aTransitionInfoTable[DISSOLVE_TRANSITION][DEFAULT_TRANS_SUBTYPE] = function createStateTransitionTable() { - var aSTT = {} - var aTable = null; + var aSTT = {}; aSTT[RESTART_MODE_NEVER] = {}; aSTT[RESTART_MODE_WHEN_NOT_ACTIVE] = {}; aSTT[RESTART_MODE_ALWAYS] = {}; // transition table for restart=NEVER, fill=REMOVE - aTable = + var aTable = aSTT[RESTART_MODE_NEVER][FILL_MODE_REMOVE] = {}; aTable[INVALID_NODE] = INVALID_NODE; aTable[UNRESOLVED_NODE] = RESOLVED_NODE | ENDED_NODE; @@ -4608,7 +4599,6 @@ function createStateTransitionTable() aTable[FROZEN_NODE] = RESOLVED_NODE | ACTIVE_NODE | ENDED_NODE; // restart is possible aTable[ENDED_NODE] = RESOLVED_NODE | ACTIVE_NODE | ENDED_NODE; // restart is possible - return aSTT; } @@ -4767,7 +4757,7 @@ Timing.prototype.parse = function() } else { - var aTimingSplit = new Array(); + var aTimingSplit = []; bPositiveOffset = true; if( this.sTimingDescription.indexOf( '+' ) != -1 ) { @@ -5136,7 +5126,7 @@ function BaseNode( aAnimElem, aParentNode, aNodeContext ) this.nStartDelay = aNodeContext.nStartDelay; this.eCurrentState = UNRESOLVED_NODE; this.nCurrentStateTransition = 0; - this.aDeactivatingListenerArray = new Array(); + this.aDeactivatingListenerArray = []; this.aActivationEvent = null; this.aDeactivationEvent = null; @@ -5219,7 +5209,7 @@ BaseNode.prototype.parseElement = function() this.nReapeatCount = 1; else this.nReapeatCount = parseFloat( sRepeatCount ); - if( ( this.nReapeatCount == NaN ) && ( sRepeatCount != 'indefinite' ) ) + if( ( isNaN(this.nReapeatCount) ) && ( sRepeatCount != 'indefinite' ) ) this.nReapeatCount = 1; // accelerate attribute @@ -5227,7 +5217,7 @@ BaseNode.prototype.parseElement = function() var sAccelerateAttr = aAnimElem.getAttributeNS( NSS['smil'], 'accelerate' ); if( sAccelerateAttr ) this.nAccelerate = parseFloat( sAccelerateAttr ); - if( this.nAccelerate == NaN ) + if( isNaN(this.nAccelerate) ) this.nAccelerate = 0.0; // decelerate attribute @@ -5235,7 +5225,7 @@ BaseNode.prototype.parseElement = function() var sDecelerateAttr = aAnimElem.getAttributeNS( NSS['smil'], 'decelerate' ); if( sDecelerateAttr ) this.nDecelerate = parseFloat( sDecelerateAttr ); - if( this.nDecelerate == NaN ) + if( isNaN(this.nDecelerate) ) this.nDecelerate = 0.0; // autoReverse attribute @@ -5428,7 +5418,7 @@ BaseNode.prototype.dispose = function() this.aActivationEvent.dispose(); if( this.aDeactivationEvent ) this.aDeactivationEvent.dispose(); - this.aDeactivatingListenerArray = new Array(); + this.aDeactivatingListenerArray = []; }; BaseNode.prototype.getState = function() @@ -6023,7 +6013,7 @@ AnimationBaseNode3.prototype.parseElement = function() this.aByValue = aAnimElem.getAttributeNS( NSS['smil'], 'by' ); // keyTimes attribute - this.aKeyTimes = new Array(); + this.aKeyTimes = []; var sKeyTimesAttr = aAnimElem.getAttributeNS( NSS['smil'], 'keyTimes' ); sKeyTimesAttr = removeWhiteSpaces( sKeyTimesAttr ); if( sKeyTimesAttr ) @@ -6041,7 +6031,7 @@ AnimationBaseNode3.prototype.parseElement = function() } else { - this.aValues = new Array(); + this.aValues = []; } return bRet; @@ -6119,7 +6109,7 @@ function BaseContainerNode( aAnimElem, aParentNode, aNodeContext ) this.sClassName = 'BaseContainerNode'; this.bIsContainer = true; - this.aChildrenArray = new Array(); + this.aChildrenArray = []; this.nFinishedChildren = 0; this.bDurationIndefinite = false; this.nLeftIterations = 1; @@ -6341,7 +6331,7 @@ BaseContainerNode.prototype.saveStateOfAnimatedElement = function() { this.aChildrenArray[i].saveStateOfAnimatedElement(); } -} +}; BaseContainerNode.prototype.forEachChildNode = function( aFunction, eNodeStateMask ) { @@ -7531,8 +7521,6 @@ function SlideChangeBase(aLeavingSlide, aEnteringSlide) */ SlideChangeBase.prototype.start = function() { - if( this.bIsFinished ) - return; }; /** end @@ -7843,7 +7831,7 @@ extend( ClippedSlideChange, SlideChangeBase ); ClippedSlideChange.prototype.start = function() { ClippedSlideChange.superclass.start.call( this ); - this.aEnteringSlide.notifyUsedAttribute( 'clip-path' );; + this.aEnteringSlide.notifyUsedAttribute( 'clip-path' ); this.performIn( 0 ); this.aEnteringSlide.show(); }; @@ -7924,7 +7912,7 @@ function ClippingFunctor( aParametricPolyPolygon, aTransitionInfo, switch( aTransitionInfo.reverseMethod ) { default: - log( 'ClippingFunctor: unexpected reverse method.' ) + log( 'ClippingFunctor: unexpected reverse method.' ); break; case REVERSEMETHOD_IGNORE: break; @@ -7988,7 +7976,7 @@ ClippingFunctor.aBoundingPath.setAttribute( 'd', 'M -1 -1 L 2 -1 L 2 2 L -1 2 L * The width of the bounding box of the slide/shape to be clipped. * @param nHeight * The height of the bounding box of the slide/shape to be clipped. - * @return {SVGPathElement} + * @return SVGPathElement * A svg <path> element representing the path to be used for the clipping * operation. */ @@ -8139,7 +8127,7 @@ function BarWipePath( nBars /* nBars > 1: blinds effect */ ) * * @param nT * A parameter in [0,1] representing the width of the generated bars. - * @return {SVGPathElement} + * @return SVGPathElement * A svg <path> element representing a multi-bars. */ BarWipePath.prototype.perform = function( nT ) @@ -8368,7 +8356,7 @@ function CheckerBoardWipePath( unitsPerEdge ) * * @param nT * A parameter in [0,1] representing the width of the generated bars. - * @return {SVGPathElement} + * @return SVGPathElement * A svg <path> element representing a multi-bars. */ CheckerBoardWipePath.prototype.perform = function( nT ) @@ -8423,28 +8411,28 @@ function RandomWipePath( nElements, bRandomBars ) this.aClipPath = createEmptyPath(); this.nAlreadyAppendedElements = 0; + var fEdgeLength, nPos, aTransform; + if( bRandomBars ) // random bar wipe { - var fEdgeLength = 1.0 / nElements; - var nPos; + fEdgeLength = 1.0 / nElements; for( nPos = 0; nPos < nElements; ++nPos ) { this.aPositionArray[nPos] = { x: 0.0, y: pruneScaleValue( nPos * fEdgeLength ) } } - var aTransform = SVGIdentityMatrix.scaleNonUniform( 1.0, pruneScaleValue( fEdgeLength ) ); + aTransform = SVGIdentityMatrix.scaleNonUniform( 1.0, pruneScaleValue( fEdgeLength ) ); } else // dissolve wipe { var nSqrtElements = Math.round( Math.sqrt( nElements ) ); - var fEdgeLength = 1.0 / nSqrtElements; - var nPos; + fEdgeLength = 1.0 / nSqrtElements; for( nPos = 0; nPos < nElements; ++nPos ) { this.aPositionArray[nPos] = { x: pruneScaleValue( ( nPos % nSqrtElements ) * fEdgeLength ), y: pruneScaleValue( ( nPos / nSqrtElements ) * fEdgeLength ) } } - var aTransform = SVGIdentityMatrix.scale( pruneScaleValue( fEdgeLength ) ); + aTransform = SVGIdentityMatrix.scale( pruneScaleValue( fEdgeLength ) ); } this.aBasePath.matrixTransform( aTransform ); @@ -8463,7 +8451,7 @@ function RandomWipePath( nElements, bRandomBars ) * * @param nT * A parameter in [0,1] representing the width of the generated bars or squares. - * @return {SVGPathElement} + * @return SVGPathElement * A svg <path> element representing a multi bars or a multi squared cells. */ RandomWipePath.prototype.perform = function( nT ) @@ -8518,7 +8506,7 @@ function AnimatedSlide( aMetaSlide ) this.aSlideElement = this.aMetaSlide.slideElement; this.sSlideId = this.aMetaSlide.slideId; - this.aUsedAttributeSet = new Array(); + this.aUsedAttributeSet = []; this.aClipPathElement = null; this.aClipPathContent = null; @@ -8579,7 +8567,7 @@ AnimatedSlide.prototype.reset = function() var sAttrName = this.aUsedAttributeSet[i]; this.aSlideElement.removeAttribute( sAttrName ); } - this.aUsedAttributeSet = new Array(); + this.aUsedAttributeSet = []; }; /** initClipPath @@ -8761,7 +8749,7 @@ function AnimatedElement( aElement ) this.aClipPathContent = null; this.aPreviousElement = null; - this.aStateSet = new Object(); + this.aStateSet = {}; this.eAdditiveMode = ADDITIVE_MODE_REPLACE; this.bIsUpdated = true; @@ -8915,7 +8903,7 @@ AnimatedElement.prototype.saveState = function( nAnimationNodeId ) ANIMDBG.print( 'AnimatedElement(' + this.getId() + ').saveState(' + nAnimationNodeId +')' ); if( !this.aStateSet[ nAnimationNodeId ] ) { - this.aStateSet[ nAnimationNodeId ] = new Object(); + this.aStateSet[ nAnimationNodeId ] = {}; } var aState = this.aStateSet[ nAnimationNodeId ]; aState.aElement = this.aActiveElement.cloneNode( true ); @@ -9391,12 +9379,12 @@ function AnimatedTextElement( aElement, aEventMultiplexer ) } // In case there are embedded bitmaps we need to clone them - var aBitmapElemSet = new Array(); - var aBitmapCloneSet = new Array(); + var aBitmapElemSet = []; + var aBitmapCloneSet = []; var aBitmapPlaceholderSet = getElementsByClassName( aElement, 'BitmapPlaceholder' ); + var i; if( aBitmapPlaceholderSet ) { - var i; for( i = 0; i < aBitmapPlaceholderSet.length; ++i ) { sId = aBitmapPlaceholderSet[i].getAttribute( 'id' ); @@ -9477,11 +9465,10 @@ function AnimatedTextElement( aElement, aEventMultiplexer ) this.nRunningAnimations = 0; // we collect all hyperlink ids - this.aHyperlinkIdSet = new Array(); + this.aHyperlinkIdSet = []; var aHyperlinkElementSet = getElementsByClassName( this.aParagraphElement, 'UrlField' ); - var i = 0; var sHyperlinkId; - for( ; i < aHyperlinkElementSet.length; ++i ) + for( i = 0; i < aHyperlinkElementSet.length; ++i ) { sHyperlinkId = aHyperlinkElementSet[i].getAttribute( 'id' ); if( sHyperlinkId ) @@ -9490,7 +9477,6 @@ function AnimatedTextElement( aElement, aEventMultiplexer ) log( 'error: AnimatedTextElement constructor: hyperlink element has no id' ); } - AnimatedTextElement.superclass.constructor.call( this, aAnimatableElement, aEventMultiplexer ); } @@ -9900,11 +9886,11 @@ SlideTransition.prototype.info = function() function SlideAnimations( aSlideShowContext ) { this.aContext = new NodeContext( aSlideShowContext ); - this.aAnimationNodeMap = new Object(); - this.aAnimatedElementMap = new Object(); - this.aSourceEventElementMap = new Object(); + this.aAnimationNodeMap = {}; + this.aAnimatedElementMap = {}; + this.aSourceEventElementMap = {}; this.aNextEffectEventArray = new NextEffectEventArray(); - this.aInteractiveAnimationSequenceMap = new Object(); + this.aInteractiveAnimationSequenceMap = {}; this.aEventMultiplexer = new EventMultiplexer( aSlideShowContext.aTimerEventQueue ); this.aRootNode = null; this.bElementsParsed = false; @@ -9982,10 +9968,7 @@ SlideAnimations.prototype.start = function() return false; // resolve root node - if( !this.aRootNode.resolve() ) - return false; - - return true; + return this.aRootNode.resolve(); }; SlideAnimations.prototype.end = function( bLeftEffectsSkipped ) @@ -10179,8 +10162,7 @@ function registerEvent( nNodeId, aTiming, aEvent, aNodeContext ) if( !aInteractiveAnimationSequenceMap[ nNodeId ] ) { - var aInteractiveAnimationSequence = new InteractiveAnimationSequence( nNodeId ); - aInteractiveAnimationSequenceMap[ nNodeId ] = aInteractiveAnimationSequence; + aInteractiveAnimationSequenceMap[ nNodeId ] = new InteractiveAnimationSequence(nNodeId); } var bEventRegistered = false; @@ -10422,7 +10404,6 @@ HyperlinkElement.prototype.handleClick = function( aMouseEvent ) } } - return true; }; @@ -10521,7 +10502,7 @@ function PriorityEntry( aValue, nPriority ) * An instance of type PriorityEntry. * @param aRhsEntry * An instance of type PriorityEntry. - * @return {Integer} + * @return Integer * -1 if the left entry has lower priority of the right entry, * 1 if the left entry has higher priority of the right entry, * 0 if the two entry have the same priority @@ -10549,17 +10530,17 @@ function EventMultiplexer( aTimerEventQueue ) { this.nId = EventMultiplexer.getUniqueId(); this.aTimerEventQueue = aTimerEventQueue; - this.aEventMap = new Object(); - this.aSkipEffectEndHandlerSet = new Array(); + this.aEventMap = {}; + this.aSkipEffectEndHandlerSet = []; this.aMouseClickHandlerSet = new PriorityQueue( PriorityEntry.compare ); this.aSkipEffectEvent = null; this.aRewindCurrentEffectEvent = null; this.aRewindLastEffectEvent = null; - this.aSkipInteractiveEffectEventSet = new Object(); - this.aRewindRunningInteractiveEffectEventSet = new Object(); - this.aRewindEndedInteractiveEffectEventSet = new Object(); - this.aRewindedEffectHandlerSet = new Object(); - this.aElementChangedHandlerSet = new Object(); + this.aSkipInteractiveEffectEventSet = {}; + this.aRewindRunningInteractiveEffectEventSet = {}; + this.aRewindEndedInteractiveEffectEventSet = {}; + this.aRewindedEffectHandlerSet = {}; + this.aElementChangedHandlerSet = {}; } EventMultiplexer.CURR_UNIQUE_ID = 0; @@ -10573,12 +10554,12 @@ EventMultiplexer.getUniqueId = function() EventMultiplexer.prototype.getId = function() { return this.nId; -} +}; EventMultiplexer.prototype.hasRegisteredMouseClickHandlers = function() { return !this.aMouseClickHandlerSet.isEmpty(); -} +}; EventMultiplexer.prototype.registerMouseClickHandler = function( aHandler, nPriority ) { @@ -10603,11 +10584,11 @@ EventMultiplexer.prototype.registerEvent = function( eEventType, aNotifierId, aE this.DBG( 'registerEvent', eEventType, aNotifierId ); if( !this.aEventMap[ eEventType ] ) { - this.aEventMap[ eEventType ] = new Object(); + this.aEventMap[ eEventType ] = {}; } if( !this.aEventMap[ eEventType ][ aNotifierId ] ) { - this.aEventMap[ eEventType ][ aNotifierId ] = new Array(); + this.aEventMap[ eEventType ][ aNotifierId ] = []; } this.aEventMap[ eEventType ][ aNotifierId ].push( aEvent ); }; @@ -10642,7 +10623,7 @@ EventMultiplexer.prototype.notifyNextEffectEndEvent = function() { (this.aSkipEffectEndHandlerSet[i])(); } - this.aSkipEffectEndHandlerSet = new Array(); + this.aSkipEffectEndHandlerSet = []; }; EventMultiplexer.prototype.registerSkipEffectEvent = function( aEvent ) @@ -10742,7 +10723,7 @@ EventMultiplexer.prototype.notifyRewindedEffectEvent = function( aNotifierId ) EventMultiplexer.prototype.registerElementChangedHandler = function( aNotifierId, aHandler ) { this.aElementChangedHandlerSet[ aNotifierId ] = aHandler; -} +}; EventMultiplexer.prototype.notifyElementChangedEvent = function( aNotifierId, aElement ) { @@ -10771,7 +10752,7 @@ EventMultiplexer.prototype.DBG = function( sMethodName, eEventType, aNotifierId, * Interpolator Handler and KeyStopLerp **********************************************************************************************/ -var aInterpolatorHandler = new Object(); +var aInterpolatorHandler = {}; aInterpolatorHandler.getInterpolator = function( eCalcMode, eValueType, eValueSubtype ) { @@ -10793,9 +10774,9 @@ aInterpolatorHandler.getInterpolator = function( eCalcMode, eValueType, eValueSu } }; -aInterpolatorHandler.aLerpFunctorMap = new Array(); -aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_DISCRETE ] = new Array(); -aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_LINEAR ] = new Array(); +aInterpolatorHandler.aLerpFunctorMap = []; +aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_DISCRETE ] = []; +aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_LINEAR ] = []; // interpolators for linear calculation @@ -10806,7 +10787,7 @@ aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_LINEAR ][ NUMBER_PROPERTY ] = return ( ( 1.0 - nT )* nFrom + nT * nTo ); }; -aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_LINEAR ][ COLOR_PROPERTY ] = new Array(); +aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_LINEAR ][ COLOR_PROPERTY ] = []; aInterpolatorHandler.aLerpFunctorMap[ CALC_MODE_LINEAR ][ COLOR_PROPERTY ][ COLOR_SPACE_RGB ] = function ( nFrom, nTo, nT ) @@ -10832,7 +10813,7 @@ function KeyStopLerp( aValueList ) { KeyStopLerp.validateInput( aValueList ); - this.aKeyStopList = new Array(); + this.aKeyStopList = []; this.nLastIndex = 0; this.nKeyStopDistance = aValueList[1] - aValueList[0]; if( this.nKeyStopDistance <= 0 ) @@ -10884,7 +10865,7 @@ KeyStopLerp.prototype.lerp = function( nAlpha ) nRawLerp = clamp( nRawLerp, 0.0, 1.0 ); - var aResult = new Object(); + var aResult = {}; aResult.nIndex = this.nLastIndex; aResult.nLerp = nRawLerp; @@ -10913,7 +10894,7 @@ KeyStopLerp.prototype.lerp_ported = function( nAlpha ) nRawLerp = clamp( nRawLerp, 0.0, 1.0 ); - var aResult = new Object(); + var aResult = {}; aResult.nIndex = this.nLastIndex; aResult.nLerp = nRawLerp; @@ -10926,10 +10907,10 @@ KeyStopLerp.prototype.lerp_ported = function( nAlpha ) * Operators **********************************************************************************************/ -var aOperatorSetMap = new Array(); +var aOperatorSetMap = []; // number operators -aOperatorSetMap[ NUMBER_PROPERTY ] = new Object(); +aOperatorSetMap[ NUMBER_PROPERTY ] = {}; aOperatorSetMap[ NUMBER_PROPERTY ].equal = function( a, b ) { @@ -10947,7 +10928,7 @@ aOperatorSetMap[ NUMBER_PROPERTY ].scale = function( k, v ) }; // color operators -aOperatorSetMap[ COLOR_PROPERTY ] = new Object(); +aOperatorSetMap[ COLOR_PROPERTY ] = {}; aOperatorSetMap[ COLOR_PROPERTY ].equal = function( a, b ) { @@ -10988,7 +10969,7 @@ function ActivityParamSet() this.nDecelerationFraction = 0.0; this.nSlideWidth = undefined; this.nSlideHeight = undefined; - this.aDiscreteTimes = new Array(); + this.aDiscreteTimes = []; } @@ -11259,10 +11240,7 @@ ActivityBase.prototype.getTargetElement = function() ActivityBase.prototype.isRepeatCountValid = function() { - if( this.nRepeats ) - return true; - else - return false; + return !!this.nRepeats; // first ! convert to bool }; ActivityBase.prototype.getRepeatCount = function() @@ -12062,7 +12040,7 @@ function createValueListActivity( aActivityParamSet, aAnimationNode, aAnimation, var aValueSet = aAnimationNode.getValues(); - var aValueList = new Array(); + var aValueList = []; extractAttributeValues( eValueType, aValueList, @@ -12091,7 +12069,7 @@ function createFromToByActivity( aActivityParamSet, aAnimationNode, aAnimation, var aOperatorSet = aOperatorSetMap[ eValueType ]; assert( aOperatorSet, 'createFromToByActivity: no operator set found' ); - var aValueSet = new Array(); + var aValueSet = []; aValueSet[0] = aAnimationNode.getFromValue(); aValueSet[1] = aAnimationNode.getToValue(); aValueSet[2] = aAnimationNode.getByValue(); @@ -12101,7 +12079,7 @@ function createFromToByActivity( aActivityParamSet, aAnimationNode, aAnimation, ', aTo = ' + aValueSet[1] + ', aBy = ' + aValueSet[2] ); - var aValueList = new Array(); + var aValueList = []; extractAttributeValues( eValueType, aValueList, @@ -12201,8 +12179,7 @@ function Effect( nId ) { this.nId = ( typeof( nId ) === typeof( 1 ) ) ? nId : -1; this.eState = Effect.NOT_STARTED; -}; - +} Effect.NOT_STARTED = 0; Effect.PLAYING = 1; Effect.ENDED = 2; @@ -12266,8 +12243,8 @@ function SlideShow() this.bIsSkipping = false; this.bIsSkippingAll = false; this.nTotalInteractivePlayingEffects = 0; - this.aStartedEffectList = new Array(); - this.aStartedEffectIndexMap = new Object(); + this.aStartedEffectList = []; + this.aStartedEffectIndexMap = {}; this.aStartedEffectIndexMap[ -1 ] = undefined; } @@ -12398,8 +12375,8 @@ SlideShow.prototype.notifySlideStart = function( nNewSlideIndex, nOldSlideIndex this.bIsSkipping = false; this.bIsSkippingAll = false; this.nTotalInteractivePlayingEffects = 0; - this.aStartedEffectList = new Array(); - this.aStartedEffectIndexMap = new Object(); + this.aStartedEffectList = []; + this.aStartedEffectIndexMap = {}; this.aStartedEffectIndexMap[ -1 ] = undefined; var aAnimatedElementMap; @@ -12455,7 +12432,7 @@ SlideShow.prototype.notifyInteractiveAnimationSequenceStart = function( nNodeId SlideShow.prototype.notifyInteractiveAnimationSequenceEnd = function( nNodeId ) { assert( this.isInteractiveEffectPlaying(), - 'SlideShow.notifyInteractiveAnimationSequenceEnd: no interactive effect playing.' ) + 'SlideShow.notifyInteractiveAnimationSequenceEnd: no interactive effect playing.' ); this.aStartedEffectList[ this.aStartedEffectIndexMap[ nNodeId ] ].end(); --this.nTotalInteractivePlayingEffects; @@ -12985,7 +12962,7 @@ FrameSynchronization.prototype.deactivate = function() function NextEffectEventArray() { - this.aEventArray = new Array(); + this.aEventArray = []; } @@ -13017,7 +12994,7 @@ NextEffectEventArray.prototype.appendEvent = function( aEvent ) NextEffectEventArray.prototype.clear = function( ) { - this.aEventArray = new Array(); + this.aEventArray = []; }; @@ -13149,9 +13126,9 @@ EventEntry.compare = function( aLhsEventEntry, aRhsEventEntry ) function ActivityQueue( aTimer ) { this.aTimer = aTimer; - this.aCurrentActivityWaitingSet = new Array(); - this.aCurrentActivityReinsertSet = new Array(); - this.aDequeuedActivitySet = new Array(); + this.aCurrentActivityWaitingSet = []; + this.aCurrentActivityReinsertSet = []; + this.aDequeuedActivitySet = []; } @@ -13214,7 +13191,7 @@ ActivityQueue.prototype.process = function() { // TODO: optimization, try to swap reference here this.aCurrentActivityWaitingSet = this.aCurrentActivityReinsertSet; - this.aCurrentActivityReinsertSet = new Array(); + this.aCurrentActivityReinsertSet = []; } }; @@ -13225,7 +13202,7 @@ ActivityQueue.prototype.processDequeued = function() for( var i = 0; i < nSize; ++i ) this.aDequeuedActivitySet[i].dequeued(); - this.aDequeuedActivitySet = new Array(); + this.aDequeuedActivitySet = []; }; ActivityQueue.prototype.isEmpty = function() @@ -13241,12 +13218,12 @@ ActivityQueue.prototype.clear = function() var i; for( i = 0; i < nSize; ++i ) this.aCurrentActivityWaitingSet[i].dequeued(); - this.aCurrentActivityWaitingSet = new Array(); + this.aCurrentActivityWaitingSet = []; nSize = this.aCurrentActivityReinsertSet.length; for( i = 0; i < nSize; ++i ) this.aCurrentActivityReinsertSet[i].dequeued(); - this.aCurrentActivityReinsertSet = new Array(); + this.aCurrentActivityReinsertSet = []; }; ActivityQueue.prototype.endAll = function() @@ -13256,12 +13233,12 @@ ActivityQueue.prototype.endAll = function() var i; for( i = 0; i < nSize; ++i ) this.aCurrentActivityWaitingSet[i].end(); - this.aCurrentActivityWaitingSet = new Array(); + this.aCurrentActivityWaitingSet = []; nSize = this.aCurrentActivityReinsertSet.length; for( i = 0; i < nSize; ++i ) this.aCurrentActivityReinsertSet[i].end(); - this.aCurrentActivityReinsertSet = new Array(); + this.aCurrentActivityReinsertSet = []; }; ActivityQueue.prototype.getTimer = function() |