Bug 1351383 Part 2: Collect telemetry for nsBlockFrame and children with css box align styles. r=dholbert

MozReview-Commit-ID: H8oCHAtBMyg

--HG--
extra : rebase_source : 483f9436fe69daa1dfaaf5bdae3c0a4c0aff49f7
This commit is contained in:
Brad Werth 2017-04-25 16:52:45 -07:00
Родитель cffd503744
Коммит 9a36059cb9
1 изменённых файлов: 48 добавлений и 0 удалений

Просмотреть файл

@ -56,6 +56,7 @@
#include "mozilla/dom/HTMLSummaryElement.h"
#include "mozilla/StyleSetHandle.h"
#include "mozilla/StyleSetHandleInlines.h"
#include "mozilla/Telemetry.h"
#include "nsBidiPresUtils.h"
@ -1512,6 +1513,53 @@ nsBlockFrame::Reflow(nsPresContext* aPresContext,
}
#endif
#ifdef EARLY_BETA_OR_EARLIER
// Bug 1358299 START: Remove this code after the 56 merge date.
static bool sIsTelemetryEnabled;
static bool sTelemetryPrefCached = false;
if (!sTelemetryPrefCached) {
sTelemetryPrefCached = true;
Preferences::AddBoolVarCache(&sIsTelemetryEnabled,
"toolkit.telemetry.enabled");
}
if (sIsTelemetryEnabled) {
// Collect data for the BOX_ALIGN_PROPS_IN_BLOCKS_FLAG probe.
auto IsStyleNormalOrAuto = [](uint16_t value)->bool {
return ((value == NS_STYLE_ALIGN_NORMAL) ||
(value == NS_STYLE_ALIGN_AUTO));
};
// First check this frame for non-default values of the css-align properties
// that apply to block containers.
// Note: we check here for non-default "justify-items", though technically
// that'd only affect rendering if some child has "justify-self:auto".
// (It's safe to assume that's likely, since it's the default value that
// a child would have.) We also pass in nullptr for the parent style context
// because an accurate parameter is slower and only necessary to detect a
// narrow edge case with the "legacy" keyword.
const nsStylePosition* stylePosition = reflowInput->mStylePosition;
if (!IsStyleNormalOrAuto(stylePosition->mJustifyContent) ||
!IsStyleNormalOrAuto(stylePosition->mAlignContent) ||
!IsStyleNormalOrAuto(stylePosition->ComputedJustifyItems(nullptr))) {
Telemetry::Accumulate(Telemetry::BOX_ALIGN_PROPS_IN_BLOCKS_FLAG, true);
} else {
// If not already flagged by the parent, now check justify-self of the
// block-level child frames.
for (nsBlockFrame::LineIterator line = LinesBegin();
line != LinesEnd(); ++line) {
if (line->IsBlock() &&
!IsStyleNormalOrAuto(line->mFirstChild->StylePosition()->mJustifySelf)) {
Telemetry::Accumulate(Telemetry::BOX_ALIGN_PROPS_IN_BLOCKS_FLAG, true);
break;
}
}
}
}
// Bug 1358299 END
#endif
NS_FRAME_SET_TRUNCATION(aStatus, (*reflowInput), aMetrics);
}