History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-2894
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: P1 P1
Assignee: Unassigned
Reporter: Benjamin Shine
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

CSS: subclasses and instances can't override style constraints set on superclass*

Created: 06/Oct/06 04:43 PM   Updated: 15/Aug/08 12:28 PM
Component/s: LFC - CSS
Affects Version/s: 3.3.3, Legals PR4
Fix Version/s: DingDong (4.2 Alpha)

Time Tracking:
Not Specified

File Attachments: 1. File LPP-2894.lzx (0.5 kb)
2. File LPP-2894a.lzx (0.2 kb)


Severity: Minor
Fixed in Change#: 5,950
Runtime: N/A
Flags: Emerald
Fix in hand: False


 Description  « Hide
Subclasses and instances cannot override style constraints set on the superclass. If a class has a attr="$style{'thingy'}", then all subclasses and instances of that class will have that style constraint -- even if a subclass explicitly sets the value of that attribute to a constant. The expected behavior is: if a class explicitly sets the value of an attribute to a constant, instances of that class have the attribute value specified by that constant, regardless of what the class's superclasses do.
I see the correct behavior on non-style-constraint attributes, such as width, below, but the wrong behavior on the bgcolor attribute below:

  <class name="styledbox" width="70" height="70" bgcolor="$style{'stylebgcolor'}" >
        <view name="inner" bgcolor="$style{'styleinnercolor'}" x="5" y="5" width="10" height="10" />
    </class>

    <class name="subclassbox" extends="styledbox">
        <attribute name="bgcolor" value="0x000088" />
        <attribute name="width" value="150" />
    </class>
    
    <subclassbox id="sb2" />

EXPECTED: sb2 should be green and have width 150
ACTUALLY sb2 is purple and has width 150.




 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Benjamin Shine - 06/Oct/06 04:47 PM
Test case checked in to trunk as test/style/constraints/subclassing.lzx

Sarah Allen - 20/Dec/06 12:35 PM
* high P2 -- not a stop ship, but really bad. Will probably drive people crazy.

Sarah Allen - 20/Dec/06 12:38 PM
note that this does work:
<canvas>
<stylesheet>
    styledview {
        bgcolor: "0x3980F4";
    }
</stylesheet>
<class name="styledview" bgcolor="$style{'bgcolor'}" width="200" height="100"/>
<styledview bgcolor="$once{'0xff0000'}"/>
</canvas>

Benjamin Shine - 03/Jan/07 07:45 PM
This should be fix for 3.4.

P T Withington - 05/Jan/07 12:55 PM
Awaiting review by Ben

P T Withington - 07/Jan/07 08:36 AM
r3313 | ptw | 2007-01-07 09:08:56 -0500 (Sun, 07 Jan 2007) | 27 lines
Changed paths:
   M /openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.as
   M /openlaszlo/trunk/WEB-INF/lps/server/src/org/openlaszlo/css/CSSHandler.java
   M /openlaszlo/trunk/test/style/constraints/subclassing.lzx

Change 20070104-ptw-n by ptw@dueling-banjos.local on 2007-01-04 15:50:27 EST
    in /Users/ptw/OpenLaszlo/trunk

Summary: Make style constraints play nice

Bugs Fixed:
LPP-2894: 'CSS: subclasses and instances can't override style constraints set on superclass*'

Technical Reviewer: ben (Message-Id: <F52C2076-08E8-4869-BB03-22F38C99BC6F@laszlosystems.com>)
QA Reviewer: adam (pending)
Doc Reviewer: (pending)

Details:
    subclassing.lzx: Added styleinnercolor, just so I can understand
    what the test was trying to do. Added a more complex dependency,
    using an `attr()` style to 'stress-test' style constraints

    LzNode.as: __LZapplyStyle map now checks to make sure to _not_
    constrain an attribute that has an explicit value. It splits
    style constraints into constant and computed constraints, the
    computed constraints are applied after the node is init-ed, since
    those constraints may depend on other node attributes.

    CSSHandler.java: SAC_ATTR and SAC_IDENT values should be computed values.

Tests:
    test/style/constraints/subclassing.lzx

P T Withington - 07/Jan/07 08:36 AM
To Frisco for verification

Benjamin Shine - 29/May/07 10:24 AM
This is broken in legals.

Mamye Kratt - 06/Jun/07 10:41 AM
Needs to be checked on a changeset after 5309.

Mamye Kratt - 06/Jun/07 12:47 PM
Misread Ben's comments. Reopen and assign to Ben.

P T Withington - 24/Jul/07 09:44 AM
This is blocked awaiting some compiler re-org that I am doing. (cf., LPP-2302)

Benjamin Shine - 02/Aug/07 04:50 PM
This is currently manifesting as a failure in wafflecone, in http://localhost:8080/wafflecone/test/style/constraints/main.lzx

Benjamin Shine - 03/Aug/07 05:53 PM
Upon discussion, reassigning to Max.

Max Carlson - 06/Aug/07 07:40 PM
Author: max
Date: 2007-08-06 19:38:56 -0700 (Mon, 06 Aug 2007)
New Revision: 5951

Modified:
   openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs
Log:
Change 20070806-maxcarlson-l by maxcarlson@plastik on 2007-08-06 18:53:14 PDT
    in /Users/maxcarlson/openlaszlo/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Only set style constraints if the existing value is null

New Features:

Bugs Fixed: LPP-2894 - CSS: subclasses and instances can't override style constraints set on superclass*

Technical Reviewer: promanik
QA Reviewer: ben, ptw
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: LzNode.lzs - Only set styleConstraints[k] if this[k] is null.
    

Tests: http://localhost:8080/wafflecone/test/style/constraints/main.lzx?lzr=swf8 now passes.



Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs 2007-08-07 01:57:02 UTC (rev 5950)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/core/LzNode.lzs 2007-08-07 02:38:56 UTC (rev 5951)
@@ -514,7 +514,10 @@
         if (! (k in initialArgs)) {
             // A style that is a function is a constraint
             if (v instanceof Function) {
- styleConstraints[k] = v;
+ if (this[k] == null) {
+// Debug.warn("setting %w[%w] to %w, was %w", this, k, v, this[k]);
+ styleConstraints[k] = v;
+ }
             } else {
 // Debug.format("%w[%s] (%#w) %#w -> %#w", this, k, stylemap[k], this.k, v);
                 if (v != null) this.setAttribute(k, v);


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Steve O'Sullivan - 25/Oct/07 09:18 AM
I am testing in r6938 running Firefox 2.0.0.8 in Windows and seem to be seeing bad behavior in both of the attached tests (taken from the bug notes).

It seems that styles applied to subclasses do not override styles applied to the superclass in this build.

P T Withington - 08/Feb/08 05:28 AM
The stuff I am working on for LPP-1587 should lead to a solution for this

P T Withington - 20/Feb/08 04:25 PM
The test case given in the initial bug is incomplete/inaccurate, which is why this bug keeps getting re-opened. Here is a complete testcase, but this test is also already included in test/style/constraints/subclassing.lzx:

<canvas>
    <stylesheet>
        styledbox {
            stylebgcolor : purple;
        }
    </stylesheet>

  <class name="styledbox" width="70" height="70" bgcolor="$style{'stylebgcolor'}" />

  <class name="subclassbox" extends="styledbox">
    <attribute name="bgcolor" value="green" />
    <attribute name="width" value="150" />
  </class>

  <subclassbox id="sb2" />
</canvas>

Correct: green rectangle
Incorrect: purple rectangle


Mamye Kratt - 15/Aug/08 12:28 PM
(4.2alpha build r10620)

Fixed rectangle is green.