Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-14941

CanvasLayout.measure handling horizontalCenter and verticalCenter incorrectly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Adobe Flex SDK 3.0 (Release)
    • None
    • None
    • Affected OS(s): All OS Platforms
      Affected OS(s): All OS Platforms
      Language Found: English

    Description

      When measuring the width and height of its target, CanvasLayout takes into account styles, positions, and sizes on the target's children. The problem is when dealing with horizontalCenter and verticalCenter (both have the same behaviour).

      Pseudocode for the current behaviour:

      effectiveChildWidth = child.x + child.measuredWidth + child.horizontalCenter;

      Pseudocode for what I believe to be correct behaviour:

      effectiveChildWidth = child.measuredWidth + child.horizontalCenter;

      The net result is that if a container ever calls setActualSize() to resize a Canvas larger than its measured size, the subsequent measure() on that Canvas will generate an incorrect measuredWIdth and/or measuredHeight if that Canvas contains children with horizontalCenter or verticalCenter styles.

      This is normally not a serious problem besides wasted CPU cycles as a component slowly reaches its correct size over several invalidateSize / measure / updateDisplayList cycles. However it's a real stumbling block when you need the measured size data to be correct, and can lead to infinite loops in many situations when writing custom container layout code.

      Example code to demonstrate this effect:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Canvas backgroundColor="blue" id="container" resize="trace('resized to ' + event.target.width + ' x ' + event.target.height)">
      <mx:Button width="100" height="50" label="Button"/>
      <mx:Label text="This is text, it's wider than the button!" width="200" id="lb" horizontalCenter="0" verticalCenter="0"/>
      </mx:Canvas>

      <mx:Button click="trace('');container.setActualSize(400,200)" label="Mess It up" horizontalCenter="0" verticalCenter="0"/>

      </mx:Application>

      Attachments

        Activity

          People

            Unassigned Unassigned
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: