You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by yi...@apache.org on 2016/09/29 07:36:25 UTC
git commit: [flex-asjs] [refs/heads/refactor-sprite] - Refactoring
BinaryImage. Instead of using BinaryImageView to load binary image data,
use a specialized BinaryImageLoader bead which separates dislay/data loading
concerns. This should help in adding
Repository: flex-asjs
Updated Branches:
refs/heads/refactor-sprite 07c6c36e0 -> 3f46dd19f
Refactoring BinaryImage. Instead of using BinaryImageView to load binary image data, use a specialized BinaryImageLoader bead which separates dislay/data loading concerns. This should help in adding custom views without messing with binary loading logic.
Project: http://git-wip-us.apache.org/repos/asf/flex-asjs/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-asjs/commit/3f46dd19
Tree: http://git-wip-us.apache.org/repos/asf/flex-asjs/tree/3f46dd19
Diff: http://git-wip-us.apache.org/repos/asf/flex-asjs/diff/3f46dd19
Branch: refs/heads/refactor-sprite
Commit: 3f46dd19f3bdee82c3f0517b6b5a7f0dcdd5d24f
Parents: 07c6c36
Author: yishayw <yi...@hotmail.com>
Authored: Thu Sep 29 10:36:14 2016 +0300
Committer: yishayw <yi...@hotmail.com>
Committed: Thu Sep 29 10:36:14 2016 +0300
----------------------------------------------------------------------
.../projects/HTML/src/main/flex/HTMLClasses.as | 3 +-
.../flex/org/apache/flex/html/BinaryImage.as | 20 +++-
.../apache/flex/html/beads/BinaryImageView.as | 114 -------------------
.../org/apache/flex/html/beads/ImageView.as | 20 ++--
.../main/flex/org/apache/flex/net/URLStream.as | 8 +-
5 files changed, 38 insertions(+), 127 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f46dd19/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
index fddb2ee..f8379c1 100644
--- a/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
+++ b/frameworks/projects/HTML/src/main/flex/HTMLClasses.as
@@ -55,7 +55,7 @@ internal class HTMLClasses
import org.apache.flex.html.beads.CloseButtonView; CloseButtonView;
import org.apache.flex.html.beads.ImageAndTextButtonView; ImageAndTextButtonView;
import org.apache.flex.html.beads.ImageView; ImageView;
- import org.apache.flex.html.beads.BinaryImageView; BinaryImageView;
+ import org.apache.flex.html.beads.BinaryImageLoader; BinaryImageLoader;
}
import org.apache.flex.html.beads.ImageButtonView; ImageButtonView;
import org.apache.flex.html.beads.ListView; ListView;
@@ -102,7 +102,6 @@ internal class HTMLClasses
import org.apache.flex.html.beads.models.ImageModel; ImageModel;
import org.apache.flex.html.beads.models.ImageAndTextModel; ImageAndTextModel;
}
- import org.apache.flex.html.beads.models.BinaryImageModel; BinaryImageModel;
import org.apache.flex.html.beads.models.PanelModel; PanelModel;
COMPILE::SWF
{
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f46dd19/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/BinaryImage.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/BinaryImage.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/BinaryImage.as
index 269f24f..f6fee65 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/BinaryImage.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/BinaryImage.as
@@ -18,10 +18,14 @@
////////////////////////////////////////////////////////////////////////////////
package org.apache.flex.html
{
+ import org.apache.flex.core.IBeadView;
import org.apache.flex.core.IBinaryImage;
import org.apache.flex.core.IBinaryImageModel;
import org.apache.flex.core.UIBase;
- import org.apache.flex.utils.BinaryData;
+ import org.apache.flex.core.ValuesManager;
+ import org.apache.flex.html.beads.IBinaryImageLoader;
+ import org.apache.flex.utils.BinaryData;
+
COMPILE::JS
{
import org.apache.flex.core.WrappedHTMLElement;
@@ -56,6 +60,20 @@ package org.apache.flex.html
super();
}
+ override public function addedToParent():void
+ {
+ var c:Class = ValuesManager.valuesImpl.getValue(this, "iBinaryImageLoader") as Class;
+ if (c)
+ {
+ if (c)
+ {
+ var loader:IBinaryImageLoader = (new c()) as IBinaryImageLoader;
+ addBead(loader);
+ }
+ }
+ super.addedToParent();
+ }
+
/**
* The binary bitmap data.
*
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f46dd19/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageView.as
deleted file mode 100644
index 9290b3f..0000000
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/BinaryImageView.as
+++ /dev/null
@@ -1,114 +0,0 @@
-////////////////////////////////////////////////////////////////////////////////
-//
-// 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 org.apache.flex.html.beads
-{
- COMPILE::SWF
- {
- import flash.display.Bitmap;
- import flash.display.Loader;
- import flash.display.LoaderInfo;
- import flash.events.IOErrorEvent;
- import flash.net.URLRequest;
- }
- COMPILE::JS
- {
- import goog.events;
- import org.apache.flex.utils.URLUtils;
- }
-
- import org.apache.flex.core.BeadViewBase;
- import org.apache.flex.core.IBeadView;
- import org.apache.flex.core.IBinaryImageModel;
- import org.apache.flex.core.IStrand;
- import org.apache.flex.core.IUIBase;
- import org.apache.flex.core.UIBase;
- import org.apache.flex.events.Event;
- import org.apache.flex.events.IEventDispatcher;
- import org.apache.flex.utils.BinaryData;
-
- /**
- * The ImageView class creates the visual elements of the org.apache.flex.html.Image component.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public class BinaryImageView extends ImageView
- {
- /**
- * constructor.
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- public function BinaryImageView()
- {
- }
-
- private var _objectURL:String;
-
- /**
- * @copy org.apache.flex.core.IBead#strand
- *
- * @langversion 3.0
- * @playerversion Flash 10.2
- * @playerversion AIR 2.6
- * @productversion FlexJS 0.0
- */
- override public function set strand(value:IStrand):void
- {
- super.strand = value;
- _model.addEventListener("binaryChanged",handleBinaryChange);
-
- }
-
- /**
- * @private
- * @flexjsignorecoercion HTMLImageELement
- * @flexjsignorecoercion BinaryImageModel
- */
- private function handleBinaryChange(event:Event):void
- {
- var m:IBinaryImageModel = _model as IBinaryImageModel;
- COMPILE::SWF
- {
- if (m.binary) {
- setupLoader();
- loader.loadBytes(m.binary.array);
- }
- }
- COMPILE::JS
- {
- if (m.binary) {
- setupLoader();
- if(_objectURL)
- URLUtils.revokeObjectURL(_objectURL);
- var blob:Blob = new Blob([m.binary.array]);
-// I don't think we need to specify the type.
-// var blob = new Blob([response], {type: "image/png"});
- _objectURL = URLUtils.createObjectURL(blob);
- (host.element as HTMLImageElement).src = _objectURL;
- }
- }
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f46dd19/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ImageView.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ImageView.as b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ImageView.as
index 7f093cb..faecbd7 100644
--- a/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ImageView.as
+++ b/frameworks/projects/HTML/src/main/flex/org/apache/flex/html/beads/ImageView.as
@@ -33,14 +33,12 @@ package org.apache.flex.html.beads
}
import org.apache.flex.core.BeadViewBase;
- import org.apache.flex.core.IBeadView;
import org.apache.flex.core.IImageModel;
import org.apache.flex.core.IStrand;
- import org.apache.flex.core.IUIBase;
import org.apache.flex.core.UIBase;
import org.apache.flex.events.Event;
import org.apache.flex.events.IEventDispatcher;
- import org.apache.flex.utils.BinaryData;
+ import org.apache.flex.core.IImageView;
/**
* The ImageView class creates the visual elements of the org.apache.flex.html.Image component.
@@ -50,7 +48,7 @@ package org.apache.flex.html.beads
* @playerversion AIR 2.6
* @productversion FlexJS 0.0
*/
- public class ImageView extends BeadViewBase implements IBeadView
+ public class ImageView extends BeadViewBase implements IImageView
{
/**
* constructor.
@@ -67,10 +65,16 @@ package org.apache.flex.html.beads
COMPILE::SWF
protected var bitmap:Bitmap;
COMPILE::SWF
- protected var loader:Loader;
+ private var _loader:Loader;
protected var _model:IImageModel;
+ COMPILE::SWF
+ public function get loader():Loader
+ {
+ return _loader;
+ }
+
/**
* @copy org.apache.flex.core.IBead#strand
*
@@ -117,9 +121,9 @@ package org.apache.flex.html.beads
}
COMPILE::SWF
- protected function setupLoader():void
+ public function setupLoader():void
{
- loader = new Loader();
+ _loader = new Loader();
loader.contentLoaderInfo.addEventListener("complete",onComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function (e:IOErrorEvent):void {
trace(e);
@@ -128,7 +132,7 @@ package org.apache.flex.html.beads
}
COMPILE::JS
- protected function setupLoader():void
+ public function setupLoader():void
{
var host:IUIBase = _strand as IUIBase;
(host.element as HTMLImageElement).addEventListener('load',
http://git-wip-us.apache.org/repos/asf/flex-asjs/blob/3f46dd19/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as
----------------------------------------------------------------------
diff --git a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as
index 1df5cbf..2ec3c85 100644
--- a/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as
+++ b/frameworks/projects/Network/src/main/flex/org/apache/flex/net/URLStream.as
@@ -136,8 +136,12 @@ package org.apache.flex.net
req.requestHeaders.push(new flash.net.URLRequestHeader("Content-type", urlRequest.contentType));
}
- req.data = urlRequest.data is BinaryData ? (urlRequest.data as BinaryData).data :
- new flash.net.URLVariables(HTTPUtils.encodeUrlVariables(urlRequest.data));
+ if (urlRequest.data)
+ {
+ req.data = urlRequest.data is BinaryData ? (urlRequest.data as BinaryData).data :
+ new flash.net.URLVariables(HTTPUtils.encodeUrlVariables(urlRequest.data));
+ }
+
req.method = urlRequest.method;
flashUrlStream.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, flash_status);
flashUrlStream.addEventListener(HTTPStatusEvent.HTTP_STATUS, flash_status);