refactor again so UIHTMLElementWrapper is the base for all exposed components, but CSSShape and friend are simple subclasses of Flash display objects and are directly added to the display list
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/472c7af2 Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/472c7af2 Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/472c7af2 Branch: refs/heads/refactor-sprite Commit: 472c7af2059e301faf565215ee219fe7c10cd44e Parents: 1b3d413 Author: Alex Harui <aha...@apache.org> Authored: Tue Aug 2 10:05:57 2016 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Tue Aug 2 10:23:49 2016 -0700 ---------------------------------------------------------------------- .../org/apache/flex/charts/core/IAxisGroup.as | 3 +- .../flex/charts/optimized/SVGChartDataGroup.as | 5 +- .../flex/org/apache/flex/core/Application.as | 156 ++-------- .../org/apache/flex/core/ApplicationBase.as | 4 +- .../org/apache/flex/core/ApplicationFactory.as | 3 +- .../apache/flex/core/BrowserResizeListener.as | 10 +- .../main/flex/org/apache/flex/core/CSSShape.as | 102 +------ .../main/flex/org/apache/flex/core/CSSSprite.as | 14 +- .../flex/org/apache/flex/core/CSSTextField.as | 305 +------------------ .../flex/org/apache/flex/core/ContainerBase.as | 20 +- .../flex/core/ContainerBaseStrandChildren.as | 10 +- .../org/apache/flex/core/FilledRectangle.as | 2 +- .../org/apache/flex/core/HTMLElementWrapper.as | 210 +++++-------- .../main/flex/org/apache/flex/core/IChild.as | 15 +- .../flex/org/apache/flex/core/IContentView.as | 5 +- .../flex/org/apache/flex/core/IFlexJSElement.as | 3 +- .../flex/org/apache/flex/core/IItemRenderer.as | 2 +- .../main/flex/org/apache/flex/core/IParent.as | 10 +- .../org/apache/flex/core/ISWFApplication.as | 6 +- .../main/flex/org/apache/flex/core/IUIBase.as | 47 +-- .../main/flex/org/apache/flex/core/ListBase.as | 10 +- .../apache/flex/core/ListBaseStrandChildren.as | 10 +- .../org/apache/flex/core/SimpleApplication.as | 4 +- .../org/apache/flex/core/SimpleCSSValuesImpl.as | 3 +- .../org/apache/flex/core/SimpleStatesImpl.as | 13 +- .../apache/flex/core/StyleableCSSTextField.as | 6 +- .../main/flex/org/apache/flex/core/UIBase.as | 202 +++--------- .../flex/org/apache/flex/core/UIButtonBase.as | 172 ++--------- .../apache/flex/core/UIHTMLElementWrapper.as | 257 ++++++++++++++++ .../org/apache/flex/core/WrappedHTMLElement.as | 2 +- .../org/apache/flex/core/WrappedMovieClip.as | 52 ++++ .../flex/org/apache/flex/core/WrappedShape.as | 20 +- .../org/apache/flex/core/WrappedSimpleButton.as | 19 +- .../flex/org/apache/flex/core/WrappedSprite.as | 19 +- .../org/apache/flex/core/WrappedTextField.as | 11 +- .../flex/org/apache/flex/utils/DisplayUtils.as | 8 +- .../apache/flex/utils/MXMLDataInterpreter.as | 5 +- .../flex/utils/ViewSourceContextMenuOption.as | 4 +- .../org/apache/flex/createjs/Application.as | 24 +- .../org/apache/flex/createjs/core/UIBase.as | 43 +-- .../flex/org/apache/flex/events/DragEvent.as | 3 +- .../flex/core/StatesWithTransitionsImpl.as | 9 +- .../beads/CSSContentAndTextToggleButtonView.as | 6 +- .../flex/flat/beads/CSSScrollBarButtonView.as | 6 +- .../apache/flex/flat/beads/DropDownListView.as | 36 +-- .../flex/html/beads/FormatableTextInputView.as | 2 +- .../flex/org/apache/flex/svg/CompoundGraphic.as | 2 +- .../org/apache/flex/svg/GraphicContainer.as | 11 +- .../flex/org/apache/flex/svg/GraphicShape.as | 13 +- .../flex/org/apache/flex/svg/LinearGradient.as | 8 +- .../src/main/flex/org/apache/flex/svg/Text.as | 2 +- .../flex/org/apache/flex/html/RadioButton.as | 4 +- .../accessories/NumericOnlyTextInputBead.as | 2 +- .../flex/html/accessories/TextPromptBead.as | 4 +- .../flex/html/beads/BackgroundImageBead.as | 4 +- .../html/beads/CSSImageAndTextButtonView.as | 14 +- .../apache/flex/html/beads/CSSTextButtonView.as | 12 +- .../org/apache/flex/html/beads/CheckBoxView.as | 2 +- .../org/apache/flex/html/beads/ComboBoxView.as | 117 +++---- .../org/apache/flex/html/beads/ContainerView.as | 11 +- .../apache/flex/html/beads/DropDownListView.as | 21 +- .../flex/html/beads/ImageAndTextButtonView.as | 2 +- .../org/apache/flex/html/beads/ImageView.as | 3 +- .../apache/flex/html/beads/RadioButtonView.as | 2 +- .../apache/flex/html/beads/SliderThumbView.as | 2 +- .../org/apache/flex/html/beads/TextAreaView.as | 6 +- .../apache/flex/html/beads/TextButtonView.as | 6 +- .../apache/flex/html/beads/TextFieldViewBase.as | 4 +- .../apache/flex/html/beads/WebBrowserView.as | 2 +- .../EditableTextKeyboardController.as | 2 +- .../flex/html/beads/layouts/HorizontalLayout.as | 4 +- .../flex/html/supportClasses/DataGroup.as | 5 +- .../html/supportClasses/ScrollingViewport.as | 5 +- .../html/supportClasses/StringItemRenderer.as | 2 +- .../supportClasses/TextFieldItemRenderer.as | 7 +- .../src/main/resources/basic-as-manifest.xml | 2 +- .../org/apache/flex/mobile/IViewManagerView.as | 4 +- .../flex/org/apache/flex/mobile/ManagerBase.as | 11 +- .../apache/flex/mobile/StackedViewManager.as | 5 +- .../flex/mobile/models/ViewManagerModel.as | 5 +- 80 files changed, 889 insertions(+), 1295 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/core/IAxisGroup.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/core/IAxisGroup.as b/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/core/IAxisGroup.as index 23e711f..3d75b3f 100644 --- a/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/core/IAxisGroup.as +++ b/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/core/IAxisGroup.as @@ -18,6 +18,7 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.charts.core { + import org.apache.flex.core.IChild; import org.apache.flex.graphics.IFill; import org.apache.flex.graphics.IStroke; @@ -30,7 +31,7 @@ package org.apache.flex.charts.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public interface IAxisGroup + public interface IAxisGroup extends IChild { function removeAllElements():void; http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/optimized/SVGChartDataGroup.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/optimized/SVGChartDataGroup.as b/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/optimized/SVGChartDataGroup.as index bc2fbe3..270c034 100644 --- a/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/optimized/SVGChartDataGroup.as +++ b/frameworks/projects/Charts/src/main/flex/org/apache/flex/charts/optimized/SVGChartDataGroup.as @@ -21,6 +21,7 @@ package org.apache.flex.charts.optimized import org.apache.flex.charts.core.IChartDataGroup; import org.apache.flex.charts.core.IChartItemRenderer; import org.apache.flex.charts.core.IChartSeries; + import org.apache.flex.core.IChild; import org.apache.flex.core.IContentView; import org.apache.flex.core.IItemRenderer; import org.apache.flex.core.IItemRendererParent; @@ -141,7 +142,7 @@ package org.apache.flex.charts.optimized * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - override public function addElement(value:Object, dispatchEvent:Boolean = true):void + override public function addElement(value:IChild, dispatchEvent:Boolean = true):void { _children.push(value); @@ -160,7 +161,7 @@ package org.apache.flex.charts.optimized * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - override public function addElementAt(value:Object, index:int, dispatchEvent:Boolean = true):void + override public function addElementAt(value:IChild, index:int, dispatchEvent:Boolean = true):void { if (index >= _children.length) _children.push(value); else _children.splice(index, 0, value); http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as index 43f8494..693b442 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/Application.as @@ -27,6 +27,7 @@ package org.apache.flex.core COMPILE::SWF { import flash.display.DisplayObject; + import flash.display.Graphics; import flash.display.Sprite; import flash.events.Event; import flash.system.ApplicationDomain; @@ -136,9 +137,9 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public function setRoot(r:Sprite):void + public function setRoot(r:WrappedMovieClip):void { - $sprite = r; + element = r; MouseEventConverter.setupAllConverters(r.stage); initHandler(); } @@ -195,18 +196,18 @@ package org.apache.flex.core COMPILE::SWF { // if someone has installed a resize listener, fake an event to run it now - if ($sprite.stage.hasEventListener("resize")) - $sprite.stage.dispatchEvent(new flash.events.Event("resize")); + if ($displayObject.stage.hasEventListener("resize")) + $displayObject.stage.dispatchEvent(new flash.events.Event("resize")); else if (initialView is ILayoutChild) { var ilc:ILayoutChild = initialView as ILayoutChild; // otherwise, size once like this if (!isNaN(ilc.percentWidth) && !isNaN(ilc.percentHeight)) - ilc.setWidthAndHeight($sprite.stage.stageWidth, $sprite.stage.stageHeight, true); + ilc.setWidthAndHeight($displayObject.stage.stageWidth, $displayObject.stage.stageHeight, true); else if (!isNaN(ilc.percentWidth)) - ilc.setWidth($sprite.stage.stageWidth); + ilc.setWidth($displayObject.stage.stageWidth); else if (!isNaN(ilc.percentHeight)) - ilc.setHeight($sprite.stage.stageHeight); + ilc.setHeight($displayObject.stage.stageHeight); } } COMPILE::JS @@ -224,9 +225,10 @@ package org.apache.flex.core if (bgColor != null) { var backgroundColor:uint = ValuesManager.valuesImpl.convertColor(bgColor); - $sprite.graphics.beginFill(backgroundColor); - $sprite.graphics.drawRect(0, 0, initialView.width, initialView.height); - $sprite.graphics.endFill(); + var graphics:Graphics = Sprite($displayObject).graphics; + graphics.beginFill(backgroundColor); + graphics.drawRect(0, 0, initialView.width, initialView.height); + graphics.endFill(); } } dispatchEvent(new org.apache.flex.events.Event("viewChanged")); @@ -267,46 +269,6 @@ package org.apache.flex.core public var initialView:IApplicationView; /** - * The data model (for the initial view). - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Bindable("__NoChangeEvent__")] - COMPILE::SWF - public var model:Object; - - COMPILE::JS - private var _model:Object; - - /** - * The data model (for the initial view). - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - [Bindable("__NoChangeEvent__")] - COMPILE::JS - override public function get model():Object - { - return _model; - } - - /** - * @private - */ - [Bindable("__NoChangeEvent__")] - COMPILE::JS - override public function set model(value:Object):void - { - _model = value; - } - - /** * The controller. The controller typically watches * the UI for events and updates the model accordingly. * @@ -370,69 +332,6 @@ package org.apache.flex.core */ public var beads:Array; - COMPILE::SWF - private var _beads:Vector.<IBead>; - - /** - * @copy org.apache.flex.core.IStrand#addBead() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - override public function addBead(bead:IBead):void - { - if (!_beads) - _beads = new Vector.<IBead>; - _beads.push(bead); - bead.strand = this; - } - - /** - * @copy org.apache.flex.core.IStrand#getBeadByType() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - public function getBeadByType(classOrInterface:Class):IBead - { - for each (var bead:IBead in _beads) - { - if (bead is classOrInterface) - return bead; - } - return null; - } - - /** - * @copy org.apache.flex.core.IStrand#removeBead() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - public function removeBead(value:IBead):IBead - { - var n:int = _beads.length; - for (var i:int = 0; i < n; i++) - { - var bead:IBead = _beads[i]; - if (bead == value) - { - _beads.splice(i, 1); - return bead; - } - } - return null; - } - private var _elements:Array; /** @@ -442,24 +341,25 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.IUIBase + * @flexjsignorecoercion HTMLElement */ - public function addElement(c:Object, dispatchEvent:Boolean = true):void + public function addElement(c:IChild, dispatchEvent:Boolean = true):void { COMPILE::SWF { if(_elements == null) _elements = []; _elements[_elements.length] = c; - $sprite.addChild(c.$sprite); - c.parent = this; + $displayObjectContainer.addChild(c.$displayObject); if (c is IUIBase) { IUIBase(c).addedToParent(); } } COMPILE::JS { - this.element.appendChild(c.element); - c.addedToParent(); + this.element.appendChild(c.element as HTMLElement); + (c as IUIBase).addedToParent(); } } @@ -470,8 +370,9 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.IUIBase */ - public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { COMPILE::SWF { @@ -479,8 +380,7 @@ package org.apache.flex.core _elements = []; _elements.splice(index,0,c); - $sprite.addChildAt(c.$sprite,index); - c.parent = this; + $displayObjectContainer.addChildAt(c.$displayObject,index); if (c is IUIBase) { @@ -495,7 +395,7 @@ package org.apache.flex.core { element.insertBefore(c.positioner, children[index]); - c.addedToParent(); + (c as IUIBase).addedToParent(); } } @@ -509,7 +409,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function getElementAt(index:int):Object + public function getElementAt(index:int):IChild { COMPILE::SWF { @@ -532,7 +432,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function getElementIndex(c:Object):int + public function getElementIndex(c:IChild):int { COMPILE::SWF { @@ -559,8 +459,9 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLElement */ - public function removeElement(c:Object, dispatchEvent:Boolean = true):void + public function removeElement(c:IChild, dispatchEvent:Boolean = true):void { COMPILE::SWF { @@ -569,13 +470,12 @@ package org.apache.flex.core var idx:int = _elements.indexOf(c); if(idx>=0) _elements.splice(idx,1); - c.parent = null; } - $sprite.removeChild(c.$sprite as DisplayObject); + $displayObjectContainer.removeChild(c.$displayObject as DisplayObject); } COMPILE::JS { - element.removeChild(c.element); + element.removeChild(c.element as HTMLElement); } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as index 4040395..0fe63ba 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationBase.as @@ -33,7 +33,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class ApplicationBase extends HTMLElementWrapper implements IFlexInfo + public class ApplicationBase extends UIHTMLElementWrapper implements IFlexInfo { /** * Constructor. @@ -73,7 +73,7 @@ package org.apache.flex.core } COMPILE::JS - public class ApplicationBase extends HTMLElementWrapper implements IFlexInfo + public class ApplicationBase extends UIHTMLElementWrapper implements IFlexInfo { /** * Constructor. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as index e3698c1..0b75d6c 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ApplicationFactory.as @@ -19,7 +19,6 @@ package org.apache.flex.core { COMPILE::SWF { - import flash.display.MovieClip; import flash.display.StageAlign; import flash.display.StageQuality; import flash.display.StageScaleMode; @@ -37,7 +36,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class ApplicationFactory extends MovieClip + public class ApplicationFactory extends WrappedMovieClip { /** * Constructor. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as index 8c3c456..9dcd96b 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/BrowserResizeListener.as @@ -83,7 +83,7 @@ COMPILE::SWF app = value as Application; COMPILE::SWF { - app.$sprite.stage.addEventListener("resize", resizeHandler); + app.$displayObject.stage.addEventListener("resize", resizeHandler); if (ExternalInterface.available && (!isNaN(minWidth) || !isNaN(minHeight))) { // Get application name. This assumes that the wrapper is using an @@ -115,12 +115,12 @@ COMPILE::SWF { var initialView:UIBase = app.initialView as UIBase; if (!isNaN(initialView.percentWidth) && !isNaN(initialView.percentHeight)) - initialView.setWidthAndHeight(Math.max(minWidth, app.$sprite.stage.stageWidth), - Math.max(minHeight, app.$sprite.stage.stageHeight), true); + initialView.setWidthAndHeight(Math.max(minWidth, app.$displayObject.stage.stageWidth), + Math.max(minHeight, app.$displayObject.stage.stageHeight), true); else if (!isNaN(initialView.percentWidth)) - initialView.setWidth(Math.max(minWidth, app.$sprite.stage.stageWidth)); + initialView.setWidth(Math.max(minWidth, app.$displayObject.stage.stageWidth)); else if (!isNaN(initialView.percentHeight)) - initialView.setHeight(Math.max(minHeight, app.$sprite.stage.stageHeight)); + initialView.setHeight(Math.max(minHeight, app.$displayObject.stage.stageHeight)); } COMPILE::JS { http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as index c024822..a2791fa 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSShape.as @@ -24,9 +24,8 @@ package org.apache.flex.core import org.apache.flex.core.IChild; import org.apache.flex.events.Event; - import org.apache.flex.utils.CSSBorderUtils; - import org.apache.flex.events.Event; import org.apache.flex.events.EventDispatcher; + import org.apache.flex.utils.CSSBorderUtils; /** * The Border class is a class used internally by many @@ -39,7 +38,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class CSSShape extends EventDispatcher implements IStyleableObject, IChild + public class CSSShape extends Shape implements IStyleableObject { /** * Constructor. @@ -51,103 +50,8 @@ package org.apache.flex.core */ public function CSSShape() { - _shape = new WrappedShape(); - _shape.flexjs_wrapper = this; } - private var _shape:WrappedShape; - public function get $diplayObject():DisplayObject - { - return _shape; - } - - public function get $shape():Shape - { - return _shape; - } - - /** - * @copy org.apache.flex.core.HTMLElementWrapper#element - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get element():IFlexJSElement - { - return _shape; - } - - private var _parent:IParent; - public function get parent():IParent - { - return _parent; - } - public function set parent(val:IParent):void - { - _parent = val; - } - - public function get width():Number - { - return _shape.width; - } - - public function set width(value:Number):void - { - _shape.width = value; - } - - public function get height():Number - { - return _shape.height; - } - - public function set height(value:Number):void - { - _shape.height = value; - } - - public function get x():Number - { - return _shape.x; - } - - public function set x(value:Number):void - { - _shape.x = value; - } - - public function get y():Number - { - return _shape.y; - } - - public function set y(value:Number):void - { - _shape.y = value; - } - - public function get visible():Boolean - { - return _shape.visible; - } - - public function set visible(value:Boolean):void - { - _shape.visible = value; - } - public function get alpha():Number - { - return _shape.alpha; - } - - public function set alpha(value:Number):void - { - _shape.alpha = value; - } - private var _id:String; /** @@ -254,7 +158,7 @@ package org.apache.flex.core */ public function draw(w:Number, h:Number):void { - CSSBorderUtils.draw(_shape.graphics, w, h, this, state, true); + CSSBorderUtils.draw(graphics, w, h, this, state, true); } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSSprite.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSSprite.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSSprite.as index c9e0742..35711bc 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSSprite.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSSprite.as @@ -18,8 +18,15 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { +<<<<<<< HEAD import flash.display.DisplayObject; +======= + COMPILE::SWF + { +>>>>>>> refactor again so UIHTMLElementWrapper is the base for all exposed components, but CSSShape and friend are simple subclasses of Flash display objects and are directly added to the display list import flash.display.Graphics; + import flash.display.Sprite; + } import org.apache.flex.core.IChild; import org.apache.flex.events.Event; @@ -37,7 +44,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class CSSSprite extends HTMLElementWrapper implements IStyleableObject, IChild, IParentIUIBase + public class CSSSprite extends Sprite implements IStyleableObject { /** * Constructor. @@ -49,7 +56,6 @@ package org.apache.flex.core */ public function CSSSprite() { - super(); } private var _id:String; @@ -158,7 +164,11 @@ package org.apache.flex.core */ public function draw(w:Number, h:Number):void { +<<<<<<< HEAD CSSBorderUtils.draw($sprite.graphics, w, h,this, state, true); +======= + CSSBorderUtils.draw(graphics, w, h, this, state, true); +>>>>>>> refactor again so UIHTMLElementWrapper is the base for all exposed components, but CSSShape and friend are simple subclasses of Flash display objects and are directly added to the display list } /** http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as index effb787..87dfafd 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/CSSTextField.as @@ -41,7 +41,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class CSSTextField extends EventDispatcher + public class CSSTextField extends TextField { /** * Constructor. @@ -53,292 +53,8 @@ package org.apache.flex.core */ public function CSSTextField() { - _textField = new WrappedTextField(); - _textField.flexjs_wrapper = this; - } - private var _textField:WrappedTextField; - - public function get $textField():TextField - { - return _textField; - } - - - public function get $displayObject():DisplayObject - { - return _textField; - } - - /** - * @copy org.apache.flex.core.HTMLElementWrapper#element - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get element():IFlexJSElement - { - return _textField; - } - - private var _parent:IParent; - public function get parent():IParent - { - return _parent; - } - public function set parent(val:IParent):void - { - _parent = val; - } - - public function get width():Number - { - return _textField.width; - } - - public function set width(value:Number):void - { - _textField.width = value; - } - - public function get height():Number - { - return _textField.height; - } - - public function set height(value:Number):void - { - _textField.height = value; - } - - public function get x():Number - { - return _textField.x; - } - - public function set x(value:Number):void - { - _textField.x = value; - } - - public function get y():Number - { - return _textField.y; - } - - public function set y(value:Number):void - { - _textField.y = value; - } - - public function get visible():Boolean - { - return _textField.visible; - } - - public function set visible(value:Boolean):void - { - _textField.visible = value; - } - - public function get alpha():Number - { - return _textField.alpha; - } - - public function set alpha(value:Number):void - { - _textField.alpha = value; - } - - public function get embedFonts():Boolean - { - return _textField.embedFonts; - } - - public function set embedFonts(value:Boolean):void - { - _textField.embedFonts = value; - } - - public function get selectable():Boolean - { - return _textField.selectable; - } - - public function set selectable(value:Boolean):void - { - _textField.selectable = value; - } - - public function get type():String - { - return _textField.type; - } - - public function set type(value:String):void - { - _textField.type = value; - } - - public function get mouseEnabled():Boolean - { - return _textField.mouseEnabled; - } - - public function set mouseEnabled(value:Boolean):void - { - _textField.mouseEnabled = value; - } - - public function get autoSize():String - { - return _textField.autoSize; - } - - public function set autoSize(value:String):void - { - _textField.autoSize = value; - } - - public function get textColor():uint - { - return _textField.textColor; - } - - public function set textColor(value:uint):void - { - _textField.textColor = value; - } - - public function get textWidth():Number - { - return _textField.textWidth; - } - - public function get textHeight():Number - { - return _textField.textHeight; - } - - public function get wordWrap():Boolean - { - return _textField.wordWrap; - } - - public function set wordWrap(value:Boolean):void - { - _textField.wordWrap = value; - } - - public function get multiline():Boolean - { - return _textField.multiline; - } - - public function set multiline(value:Boolean):void - { - _textField.multiline = value; - } - - public function get restrict():String - { - return _textField.restrict; - } - - public function set restrict(value:String):void - { - _textField.restrict = value; - } - - public function get maxChars():int - { - return _textField.maxChars; - } - - public function set maxChars(value:int):void - { - _textField.maxChars = value; - } - - public function get displayAsPassword():Boolean - { - return _textField.displayAsPassword; - } - - public function set displayAsPassword(value:Boolean):void - { - _textField.displayAsPassword = value; - } - - public function get htmlText():String - { - return _textField.htmlText; - } - - public function set htmlText(value:String):void - { - _textField.htmlText = value; - } - - public function get name():String - { - return _textField.name; - } - - public function set name(value:String):void - { - _textField.name = value; - } - - public function get background():Boolean - { - return _textField.background; - } - - public function set background(value:Boolean):void - { - _textField.background = value; - } - - public function get backgroundColor():uint - { - return _textField.backgroundColor; - } - - public function set backgroundColor(value:uint):void - { - _textField.backgroundColor = value; - } - - public function get border():Boolean - { - return _textField.border; - } - - public function set border(value:Boolean):void - { - _textField.border = value; - } - - public function get borderColor():uint - { - return _textField.borderColor; - } - - public function set borderColor(value:uint):void - { - _textField.borderColor = value; - } - - public function get numLines():int - { - return _textField.numLines; - } - /** * @private * The styleParent property is set if the CSSTextField @@ -390,7 +106,7 @@ package org.apache.flex.core /** * @private */ - public function set text(value:String):void + override public function set text(value:String):void { var sp:Object = parent; if (styleParent) @@ -413,32 +129,27 @@ package org.apache.flex.core var align:Object = ValuesManager.valuesImpl.getValue(sp, "text-align", styleState); if (align == "center") { - _textField.autoSize = TextFieldAutoSize.NONE; + autoSize = TextFieldAutoSize.NONE; tf.align = "center"; } else if (align == "right") { tf.align = "right"; - _textField.autoSize = TextFieldAutoSize.NONE; + autoSize = TextFieldAutoSize.NONE; } if (!parentDrawsBackground) { var backgroundColor:Object = ValuesManager.valuesImpl.getValue(sp, "background-color", styleState); if (backgroundColor != null) { - _textField.background = true; - _textField.backgroundColor = CSSUtils.toColor(backgroundColor); + background = true; + backgroundColor = CSSUtils.toColor(backgroundColor); } } - _textField.defaultTextFormat = tf; - _textField.text = value; + defaultTextFormat = tf; + text = value; } - public function get text():String - { - return _textField.text; - } - private function updateStyles(event:Event):void { // force styles to be re-calculated http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBase.as index 5b6cc26..0dd0b53 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBase.as @@ -106,7 +106,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - override public function getElementAt(index:int):Object + override public function getElementAt(index:int):IChild { var contentView:IParent = view as IParent; if (contentView != null) { @@ -119,7 +119,7 @@ package org.apache.flex.core /** * @private */ - override public function getElementIndex(c:Object):int + override public function getElementIndex(c:IChild):int { var contentView:IParent = view as IParent; if (contentView != null) { @@ -132,7 +132,7 @@ package org.apache.flex.core /** * @private */ - override public function addElement(c:Object, dispatchEvent:Boolean = true):void + override public function addElement(c:IChild, dispatchEvent:Boolean = true):void { var contentView:IParent = view as IParent; if (contentView != null) { @@ -148,7 +148,7 @@ package org.apache.flex.core /** * @private */ - override public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + override public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { var contentView:IParent = view as IParent; if (contentView != null) { @@ -164,7 +164,7 @@ package org.apache.flex.core /** * @private */ - override public function removeElement(c:Object, dispatchEvent:Boolean = true):void + override public function removeElement(c:IChild, dispatchEvent:Boolean = true):void { var contentView:IParent = view as IParent; if (contentView != null) { @@ -229,7 +229,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $addElement(c:Object, dispatchEvent:Boolean = true):void + public function $addElement(c:IChild, dispatchEvent:Boolean = true):void { super.addElement(c, dispatchEvent); } @@ -239,7 +239,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + public function $addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { super.addElementAt(c, index, dispatchEvent); } @@ -249,7 +249,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $removeElement(c:Object, dispatchEvent:Boolean = true):void + public function $removeElement(c:IChild, dispatchEvent:Boolean = true):void { super.removeElement(c, dispatchEvent); } @@ -259,7 +259,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $getElementIndex(c:Object):int + public function $getElementIndex(c:IChild):int { return super.getElementIndex(c); } @@ -269,7 +269,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $getElementAt(index:int):Object + public function $getElementAt(index:int):IChild { return super.getElementAt(index); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as index 93e5c53..e961c1f 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ContainerBaseStrandChildren.as @@ -59,7 +59,7 @@ package org.apache.flex.core /** * @private */ - public function addElement(c:Object, dispatchEvent:Boolean = true):void + public function addElement(c:IChild, dispatchEvent:Boolean = true):void { owner.$addElement(c, dispatchEvent); } @@ -67,7 +67,7 @@ package org.apache.flex.core /** * @private */ - public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { owner.$addElementAt(c, index, dispatchEvent); } @@ -75,7 +75,7 @@ package org.apache.flex.core /** * @private */ - public function removeElement(c:Object, dispatchEvent:Boolean = true):void + public function removeElement(c:IChild, dispatchEvent:Boolean = true):void { owner.$removeElement(c, dispatchEvent); } @@ -83,7 +83,7 @@ package org.apache.flex.core /** * @private */ - public function getElementIndex(c:Object):int + public function getElementIndex(c:IChild):int { return owner.$getElementIndex(c); } @@ -91,7 +91,7 @@ package org.apache.flex.core /** * @private */ - public function getElementAt(index:int):Object + public function getElementAt(index:int):IChild { return owner.$getElementAt(index); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/FilledRectangle.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/FilledRectangle.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/FilledRectangle.as index 962a11d..5888a94 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/FilledRectangle.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/FilledRectangle.as @@ -51,7 +51,7 @@ package org.apache.flex.core COMPILE::SWF { _shape = new flash.display.Shape(); - this.addElement(_shape); + $displayObjectContainer.addChild(_shape); } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as index 4879f42..1b42a83 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/HTMLElementWrapper.as @@ -18,12 +18,6 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - COMPILE::SWF - { - import flash.display.DisplayObject; - import flash.display.Sprite; - } - COMPILE::JS { import window.Event; @@ -36,119 +30,98 @@ package org.apache.flex.core import org.apache.flex.events.EventDispatcher; COMPILE::SWF - public class HTMLElementWrapper extends EventDispatcher + public class HTMLElementWrapper extends EventDispatcher implements IStrand { public function HTMLElementWrapper() { - _sprite = new WrappedSprite(); - _sprite.flexjs_wrapper = this; } - private var _sprite:WrappedSprite; + //-------------------------------------- + // Property + //-------------------------------------- - public function get $sprite():Sprite - { - return _sprite; - } + protected var _element:IFlexJSElement; - public function get $displayObject():DisplayObject + public function get element():IFlexJSElement { - return _sprite; + return _element; } - - /** - * Returns the IFlexJSElement which wraps the Display Object - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - public function get element():IFlexJSElement + + public function set element(value:IFlexJSElement):void { - return _sprite; + _element = value; } - - protected var _elements:Array; - + + protected var _beads:Vector.<IBead>; + + //-------------------------------------- + // Function + //-------------------------------------- + /** - * "abstract" method so we can override in JS * @param bead The new bead. */ public function addBead(bead:IBead):void - { - } - - private var _parent:IParent; - public function get parent():IParent - { - return _parent; - } - public function set parent(val:IParent):void - { - _parent = val; - } - - public function get width():Number - { - return _sprite.width; - } - - public function set width(value:Number):void - { - _sprite.width = value; - } - - public function get height():Number - { - return _sprite.height; - } - - public function set height(value:Number):void { - _sprite.height = value; - } - - public function get x():Number - { - return _sprite.x; - } - - public function set x(value:Number):void - { - _sprite.x = value; - } - - public function get y():Number - { - return _sprite.y; + if (!_beads) + { + _beads = new Vector.<IBead>(); + } + + _beads.push(bead); + bead.strand = this; } - - public function set y(value:Number):void - { - _sprite.y = value; - } - - public function get visible():Boolean + + /** + * @param classOrInterface The requested bead type. + * @return The bead. + */ + public function getBeadByType(classOrInterface:Class):IBead { - return _sprite.visible; + var bead:IBead, i:uint, n:uint; + + if (!_beads) return null; + + n = _beads.length; + + for (i = 0; i < n; i++) + { + bead = _beads[i]; + + if (bead is classOrInterface) + { + return bead; + } + } + + return null; } - - public function set visible(value:Boolean):void - { - _sprite.visible = value; - } - - public function get alpha():Number + + /** + * @param bead The bead to remove. + * @return The bead. + */ + public function removeBead(bead:IBead):IBead { - return _sprite.alpha; + var i:uint, n:uint, value:Object; + + n = _beads.length; + + for (i = 0; i < n; i++) + { + value = _beads[i]; + + if (bead === value) + { + _beads.splice(i, 1); + + return bead; + } + } + + return null; } - - public function set alpha(value:Number):void - { - _sprite.alpha = value; - } - + } COMPILE::JS @@ -198,7 +171,10 @@ package org.apache.flex.core // Property //-------------------------------------- - private var _element:WrappedHTMLElement; + /** + * An optimization to skip the getter of the element property + */ + protected var _element:WrappedHTMLElement; public function get element():WrappedHTMLElement { @@ -210,36 +186,6 @@ package org.apache.flex.core _element = value; } - /** - * allow access from overrides - */ - protected var _model:IBeadModel; - - /** - * @flexjsignorecoercion Class - * @flexjsignorecoercion org.apache.flex.core.IBeadModel - */ - public function get model():Object - { - if (_model == null) - { - // addbead will set _model - var m:Class = org.apache.flex.core.ValuesManager.valuesImpl. - getValue(this, 'iBeadModel') as Class; - var b:IBeadModel = new m() as IBeadModel; - addBead(b); - } - return _model; - } - - public function set model(value:Object):void - { - if (_model != value) - { - addBead(value as IBead); - dispatchEvent(new org.apache.flex.events.Event("modelChanged")); - } - } protected var _beads:Vector.<IBead>; @@ -258,12 +204,6 @@ package org.apache.flex.core } _beads.push(bead); - - if (bead is IBeadModel) - { - _model = bead as IBeadModel; - } - bead.strand = this; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as index f1e893b..30a358f 100755 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IChild.as @@ -18,7 +18,10 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { - +COMPILE::SWF +{ + import flash.display.DisplayObject; +} /** * The IChild interface is the basic interface for a * component that is parented by another component. @@ -40,5 +43,15 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ function get parent():IParent; + + COMPILE::SWF + function get $displayObject():DisplayObject; + + COMPILE::JS + function get element():IFlexJSElement; + + COMPILE::JS + function get positioner():WrappedHTMLElement; + } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IContentView.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IContentView.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IContentView.as index 42cc685..364f971 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IContentView.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IContentView.as @@ -17,8 +17,8 @@ // //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core -{ - public interface IContentView +{ + public interface IContentView extends IParent { function get x():Number; function set x(value:Number):void; @@ -32,7 +32,6 @@ package org.apache.flex.core function get height():Number; function set height(value:Number):void; - function addElement(value:Object, dispatchEvent:Boolean = true):void; function removeAllElements():void; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IFlexJSElement.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IFlexJSElement.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IFlexJSElement.as index 1136297..9963c4e 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IFlexJSElement.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IFlexJSElement.as @@ -33,7 +33,8 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.7 */ - //function get flexjs_wrapper():Object; + function get flexjs_wrapper():HTMLElementWrapper; + function set flexjs_wrapper(value:HTMLElementWrapper):void; } COMPILE::JS http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IItemRenderer.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IItemRenderer.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IItemRenderer.as index 237517d..ddd8bbd 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IItemRenderer.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IItemRenderer.as @@ -29,7 +29,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public interface IItemRenderer extends IEventDispatcher + public interface IItemRenderer extends IEventDispatcher, IChild { /** * The data item to be displayed by the item renderer. http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IParent.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IParent.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IParent.as index 2b49278..9b0a09b 100755 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IParent.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IParent.as @@ -41,7 +41,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function addElement(c:Object, dispatchEvent:Boolean = true):void; + function addElement(c:IChild, dispatchEvent:Boolean = true):void; /** * Add a component to the parent. @@ -55,7 +55,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void; + function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void; /** * Gets the index of this subcomponent. @@ -68,7 +68,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function getElementIndex(c:Object):int; + function getElementIndex(c:IChild):int; /** * Remove a component from the parent. @@ -81,7 +81,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function removeElement(c:Object, dispatchEvent:Boolean = true):void; + function removeElement(c:IChild, dispatchEvent:Boolean = true):void; /** * The number of elements in the parent. @@ -103,7 +103,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - function getElementAt(index:int):Object; + function getElementAt(index:int):IChild; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as index 272d6b6..41e1beb 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ISWFApplication.as @@ -18,10 +18,6 @@ //////////////////////////////////////////////////////////////////////////////// package org.apache.flex.core { -COMPILE::SWF -{ - import flash.display.Sprite; -} /** * Interface for bootstrapping SWF Applications. @@ -42,7 +38,7 @@ COMPILE::SWF * @productversion FlexJS 0.0 */ COMPILE::SWF - function setRoot(root:Sprite):void; + function setRoot(root:WrappedMovieClip):void; } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IUIBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IUIBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IUIBase.as index 60b3029..7e566d1 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IUIBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/IUIBase.as @@ -32,55 +32,10 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public interface IUIBase extends IStrand, IEventDispatcher + public interface IUIBase extends IStrand, IEventDispatcher, IChild { /** - * - * @private - */ - COMPILE::SWF - function get $displayObject():DisplayObject; - /** - * Each IUIBase has an element that is actually added to - * the platform's display list DOM. It may not be the actual - * component itself. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - function get element():IFlexJSElement; - - /** - * Each IUIBase has an element that is actually added to - * the platform's display list DOM. It may not be the actual - * component itself. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::JS - function get element():WrappedHTMLElement; - - /** - * Each IUIBase has an element that is actually added to - * the platform's display list DOM. It may not be the actual - * component itself. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::JS - function get positioner():WrappedHTMLElement; - - /** * Called by parent components when the component is * added via a call to addElement or addElementAt. * http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBase.as index dbdcace..f9c0aaa 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBase.as @@ -77,7 +77,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $addElement(c:Object, dispatchEvent:Boolean = true):void + public function $addElement(c:IChild, dispatchEvent:Boolean = true):void { super.addElement(c, dispatchEvent); } @@ -87,7 +87,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + public function $addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { super.addElementAt(c, index, dispatchEvent); } @@ -97,7 +97,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $removeElement(c:Object, dispatchEvent:Boolean = true):void + public function $removeElement(c:IChild, dispatchEvent:Boolean = true):void { super.removeElement(c, dispatchEvent); } @@ -107,7 +107,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $getElementIndex(c:Object):int + public function $getElementIndex(c:IChild):int { return super.getElementIndex(c); } @@ -117,7 +117,7 @@ package org.apache.flex.core * @suppress {undefinedNames} * Support strandChildren. */ - public function $getElementAt(index:int):Object + public function $getElementAt(index:int):IChild { return super.getElementAt(index); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as index e8f2fa5..b1748f9 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/ListBaseStrandChildren.as @@ -60,7 +60,7 @@ package org.apache.flex.core /** * @private */ - public function addElement(c:Object, dispatchEvent:Boolean = true):void + public function addElement(c:IChild, dispatchEvent:Boolean = true):void { owner.$addElement(c, dispatchEvent); } @@ -68,7 +68,7 @@ package org.apache.flex.core /** * @private */ - public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { owner.$addElementAt(c, index, dispatchEvent); } @@ -76,7 +76,7 @@ package org.apache.flex.core /** * @private */ - public function removeElement(c:Object, dispatchEvent:Boolean = true):void + public function removeElement(c:IChild, dispatchEvent:Boolean = true):void { owner.$removeElement(c, dispatchEvent); } @@ -84,7 +84,7 @@ package org.apache.flex.core /** * @private */ - public function getElementIndex(c:Object):int + public function getElementIndex(c:IChild):int { return owner.$getElementIndex(c); } @@ -92,7 +92,7 @@ package org.apache.flex.core /** * @private */ - public function getElementAt(index:int):Object + public function getElementAt(index:int):IChild { return owner.$getElementAt(index); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as index 93af131..770d0b2 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleApplication.as @@ -75,9 +75,9 @@ package org.apache.flex.core } COMPILE::SWF - public function setRoot(r:Sprite):void + public function setRoot(r:WrappedMovieClip):void { - $sprite = r; + element = r; start(); } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as index dd1f3d1..7435ef4 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleCSSValuesImpl.as @@ -706,6 +706,7 @@ package org.apache.flex.core /** * @param thisObject The object to apply styles to; * @param styles The styles. + * @flexjsignorecoercion HTMLElement */ COMPILE::JS public function applyStyles(thisObject:IUIBase, styles:Object):void @@ -734,7 +735,7 @@ package org.apache.flex.core if (p.indexOf('url') !== 0) value = 'url(' + value + ')'; } - thisObject.element.style[p] = value; + (thisObject.element as HTMLElement).style[p] = value; } } } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as index 4a27318..81b8f81 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/SimpleStatesImpl.as @@ -83,6 +83,9 @@ package org.apache.flex.core IStatesObject(_strand).currentState)); } + /** + * @flexjsignorecoercion org.apache.flex.core.IStatesObject + */ private function stateChangeHandler(event:ValueChangeEvent):void { if (!sawInitComplete) @@ -109,6 +112,9 @@ package org.apache.flex.core doc.dispatchEvent(new Event("stateChangeComplete")); } + /** + * @flexjsignorecoercion org.apache.flex.core.IParent + */ private function revert(s:State):void { var arr:Array = s.overrides; @@ -148,6 +154,11 @@ package org.apache.flex.core } } + /** + * @flexjsignorecoercion org.apache.flex.core.IChild + * @flexjsignorecoercion org.apache.flex.core.IParent + * @flexjsignorecoercion Array + */ private function apply(s:State):void { var arr:Array = s.overrides; @@ -174,7 +185,7 @@ package org.apache.flex.core parent = parent[ai.destination] as IParent; if (ai.relativeTo != null) { - var child:Object = ai.document[ai.relativeTo]; + var child:IChild = ai.document[ai.relativeTo] as IChild; if (ai.destination == null) parent = child.parent as IParent; var index:int = parent.getElementIndex(child); http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as index 0d6841b..d362d60 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/StyleableCSSTextField.as @@ -34,7 +34,7 @@ package org.apache.flex.core * @productversion FlexJS 0.0 */ COMPILE::SWF - public class StyleableCSSTextField extends CSSTextField implements IStyleableObject, IChild + public class StyleableCSSTextField extends CSSTextField implements IStyleableObject { /** * Constructor. @@ -66,10 +66,10 @@ package org.apache.flex.core */ public var CSSParent:Object; - override public function get parent():IParent + override public function get parent():DisplayObjectContainer { if (CSSParent) - return CSSParent as IParent; + return CSSParent as DisplayObjectContainer; return super.parent; } http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/472c7af2/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as ---------------------------------------------------------------------- diff --git a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as index 5e65dfc..fe303ab 100644 --- a/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as +++ b/frameworks/projects/Core/src/main/flex/org/apache/flex/core/UIBase.as @@ -138,7 +138,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public class UIBase extends HTMLElementWrapper implements IStrandWithModel, IEventDispatcher, IParentIUIBase, IStyleableObject, ILayoutChild, IFlexJSElement + public class UIBase extends UIHTMLElementWrapper implements IStrandWithModel, IEventDispatcher, IParentIUIBase, IStyleableObject, ILayoutChild { /** * Constructor. @@ -157,10 +157,13 @@ package org.apache.flex.core MouseEventConverter.setupInstanceConverters(this); } - COMPILE::JS - { - createElement(); - } + createElement(); + } + + COMPILE::SWF + public function get $sprite():Sprite + { + return $displayObject as Sprite; } private var _explicitWidth:Number; @@ -794,42 +797,7 @@ package org.apache.flex.core { return element.childNodes as Array; } - - COMPILE::SWF - private var _model:IBeadModel; - - /** - * An IBeadModel that serves as the data model for the component. - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - public function get model():Object - { - if (_model == null) - { - // addbead will set _model - addBead(new (ValuesManager.valuesImpl.getValue(this, "iBeadModel")) as IBead); - } - return _model; - } - - /** - * @private - */ - COMPILE::SWF - public function set model(value:Object):void - { - if (_model != value) - { - addBead(value as IBead); - dispatchEvent(new Event("modelChanged")); - } - } - + private var _view:IBeadView; /** @@ -1004,63 +972,19 @@ package org.apache.flex.core */ override public function addBead(bead:IBead):void { - if (!_beads) - _beads = new Vector.<IBead>; - _beads.push(bead); - if (bead is IBeadModel) - _model = bead as IBeadModel; - else if (bead is IBeadView) + super.addBead(bead); + if (bead is IBeadView) _view = bead as IBeadView; - bead.strand = this; if (bead is IBeadView) { IEventDispatcher(this).dispatchEvent(new Event("viewChanged")); } } - /** - * @copy org.apache.flex.core.IStrand#getBeadByType() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - public function getBeadByType(classOrInterface:Class):IBead - { - for each (var bead:IBead in _beads) - { - if (bead is classOrInterface) - return bead; - } - return null; - } - - /** - * @copy org.apache.flex.core.IStrand#removeBead() - * - * @langversion 3.0 - * @playerversion Flash 10.2 - * @playerversion AIR 2.6 - * @productversion FlexJS 0.0 - */ - COMPILE::SWF - public function removeBead(value:IBead):IBead - { - var n:int = _beads.length; - for (var i:int = 0; i < n; i++) - { - var bead:IBead = _beads[i]; - if (bead == value) - { - _beads.splice(i, 1); - return bead; - } - } - return null; - } + // maintain this or just calculate it from the displayobject children on demand? + private var _elements:Array; + /** * @copy org.apache.flex.core.IParent#addElement() * @@ -1068,16 +992,16 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.IUIBase */ - public function addElement(c:Object, dispatchEvent:Boolean = true):void + public function addElement(c:IChild, dispatchEvent:Boolean = true):void { COMPILE::SWF { if(_elements == null) _elements = []; _elements[_elements.length] = c; - $sprite.addChild(c.$displayObject); - c.parent = this; + $displayObjectContainer.addChild(c.$displayObject); if (c is IUIBase) { IUIBase(c).addedToParent(); @@ -1087,7 +1011,7 @@ package org.apache.flex.core COMPILE::JS { element.appendChild(c.positioner); - c.addedToParent(); + (c as IUIBase).addedToParent(); } } @@ -1098,8 +1022,9 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion org.apache.flex.core.IUIBase */ - public function addElementAt(c:Object, index:int, dispatchEvent:Boolean = true):void + public function addElementAt(c:IChild, index:int, dispatchEvent:Boolean = true):void { COMPILE::SWF { @@ -1107,12 +1032,11 @@ package org.apache.flex.core _elements = []; _elements.splice(index,0,c); - $sprite.addChildAt(c.$sprite,index); - c.parent = this; + $displayObjectContainer.addChildAt(c.$displayObject,index); if (c is IUIBase) { - IUIBase(c).addedToParent(); + (c as IUIBase).addedToParent(); } } COMPILE::JS @@ -1124,7 +1048,7 @@ package org.apache.flex.core { element.insertBefore(c.positioner, children[index]); - c.addedToParent(); + (c as IUIBase).addedToParent(); } } } @@ -1137,7 +1061,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function getElementAt(index:int):Object + public function getElementAt(index:int):IChild { COMPILE::SWF { @@ -1160,7 +1084,7 @@ package org.apache.flex.core * @playerversion AIR 2.6 * @productversion FlexJS 0.0 */ - public function getElementIndex(c:Object):int + public function getElementIndex(c:IChild):int { COMPILE::SWF { @@ -1188,8 +1112,9 @@ package org.apache.flex.core * @playerversion Flash 10.2 * @playerversion AIR 2.6 * @productversion FlexJS 0.0 + * @flexjsignorecoercion HTMLElement */ - public function removeElement(c:Object, dispatchEvent:Boolean = true):void + public function removeElement(c:IChild, dispatchEvent:Boolean = true):void { COMPILE::SWF { @@ -1198,13 +1123,12 @@ package org.apache.flex.core var idx:int = _elements.indexOf(c); if(idx>=0) _elements.splice(idx,1); - c.parent = null; } - $sprite.removeChild(c.$sprite as DisplayObject); + $displayObjectContainer.removeChild(c.$displayObject as DisplayObject); } COMPILE::JS { - element.removeChild(c.element); + element.removeChild(c.element as HTMLElement); } } @@ -1367,7 +1291,7 @@ package org.apache.flex.core { if (!_stageProxy) { - _stageProxy = new StageProxy($sprite.stage); + _stageProxy = new StageProxy($displayObject.stage); _stageProxy.addEventListener("removedFromStage", stageProxy_removedFromStageHandler); } @@ -1394,44 +1318,31 @@ package org.apache.flex.core dispatchEvent(event); } - COMPILE::JS - private var _positioner:WrappedHTMLElement; - - /** - * The HTMLElement used to position the component. - */ - COMPILE::JS - public function get positioner():WrappedHTMLElement - { - return _positioner; - } - - /** - * @private - */ - COMPILE::JS - public function set positioner(value:WrappedHTMLElement):void - { - _positioner = value; - } - /** * @return The actual element to be parented. * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement */ - COMPILE::JS - protected function createElement():WrappedHTMLElement + protected function createElement():IFlexJSElement { - if (element == null) - element = document.createElement('div') as WrappedHTMLElement; - if (positioner == null) - positioner = element; - positioner.style.display = 'block'; - positioner.style.position = 'relative'; - - element.flexjs_wrapper = this; - - return positioner; + COMPILE::SWF + { + element = new WrappedSprite(); + element.flexjs_wrapper = this; + return element; + } + COMPILE::JS + { + if (element == null) + element = document.createElement('div') as WrappedHTMLElement; + if (positioner == null) + positioner = element; + positioner.style.display = 'block'; + positioner.style.position = 'relative'; + + element.flexjs_wrapper = this; + + return positioner; + } } /** @@ -1463,18 +1374,5 @@ package org.apache.flex.core ValuesManager.valuesImpl.applyStyles(this, newStyle); }; - /** - * @param value The event containing new style properties. - * @flexjsignorecoercion org.apache.flex.core.WrappedHTMLElement - * @flexjsignorecoercion org.apache.flex.core.IParent - */ - COMPILE::JS - public function get parent():IParent - { - var p:WrappedHTMLElement = this.positioner.parentNode as WrappedHTMLElement; - var wrapper:IParent = p ? p.flexjs_wrapper as IParent : null; - return wrapper; - } - } }