|
|
Chromium Code Reviews|
Created:
4 years, 3 months ago by hayato Modified:
4 years, 3 months ago CC:
darktears, apavlov+blink_chromium.org, blink-reviews, blink-reviews-css, blink-reviews-dom_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, rwlbuis, sof Target Ref:
refs/pending/heads/master Project:
chromium Visibility:
Public. |
DescriptionFix the wrong usages of CSSSelectorList::selectorUsesXXX() functions
It looks that a wrong `selectorIndex` argument is passed to
CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions.
- The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec.
- The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray.
They are totally different if a selector list has more than one selectors.
This CL moved all functions to CSSSelector to prevent the wrong usage from happening
in the future. It is error-prone that CSSSelectorList has these functions.
This CL also fixes bug 643316.
BUG=643316
Committed: https://crrev.com/78be6354d3b13dff165e2715957bab3a6d158098
Cr-Commit-Position: refs/heads/master@{#416214}
Patch Set 1 #Patch Set 2 : Add a test #
Total comments: 7
Patch Set 3 : Fix #
Total comments: 5
Messages
Total messages: 34 (20 generated)
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Description was changed from ========== Fix the broken CSSSelectorList::usesXXXX() BUG=643316 ========== to ========== Fix the wrong usage of CSSSelectorList::selectorUsesXXX() functions It looks that the wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions, based on the wrong assumption. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
Description was changed from ========== Fix the wrong usage of CSSSelectorList::selectorUsesXXX() functions It looks that the wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions, based on the wrong assumption. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usage of CSSSelectorList::selectorUsesXXX() functions It looks that the wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions, based on the wrong assumption. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
Description was changed from ========== Fix the wrong usage of CSSSelectorList::selectorUsesXXX() functions It looks that the wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions, based on the wrong assumption. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usage of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
hayato@chromium.org changed reviewers: + kochi@chromium.org, rune@opera.com, tkent@chromium.org
PTAL
Add a test
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/CSSSelectorList.cpp (left): https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/CSSSelectorList.cpp:145: static bool forEachSelector(const Functor& functor, const CSSSelectorList* selectorList) This template is not used.
Description was changed from ========== Fix the wrong usage of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
Description was changed from ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a selector in selectors. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the sense of the spec. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
Description was changed from ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the sense of the spec. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
Description was changed from ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of a CSSSelector in the CSSSelecorList. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
Description was changed from ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different if a selector list has more than one selectors. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ==========
nice find and nice refactoring. lgtm % nits Does this fix the case that the linked bug reports? If so, could you improve the CL description about where specifically used wrong argument (SelectorQuery.cpp only?) and what went wrong? https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/CSSSelector.cpp (right): https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/CSSSelector.cpp:950: }, *this); Wrong indent? Please be consistent with other cases. https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/SelectorQuery.cpp:116: unsigned index = 0; You no longer need this index. https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/SelectorQuery.cpp:117: for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector), ++index) { Remove '++index'
Description was changed from ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different if a selector list has more than one selectors. This CL fixes that, and moves all functions to CSSSelector because it is error-prone that CSSSelectorList has these functions. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different if a selector list has more than one selectors. This CL moved all functions to CSSSelector to prevent the wrong usage from happening in the future. It is error-prone that CSSSelectorList has these functions. This CL also fixes bug 643316. BUG=643316 ==========
Fix
The CQ bit was checked by hayato@chromium.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
> Does this fix the case that the linked bug reports? Yes. > If so, could you improve the CL description about where specifically used wrong argument (SelectorQuery.cpp only?) and what went wrong? Only SelectorQuery.cpp. I have updated the description. https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/CSSSelector.cpp (right): https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/CSSSelector.cpp:950: }, *this); Done https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/dom/SelectorQuery.cpp (right): https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/SelectorQuery.cpp:116: unsigned index = 0; Done https://codereview.chromium.org/2306903002/diff/20001/third_party/WebKit/Sour... third_party/WebKit/Source/core/dom/SelectorQuery.cpp:117: for (const CSSSelector* selector = selectorList.first(); selector; selector = CSSSelectorList::next(*selector), ++index) { Done
The CQ bit was unchecked by hayato@chromium.org
The CQ bit was checked by hayato@chromium.org
The patchset sent to the CQ was uploaded after l-g-t-m from kochi@chromium.org Link to the patchset: https://codereview.chromium.org/2306903002/#ps40001 (title: "Fix")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.or...
Note: It looks I forgot to upload a layout test in the previous patch set. The latest patch set includes it.
Adding a test case makes sense very much, now it is clear that this CL fixes the case for querySelector() which has multiple selectors. lgtm
Message was sent while issue was closed.
Committed patchset #3 (id:40001)
Message was sent while issue was closed.
Description was changed from ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different if a selector list has more than one selectors. This CL moved all functions to CSSSelector to prevent the wrong usage from happening in the future. It is error-prone that CSSSelectorList has these functions. This CL also fixes bug 643316. BUG=643316 ========== to ========== Fix the wrong usages of CSSSelectorList::selectorUsesXXX() functions It looks that a wrong `selectorIndex` argument is passed to CSSSelectorList::selectorUsesDeepCombinatorOrShadowPseudo(), and similar functions. - The clients are passing the index of a *selector* in *selectors*, in the meaning used in the spec. - The member functions are using this parameter as the index of CSSSelecorList::m_selectorArray. They are totally different if a selector list has more than one selectors. This CL moved all functions to CSSSelector to prevent the wrong usage from happening in the future. It is error-prone that CSSSelectorList has these functions. This CL also fixes bug 643316. BUG=643316 Committed: https://crrev.com/78be6354d3b13dff165e2715957bab3a6d158098 Cr-Commit-Position: refs/heads/master@{#416214} ==========
Message was sent while issue was closed.
Patchset 3 (id:??) landed as https://crrev.com/78be6354d3b13dff165e2715957bab3a6d158098 Cr-Commit-Position: refs/heads/master@{#416214}
Message was sent while issue was closed.
https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/CSSSelector.cpp (right): https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/CSSSelector.cpp:916: static bool forEachTagSelector(const Functor& functor, const CSSSelector& selector) This is a weird name. It sounds like it's looking at "Tag" (type?) selectors only. But it's in fact looking at every simple selector. https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/RuleSet.cpp (left): https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/RuleSet.cpp:260: for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { SelectorList::next() would be a better choice, I think. indexOfNextSelectorAfter() calls next(), and is a convenience method for the RuleData code which stores the selectorIndex.
Message was sent while issue was closed.
https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/CSSSelector.cpp (right): https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/CSSSelector.cpp:916: static bool forEachTagSelector(const Functor& functor, const CSSSelector& selector) On 2016/09/02 at 09:14:31, rune wrote: > This is a weird name. It sounds like it's looking at "Tag" (type?) selectors only. But it's in fact looking at every simple selector. I think this name is coming from CSSSelector::m_tagHistory. Using a simple selector here might be confusing here because what it does is traversing CSSSelector's internal structures, which is slightly different for traversing each simple selector. Anyway, let me rename this to forEachTagHistory since it reflects more accurately. https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/RuleSet.cpp (left): https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/RuleSet.cpp:260: for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { On 2016/09/02 at 09:14:31, rune wrote: > SelectorList::next() would be a better choice, I think. indexOfNextSelectorAfter() calls next(), and is a convenience method for the RuleData code which stores the selectorIndex. Yeah, but we still need a selectorIndex here because we call addRule here. Let me try to use next() here anyway in another CL.
Message was sent while issue was closed.
https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... File third_party/WebKit/Source/core/css/RuleSet.cpp (left): https://codereview.chromium.org/2306903002/diff/40001/third_party/WebKit/Sour... third_party/WebKit/Source/core/css/RuleSet.cpp:260: for (size_t selectorIndex = 0; selectorIndex != kNotFound; selectorIndex = selectorList.indexOfNextSelectorAfter(selectorIndex)) { On 2016/09/05 02:36:11, hayato wrote: > On 2016/09/02 at 09:14:31, rune wrote: > > SelectorList::next() would be a better choice, I think. > indexOfNextSelectorAfter() calls next(), and is a convenience method for the > RuleData code which stores the selectorIndex. > > Yeah, but we still need a selectorIndex here because we call addRule here. Let > me try to use next() here anyway in another CL. Ah. I didn't notice. Just leave it like this then. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
