review feedback. draft
authorBrad Werth <bwerth@mozilla.com>
Thu, 20 Apr 2017 15:15:23 -0700
changeset 566142 3ed84e49f3c858c6752687710b6ff90a9ddb976c
parent 566141 4f99a497ec7cfdfef046f4dbf6d7799b55f6f123
child 566143 52fce16f71f2fd8131d89ef53ea3fd02f0c01ec6
push id55100
push userbwerth@mozilla.com
push dateThu, 20 Apr 2017 23:03:11 +0000
milestone55.0a1
review feedback. MozReview-Commit-ID: FyaYsmfoxnj
layout/generic/nsBlockFrame.cpp
--- a/layout/generic/nsBlockFrame.cpp
+++ b/layout/generic/nsBlockFrame.cpp
@@ -1509,46 +1509,43 @@ nsBlockFrame::Reflow(nsPresContext*     
     SprintfLiteral(buf,
                    ": %" PRId64 " elapsed (%" PRId64 " per line) (%d lines; %d new lines)",
                    delta, perLineDelta, numLines, ectc - ctc);
     printf("%s\n", buf);
   }
 #endif
 
   // Bug 1351383: Collect data for the BOX_ALIGN_PROPS_IN_BLOCKS_FLAG probe.
-  auto IsBoxAlignProperty = [](uint16_t value)->bool {
-    return (value == NS_STYLE_ALIGN_CENTER ||
-            value == NS_STYLE_ALIGN_START ||
-            value == NS_STYLE_ALIGN_END ||
-            value == NS_STYLE_ALIGN_FLEX_START ||
-            value == NS_STYLE_ALIGN_FLEX_END ||
-            value == NS_STYLE_ALIGN_LEFT ||
-            value == NS_STYLE_ALIGN_RIGHT ||
-            value == NS_STYLE_ALIGN_SPACE_BETWEEN ||
-            value == NS_STYLE_ALIGN_SPACE_EVENLY ||
-            value == NS_STYLE_ALIGN_SPACE_AROUND);
+  auto IsStyleNormal = [](uint16_t value)->bool {
+    return (value == NS_STYLE_ALIGN_NORMAL);
   };
 
-  // First check this frame's properties.
-  // We look for any non-default value for justify-items, but don't explicitly
-  // check to see if any block-level children have justify-self:auto.
-  if (IsBoxAlignProperty(StylePosition()->mJustifyContent) ||
-      IsBoxAlignProperty(StylePosition()->mAlignContent) ||
-      IsBoxAlignProperty(StylePosition()->ComputedJustifyItems(
-        StyleContext()->GetParent()))) {
-    mozilla::Telemetry::Accumulate(
-      mozilla::Telemetry::BOX_ALIGN_PROPS_IN_BLOCKS_FLAG, true);
+  // 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 (!IsStyleNormal(stylePosition->mJustifyContent) ||
+      !IsStyleNormal(stylePosition->mAlignContent) ||
+      !IsStyleNormal(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 (auto iter = mLines.begin(); iter != mLines.end(); iter++) {
-      if (iter->IsBlock() &&
-          IsBoxAlignProperty(iter->mFirstChild->StylePosition()->mJustifySelf)) {
-        mozilla::Telemetry::Accumulate(
-          mozilla::Telemetry::BOX_ALIGN_PROPS_IN_BLOCKS_FLAG, true);
+    for (nsBlockFrame::LineIterator line = LinesBegin();
+         line != LinesEnd(); ++line) {
+      if (line->IsBlock() &&
+          !IsStyleNormal(line->mFirstChild->StylePosition()->mJustifySelf)) {
+        Telemetry::Accumulate(
+          Telemetry::BOX_ALIGN_PROPS_IN_BLOCKS_FLAG, true);
         break;
       }
     }
   }
 
   NS_FRAME_SET_TRUNCATION(aStatus, (*reflowInput), aMetrics);
 }