Bug 84383

Summary: Remove unnecessary null check for styleSelector on RuleSet::addRulesFromSheet
Product: WebKit Reporter: Rafael Brandao <rafael.lobo>
Component: CSSAssignee: Rafael Brandao <rafael.lobo>
Status: RESOLVED WONTFIX    
Severity: Normal CC: eric, haraken, kling, koivisto, macpherson, menard, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch koivisto: review-

Rafael Brandao
Reported 2012-04-19 14:26:01 PDT
Remove unnecessary check on CSSStyleSelector::addRulesFromSheet
Attachments
Patch (1.53 KB, patch)
2012-04-19 14:26 PDT, Rafael Brandao
no flags
Patch (5.84 KB, patch)
2012-05-04 15:10 PDT, Rafael Brandao
koivisto: review-
Rafael Brandao
Comment 1 2012-04-19 14:26:49 PDT
Alexis Menard (darktears)
Comment 2 2012-04-19 14:33:50 PDT
Comment on attachment 137975 [details] Patch Changelog should be more explicit why it is unnecessary and also why you don't change line 2527, 2535?
Alexey Proskuryakov
Comment 3 2012-04-19 22:21:12 PDT
Comment on attachment 137975 [details] Patch > Changelog should be more explicit why it is unnecessary and also why you don't change line 2527, 2535? I strongly agree. Let's make this r- until there full is clarity.
Alexey Proskuryakov
Comment 4 2012-04-19 22:21:28 PDT
...there is full clarity.
Rafael Brandao
Comment 5 2012-04-23 07:28:37 PDT
Sure. The thing is inside that if we don't make use of styleSelector, like on the previous ifs (for example rule->isStyleRule() or rule->isPageRule()). Differently from lines 2527 and 2535 where we use styleSelector inside, so it's reasonable to check that pointer.
Luke Macpherson
Comment 6 2012-04-26 20:07:55 PDT
Comment on attachment 137975 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=137975&action=review > Source/WebCore/ChangeLog:3 > + Remove unnecessary check on CSSStyleSelector::addRulesFromSheet Bug title could be improved by using the word null somewhere. > Source/WebCore/ChangeLog:8 > + No new tests needed, just a cleanup. I think you should just update the ChangeLog to say that the styleSelector null check is not needed in this case because styleSelector is not dereferenced or passed to anything else here. > Source/WebCore/css/CSSStyleSelector.cpp:2540 > + } else if (rule->isRegionRule()) { FWIW the actual code change seems safe, though since it is always checked right now, it might be even better to remove all the individual styleSelector checks and instead have a single check earlier in the function.
Rafael Brandao
Comment 7 2012-05-04 14:52:55 PDT
StyleSelector became StyleResolver, should I also rename the variable for styleResolver? I won't do it unless it's necessary. > > Source/WebCore/css/CSSStyleSelector.cpp:2540 > > + } else if (rule->isRegionRule()) { > > FWIW the actual code change seems safe, though since it is always checked right now, it might be even better to remove all the individual styleSelector checks and instead have a single check earlier in the function. You mean to add a null check on the beginning of addRulesFromSheet? If so, that would change the behavior here, some rules doesn't depend on that styleSelector. Maybe grouping rules that depend on it would be better? I will submit a patch trying this approach.
Rafael Brandao
Comment 8 2012-05-04 15:10:13 PDT
Brent Fulgham
Comment 9 2012-11-14 00:15:37 PST
Comment on attachment 140337 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=140337&action=review > Source/WebCore/css/StyleResolver.cpp:-2545 > - } else if (rule->isRegionRule() && styleSelector) { Can rules have multiple categories (e.g,, a rule is both a key frame style *and* a region rule? If so, this change will subtly modify the behavior of this code. If they can never be overlapping, this change looks fine (but that might imply that the rules should be unique objects, rather than flags on a generic rule object.)
Antti Koivisto
Comment 10 2012-11-14 05:59:54 PST
Comment on attachment 140337 [details] Patch This patch is almost pure noise.
Note You need to log in before you can comment on or make changes to this bug.