http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/text/TextField.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/text/TextField.as index 92f27c8,0000000..80f88ff mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/text/TextField.as +++ b/frameworks/projects/MX/src/main/flex/flex/text/TextField.as @@@ -1,621 -1,0 +1,621 @@@ +package flex.text +{ + - COMPILE::AS3 ++COMPILE::SWF +{ + import flash.text.TextField; +} +COMPILE::JS +{ + import mx.core.IFlexModuleFactory; + import mx.core.IUITextField; + import mx.core.UITextFormat; + import mx.managers.ISystemManager; + + import flex.display.DisplayObject; + import flex.display.DisplayObjectContainer; + import flex.display.Sprite; + import flex.display.TopOfDisplayList; + + import org.apache.flex.geom.Rectangle; + import org.apache.flex.html.Label; +} + - COMPILE::AS3 ++COMPILE::SWF +public class TextField extends flash.text.TextField +{ + public function TextField() + { + super(); + } +} + +COMPILE::JS +public class TextField extends Label +{ + + private var _alwaysShowSelection:Boolean; + public function get alwaysShowSelection():Boolean + { + return _alwaysShowSelection; + } + public function set alwaysShowSelection(value:Boolean):void + { + _alwaysShowSelection = value; + trace("TextField.alwaysShowSelection not implemented"); + } + + private var _antiAliasType:String; + public function get antiAliasType():String + { + trace("TextField.antiAliasType not implemented"); + return _antiAliasType; + } + public function set antiAliasType(value:String):void + { + _antiAliasType = value; + trace("TextField.antiAliasType not implemented"); + } + + private var _autoSize:String; + public function get autoSize():String + { + trace("TextField.autoSize not implemented"); + return _autoSize; + } + public function set autoSize(value:String):void + { + _autoSize = value; + trace("TextField.autoSize not implemented"); + } + + private var _background:Boolean; + public function get background():Boolean + { + return _background; + } + public function set background(value:Boolean):void + { + _background = value; + if (!value) + element.style.backgroundColor = undefined; + else + element.style.backgroundColor = "#" + _backgroundColor.toString(16); + } + + private var _backgroundColor:uint; + public function get backgroundColor():uint + { + return _backgroundColor; + } + public function set backgroundColor(value:uint):void + { + _backgroundColor = value; + if (_background) + element.style.backgroundColor = "#" + _backgroundColor.toString(16); + } + + private var _border:Boolean; + public function get border():Boolean + { + return _border; + } + public function set border(value:Boolean):void + { + _border = value; + if (!value) + element.style.border = "1px none"; + else + element.style.border = "1px solid"; + } + + private var _borderColor:uint; + public function get borderColor():uint + { + return _borderColor; + } + public function set borderColor(value:uint):void + { + _borderColor = value; + if (_border) + element.style.borderColor = "#" + _borderColor.toString(16); + } + + public function get bottomScrollV():int + { + trace("TextField.bottomScrollV not implemented"); + return 0; + } + + public function get caretIndex():int + { + trace("TextField.caretIndex not implemented"); + return 0; + } + + private var _condenseWhite:Boolean; + public function get condenseWhite():Boolean + { + trace("TextField.condenseWhite not implemented"); + return _condenseWhite; + } + public function set condenseWhite(value:Boolean):void + { + _condenseWhite = value; + trace("TextField.condenseWhite not implemented"); + } + + private var _defaultTextFormat:TextFormat; + public function get defaultTextFormat():TextFormat + { + trace("TextField.defaultTextFormat not implemented"); + return _defaultTextFormat; + } + public function set defaultTextFormat(value:TextFormat):void + { + _defaultTextFormat = value; + trace("TextField.defaultTextFormat not implemented"); + } + + private var _displayAsPassword:Boolean; + public function get displayAsPassword():Boolean + { + return _displayAsPassword; + } + /** + * @flexjsignorecoercion HTMLInputElement + */ + public function set displayAsPassword(value:Boolean):void + { + _displayAsPassword = value; + if (value) + (element as HTMLInputElement).type = "password"; + else + (element as HTMLInputElement).type = "input"; + } + + private var _doubleClickEnabled:Boolean; + public function get doubleClickEnabled():Boolean + { + trace("TextField.doubleClickEnabled not implemented"); + return _doubleClickEnabled; + } + public function set doubleClickEnabled(value:Boolean):void + { + _doubleClickEnabled = value; + trace("TextField.doubleClickEnabled not implemented"); + } + + private var _embedFonts:Boolean; + public function get embedFonts():Boolean + { + trace("TextField.embedFonts not implemented"); + return _embedFonts; + } + public function set embedFonts(value:Boolean):void + { + _embedFonts = value; + trace("TextField.embedFonts not implemented"); + } + + private var _focusRect:Object; + public function get focusRect():Object + { + trace("TextField.focusRect not implemented"); + return _focusRect; + } + public function set focusRect(value:Object):void + { + _focusRect = value; + trace("TextField.focusRect not implemented"); + } + + private var _gridFitType:String; + public function get gridFitType():String + { + trace("TextField.gridFitType not implemented"); + return _gridFitType; + } + public function set gridFitType(value:String):void + { + _gridFitType = value; + trace("TextField.gridFitType not implemented"); + } + + private var _htmlText:String; + public function get htmlText():String + { + return _htmlText; + } + public function set htmlText(value:String):void + { + element.innerHTML = _htmlText = value; + } + + public function get length():int + { + return element.innerText.length; + } + + private var _maxChars:int; + public function get maxChars():int + { + return _maxChars; + } + public function set maxChars(value:int):void + { + _maxChars = value; + (element as HTMLInputElement).maxLength = value; + } + + public function get maxScrollH():int + { + trace("TextField.maxScrollH not implemented"); + return 0; + } + + public function get maxScrollV():int + { + trace("TextField.maxScrollV not implemented"); + return 0; + } + + private var _mouseEnabled:Boolean; + public function get mouseEnabled():Boolean + { + trace("TextField.mouseEnabled not implemented"); + return _mouseEnabled; + } + public function set mouseEnabled(value:Boolean):void + { + _mouseEnabled = value; + trace("TextField.mouseEnabled not implemented"); + } + + private var _mouseWheelEnabled:Boolean; + public function get mouseWheelEnabled():Boolean + { + trace("TextField.mouseWheelEnabled not implemented"); + return _mouseWheelEnabled; + } + public function set mouseWheelEnabled(value:Boolean):void + { + _mouseWheelEnabled = value; + trace("TextField.mouseWheelEnabled not implemented"); + } + + public function get mouseX():Number + { + trace("TextField.mouseX not implemented"); + return 0; + } + + public function get mouseY():Number + { + trace("TextField.mouseY not implemented"); + return 0; + } + + private var _multiline:Boolean; + public function get multiline():Boolean + { + trace("TextField.multiline not implemented"); + return _multiline; + } + public function set multiline(value:Boolean):void + { + _multiline = value; + trace("TextField.multiline not implemented"); + } + + private var _name:String; + public function get name():String + { + return _name; + } + public function set name(value:String):void + { + _name = value; + element.id = name; + } + + public function get numLines():int + { + trace("TextField.numLines not implemented"); + return -1; + } + + private var _restrict:String; + public function get restrict():String + { + trace("TextField.restrict not implemented"); + return _restrict; + } + public function set restrict(value:String):void + { + _restrict = value; + trace("TextField.restrict not implemented"); + } + + private var _scrollH:int; + public function get scrollH():int + { + trace("TextField.scrollH not implemented"); + return _scrollH; + } + public function set scrollH(value:int):void + { + _scrollH = value; + trace("TextField.scrollH not implemented"); + } + + private var _scrollV:int; + public function get scrollV():int + { + trace("TextField.scrollV not implemented"); + return _scrollV; + } + public function set scrollV(value:int):void + { + _scrollV = value; + trace("TextField.scrollV not implemented"); + } + + public function get root():DisplayObject + { + trace("TextField.root not implemented"); + return null; + } + + private var _selectable:Boolean; + public function get selectable():Boolean + { + trace("TextField.selectable not implemented"); + return _selectable; + } + public function set selectable(value:Boolean):void + { + _selectable = value; + trace("TextField.selectable not implemented"); + } + + public function get selectionBeginIndex():int + { + trace("TextField.selectionBeginIndex not implemented"); + return 0; + } + + public function get selectionEndIndex():int + { + trace("TextField.selectionEndIndex not implemented"); + return 0; + } + + private var _sharpness:Number; + public function get sharpness():Number + { + trace("TextField.sharpness not implemented"); + return _sharpness; + } + public function set sharpness(value:Number):void + { + _sharpness = value; + trace("TextField.sharpness not implemented"); + } + + private var _styleSheet:StyleSheet; + public function get styleSheet():StyleSheet + { + trace("TextField.styleSheet not implemented"); + return _styleSheet; + } + public function set styleSheet(value:StyleSheet):void + { + _styleSheet = value; + trace("TextField.styleSheet not implemented"); + } + + private var _tabEnabled:Boolean; + public function get tabEnabled():Boolean + { + trace("TextField.tabEnabled not implemented"); + return _tabEnabled; + } + public function set tabEnabled(value:Boolean):void + { + _tabEnabled = value; + trace("TextField.tabEnabled not implemented"); + } + + private var _textColor:uint; + public function get textColor():uint + { + return _textColor; + } + public function set textColor(value:uint):void + { + _textColor = value; + element.style.color = "#" + value.toString(16); + } + + public function get textHeight():Number + { + return element.offsetHeight; + } + + public function get textWidth():Number + { + return element.offsetWidth; + } + + private var _thickness:Number; + public function get thickness():Number + { + trace("TextField.thickness not implemented"); + return _thickness; + } + public function set thickness(value:Number):void + { + _thickness = value; + trace("TextField.thickness not implemented"); + } + + public function get topOfDisplayList():TopOfDisplayList + { + trace("TextField.topOfDisplayList not implemented"); + return null; + } + + private var _type:String; + public function get type():String + { + trace("TextField.type not implemented"); + return _type; + } + public function set type(value:String):void + { + _type = value; + trace("TextField.type not implemented"); + } + + private var _useRichTextClipboard:Boolean; + public function get useRichTextClipboard():Boolean + { + trace("TextField.useRichTextClipboard not implemented"); + return _useRichTextClipboard; + } + public function set useRichTextClipboard(value:Boolean):void + { + _useRichTextClipboard = value; + trace("TextField.useRichTextClipboard not implemented"); + } + + private var _wordWrap:Boolean; + public function get wordWrap():Boolean + { + trace("TextField.wordWrap not implemented"); + return _wordWrap; + } + public function set wordWrap(value:Boolean):void + { + _wordWrap = value; + trace("TextField.wordWrap not implemented"); + } + + public function appendText(value:String):void + { + element.innerText += value; + } + + public function getCharBoundaries(charIndex:int):Rectangle + { + trace("TextField.getCharBoundaries not implemented"); + return null; + } + + public function getCharIndexAtPoint(x:Number, y:Number):int + { + trace("TextField.getCharIndexAtPoint not implemented"); + return 0; + } + + public function getFirstCharInParagraph(index:int):int + { + trace("TextField.getFirstCharInParagraph not implemented"); + return 0; + } + + public function getImageReference(id:String):DisplayObject + { + trace("TextField.getImageReference not implemented"); + return null; + } + + public function getLineIndexAtPoint(x:Number, y:Number):int + { + trace("TextField.getLineIndexAtPoint not implemented"); + return 0; + } + + public function getLineIndexOfChar(index:int):int + { + trace("TextField.getLineIndexOfChar not implemented"); + return 0; + } + + public function getLineLength(index:int):int + { + trace("TextField.getLineLength not implemented"); + return 0; + } + + public function getLineMetrics(index:int):TextLineMetrics + { + trace("TextField.getLineMetrics not implemented"); + return null; + } + + public function getLineOffset(index:int):int + { + trace("TextField.getLineOffset not implemented"); + return 0; + } + + public function getLineText(index:int):String + { + trace("TextField.getLineText not implemented"); + return null; + } + + public function getParagraphLength(index:int):int + { + trace("TextField.getParagraphLength not implemented"); + return 0; + } + + public function getTextFormat(beginIndex:int = -1, endIndex:int = -1):TextFormat + { + trace("TextField.getTextFormat not implemented"); + return null; + } + + public function replaceSelectedText(text:String):void + { + trace("TextField.replaceSelectedText not implemented"); + } + + public function replaceText(begin:int, end:int, text:String):void + { + trace("TextField.replaceText not implemented"); + } + + public function setColor(color:uint):void + { + element.style.color = "#" + color.toString(16); + } + + public function setFocus():void + { + element.focus(); + } + + public function setSelection(begin:int, end:int):void + { + trace("TextField.setSelection not implemented"); + } + + public function setTextFormat(format:TextFormat, begin:int = -1, end:int = -1):void + { + trace("TextField.setTextFormat not implemented"); + } + + /** + * @flexjsignorecoercion flex.display.DisplayObjectContainer + */ + override public function get parent():DisplayObjectContainer + { + return super.parent as DisplayObjectContainer; + } + +} - } ++}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/text/TextFieldType.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/text/TextFieldType.as index 39df8a0,0000000..8cc24a8 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/text/TextFieldType.as +++ b/frameworks/projects/MX/src/main/flex/flex/text/TextFieldType.as @@@ -1,12 -1,0 +1,12 @@@ +package flex.text +{ + public class TextFieldType + { + public function TextFieldType() + { + } + + public static const INPUT:String = "input"; + public static const DYNAMIC:String = "dynamic"; + } - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/text/TextFormat.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/text/TextFormat.as index 105fc22,0000000..321e72d mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/text/TextFormat.as +++ b/frameworks/projects/MX/src/main/flex/flex/text/TextFormat.as @@@ -1,45 -1,0 +1,45 @@@ +package flex.text +{ + public class TextFormat + { + public function TextFormat(font:String = null, size:Object = null, color:Object = null, + bold:Object = null, italic:Object = null, underline:Object = null, + url:String = null, target:String = null, align:String = null, + leftMargin:Object = null, rightMargin:Object = null, + indent:Object = null, leading:Object = null) + { + this.font = font; + this.size = size; + this.color = color; + this.bold = bold; + this.italic = italic; + this.underline = underline; + this.url = url; + this.target = target; + this.align = align; + this.leftMargin = leftMargin; + this.rightMargin = rightMargin; + this.indent = indent; + this.leading = leading; + } + + public var align:String; + public var blockIndent:Object; + public var bold:Object; + public var bullet:Object; + public var color:Object; + public var font:String; + public var indent:Object; + public var italic:Object; + public var kerning:Object; + public var leading:Object; + public var leftMargin:Object; + public var letterSpacing:Object; + public var rightMargin:Object; + public var size:Object; + public var tabStops:Array; + public var target:Object; + public var underline:Object; + public var url:Object; + } - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/text/TextFormatAlign.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/text/TextFormatAlign.as index 6305621,0000000..a1e8521 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/text/TextFormatAlign.as +++ b/frameworks/projects/MX/src/main/flex/flex/text/TextFormatAlign.as @@@ -1,16 -1,0 +1,16 @@@ +package flex.text +{ + public class TextFormatAlign + { + public function TextFormatAlign() + { + } + + public static const CENTER:String = "center"; + public static const END:String = "end"; + public static const JUSTIFY:String = "justify"; + public static const LEFT:String = "left"; + public static const RIGHT:String = "right"; + public static const START:String = "start"; + } - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/text/TextLineMetrics.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/text/TextLineMetrics.as index 165f87e,0000000..5c2a347 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/text/TextLineMetrics.as +++ b/frameworks/projects/MX/src/main/flex/flex/text/TextLineMetrics.as @@@ -1,42 -1,0 +1,42 @@@ +package flex.text +{ - COMPILE::AS3 ++COMPILE::SWF +{ + import flash.text.TextLineMetrics; +} + - COMPILE::AS3 ++COMPILE::SWF +public class TextLineMetrics extends flash.text.TextLineMetrics +{ + public function TextLineMetrics(x:Number, width:Number, height:Number, ascent:Number, descent:Number, leading:Number) + { + super(x, width, height, ascent, descent, leading); + } + + public static function convert(tlm:flash.text.TextLineMetrics):flex.text.TextLineMetrics + { + return new flex.text.TextLineMetrics(tlm.x, tlm.width, tlm.height, tlm.ascent, tlm.descent, tlm.leading); + } +} + +COMPILE::JS +public class TextLineMetrics +{ + public function TextLineMetrics(x:Number, width:Number, height:Number, ascent:Number, descent:Number, leading:Number) + { + this.x = x; + this.width = width; + this.height = height; + this.ascent = ascent; + this.descent = descent; + this.leading = leading; + } + + public var x:Number; + public var width:Number; + public var height:Number; + public var ascent:Number; + public var descent:Number; + public var leading:Number; +} - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/ui/Keyboard.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/ui/Keyboard.as index 002adde,0000000..bc04644 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/ui/Keyboard.as +++ b/frameworks/projects/MX/src/main/flex/flex/ui/Keyboard.as @@@ -1,40 -1,0 +1,40 @@@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (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.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package flex.ui +{ + public class Keyboard + { + public function Keyboard() + { + } + + public static const TAB:int = 0x09; + public static const LEFT:int = 0x25; + public static const UP:int = 0x26; + public static const RIGHT:int = 0x27; + public static const DOWN:int = 0x28; + public static const PAGE_UP:int = 0x21; + public static const PAGE_DOWN:int = 0x22; + public static const HOME:int = 0x24; + public static const END:int = 0x23; + public static const ENTER:int = 0x0D; + + } - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/ui/Mouse.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/ui/Mouse.as index bbda041,0000000..bab9df9 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/ui/Mouse.as +++ b/frameworks/projects/MX/src/main/flex/flex/ui/Mouse.as @@@ -1,53 -1,0 +1,53 @@@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (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.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package flex.ui +{ + public class Mouse + { + public function Mouse() + { + } + + COMPILE::JS + private static var styleElement:HTMLStyleElement; + + /** + * @flexjsignorecoercion HTMLStyleElement + */ + COMPILE::JS + public static function hide():void + { + if (!styleElement) + styleElement = document.createElement("STYLE") as HTMLStyleElement; + var css:CSSStyleSheet = styleElement.sheet as CSSStyleSheet; + css.insertRule("* { cursor: none; }", 0); + } + + COMPILE::JS + public static function show():void + { + if (!styleElement) + return; + var css:CSSStyleSheet = styleElement.sheet as CSSStyleSheet; + css.deleteRule(0); + } + + } - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/flex/utils/IExternalizable.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/flex/utils/IExternalizable.as index a75a480,0000000..d8ce817 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/flex/utils/IExternalizable.as +++ b/frameworks/projects/MX/src/main/flex/flex/utils/IExternalizable.as @@@ -1,26 -1,0 +1,26 @@@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (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.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package flex.utils +{ + public interface IExternalizable + { + + } - } ++} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/automation/IAutomationObject.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/mx/automation/IAutomationObject.as index 61882a8,0000000..18dbeba mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/mx/automation/IAutomationObject.as +++ b/frameworks/projects/MX/src/main/flex/mx/automation/IAutomationObject.as @@@ -1,324 -1,0 +1,324 @@@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (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.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package mx.automation +{ + - COMPILE::AS3 ++COMPILE::SWF +{ + import flash.display.DisplayObjectContainer; +} +COMPILE::JS +{ + import flex.display.DisplayObjectContainer; +} +import flex.events.Event; + +/** + * The IAutomationObject interface defines the interface + * for a delegate object that implements automation + * for a component. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ +public interface IAutomationObject +{ + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + //---------------------------------- + // automationDelegate + //---------------------------------- + + /** + * The delegate object that is handling the automation-related functionality. + * Automation sets this when it creates the delegate object. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get automationDelegate():Object; + + /** + * @private + */ + function set automationDelegate(delegate:Object):void; + + //---------------------------------- + // automationName + //---------------------------------- + + /** + * Name that can be used as an identifier for this object. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get automationName():String; + + /** + * @private + */ + function set automationName(name:String):void; + + //---------------------------------- + // automationValue + //---------------------------------- + + /** + * This value generally corresponds to the rendered appearance of the + * object and should be usable for correlating the identifier with + * the object as it appears visually within the application. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get automationValue():Array; + + /** + * The number of automation children this container has. + * This sum should not include any composite children, though + * it does include those children not significant within the + * automation hierarchy. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get numAutomationChildren():int; + + /** + * A flag that determines if an automation object + * shows in the automation hierarchy. + * Children of containers that are not visible in the hierarchy + * appear as children of the next highest visible parent. + * Typically containers used for layout, such as boxes and Canvas, + * do not appear in the hierarchy. + * + * <p>Some controls force their children to appear + * in the hierarchy when appropriate. + * For example a List will always force item renderers, + * including boxes, to appear in the hierarchy. + * Implementers must support setting this property + * to <code>true</code>.</p> + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get showInAutomationHierarchy():Boolean; + + /** + * @private + */ + function set showInAutomationHierarchy(value:Boolean):void; + + /** + * An implementation of the <code>IAutomationTabularData</code> interface, which + * can be used to retrieve the data. + * + * @return An implementation of the <code>IAutomationTabularData</code> interface. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function get automationTabularData():Object; + + /** + * The owner of this component for automation purposes. + * + * @see mx.core.IVisualElement#owner + * + * @return The owner of this component + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 4 + */ + function get automationOwner():DisplayObjectContainer; + + /** + * The parent of this component for automation purposes. + * + * @see mx.core.IVisualElement#parent + * + * @return The parent of this component + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 4 + */ + function get automationParent():DisplayObjectContainer; + + /** + * True if this component is enabled for automation, false + * otherwise. + * + * @see mx.core.IUIComponent#enabled + * + * @return <code>true</code> if this component is enabled for automation, + * <code>false</code> otherwise. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 4 + */ + function get automationEnabled():Boolean; + + /** + * True if this component is visible for automation, false + * otherwise. + * + * @see flash.display.DisplayObject#visible + * + * @return <code>true</code> if this component is visible for automation, + * <code>false</code> otherwise. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 4 + */ + function get automationVisible():Boolean; + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + /** + * Returns a set of properties that identify the child within + * this container. These values should not change during the + * lifespan of the application. + * + * @param child Child for which to provide the id. + * + * @return Sets of properties describing the child which can + * later be used to resolve the component. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function createAutomationIDPart(child:IAutomationObject):Object; + + /** + * Returns a set of properties as automation IDs that identify the child within + * this container. These values should not change during the + * lifespan of the application + * + * @param child Child for which to provide the id. + * + * @param properties which needs to be considered for forming the Id. + * + * @return Sets of properties describing the child which can + * later be used to resolve the component. + * + * @langversion 3.0 + * @playerversion Flash 10 + * @playerversion AIR 1.5 + * @productversion Flex 4 + */ + function createAutomationIDPartWithRequiredProperties(child:IAutomationObject, properties:Array):Object; + + /** + * Resolves a child by using the id provided. The id is a set + * of properties as provided by the <code>createAutomationIDPart()</code> method. + * + * @param criteria Set of properties describing the child. + * The criteria can contain regular expression values + * resulting in multiple children being matched. + * @return Array of children that matched the criteria + * or <code>null</code> if no children could not be resolved. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function resolveAutomationIDPart(criteria:Object):Array; + + /** + * Provides the automation object at the specified index. This list + * should not include any children that are composites. + * + * @param index The index of the child to return + * + * @return The child at the specified index. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function getAutomationChildAt(index:int):IAutomationObject; + + /** + * Provides the automation object list . This list + * does not include any children that are composites. + * + * @return the automation children. + * + * @langversion 3.0 + * @playerversion Flash 10 + * @playerversion AIR 1.5 + * @productversion Flex 4 + */ + function getAutomationChildren():Array; + + /** + * Replays the specified event. A component author should probably call + * super.replayAutomatableEvent in case default replay behavior has been defined + * in a superclass. + * + * @param event The event to replay. + * + * @return <code>true</code> if a replay was successful. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + function replayAutomatableEvent(event:Event):Boolean; + +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/binding/Binding.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/mx/binding/Binding.as index 40a12e8,0000000..c19cced mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/mx/binding/Binding.as +++ b/frameworks/projects/MX/src/main/flex/mx/binding/Binding.as @@@ -1,592 -1,0 +1,592 @@@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (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.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package mx.binding +{ + +import mx.collections.errors.ItemPendingError; +import mx.core.mx_internal; +COMPILE::LATER +{ +import flash.utils.Dictionary; +} + +use namespace mx_internal; + +[ExcludeClass] + +/** + * @private + */ +public class Binding +{ + include "../core/Version.as"; + + // Certain errors are normal during binding execution, so we swallow them. + // 1507 - invalid null argument + // 2005 - argument error (null gets converted to 0) + mx_internal static var allowedErrors:Object = generateAllowedErrors(); + mx_internal static function generateAllowedErrors():Object + { + var o:Object = {}; + o[1507] = 1; + o[2005] = 1; + return o; + } + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Create a Binding object + * + * @param document The document that is the target of all of this work. + * + * @param srcFunc The function that returns us the value + * to use in this Binding. + * + * @param destFunc The function that will take a value + * and assign it to the destination. + * + * @param destString The destination represented as a String. + * We can then tell the ValidationManager to validate this field. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Binding(document:Object, srcFunc:Function, + destFunc:Function, destString:String, + srcString:String = null) + { + super(); + + this.document = document; + this.srcFunc = srcFunc; + this.destFunc = destFunc; + this.destString = destString; + this.srcString = srcString; + this.destFuncFailed = false; + + if (this.srcFunc == null) + { + this.srcFunc = defaultSrcFunc; + } + + if (this.destFunc == null) + { + this.destFunc = defaultDestFunc; + } + + _isEnabled = true; + isExecuting = false; + isHandlingEvent = false; + hasHadValue = false; + uiComponentWatcher = -1; + + BindingManager.addBinding(document, destString, this); + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * Internal storage for isEnabled property. + */ + mx_internal var _isEnabled:Boolean; + + /** + * @private + * Indicates that a Binding is enabled. + * Used to disable bindings. + */ + mx_internal function get isEnabled():Boolean + { + return _isEnabled; + } + + /** + * @private + */ + mx_internal function set isEnabled(value:Boolean):void + { + _isEnabled = value; + + if (value) + { + processDisabledRequests(); + } + } + + /** + * @private + * Indicates that a Binding is executing. + * Used to prevent circular bindings from causing infinite loops. + */ + mx_internal var isExecuting:Boolean; + + /** + * @private + * Indicates that the binding is currently handling an event. + * Used to prevent us from infinitely causing an event + * that re-executes the the binding. + */ + mx_internal var isHandlingEvent:Boolean; + + /** + * @private + * Queue of watchers that fired while we were disabled. + * We will resynch with our binding if isEnabled is set to true + * and one or more of our watchers fired while we were disabled. + */ + mx_internal var disabledRequests:Array; + + /** + * @private + * True as soon as a non-null or non-empty-string value has been used. + * We don't auto-validate until this is true + */ + private var hasHadValue:Boolean; + + /** + * @private + * This is no longer used in Flex 3.0, but it is required to load + * Flex 2.0.0 and Flex 2.0.1 modules. + */ + public var uiComponentWatcher:int; + + /** + * @private + * It's possible that there is a two-way binding set up, in which case + * we'll do a rudimentary optimization by not executing ourselves + * if our counterpart is already executing. + */ + public var twoWayCounterpart:Binding; + + /** + * @private + * If there is a twoWayCounterpart, hasHadValue is false, and + * isTwoWayPrimary is true, then the twoWayCounterpart will be + * executed first. + */ + public var isTwoWayPrimary:Boolean; + + /** + * @private + * True if a wrapped function call does not throw an error. This is used by + * innerExecute() to tell if the srcFunc completed successfully. + */ + private var wrappedFunctionSuccessful:Boolean; + + //-------------------------------------------------------------------------- + // + // Properties + // + //-------------------------------------------------------------------------- + + /** + * All Bindings hang off of a document for now, + * but really it's just the root of where these functions live. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + mx_internal var document:Object; + + /** + * The function that will return us the value. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + mx_internal var srcFunc:Function; + + /** + * The function that takes the value and assigns it. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + mx_internal var destFunc:Function; + + /** + * @private + */ + mx_internal var destFuncFailed:Boolean; + + /** + * The destination represented as a String. + * This will be used so we can signal validation on a field. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + mx_internal var destString:String; + + /** + * The source represented as a String. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 4 + */ + mx_internal var srcString:String; + + /** + * @private + * Used to suppress calls to destFunc when incoming value is either + * a) an XML node identical to the previously assigned XML node, or + * b) an XMLList containing the identical node sequence as the previously assigned XMLList + */ + private var lastValue:Object; + + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + private function defaultDestFunc(value:Object):void + { + var chain:Array = destString.split("."); + var element:Object = document; + var i:uint = 0; + + if (chain[0] == "this") + { + i++; + } + + while (i < (chain.length - 1)) + { + element = element[chain[i++]]; + //if the element does not exist : avoid exception as it's heavy on memory allocations + if (element == null) { + destFuncFailed = true; + if (BindingManager.debugDestinationStrings[destString]) + { + trace("Binding: destString = " + destString + ", error = 1009"); + } + return; + } + } + + element[chain[i]] = value; + } + + private function defaultSrcFunc():Object + { + return document[srcString]; + } + + /** + * Execute the binding. + * Call the source function and get the value we'll use. + * Then call the destination function passing the value as an argument. + * Finally try to validate the destination. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function execute(o:Object = null):void + { + if (!isEnabled) + { + if (o != null) + { + registerDisabledExecute(o); + } + return; + } + + if (twoWayCounterpart && !twoWayCounterpart.hasHadValue && twoWayCounterpart.isTwoWayPrimary) + { + twoWayCounterpart.execute(); + hasHadValue = true; + return; + } + + if (isExecuting || (twoWayCounterpart && twoWayCounterpart.isExecuting)) + { + // If there is a twoWayCounterpart already executing, that means that it is + // assigning something of value so even though we won't execute we should be + // sure to mark ourselves as having had a value so that future executions will + // be correct. If isExecuting is true but we re-entered, that means we + // clearly had a value so setting hasHadValue is safe. + hasHadValue = true; + return; + } + + try + { + isExecuting = true; + wrapFunctionCall(this, innerExecute, o); + } + catch(error:Error) + { - COMPILE::AS3 ++ COMPILE::SWF + { + if (allowedErrors[error.errorID] == null) + throw error; + } + COMPILE::JS + { + if (allowedErrors[error.name] == null) + throw error; + } + } + finally + { + isExecuting = false; + } + } + + /** + * @private + * Take note of any execute request that occur when we are disabled. + */ + private function registerDisabledExecute(o:Object):void + { + if (o != null) + { + disabledRequests = (disabledRequests != null) ? disabledRequests : + []; + + disabledRequests.push(o); + } + } + + /** + * @private + * Resynch with any watchers that may have updated while we were disabled. + */ + private function processDisabledRequests():void + { + if (disabledRequests != null) + { + for each (var key:Object in disabledRequests) + { + execute(key); + } + + disabledRequests = null; + } + } + + + /** + * @private + * Note: use of this wrapper needs to be reexamined. Currently there's at least one situation where a + * wrapped function invokes another wrapped function, which is unnecessary (i.e., only the inner function + * will throw), and also risks future errors due to the 'wrappedFunctionSuccessful' member variable + * being stepped on. Leaving alone for now to minimize pre-GMC volatility, but should be revisited for + * an early dot release. + * Also note that the set of suppressed error codes below is repeated verbatim in Watcher.wrapUpdate. + * These need to be consolidated and the motivations for each need to be documented. + */ + protected function wrapFunctionCall(thisArg:Object, wrappedFunction:Function, object:Object = null, ...args):Object + { + wrappedFunctionSuccessful = false; + + try + { + var result:Object = wrappedFunction.apply(thisArg, args); + if(destFuncFailed == true) { + destFuncFailed = false; + return null; + } + wrappedFunctionSuccessful = true; + return result; + } + catch(error:Error) + { + if (error is ItemPendingError) { + (error as ItemPendingError).addResponder(new EvalBindingResponder(this, object)); + if (BindingManager.debugDestinationStrings[destString]) + { + trace("Binding: destString = " + destString + ", error = " + error); + } + } else if (error is RangeError) { + if (BindingManager.debugDestinationStrings[destString]) + { + trace("Binding: destString = " + destString + ", error = " + error); + } + } else { + // Certain errors are normal when executing a srcFunc or destFunc, + // so we swallow them: + // Error #1006: Call attempted on an object that is not a function. + // Error #1009: null has no properties. + // Error #1010: undefined has no properties. + // Error #1055: - has no properties. + // Error #1069: Property - not found on - and there is no default value + // We allow any other errors to be thrown. - COMPILE::AS3 ++ COMPILE::SWF + { + if ((error.errorID != 1006) && + (error.errorID != 1009) && + (error.errorID != 1010) && + (error.errorID != 1055) && + (error.errorID != 1069)) + { + throw error; + } + else + { + if (BindingManager.debugDestinationStrings[destString]) + { + trace("Binding: destString = " + destString + ", error = " + error); + } + } + } + COMPILE::JS + { + /* + if ((error.name != 1006) && + (error.name != 1009) && + (error.name != 1010) && + (error.name != 1055) && + (error.name != 1069)) + { + throw error; + } + else + {*/ + if (BindingManager.debugDestinationStrings[destString]) + { + trace("Binding: destString = " + destString + ", error = " + error); + } + /*}*/ + } + } + } + + return null; + } + + /** + * @private + * true if XMLLists x and y contain the same node sequence. + */ + COMPILE::LATER + private static function nodeSeqEqual(x:XMLList, y:XMLList):Boolean + { + var n:uint = x.length(); + if (n == y.length()) + { + for (var i:uint = 0; i < n && x[i] === y[i]; i++) + { + } + return i == n; + } + else + { + return false; + } + } + + /** + * @private + */ + private function innerExecute():void + { + destFuncFailed = false; + var value:Object = wrapFunctionCall(document, srcFunc); + + if (BindingManager.debugDestinationStrings[destString]) + { + trace("Binding: destString = " + destString + ", srcFunc result = " + value); + } + + if (hasHadValue || wrappedFunctionSuccessful) + { + // Suppress binding assignments on non-simple XML: identical single nodes, or + // lists over identical node sequences. + // Note: outer tests are inline for efficiency + COMPILE::LATER + { + if (!(lastValue is XML && lastValue.hasComplexContent() && lastValue === value) && + !(lastValue is XMLList && lastValue.hasComplexContent() && value is XMLList && + nodeSeqEqual(lastValue as XMLList, value as XMLList))) + { + destFunc.call(document, value); + + if(destFuncFailed == false) { + // Note: state is not updated if destFunc throws + lastValue = value; + hasHadValue = true; + } + } + } + destFunc.call(document, value); + + if(destFuncFailed == false) { + // Note: state is not updated if destFunc throws + lastValue = value; + hasHadValue = true; + } + } + } + + /** + * This function is called when one of this binding's watchers + * detects a property change. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function watcherFired(commitEvent:Boolean, cloneIndex:int):void + { + if (isHandlingEvent) + return; + + try + { + isHandlingEvent = true; + execute(cloneIndex); + } + finally + { + isHandlingEvent = false; + } + } +} + +} http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/77148f4a/frameworks/projects/MX/src/main/flex/mx/binding/Watcher.as ---------------------------------------------------------------------- diff --cc frameworks/projects/MX/src/main/flex/mx/binding/Watcher.as index c5855e1,0000000..bdfe149 mode 100644,000000..100644 --- a/frameworks/projects/MX/src/main/flex/mx/binding/Watcher.as +++ b/frameworks/projects/MX/src/main/flex/mx/binding/Watcher.as @@@ -1,326 -1,0 +1,326 @@@ +//////////////////////////////////////////////////////////////////////////////// +// +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (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.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//////////////////////////////////////////////////////////////////////////////// + +package mx.binding +{ + +import mx.collections.errors.ItemPendingError; +import mx.core.mx_internal; + +use namespace mx_internal; + +[ExcludeClass] + +/** + * @private + */ +public class Watcher +{ + include "../core/Version.as"; + + //-------------------------------------------------------------------------- + // + // Constructor + // + //-------------------------------------------------------------------------- + + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function Watcher(listeners:Array = null) + { + super(); + + this.listeners = listeners; + } + + //-------------------------------------------------------------------------- + // + // Variables + // + //-------------------------------------------------------------------------- + + /** + * @private + * The binding objects that are listening to this Watcher. + * The standard event mechanism isn't used because it's too heavyweight. + */ + protected var listeners:Array; + + /** + * @private + * Children of this watcher are watching sub values. + */ + protected var children:Array; + + /** + * @private + * The value itself. + */ + public var value:Object; + + /** + * @private + * Keep track of cloning when used in Repeaters. + */ + protected var cloneIndex:int; + + //-------------------------------------------------------------------------- + // + // Methods + // + //-------------------------------------------------------------------------- + + /** + * @private + * This is an abstract method that subclasses implement. + */ + public function updateParent(parent:Object):void + { + } + + /** + * @private + * Add a child to this watcher, meaning that the child + * is watching a sub value of ours. + */ + public function addChild(child:Watcher):void + { + if (!children) + children = [ child ]; + else + children.push(child); + + child.updateParent(this); + } + + /** + * @private + * Remove all children beginning at a starting index. + * If the index is not specified, it is assumed to be 0. + * This capability is used by Repeater, which must remove + * cloned RepeaterItemWatchers (and their descendant watchers). + */ + public function removeChildren(startingIndex:int):void + { + children.splice(startingIndex); + } + + /** + * We have probably changed, so go through + * and make sure our children are updated. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Flex 3 + */ + public function updateChildren():void + { + if (children) + { + var n:int = children.length; + for (var i:int = 0; i < n; ++i) + { + children[i].updateParent(this); + } + } + } + + /** + * @private + */ + private function valueChanged(oldval:Object):Boolean + { + if (oldval == null && value == null) + return false; + + var valType:String = typeof(value); + + // The first check is meant to catch the delayed instantiation case + // where a control comes into existence but its value is still + // the equivalent of not having been filled in. + // Otherwise we simply return whether the value has changed. + + if (valType == "string") + { + if (oldval == null && value == "") + return false; + else + return oldval != value; + } + + if (valType == "number") + { + if (oldval == null && value == 0) + return false; + else + return oldval != value; + } + + if (valType == "boolean") + { + if (oldval == null && value == false) + return false; + else + return oldval != value; + } + + return true; + } + + /** + * @private + */ + protected function wrapUpdate(wrappedFunction:Function):void + { + try + { + wrappedFunction.apply(this); + } + catch(error:Error) + { + if (error is ItemPendingError) { + // The parent's value is not yet available. This is being ignored for now - + // updateParent() will be called when the parent has a value. + value = null; + } else if (error is RangeError) { + // The parent's value is not yet available. This is being ignored for now - + // updateParent() will be called when the parent has a value. + value = null; + } else { + // Certain errors are normal when executing an update, so we swallow them: + // Error #1006: Call attempted on an object that is not a function. + // Error #1009: null has no properties. + // Error #1010: undefined has no properties. + // Error #1055: - has no properties. + // Error #1069: Property - not found on - and there is no default value + // Error #1507: - invalid null argument. + // We allow any other errors to be thrown. - COMPILE::AS3 ++ COMPILE::SWF + { + if ((error.errorID != 1006) && + (error.errorID != 1009) && + (error.errorID != 1010) && + (error.errorID != 1055) && + (error.errorID != 1069) && + (error.errorID != 1507)) + { + throw error; + } + } + } + } + } + + /** + * @private + * Clone this Watcher and all its descendants. + * Each clone triggers the same Bindings as the original; + * in other words, the Bindings do not get cloned. + * + * This cloning capability is used by Repeater in order + * to watch the subproperties of multiple dataProvider items. + * For example, suppose a repeated LinkButton's label is + * {r.currentItem.firstName} {r.currentItem.lastName} + * where r is a Repeater whose dataProvider is + * [ { firstName: "Matt", lastName: "Chotin" }, + * { firstName: "Gordon", lastName: "Smith" } ] + * The MXML compiler emits a watcher tree (one item of _watchers[]) + * that looks like this: + * PropertyWatcher for "r" + * PropertyWatcher for "dataProvider" + * RepeaterItemWatcher + * PropertyWatcher for "firstName" + * PropertyWatcher for "lastName" + * At runtime the RepeaterItemWatcher serves as a template + * which gets cloned for each dataProvider item: + * PropertyWatcher for "r" + * PropertyWatcher for "dataProvider" + * RepeaterItemWatcher (index: null) + * PropertyWatcher for "firstName" (value: null) + * PropertyWatcher for "lastName" (value: null) + * RepeaterItemWatcher (index: 0) + * PropertyWatcher for "firstName" (value: "Matt") + * PropertyWatcher for "lastName" (value: "Chotin") + * RepeaterItemWatcher (index: 1) + * PropertyWatcher for "firstName" (value: "Gordon") + * PropertyWatcher for "lastName" (value: "Smith") + */ + protected function deepClone(index:int):Watcher + { + // Clone this watcher object itself. + var w:Watcher = shallowClone(); + w.cloneIndex = index; + + // Clone its listener queue. + if (listeners) + { + w.listeners = listeners.concat(); + } + + // Recursively clone its children. + if (children) + { + var n:int = children.length; + for (var i:int = 0; i < n; i++) + { + var clonedChild:Watcher = children[i].deepClone(index); + w.addChild(clonedChild); + } + } + + // Return the cloned tree of watchers. + return w; + } + + /** + * @private + * Clone this watcher object itself, without cloning its children. + * The clone is not connec + * Subclasses must override this method to copy their properties. + */ + protected function shallowClone():Watcher + { + return new Watcher(); + } + + /** + * @private + */ + public function notifyListeners(commitEvent:Boolean):void + { + if (listeners) + { + var n:int = listeners.length; + + for (var i:int = 0; i < n; i++) + { + listeners[i].watcherFired(commitEvent, cloneIndex); + } + } + } +} + +}
