|
|
b3d7060 |
#
|
|
|
b3d7060 |
# Do separate handling of '+' (adjacent sibling combinator)
|
|
|
b3d7060 |
# in the context of the pending restyling.
|
|
|
b3d7060 |
#
|
|
|
b3d7060 |
# If we set 'eRestyle_LaterSiblings' for '+' in the same way as for '~' (general sibling),
|
|
|
b3d7060 |
# this results in an unneeded iteration for all the siblings in RestyleTracker::DoProcessRestyles().
|
|
|
b3d7060 |
# This can cause certain sites to slow down significantly.
|
|
|
b3d7060 |
#
|
|
|
b3d7060 |
# A good example for the issue is hg.mozilla.org with a huge enough file (about 10000 lines),
|
|
|
b3d7060 |
# say https://hg.mozilla.org/mozilla-central/file/tip/js/src/frontend/BytecodeEmitter.cpp .
|
|
|
b3d7060 |
# Just move mouse a bit over the row number column somewhere in the top of the page.
|
|
|
b3d7060 |
# The correspond style code uses '+' here, but instead of checking the adjacent element only,
|
|
|
b3d7060 |
# all about 10000 later siblings (rows) are checked. This results in a kind of 'o(n^2)',
|
|
|
b3d7060 |
# which freezes cpu up to a few seconds.
|
|
|
b3d7060 |
#
|
|
|
b3d7060 |
|
|
|
b3d7060 |
diff -Nrup mozilla-OLD/layout/base/GeckoRestyleManager.cpp mozilla/layout/base/GeckoRestyleManager.cpp
|
|
|
75d68f4 |
--- mozilla-OLD/layout/base/GeckoRestyleManager.cpp 2022-04-11 23:40:35.197413086 +0300
|
|
|
75d68f4 |
+++ mozilla/layout/base/GeckoRestyleManager.cpp 2022-04-11 23:35:45.751600219 +0300
|
|
|
75d68f4 |
@@ -742,6 +742,23 @@ GeckoRestyleManager::PostRestyleEvent(El
|
|
|
b3d7060 |
return;
|
|
|
b3d7060 |
}
|
|
|
b3d7060 |
|
|
|
b3d7060 |
+ if (aRestyleHint & eRestyle_NextSibling) {
|
|
|
b3d7060 |
+ aRestyleHint &= ~eRestyle_NextSibling;
|
|
|
b3d7060 |
+
|
|
|
b3d7060 |
+ if (!(aRestyleHint & eRestyle_LaterSiblings)) {
|
|
|
75d68f4 |
+ // Just the one next sibling is not enough on practice,
|
|
|
75d68f4 |
+ // at least 2 seem to be needed in some cases.
|
|
|
75d68f4 |
+ int maxNextSiblings = 10;
|
|
|
75d68f4 |
+
|
|
|
75d68f4 |
+ for (Element* nextSibling = aElement->GetNextElementSibling();
|
|
|
75d68f4 |
+ nextSibling && maxNextSiblings--;
|
|
|
75d68f4 |
+ nextSibling = nextSibling->GetNextElementSibling()) {
|
|
|
75d68f4 |
+ mPendingRestyles.AddPendingRestyle(nextSibling, eRestyle_Subtree, nsChangeHint(0),
|
|
|
75d68f4 |
+ aRestyleHintData);
|
|
|
b3d7060 |
+ }
|
|
|
b3d7060 |
+ }
|
|
|
b3d7060 |
+ }
|
|
|
b3d7060 |
+
|
|
|
b3d7060 |
mPendingRestyles.AddPendingRestyle(aElement, aRestyleHint, aMinChangeHint,
|
|
|
b3d7060 |
aRestyleHintData);
|
|
|
b3d7060 |
|
|
|
b3d7060 |
diff -Nrup mozilla-OLD/layout/base/nsChangeHint.h mozilla/layout/base/nsChangeHint.h
|
|
|
b3d7060 |
--- mozilla-OLD/layout/base/nsChangeHint.h 2021-08-08 16:02:00.000000000 +0300
|
|
|
b3d7060 |
+++ mozilla/layout/base/nsChangeHint.h 2022-02-01 20:05:06.767443223 +0300
|
|
|
b3d7060 |
@@ -600,6 +600,10 @@ enum nsRestyleHint : uint32_t {
|
|
|
b3d7060 |
// descendants rather than just continuing the restyling process.
|
|
|
b3d7060 |
eRestyle_ForceDescendants = 1 << 9,
|
|
|
b3d7060 |
|
|
|
b3d7060 |
+ // Rerun selector matching on the next sibling of the element and
|
|
|
b3d7060 |
+ // all of its descendants.
|
|
|
b3d7060 |
+ eRestyle_NextSibling = 1 << 10,
|
|
|
b3d7060 |
+
|
|
|
b3d7060 |
// Useful unions:
|
|
|
b3d7060 |
eRestyle_AllHintsWithAnimations = eRestyle_CSSTransitions |
|
|
|
b3d7060 |
eRestyle_CSSAnimations |
|
|
|
b3d7060 |
diff -Nrup mozilla-OLD/layout/style/nsCSSRuleProcessor.cpp mozilla/layout/style/nsCSSRuleProcessor.cpp
|
|
|
b3d7060 |
--- mozilla-OLD/layout/style/nsCSSRuleProcessor.cpp 2020-02-18 02:37:58.000000000 +0300
|
|
|
b3d7060 |
+++ mozilla/layout/style/nsCSSRuleProcessor.cpp 2022-02-02 09:46:52.736328160 +0300
|
|
|
b3d7060 |
@@ -2705,7 +2705,11 @@ nsCSSRuleProcessor::RulesMatching(XULTre
|
|
|
b3d7060 |
|
|
|
b3d7060 |
static inline nsRestyleHint RestyleHintForOp(char16_t oper)
|
|
|
b3d7060 |
{
|
|
|
b3d7060 |
- if (oper == char16_t('+') || oper == char16_t('~')) {
|
|
|
b3d7060 |
+ if (oper == char16_t('+')) {
|
|
|
b3d7060 |
+ return eRestyle_NextSibling;
|
|
|
b3d7060 |
+ }
|
|
|
b3d7060 |
+
|
|
|
b3d7060 |
+ if (oper == char16_t('~')) {
|
|
|
b3d7060 |
return eRestyle_LaterSiblings;
|
|
|
b3d7060 |
}
|
|
|
b3d7060 |
|
|
|
b3d7060 |
@@ -2852,7 +2856,11 @@ RestyleHintForSelectorWithAttributeChang
|
|
|
b3d7060 |
|
|
|
b3d7060 |
char16_t oper = aSelector->mOperator;
|
|
|
b3d7060 |
|
|
|
b3d7060 |
- if (oper == char16_t('+') || oper == char16_t('~')) {
|
|
|
b3d7060 |
+ if (oper == char16_t('+')) {
|
|
|
b3d7060 |
+ return eRestyle_NextSibling;
|
|
|
b3d7060 |
+ }
|
|
|
b3d7060 |
+
|
|
|
b3d7060 |
+ if (oper == char16_t('~')) {
|
|
|
b3d7060 |
return eRestyle_LaterSiblings;
|
|
|
b3d7060 |
}
|
|
|
b3d7060 |
|