<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2007 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package mx.flash
{

import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.InteractiveObject;
import flash.utils.getDefinitionByName;

import mx.core.IUIComponent;
import mx.core.mx_internal;

/**
 *  The FlexContentHolder class is for internal use only.
 */
public dynamic class FlexContentHolder extends ContainerMovieClip 
{
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------
    
    /**
     *  Constructor.
     */
    public function FlexContentHolder()
    {
        super();
        trackSizeChanges = false;
        showInAutomationHierarchy = false;

    }
    
    //--------------------------------------------------------------------------
    //
    //  Internal variables
    //
    //--------------------------------------------------------------------------
    
    private var flexContent:IUIComponent;           // The Flex content
    
    private var pendingFlexContent:IUIComponent;    // Only used if flexContent is set early

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------
        
    //----------------------------------
    //  content
    //----------------------------------
     
    /**
     *  @inheritDoc
     */
    override public function get content():IUIComponent
    {
        return flexContent;
    }
        
    override public function set content(value:IUIComponent):void
    {
        if (initialized)
            setFlexContent(value);
        else
            pendingFlexContent = value;
    }

    //--------------------------------------------------------------------------
    //
    //  IUIComponent methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Initialize the object.
     *
     *  @see mx.core.UIComponent#initialize()
     */
    override public function initialize():void
    {
        super.initialize();
        
        // initialize is only called when we are running in Flex. 
        // Since we are in Flex, let's hide the content placeholder.
        // Rather than removing it (which can cause problems with
        // sizing), we set the alpha to 0.
        getChildAt(0).alpha = 0;

        // See if we have any pending flex content
        if (pendingFlexContent)
        {
            setFlexContent(pendingFlexContent);
            pendingFlexContent = null;
        }
    }

    //--------------------------------------------------------------------------
    //
    //  IFlexDisplayObject methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Sets the actual size of this object.
     *
     *  <p>This method is mainly for use in implementing the
     *  <code>updateDisplayList()</code> method, which is where
     *  this object's actual size is computed based on
     *  its explicit size, parent-relative (percent) size,
     *  and measured size.
     *  Apply this actual size to the object
     *  by calling the <code>setActualSize()</code> method.</p>
     *
     *  <p>In other situations, you should be setting properties
     *  such as <code>width</code>, <code>height</code>,
     *  <code>percentWidth</code>, or <code>percentHeight</code>
     *  rather than calling this method.</p>
     * 
     *  @param newWidth The new width for this object.
     * 
     *  @param newHeight The new height for this object.
     */
    override public function setActualSize(newWidth:Number, newHeight:Number):void
    {
        if (sizeChanged(_width, newWidth) || sizeChanged(_height, newHeight))
            dispatchResizeEvent();
            
        // Remember our new actual size so we can report it later in the
        // width/height getters.
        _width = newWidth;
        _height = newHeight;
        
        if (flexContent)
        {
            sizeFlexContent();
        }
    }

    //--------------------------------------------------------------------------
    //
    //  Layout methods
    //
    //--------------------------------------------------------------------------
    
    /**
     *  Notify parent that the size of this object has changed.
     */
    override protected function notifySizeChanged():void
    {
        super.notifySizeChanged();
        
        sizeFlexContent();
    }
     
    //--------------------------------------------------------------------------
    //
    //  Flex content methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Utility function that prepares Flex content to be used as a child of
     *  this component. 
     *  Set the <code>content</code> property rather than calling
     *  this method directly.
     */
    protected function setFlexContent(value:IUIComponent):void
    {
        // Remove any existing content
        if (flexContent)
        {
            removeChild(DisplayObject(flexContent));
            flexContent = null;
        }
        
        // Add the new content
        flexContent = value;
        if (flexContent)
        {
            addChild(DisplayObject(flexContent));
            
            var uiComponentClass:Class;
            
            // Dynamically load the UIComponent class, but don't fail on error.
            // This allows us to work in Flex (where UIComponent is defined), and 
            // in Flash (where it UIComponent is not defined).
            try
            {
                uiComponentClass = Class(getDefinitionByName("mx.core::UIComponent"));
            }
            catch (e:Error)
            {<commit_msg>Transferred from the Adobe Open Source Subversion Repository<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2007 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////

package mx.flash
{

import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.display.InteractiveObject;
import flash.utils.getDefinitionByName;

import mx.core.IUIComponent;
import mx.core.mx_internal;

/**
 *  The FlexContentHolder class is for internal use only.
 *  
 *  @langversion 3.0
 *  @playerversion Flash 9
 *  @playerversion AIR 1.1
 *  @productversion Flex 3
 */
public dynamic class FlexContentHolder extends ContainerMovieClip 
{
    //--------------------------------------------------------------------------
    //
    //  Constructor
    //
    //--------------------------------------------------------------------------
    
    /**
     *  Constructor.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    public function FlexContentHolder()
    {
        super();
        trackSizeChanges = false;
        showInAutomationHierarchy = false;

    }
    
    //--------------------------------------------------------------------------
    //
    //  Internal variables
    //
    //--------------------------------------------------------------------------
    
    private var flexContent:IUIComponent;           // The Flex content
    
    private var pendingFlexContent:IUIComponent;    // Only used if flexContent is set early

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------
        
    //----------------------------------
    //  content
    //----------------------------------
     
    /**
     *  @inheritDoc
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    override public function get content():IUIComponent
    {
        return flexContent;
    }
        
    override public function set content(value:IUIComponent):void
    {
        if (initialized)
            setFlexContent(value);
        else
            pendingFlexContent = value;
    }

    //--------------------------------------------------------------------------
    //
    //  IUIComponent methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Initialize the object.
     *
     *  @see mx.core.UIComponent#initialize()
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    override public function initialize():void
    {
        super.initialize();
        
        // initialize is only called when we are running in Flex. 
        // Since we are in Flex, let's hide the content placeholder.
        // Rather than removing it (which can cause problems with
        // sizing), we set the alpha to 0.
        getChildAt(0).alpha = 0;

        // See if we have any pending flex content
        if (pendingFlexContent)
        {
            setFlexContent(pendingFlexContent);
            pendingFlexContent = null;
        }
    }

    //--------------------------------------------------------------------------
    //
    //  IFlexDisplayObject methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Sets the actual size of this object.
     *
     *  <p>This method is mainly for use in implementing the
     *  <code>updateDisplayList()</code> method, which is where
     *  this object's actual size is computed based on
     *  its explicit size, parent-relative (percent) size,
     *  and measured size.
     *  Apply this actual size to the object
     *  by calling the <code>setActualSize()</code> method.</p>
     *
     *  <p>In other situations, you should be setting properties
     *  such as <code>width</code>, <code>height</code>,
     *  <code>percentWidth</code>, or <code>percentHeight</code>
     *  rather than calling this method.</p>
     * 
     *  @param newWidth The new width for this object.
     * 
     *  @param newHeight The new height for this object.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    override public function setActualSize(newWidth:Number, newHeight:Number):void
    {
        if (sizeChanged(_width, newWidth) || sizeChanged(_height, newHeight))
            dispatchResizeEvent();
            
        // Remember our new actual size so we can report it later in the
        // width/height getters.
        _width = newWidth;
        _height = newHeight;
        
        if (flexContent)
        {
            sizeFlexContent();
        }
    }

    //--------------------------------------------------------------------------
    //
    //  Layout methods
    //
    //--------------------------------------------------------------------------
    
    /**
     *  Notify parent that the size of this object has changed.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    override protected function notifySizeChanged():void
    {
        super.notifySizeChanged();
        
        sizeFlexContent();
    }
     
    //--------------------------------------------------------------------------
    //
    //  Flex content methods
    //
    //--------------------------------------------------------------------------

    /**
     *  Utility function that prepares Flex content to be used as a child of
     *  this component. 
     *  Set the <code>content</code> property rather than calling
     *  this method directly.
     *  
     *  @langversion 3.0
     *  @playerversion Flash 9
     *  @playerversion AIR 1.1
     *  @productversion Flex 3
     */
    protected function setFlexContent(value:IUIComponent):void
    {
        // Remove any existing content
        if (flexContent)
        {
            removeChild(DisplayObject(flexContent));
            flexContent = null;
        }
        
        // Add the new content
        flexContent = value;
        if (flexContent)
        {
            addChild(DisplayObject(flexContent));
            
            var uiComponentClass:Class;
            
            // Dynamically load the UIComponent class, but don't fail on error.
            // This allows us to work in Flex (where UIComponent is defined), and 
            // in Flash (where it UIComponent is not defined).
            try
            {
                uiComponentClass = Class(getDefinitionByName("mx.core::UIComponent"));
            }
            catch (e:Error)
            {
{'fraction_non_alphanumeric': 0.2606154756620802, 'fraction_numerical': 0.00414262464861666, 'mean_word_length': 1.0542470749126274, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2144954', 'n_tokens_mistral': 3154, 'n_tokens_neox': 3040, 'n_words': 882}