Bug 78140 - Add toText and isTextNode helpers in Text class
Summary: Add toText and isTextNode helpers in Text class
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-02-08 12:28 PST by Abhishek Arya
Modified: 2012-02-12 19:18 PST (History)
10 users (show)

See Also:


Attachments
ProposedPatch (47.92 KB, patch)
2012-02-11 01:05 PST, Joe Thomas
no flags Details | Formatted Diff | Diff
Patch-with-StyleChecker (49.54 KB, patch)
2012-02-11 21:29 PST, Joe Thomas
no flags Details | Formatted Diff | Diff
UnitTestCase-StyleChecker (1.65 KB, patch)
2012-02-12 17:35 PST, Joe Thomas
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Abhishek Arya 2012-02-08 12:28:45 PST
in WebKit/Source/WebCore/dom/Text.h,
toText is needed to shorten static_cast<Text>* and also detect bad cast using isTextNode
Comment 1 Joe Thomas 2012-02-11 01:05:00 PST
Created attachment 126623 [details]
ProposedPatch
Comment 2 Adam Barth 2012-02-11 10:16:00 PST
Comment on attachment 126623 [details]
ProposedPatch

Consider adding a style checker rule to remind folks to use toText rather than static_cast<Text*>
Comment 3 Joe Thomas 2012-02-11 12:02:04 PST
(In reply to comment #2)
> (From update of attachment 126623 [details])
> Consider adding a style checker rule to remind folks to use toText rather than static_cast<Text*>

Checked Tools/Scripts/webkitpy/style/, but did not get much idea how to do this. :(
Comment 4 Joe Thomas 2012-02-11 21:28:21 PST
(In reply to comment #3)
> (In reply to comment #2)
> > (From update of attachment 126623 [details] [details])
> > Consider adding a style checker rule to remind folks to use toText rather than static_cast<Text*>
> 
> Checked Tools/Scripts/webkitpy/style/, but did not get much idea how to do this. :(

I was trying to report the style check error with one of the error category mentioned in BASE_FILTER_RULES in Tools/Scripts/webkitpy/style/checker.py. As far as I understand, errors reported with this list is ignored.
Comment 5 Joe Thomas 2012-02-11 21:29:14 PST
Created attachment 126670 [details]
Patch-with-StyleChecker

Added style checker.
Comment 6 WebKit Review Bot 2012-02-11 21:31:21 PST
Attachment 126670 [details] did not pass style-queue:

Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1

Source/WebCore/dom/Text.h:76:  Consider using toText helper function in WebCore/dom/Text.h instead of static_cast<Text*>  [readability/check] [4]
Total errors found: 1 in 37 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 7 Joe Thomas 2012-02-11 22:53:11 PST
(In reply to comment #6)
> Attachment 126670 [details] did not pass style-queue:
> 
> Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'Source/WebCore/ChangeLog', u'Source/WebCor..." exit_code: 1
> 
> Source/WebCore/dom/Text.h:76:  Consider using toText helper function in WebCore/dom/Text.h instead of static_cast<Text*>  [readability/check] [4]
> Total errors found: 1 in 37 files

This error is expected as it is caused by the new style-checker added in this patch.
Comment 8 Adam Barth 2012-02-12 01:36:38 PST
Comment on attachment 126670 [details]
Patch-with-StyleChecker

Oh, I meant to make the style checker change in a separate patch, but this seems fine too.
Comment 9 WebKit Review Bot 2012-02-12 03:28:13 PST
Comment on attachment 126670 [details]
Patch-with-StyleChecker

Clearing flags on attachment: 126670

Committed r107509: <http://trac.webkit.org/changeset/107509>
Comment 10 David Levin 2012-02-12 13:45:02 PST
It looks like there wasn't a unit test for the style checker change.

Please add one -- otherwise it may break at anytime due to people changing the code and no one will know!
Comment 11 Joe Thomas 2012-02-12 14:13:14 PST
(In reply to comment #10)
> It looks like there wasn't a unit test for the style checker change.
> 
> Please add one -- otherwise it may break at anytime due to people changing the code and no one will know!

Sure I will add the unit test case. I did not know that there is a unit test suite for style checker. What is the script used for running the unit test?
Comment 12 David Levin 2012-02-12 14:14:57 PST
(In reply to comment #11)
> (In reply to comment #10)
> > It looks like there wasn't a unit test for the style checker change.
> > 
> > Please add one -- otherwise it may break at anytime due to people changing the code and no one will know!
> 
> Sure I will add the unit test case. I did not know that there is a unit test suite for style checker. What is the script used for running the unit test?

Here's a sample change: http://trac.webkit.org/changeset/105652
Comment 13 Joe Thomas 2012-02-12 17:35:29 PST
Created attachment 126692 [details]
UnitTestCase-StyleChecker

Added the unit test case for the style checker introduced in the previous commit for this bug
Comment 14 Adam Barth 2012-02-12 17:49:25 PST
Comment on attachment 126692 [details]
UnitTestCase-StyleChecker

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

> Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py:762
> +    # Test for static_cast readability.

This comment doesn't seem to be adding any value.  It's redundant with the function name.
Comment 15 WebKit Review Bot 2012-02-12 19:18:08 PST
Comment on attachment 126692 [details]
UnitTestCase-StyleChecker

Clearing flags on attachment: 126692

Committed r107522: <http://trac.webkit.org/changeset/107522>
Comment 16 WebKit Review Bot 2012-02-12 19:18:15 PST
All reviewed patches have been landed.  Closing bug.