Bug 94587 - Add methods to CounterDirectives to clean up StyleBuilder and RenderCounter.
Summary: Add methods to CounterDirectives to clean up StyleBuilder and RenderCounter.
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Elliott Sprehn
URL:
Keywords:
Depends on:
Blocks: 94642
  Show dependency treegraph
 
Reported: 2012-08-21 04:18 PDT by Elliott Sprehn
Modified: 2012-09-06 22:21 PDT (History)
7 users (show)

See Also:


Attachments
Patch (21.18 KB, patch)
2012-08-21 04:27 PDT, Elliott Sprehn
no flags Details | Formatted Diff | Diff
Patch for landing (23.27 KB, patch)
2012-09-06 18:36 PDT, Elliott Sprehn
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Elliott Sprehn 2012-08-21 04:18:42 PDT
Add methods to CounterDirectives to clean up StyleBuilder and RenderCounter.
Comment 1 Elliott Sprehn 2012-08-21 04:27:48 PDT
Created attachment 159653 [details]
Patch
Comment 2 Julien Chaffraix 2012-08-21 15:53:13 PDT
Comment on attachment 159653 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=159653&action=review

> Source/WebCore/rendering/style/CounterDirectives.h:40
>          : m_reset(false)
>          , m_increment(false)

This naming should be improved while we are touching this code. Some better names:
* m_isResetCounter / m_hasCounterResetSet
* m_isIncrementCounter / m_hasCounterIncrementSet

> Source/WebCore/rendering/style/CounterDirectives.h:86
> +    int value() const

This value name is dangerous as you have lost the information whether you actually reset. I would have anticipated that value would return something I could just add to the current value.

Maybe valueForResetOrIncrement would better convey this idea.
Comment 3 Elliott Sprehn 2012-09-06 18:10:26 PDT
This fixes 94642 because it's more careful about initializing the values.
Comment 4 Elliott Sprehn 2012-09-06 18:25:58 PDT
(In reply to comment #2)
> (From update of attachment 159653 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=159653&action=review
> ...
> 
> > Source/WebCore/rendering/style/CounterDirectives.h:86
> > +    int value() const
> 
> This value name is dangerous as you have lost the information whether you actually reset. I would have anticipated that value would return something I could just add to the current value.
> 
> Maybe valueForResetOrIncrement would better convey this idea.

Indeed it is something you can just add to the "current value", the catch being that on a reset CounterNode the current value is 0, while on other nodes the current value is the value of our ancestor node.

I changed this to combinedValue(). Overall it would be nice to get rid of CounterDirectives entirely, it's a confusing container for what should just be two maps and RenderStyle should have something like getCounterReset(String& identifier) and getCounterIncrement(String& identifier) that return a struct CounterValue() { bool isDefined(); int value(); } or something like that that.
Comment 5 Elliott Sprehn 2012-09-06 18:36:52 PDT
Created attachment 162643 [details]
Patch for landing
Comment 6 WebKit Review Bot 2012-09-06 22:21:47 PDT
Comment on attachment 162643 [details]
Patch for landing

Clearing flags on attachment: 162643

Committed r127826: <http://trac.webkit.org/changeset/127826>
Comment 7 WebKit Review Bot 2012-09-06 22:21:51 PDT
All reviewed patches have been landed.  Closing bug.