classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cp-patches] FYI: Some AWT fixes


From: Roman Kennke
Subject: [cp-patches] FYI: Some AWT fixes
Date: Fri, 05 Aug 2005 17:36:22 +0200

Hi,

I've started to look deeper into AWT and how it should work and how it
actually works in Classpath. There are some issues that are plain wrong.
This patch fixes some of them and also contains some improvements with
the caching of layouts.

I have made some tests with the update() and paint() methods and found
that they actually work different than is documented in the spec. The
correct behaviour (according to my tests) is:

Component.update(): Clears the background only when it is a toplevel
component or a lightweight component. Heavyweights are 100%
selfresponsible for that (as for everything other as we will see).

Container.update(): Calls super.update() only when we are a top-level
container, otherwise directly jump into paint().

Container.visitChildren(): All children must be visited, even
Containers. The reason for not visiting the Containers has been that it
avoided double-painting heavyweights. However, heavyweight component
must not paint themselves when paint() is called. This is implemented
wrong here. It is actually the other way around: If the toolkit thinks
it has to paint a component, then it calls paint() _after_ the component
was painted, giving subclasses a chance to paint over the component. So,
paint() only acts as a callback here. This must also be fixed later. I
don't touch this for now since I think this could break the AWT.

The other stuff is in preferred/minimum/maximumSize(): There I replaced
direct access to layoutMgr with getLayout() so that components that
override this method still work correctly. I also added a kind of
caching. When the component is valid and we have a size stored in the
private fields, then we return this instead of asking the layout
manager. This should highly increase efficiency.

If you don't agree with one of the points above please let me know. But
I am pretty sure (did test it the last couple of hours) that all this is
correct.

2005-08-05  Roman Kennke  <address@hidden>

        * java/awt/Container.java:
        (preferredSize): Call getLayout() instead of directly
referencing
        the private field. This makes components work that override
        getLayout().
        (minimumSize): Call getLayout() instead of directly referencing
        the private field. This makes components work that override
        getLayout(). Use cached size if component is still valid.
        (maximumSize): Call getLayout() instead of directly referencing
        the private field. This makes components work that override
        getLayout(). Use cached size if component is still valid.
        (update): If we are a top-level-container, call super.update(),
        otherwise directly call paint().
        (visitChildren): Also visit children that are itself Containers.
        * java/awt/Component.java
        (update): Clear the background only for lightweight and
top-level
        components.

Attachment: AWT-Cleanup-1.diff
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]