Bug 1216747 - Record dependency on writing mode in nsRuleNode::ComputeStylePosition. r=heycam
authorL. David Baron <dbaron@dbaron.org>
Tue, 20 Oct 2015 22:52:57 -0700
changeset 268661 eae93d4459583a80ee85f2350d58f983e3a6b356
parent 268660 00cd6d2a84bb7c9c613e74cb9ab685da6308c383
child 268662 8694c40c0a2a5e0fe1a17669f21e7c4ffb517195
push id66900
push userdbaron@mozilla.com
push dateWed, 21 Oct 2015 05:56:51 +0000
treeherdermozilla-inbound@eae93d445958 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1216747
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1216747 - Record dependency on writing mode in nsRuleNode::ComputeStylePosition. r=heycam Without the patch, both reftests fail; with it, both pass.
layout/reftests/writing-mode/1216747-1-notref.html
layout/reftests/writing-mode/1216747-1-ref.html
layout/reftests/writing-mode/1216747-1.html
layout/reftests/writing-mode/reftest.list
layout/style/nsRuleNode.cpp
new file mode 100644
--- /dev/null
+++ b/layout/reftests/writing-mode/1216747-1-notref.html
@@ -0,0 +1,3 @@
+<!DOCTYPE HTML>
+
+<div>This should have min-content width (i.e., many line breaks).</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/writing-mode/1216747-1-ref.html
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML>
+<style>
+
+div {
+  width: -moz-min-content;
+}
+
+</style>
+
+<div>This should have min-content width (i.e., many line breaks).</div>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/writing-mode/1216747-1.html
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML>
+<style>
+
+div {
+  width: -moz-min-content;
+}
+
+</style>
+
+<!-- If you delete this div, the bug goes away, because we don't cache
+     vertical-specific data in the rule tree.  -->
+<div style="writing-mode: vertical-rl"></div>
+
+<div>This should have min-content width (i.e., many line breaks).</div>
--- a/layout/reftests/writing-mode/reftest.list
+++ b/layout/reftests/writing-mode/reftest.list
@@ -158,13 +158,16 @@ test-pref(dom.meta-viewport.enabled,true
 == 1193519-sideways-lr-2.html 1193519-sideways-lr-2-ref.html
 == 1193519-sideways-lr-3.html 1193519-sideways-lr-3-ref.html
 == 1193519-sideways-lr-4.html 1193519-sideways-lr-4-ref.html
 fuzzy-if(gtkWidget||B2G,255,6) fuzzy-if(cocoaWidget,65,69) == 1193519-sideways-lr-decoration-1.html 1193519-sideways-lr-decoration-1-ref.html
 
 == 1196887-1-computed-display-inline-block.html 1196887-1-computed-display-inline-block-ref.html
 == 1205787-legacy-svg-values-1.html 1205787-legacy-svg-values-1-ref.html
 
+== 1216747-1.html 1216747-1-ref.html
+!= 1216747-1.html 1216747-1-notref.html
+
 # Suite of tests from GĂ©rard Talbot in bug 1079151
 include abspos/reftest.list
 
 # Tests for tables with vertical writing modes
 include tables/reftest.list
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -7701,72 +7701,91 @@ nsRuleNode::ComputePositionData(void* aS
   // be specified on both the {,min-,max-}width properties and the
   // {,min-,max-}height properties, regardless of the writing mode.  This is
   // because the writing mode is not determined until here, at computed value
   // time.  Since we do not support layout behavior of these keywords on the
   // block-axis properties, we turn them into unset if we find them in
   // that case.
 
   bool vertical;
-  switch (aContext->StyleVisibility()->mWritingMode) {
+  uint8_t writingMode = aContext->StyleVisibility()->mWritingMode;
+  switch (writingMode) {
     default:
       MOZ_ASSERT(false, "unexpected writing-mode value");
       // fall through
     case NS_STYLE_WRITING_MODE_HORIZONTAL_TB:
       vertical = false;
       break;
     case NS_STYLE_WRITING_MODE_VERTICAL_RL:
     case NS_STYLE_WRITING_MODE_VERTICAL_LR:
     case NS_STYLE_WRITING_MODE_SIDEWAYS_RL:
     case NS_STYLE_WRITING_MODE_SIDEWAYS_LR:
       vertical = true;
       break;
   }
 
   const nsCSSValue* width = aRuleData->ValueForWidth();
+  if (width->GetUnit() == eCSSUnit_Enumerated) {
+    conditions.SetWritingModeDependency(writingMode);
+  }
   SetCoord(width->GetUnit() == eCSSUnit_Enumerated && vertical ?
              nsCSSValue(eCSSUnit_Unset) : *width,
            pos->mWidth, parentPos->mWidth,
            SETCOORD_LPAEH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC |
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   const nsCSSValue* minWidth = aRuleData->ValueForMinWidth();
+  if (minWidth->GetUnit() == eCSSUnit_Enumerated) {
+    conditions.SetWritingModeDependency(writingMode);
+  }
   SetCoord(minWidth->GetUnit() == eCSSUnit_Enumerated && vertical ?
              nsCSSValue(eCSSUnit_Unset) : *minWidth,
            pos->mMinWidth, parentPos->mMinWidth,
            SETCOORD_LPAEH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC |
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   const nsCSSValue* maxWidth = aRuleData->ValueForMaxWidth();
+  if (maxWidth->GetUnit() == eCSSUnit_Enumerated) {
+    conditions.SetWritingModeDependency(writingMode);
+  }
   SetCoord(maxWidth->GetUnit() == eCSSUnit_Enumerated && vertical ?
              nsCSSValue(eCSSUnit_Unset) : *maxWidth,
            pos->mMaxWidth, parentPos->mMaxWidth,
            SETCOORD_LPOEH | SETCOORD_INITIAL_NONE | SETCOORD_STORE_CALC |
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   const nsCSSValue* height = aRuleData->ValueForHeight();
+  if (height->GetUnit() == eCSSUnit_Enumerated) {
+    conditions.SetWritingModeDependency(writingMode);
+  }
   SetCoord(height->GetUnit() == eCSSUnit_Enumerated && !vertical ?
              nsCSSValue(eCSSUnit_Unset) : *height,
            pos->mHeight, parentPos->mHeight,
            SETCOORD_LPAEH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC |
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   const nsCSSValue* minHeight = aRuleData->ValueForMinHeight();
+  if (minHeight->GetUnit() == eCSSUnit_Enumerated) {
+    conditions.SetWritingModeDependency(writingMode);
+  }
   SetCoord(minHeight->GetUnit() == eCSSUnit_Enumerated && !vertical ?
              nsCSSValue(eCSSUnit_Unset) : *minHeight,
            pos->mMinHeight, parentPos->mMinHeight,
            SETCOORD_LPAEH | SETCOORD_INITIAL_AUTO | SETCOORD_STORE_CALC |
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   const nsCSSValue* maxHeight = aRuleData->ValueForMaxHeight();
+  if (maxHeight->GetUnit() == eCSSUnit_Enumerated) {
+    conditions.SetWritingModeDependency(writingMode);
+  }
   SetCoord(maxHeight->GetUnit() == eCSSUnit_Enumerated && !vertical ?
              nsCSSValue(eCSSUnit_Unset) : *maxHeight,
            pos->mMaxHeight, parentPos->mMaxHeight,
            SETCOORD_LPOEH | SETCOORD_INITIAL_NONE | SETCOORD_STORE_CALC |
              SETCOORD_UNSET_INITIAL,
            aContext, mPresContext, conditions);
 
   // box-sizing: enum, inherit, initial