Bug 1292930: Hoist ChangeHintToString to RestyleManagerBase
MozReview-Commit-ID: BLW40PYhc0o
--- a/layout/base/RestyleManager.cpp
+++ b/layout/base/RestyleManager.cpp
@@ -3906,77 +3906,16 @@ RestyleManager::StructsToLog()
initialized = true;
}
return structs;
}
#endif
#ifdef DEBUG
/* static */ nsCString
-RestyleManager::ChangeHintToString(nsChangeHint aHint)
-{
- nsCString result;
- bool any = false;
- const char* names[] = {
- "RepaintFrame", "NeedReflow", "ClearAncestorIntrinsics",
- "ClearDescendantIntrinsics", "NeedDirtyReflow", "SyncFrameView",
- "UpdateCursor", "UpdateEffects", "UpdateOpacityLayer",
- "UpdateTransformLayer", "ReconstructFrame", "UpdateOverflow",
- "UpdateSubtreeOverflow", "UpdatePostTransformOverflow",
- "UpdateParentOverflow",
- "ChildrenOnlyTransform", "RecomputePosition", "AddOrRemoveTransform",
- "BorderStyleNoneChange", "UpdateTextPath", "SchedulePaint",
- "NeutralChange", "InvalidateRenderingObservers",
- "ReflowChangesSizeOrPosition", "UpdateComputedBSize",
- "UpdateUsesOpacity"
- };
- uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
- uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
- if (hint == nsChangeHint_Hints_NotHandledForDescendants) {
- result.AppendLiteral("nsChangeHint_Hints_NotHandledForDescendants");
- hint = 0;
- any = true;
- } else {
- if ((hint & NS_STYLE_HINT_REFLOW) == NS_STYLE_HINT_REFLOW) {
- result.AppendLiteral("NS_STYLE_HINT_REFLOW");
- hint = hint & ~NS_STYLE_HINT_REFLOW;
- any = true;
- } else if ((hint & nsChangeHint_AllReflowHints) == nsChangeHint_AllReflowHints) {
- result.AppendLiteral("nsChangeHint_AllReflowHints");
- hint = hint & ~nsChangeHint_AllReflowHints;
- any = true;
- } else if ((hint & NS_STYLE_HINT_VISUAL) == NS_STYLE_HINT_VISUAL) {
- result.AppendLiteral("NS_STYLE_HINT_VISUAL");
- hint = hint & ~NS_STYLE_HINT_VISUAL;
- any = true;
- }
- }
- for (uint32_t i = 0; i < ArrayLength(names); i++) {
- if (hint & (1 << i)) {
- if (any) {
- result.AppendLiteral(" | ");
- }
- result.AppendPrintf("nsChangeHint_%s", names[i]);
- any = true;
- }
- }
- if (rest) {
- if (any) {
- result.AppendLiteral(" | ");
- }
- result.AppendPrintf("0x%0x", rest);
- } else {
- if (!any) {
- result.AppendLiteral("nsChangeHint(0)");
- }
- }
- return result;
-}
-
-/* static */ nsCString
RestyleManager::StructNamesToString(uint32_t aSIDs)
{
nsCString result;
bool any = false;
for (nsStyleStructID sid = nsStyleStructID(0);
sid < nsStyleStructID_Length;
sid = nsStyleStructID(sid + 1)) {
if (aSIDs & nsCachedStyleData::GetBitForSID(sid)) {
--- a/layout/base/RestyleManager.h
+++ b/layout/base/RestyleManager.h
@@ -375,20 +375,16 @@ public:
nsChangeHint aMinChangeHint,
const RestyleHintData* aRestyleHintData = nullptr);
void PostRestyleEventForLazyConstruction()
{
PostRestyleEventInternal(true);
}
-#ifdef DEBUG
- static nsCString ChangeHintToString(nsChangeHint aHint);
-#endif
-
public:
/**
* Asynchronously clear style data from the root frame downwards and ensure
* it will all be rebuilt. This is safe to call anytime; it will schedule
* a restyle and take effect next time style changes are flushed.
* This method is used to recompute the style data when some change happens
* outside of any style rules, like a color preference change or a change
* in a system font size, or to fix things up when an optimization in the
--- a/layout/base/RestyleManagerBase.cpp
+++ b/layout/base/RestyleManagerBase.cpp
@@ -131,16 +131,79 @@ RestyleManagerBase::RestyleHintToString(
} else {
if (!any) {
result.AppendLiteral("0");
}
}
return result;
}
+#ifdef DEBUG
+/* static */ nsCString
+RestyleManagerBase::ChangeHintToString(nsChangeHint aHint)
+{
+ nsCString result;
+ bool any = false;
+ const char* names[] = {
+ "RepaintFrame", "NeedReflow", "ClearAncestorIntrinsics",
+ "ClearDescendantIntrinsics", "NeedDirtyReflow", "SyncFrameView",
+ "UpdateCursor", "UpdateEffects", "UpdateOpacityLayer",
+ "UpdateTransformLayer", "ReconstructFrame", "UpdateOverflow",
+ "UpdateSubtreeOverflow", "UpdatePostTransformOverflow",
+ "UpdateParentOverflow",
+ "ChildrenOnlyTransform", "RecomputePosition", "AddOrRemoveTransform",
+ "BorderStyleNoneChange", "UpdateTextPath", "SchedulePaint",
+ "NeutralChange", "InvalidateRenderingObservers",
+ "ReflowChangesSizeOrPosition", "UpdateComputedBSize",
+ "UpdateUsesOpacity"
+ };
+ uint32_t hint = aHint & ((1 << ArrayLength(names)) - 1);
+ uint32_t rest = aHint & ~((1 << ArrayLength(names)) - 1);
+ if (hint == nsChangeHint_Hints_NotHandledForDescendants) {
+ result.AppendLiteral("nsChangeHint_Hints_NotHandledForDescendants");
+ hint = 0;
+ any = true;
+ } else {
+ if ((hint & NS_STYLE_HINT_REFLOW) == NS_STYLE_HINT_REFLOW) {
+ result.AppendLiteral("NS_STYLE_HINT_REFLOW");
+ hint = hint & ~NS_STYLE_HINT_REFLOW;
+ any = true;
+ } else if ((hint & nsChangeHint_AllReflowHints) == nsChangeHint_AllReflowHints) {
+ result.AppendLiteral("nsChangeHint_AllReflowHints");
+ hint = hint & ~nsChangeHint_AllReflowHints;
+ any = true;
+ } else if ((hint & NS_STYLE_HINT_VISUAL) == NS_STYLE_HINT_VISUAL) {
+ result.AppendLiteral("NS_STYLE_HINT_VISUAL");
+ hint = hint & ~NS_STYLE_HINT_VISUAL;
+ any = true;
+ }
+ }
+ for (uint32_t i = 0; i < ArrayLength(names); i++) {
+ if (hint & (1 << i)) {
+ if (any) {
+ result.AppendLiteral(" | ");
+ }
+ result.AppendPrintf("nsChangeHint_%s", names[i]);
+ any = true;
+ }
+ }
+ if (rest) {
+ if (any) {
+ result.AppendLiteral(" | ");
+ }
+ result.AppendPrintf("0x%0x", rest);
+ } else {
+ if (!any) {
+ result.AppendLiteral("nsChangeHint(0)");
+ }
+ }
+ return result;
+}
+#endif
+
void
RestyleManagerBase::PostRestyleEventInternal(bool aForLazyConstruction)
{
// Make sure we're not in a style refresh; if we are, we still have
// a call to ProcessPendingRestyles coming and there's no need to
// add ourselves as a refresh observer until then.
bool inRefresh = !aForLazyConstruction && mInStyleRefresh;
nsIPresShell* presShell = PresContext()->PresShell();
--- a/layout/base/RestyleManagerBase.h
+++ b/layout/base/RestyleManagerBase.h
@@ -43,16 +43,18 @@ public:
mObservingRefreshDriver = aObserving;
}
void Disconnect() { mPresContext = nullptr; }
static nsCString RestyleHintToString(nsRestyleHint aHint);
#ifdef DEBUG
+ static nsCString ChangeHintToString(nsChangeHint aHint);
+
/**
* DEBUG ONLY method to verify integrity of style tree versus frame tree
*/
static void DebugVerifyStyleTree(nsIFrame* aFrame);
#endif
void FlushOverflowChangedTracker() {
mOverflowChangedTracker.Flush();