Bug 1502609 - Assert that we don't mess up pseudo-element / anon-box restyling. r=TYLin
authorEmilio Cobos Álvarez <emilio@crisal.io>
Tue, 30 Oct 2018 20:28:51 +0000
changeset 443629 58bc69aa6cac927014d679143922bbef647791db
parent 443628 432f44b8e53ec0785447b1f5fb091cf2ad08edfd
child 443630 3ae8da2e4b2bf8487ca5cf01c2236faebdb386ad
push id109420
push useraciure@mozilla.com
push dateWed, 31 Oct 2018 05:11:56 +0000
treeherdermozilla-inbound@b357da105c49 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersTYLin
bugs1502609
milestone65.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 1502609 - Assert that we don't mess up pseudo-element / anon-box restyling. r=TYLin Differential Revision: https://phabricator.services.mozilla.com/D9990
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -1188,16 +1188,35 @@ nsFrame::DidSetComputedStyle(ComputedSty
 
   RemoveStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS |
                   NS_FRAME_SIMPLE_DISPLAYLIST);
 
   mMayHaveRoundedCorners = true;
 }
 
 void
+nsIFrame::AssertNewStyleIsSane(ComputedStyle& aNewStyle)
+{
+  MOZ_DIAGNOSTIC_ASSERT(PresShell() == aNewStyle.PresContextForFrame()->PresShell());
+  MOZ_DIAGNOSTIC_ASSERT(
+    aNewStyle.GetPseudo() == mComputedStyle->GetPseudo() ||
+    // ::first-line continuations are weird, this should probably be fixed via
+    // bug 1465474.
+    (mComputedStyle->GetPseudo() == nsCSSPseudoElements::firstLine() &&
+     aNewStyle.GetPseudo() == nsCSSAnonBoxes::mozLineFrame()) ||
+    // ::first-letter continuations are broken, in particular floating ones, see
+    // bug 1490281. The construction code tries to fix this up after the fact,
+    // then restyling undoes it...
+    (mComputedStyle->GetPseudo() == nsCSSAnonBoxes::mozText() &&
+     aNewStyle.GetPseudo() == nsCSSAnonBoxes::firstLetterContinuation()) ||
+    (mComputedStyle->GetPseudo() == nsCSSAnonBoxes::firstLetterContinuation() &&
+     aNewStyle.GetPseudo() == nsCSSAnonBoxes::mozText()));
+}
+
+void
 nsIFrame::ReparentFrameViewTo(nsViewManager* aViewManager,
                               nsView*        aNewParentView,
                               nsView*        aOldParentView)
 {
   if (HasView()) {
 #ifdef MOZ_XUL
     if (IsMenuPopupFrame()) {
       // This view must be parented by the root view, don't reparent it.
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -767,20 +767,28 @@ public:
    *
    */
   virtual void AdjustOffsetsForBidi(int32_t aStart, int32_t aEnd) {}
 
   /**
    * Get the style associated with this frame.
    */
   ComputedStyle* Style() const { return mComputedStyle; }
+
+  void AssertNewStyleIsSane(ComputedStyle&)
+#ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
+    ;
+#else
+    { }
+#endif
+
   void SetComputedStyle(ComputedStyle* aStyle)
   {
     if (aStyle != mComputedStyle) {
-      MOZ_DIAGNOSTIC_ASSERT(PresShell() == aStyle->PresContextForFrame()->PresShell());
+      AssertNewStyleIsSane(*aStyle);
       RefPtr<ComputedStyle> oldComputedStyle = mComputedStyle.forget();
       mComputedStyle = aStyle;
       DidSetComputedStyle(oldComputedStyle);
     }
   }
 
   /**
    * SetComputedStyleWithoutNotification is for changes to the style