[Webkit-unassigned] [Bug 26278] Patch that make WebCore have a RenderTheme per page

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 15 09:34:24 PDT 2009


https://bugs.webkit.org/show_bug.cgi?id=26278





------- Comment #9 from aroben at apple.com  2009-06-15 09:34 PDT -------
(From update of attachment 31201)
> +class RenderTheme : public RefCounted<RenderTheme> {
>  public:
>      RenderTheme();
>      virtual ~RenderTheme() { }

Normally classes that derive from RefCounted have private constructors and a
public create() function that returns a PassRefPtr. This helps avoid
leaks/crashes due to incorrect reference count management. I think you should
follow this pattern with RenderTheme.

> +PassRefPtr<RenderTheme> RenderTheme::themeForPage(Page* page)
>  {
> -    static RenderThemeChromiumWin winTheme;
> -    return &winTheme;
> +    static RefPtr<RenderTheme> rt = new RenderThemeChromiumWin();
> +    return rt; // keep the reference of one.
>  }

This code causes a destructor to be run when the process exits, which will slow
down quit time. A better idiom is to write this like so:

static RenderTheme* rt = RenderThemeChromiumWin::create().releaseRef();
return rt;


-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.



More information about the webkit-unassigned mailing list