Bug 1055667 part 4 - Compute border/padding to zero for rbc & rtc. r=dbaron
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 15 Jan 2015 20:02:11 +1100
changeset 223922 f6f6cfd31f00
parent 223921 d220304dc8dd
child 223923 1e83e832b46b
push id54078
push userxquan@mozilla.com
push date2015-01-15 09:03 +0000
treeherdermozilla-inbound@297f99f0ed18 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs1055667
milestone38.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 1055667 part 4 - Compute border/padding to zero for rbc & rtc. r=dbaron
layout/style/nsStyleContext.cpp
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -394,16 +394,18 @@ nsStyleContext::GetUniqueStyleData(const
 #define UNIQUE_CASE(c_)                                                       \
   case eStyleStruct_##c_:                                                     \
     result = new (presContext) nsStyle##c_(                                   \
       * static_cast<const nsStyle##c_ *>(current));                           \
     break;
 
   UNIQUE_CASE(Display)
   UNIQUE_CASE(Background)
+  UNIQUE_CASE(Border)
+  UNIQUE_CASE(Padding)
   UNIQUE_CASE(Text)
   UNIQUE_CASE(TextReset)
 
 #undef UNIQUE_CASE
 
   default:
     NS_ERROR("Struct type not supported.  Please find another way to do this if you can!");
     return nullptr;
@@ -571,16 +573,40 @@ nsStyleContext::ApplyStyleFixups(bool aS
       if (displayVal != disp->mDisplay) {
         nsStyleDisplay *mutable_display =
           static_cast<nsStyleDisplay*>(GetUniqueStyleData(eStyleStruct_Display));
         mutable_display->mDisplay = displayVal;
       }
     }
   }
 
+  // Suppress border/padding of ruby level containers
+  if (disp->mDisplay == NS_STYLE_DISPLAY_RUBY_BASE_CONTAINER ||
+      disp->mDisplay == NS_STYLE_DISPLAY_RUBY_TEXT_CONTAINER) {
+    if (StyleBorder()->GetComputedBorder() != nsMargin(0, 0, 0, 0)) {
+      nsStyleBorder* border =
+        static_cast<nsStyleBorder*>(GetUniqueStyleData(eStyleStruct_Border));
+      NS_FOR_CSS_SIDES(side) {
+        border->SetBorderWidth(side, 0);
+      }
+    }
+
+    nsMargin computedPadding;
+    if (!StylePadding()->GetPadding(computedPadding) ||
+        computedPadding != nsMargin(0, 0, 0, 0)) {
+      const nsStyleCoord zero(0, nsStyleCoord::CoordConstructor);
+      nsStylePadding* padding =
+        static_cast<nsStylePadding*>(GetUniqueStyleData(eStyleStruct_Padding));
+      NS_FOR_CSS_SIDES(side) {
+        padding->mPadding.Set(side, zero);
+      }
+      padding->RecalcData();
+    }
+  }
+
   // Compute User Interface style, to trigger loads of cursors
   StyleUserInterface();
 }
 
 nsChangeHint
 nsStyleContext::CalcStyleDifference(nsStyleContext* aOther,
                                     nsChangeHint aParentHintsNotHandledForDescendants,
                                     uint32_t* aEqualStructs)