Bug 1359603 - Set text combined bit on the context for Servo as well. r=heycam draft
authorJ. Ryan Stinnett <jryans@gmail.com>
Mon, 24 Apr 2017 16:13:36 -0500
changeset 568932 2553f996afefe4276aef86c61ec99e6b7fd62242
parent 568931 73fa2a10106b7cdfb8dc3d8072934f34abaef4e2
child 568933 78dfe1937ff587f1e398b963c22d40544e4d529e
push id56024
push userbmo:jryans@gmail.com
push dateWed, 26 Apr 2017 19:05:54 +0000
reviewersheycam
bugs1359603
milestone55.0a1
Bug 1359603 - Set text combined bit on the context for Servo as well. r=heycam We want to set style bits on `nsStyleContext` regardless of which engine is providing the style source. The moves the bit set up to `SetStyleBits` which runs for both sources. MozReview-Commit-ID: 8N6oUyxz1Xs
layout/style/nsStyleContext.cpp
--- a/layout/style/nsStyleContext.cpp
+++ b/layout/style/nsStyleContext.cpp
@@ -697,44 +697,50 @@ ShouldBlockifyChildren(const nsStyleDisp
     mozilla::StyleDisplay::InlineFlex == displayVal ||
     mozilla::StyleDisplay::Grid == displayVal ||
     mozilla::StyleDisplay::InlineGrid == displayVal;
 }
 
 void
 nsStyleContext::SetStyleBits()
 {
-  // XXXbholley: We should get this information directly from the
-  // ServoComputedValues rather than computing it here. This setup for
-  // ServoComputedValues-backed nsStyleContexts is probably not something
-  // we should ship.
-  //
-  // For example, NS_STYLE_IS_TEXT_COMBINED is still set in ApplyStyleFixups,
-  // which isn't called for ServoComputedValues.
+  // Here we set up various style bits for both the Gecko and Servo paths.
+  // _Only_ change the bits here.  For fixups of the computed values, you can
+  // add to ApplyStyleFixups in Gecko and StyleAdjuster as part of Servo's
+  // cascade.
 
   // See if we have any text decorations.
   // First see if our parent has text decorations.  If our parent does, then we inherit the bit.
   if (mParent && mParent->HasTextDecorationLines()) {
-    mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
+    AddStyleBit(NS_STYLE_HAS_TEXT_DECORATION_LINES);
   } else {
     // We might have defined a decoration.
     if (StyleTextReset()->HasTextDecorationLines()) {
-      mBits |= NS_STYLE_HAS_TEXT_DECORATION_LINES;
+      AddStyleBit(NS_STYLE_HAS_TEXT_DECORATION_LINES);
     }
   }
 
   if ((mParent && mParent->HasPseudoElementData()) || IsPseudoElement()) {
-    mBits |= NS_STYLE_HAS_PSEUDO_ELEMENT_DATA;
+    AddStyleBit(NS_STYLE_HAS_PSEUDO_ELEMENT_DATA);
   }
 
   // Set the NS_STYLE_IN_DISPLAY_NONE_SUBTREE bit
   const nsStyleDisplay* disp = StyleDisplay();
   if ((mParent && mParent->IsInDisplayNoneSubtree()) ||
       disp->mDisplay == mozilla::StyleDisplay::None) {
-    mBits |= NS_STYLE_IN_DISPLAY_NONE_SUBTREE;
+    AddStyleBit(NS_STYLE_IN_DISPLAY_NONE_SUBTREE);
+  }
+
+  // Mark text combined for text-combine-upright, as needed.
+  if (mPseudoTag == nsCSSAnonBoxes::mozText && mParent &&
+      mParent->StyleVisibility()->mWritingMode !=
+        NS_STYLE_WRITING_MODE_HORIZONTAL_TB &&
+      mParent->StyleText()->mTextCombineUpright ==
+        NS_STYLE_TEXT_COMBINE_UPRIGHT_ALL) {
+    AddStyleBit(NS_STYLE_IS_TEXT_COMBINED);
   }
 }
 
 void
 nsStyleContext::ApplyStyleFixups(bool aSkipParentDisplayBasedStyleFixup)
 {
   MOZ_ASSERT(!mSource.IsServoComputedValues(),
              "Can't do Gecko style fixups on Servo values");
@@ -788,17 +794,16 @@ nsStyleContext::ApplyStyleFixups(bool aS
         NS_STYLE_WRITING_MODE_HORIZONTAL_TB &&
       mParent->StyleText()->mTextCombineUpright ==
         NS_STYLE_TEXT_COMBINE_UPRIGHT_ALL) {
     MOZ_ASSERT(!PeekStyleVisibility(), "If StyleVisibility was already "
                "computed, some properties may have been computed "
                "incorrectly based on the old writing mode value");
     nsStyleVisibility* mutableVis = GET_UNIQUE_STYLE_DATA(Visibility);
     mutableVis->mWritingMode = NS_STYLE_WRITING_MODE_HORIZONTAL_TB;
-    AddStyleBit(NS_STYLE_IS_TEXT_COMBINED);
   }
 
   // CSS 2.1 10.1: Propagate the root element's 'direction' to the ICB.
   // (PageContentFrame/CanvasFrame etc will inherit 'direction')
   if (mPseudoTag == nsCSSAnonBoxes::viewport) {
     nsPresContext* presContext = PresContext();
     mozilla::dom::Element* docElement = presContext->Document()->GetRootElement();
     if (docElement) {