Bug 22550

Summary: Add WML <timer> element support
Product: WebKit Reporter: Nikolas Zimmermann <zimmermann>
Component: XMLAssignee: Nikolas Zimmermann <zimmermann>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Macintosh   
OS: OS X 10.5   
Bug Depends on:    
Bug Blocks: 20393    
Attachments:
Description Flags
Initial patch
zwarich: review+
Layout test results
none
Updated layout test results
zwarich: review+
Updated patch zwarich: review+

Description Nikolas Zimmermann 2008-11-28 19:22:09 PST
Add WML <timer> element support.
Comment 1 Nikolas Zimmermann 2008-11-28 19:32:17 PST
Created attachment 25581 [details]
Initial patch
Comment 2 Nikolas Zimmermann 2008-11-28 19:32:38 PST
Created attachment 25582 [details]
Layout test results
Comment 3 Cameron Zwarich (cpst) 2008-11-28 19:43:37 PST
Comment on attachment 25581 [details]
Initial patch

The comment

// The value of timeout must be a positive integral number, or ignore it

would probably be more clear as

// If the value of timeout is not a positive integer, ignore it

In WMLTimerElement::insertedIntoDocument(), you have both

     ASSERT(parent);

and

    if (!parent || !parent->isWMLElement())

You should decide if parent should ever be null and make a decision accordingly. 

+    if (interval <= 0)
+        interval = m_value.toInt();
+
+    if (interval > 0)
+        m_timer.startOneShot(interval / 10.0f);

Can't the second conditional be an else?
Comment 4 Cameron Zwarich (cpst) 2008-11-28 19:44:02 PST
Oops, I forgot to say: if you address those comments, r=me.
Comment 5 Nikolas Zimmermann 2008-11-28 19:53:40 PST
> 
> // If the value of timeout is not a positive integer, ignore it
Fixed.

> 
> In WMLTimerElement::insertedIntoDocument(), you have both
> 
>      ASSERT(parent);
> 
> and
> 
>     if (!parent || !parent->isWMLElement())
> 
> You should decide if parent should ever be null and make a decision
> accordingly. 
Yeah, Holger also noted this while reviewing the <do> patch. I'll come up with a follow-up patch fixing these, as there are 7 other places which use the same piece of code.

> 
> +    if (interval <= 0)
> +        interval = m_value.toInt();
> +
> +    if (interval > 0)
> +        m_timer.startOneShot(interval / 10.0f);
> 
> Can't the second conditional be an else?
The interval may change inbetween?

Thanks for the first review
Comment 6 Nikolas Zimmermann 2008-11-28 19:55:40 PST
Created attachment 25583 [details]
Updated layout test results
Comment 7 Cameron Zwarich (cpst) 2008-11-28 19:57:15 PST
(In reply to comment #5)
> > In WMLTimerElement::insertedIntoDocument(), you have both
> > 
> >      ASSERT(parent);
> > 
> > and
> > 
> >     if (!parent || !parent->isWMLElement())
> > 
> > You should decide if parent should ever be null and make a decision
> > accordingly. 
> Yeah, Holger also noted this while reviewing the <do> patch. I'll come up with
> a follow-up patch fixing these, as there are 7 other places which use the same
> piece of code.

If it occurs elsewhere, a followup patch is okay. Be sure to do it soon, though.

> > +    if (interval <= 0)
> > +        interval = m_value.toInt();
> > +
> > +    if (interval > 0)
> > +        m_timer.startOneShot(interval / 10.0f);
> > 
> > Can't the second conditional be an else?
> The interval may change inbetween?

Wow, I'm stupid. Sorry about that. ;-)
Comment 8 Nikolas Zimmermann 2008-11-28 19:57:23 PST
Created attachment 25584 [details]
Updated patch
Comment 9 Cameron Zwarich (cpst) 2008-11-28 19:58:22 PST
Comment on attachment 25584 [details]
Updated patch

r=me
Comment 10 Cameron Zwarich (cpst) 2008-11-28 19:58:32 PST
Comment on attachment 25583 [details]
Updated layout test results

r=me
Comment 11 Nikolas Zimmermann 2008-11-28 20:00:38 PST
Landed in r38838.