Bug 1230508 - Always compute position to fixed for top layer elements for now. r=dbaron a=ritu
authorXidorn Quan <quanxunzhen@gmail.com>
Mon, 14 Dec 2015 12:31:23 +1100
changeset 305838 e71e41130c71d4b5a4011850073f5aacd9bf99a4
parent 305837 f606e47c712a4ed86f476f2f6eee064cb1d4ceb0
child 305839 87ca4a7f2c2aaaea6e25953be697af9f53661de4
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron, ritu
Bug 1230508 - Always compute position to fixed for top layer elements for now. r=dbaron a=ritu Although the spec says absolute is allowed for top layer elements, and actually other values should be computed to absolute, but this is mostly fine because the only way we currently support for web content to use the top layer is via the Fullscreen API, however, fullscreen elements are forced to be fixed by the UA sheet. Given only fixed is safe for top layer element currently, rather than doing what the spec says, we should prefer always force it, until we really add support for the other value.
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -5547,18 +5547,24 @@ nsRuleNode::ComputeDisplayData(void* aSt
   SetDiscrete(*aRuleData->ValueForPosition(), display->mPosition, conditions,
               NS_STYLE_POSITION_STATIC, 0, 0, 0, 0);
   // If an element is put in the top layer, while it is not absolutely
   // positioned, the position value should be computed to 'absolute' per
   // the Fullscreen API spec.
   if (display->mTopLayer != NS_STYLE_TOP_LAYER_NONE &&
-      !display->IsAbsolutelyPositionedStyle()) {
-    display->mPosition = NS_STYLE_POSITION_ABSOLUTE;
+      // XXX We currently only support fixed top layer element. But per
+      // spec it should check IsAbsolutelyPositionedStyle() instead.
+      // This should be fixed as soon as we support <dialog> element
+      // in bug 840640. We have to restrict it now because addons may
+      // mess with UA-only styles and cause crashes. See bug 1230508.
+      display->mPosition != NS_STYLE_POSITION_FIXED) {
+    // XXX And we should set other values to absolute instead of fixed.
+    display->mPosition = NS_STYLE_POSITION_FIXED;
     // We cannot cache this struct because otherwise it may be used as
     // an aStartStruct for some other elements.
   // clear: enum, inherit, initial
   SetDiscrete(*aRuleData->ValueForClear(), display->mBreakType, conditions,