Bug 1392093: Remove dead code to get the old style context. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Sun, 20 Aug 2017 18:01:25 +0200
changeset 649593 2485454c9e347d657aa09375f267be1e849fa2eb
parent 649592 efd1cda49b8263d93e14ee96e87ce059c1bbc845
child 649738 ed8fa1ba93f8ad0d981635a5055d4885e3d0b1eb
push id75069
push userbmo:emilio+bugs@crisal.io
push dateSun, 20 Aug 2017 16:06:28 +0000
reviewersheycam
bugs1392093, 18153
milestone57.0a1
Bug 1392093: Remove dead code to get the old style context. r?heycam Unused since https://github.com/servo/servo/pull/18153. MozReview-Commit-ID: DtQdm3ONS5E
layout/base/ServoRestyleManager.cpp
layout/base/ServoRestyleManager.h
layout/style/ServoBindings.cpp
layout/style/ServoBindings.h
--- a/layout/base/ServoRestyleManager.cpp
+++ b/layout/base/ServoRestyleManager.cpp
@@ -502,58 +502,16 @@ private:
   ServoStyleContext& mParentContext;
   ServoRestyleState& mParentRestyleState;
   RefPtr<nsStyleContext> mStyle;
   bool mShouldPostHints;
   bool mShouldComputeHints;
   nsChangeHint mComputedHint;
 };
 
-// Get the nsBlockFrame which might contain ::first-letter/::first-line for the
-// given element.  Will return null if there is no such blockframe.
-static nsBlockFrame*
-GetBlockForElement(const Element* aElement)
-{
-  nsIFrame* frame = aElement->GetPrimaryFrame();
-  if (!frame) {
-    return nullptr;
-  }
-  // The first-letter frame will always be inside the content insertion frame,
-  // which will always be a block if we have a first-letter frame at all.
-  frame = frame->GetContentInsertionFrame();
-  if (!frame) {
-    // We're a leaf; certainly no first-letter frame.
-    return nullptr;
-  }
-
-  if (!frame->IsFrameOfType(nsIFrame::eBlockFrame)) {
-    return nullptr;
-  }
-
-  return static_cast<nsBlockFrame*>(frame);
-}
-
-// Find the first-letter frame for the given element, if any.  Returns null to
-// indicate there isn't one.
-static nsIFrame*
-FindFirstLetterFrameForElement(const Element* aElement)
-{
-  nsBlockFrame* f = GetBlockForElement(aElement);
-  return f ? f->GetFirstLetter() : nullptr;
-}
-
-// Find the first-line frame for the given element, if any.  Returns null to
-// indicate there isn't one.
-static nsIFrame*
-FindFirstLineFrameForElement(const Element* aElement)
-{
-  nsBlockFrame* f = GetBlockForElement(aElement);
-  return f ? f->GetFirstLineFrame() : nullptr;
-}
-
 static void
 UpdateBackdropIfNeeded(nsIFrame* aFrame,
                        ServoStyleSet& aStyleSet,
                        nsStyleChangeList& aChangeList)
 {
   const nsStyleDisplay* display = aFrame->StyleContext()->StyleDisplay();
   if (display->mTopLayer != NS_STYLE_TOP_LAYER_TOP) {
     return;
@@ -999,47 +957,16 @@ ServoRestyleManager::SnapshotFor(Element
   aElement->SetFlags(ELEMENT_HAS_SNAPSHOT);
 
   nsIPresShell* presShell = mPresContext->PresShell();
   presShell->EnsureStyleFlush();
 
   return *snapshot;
 }
 
-/* static */ nsIFrame*
-ServoRestyleManager::FrameForPseudoElement(const Element* aElement,
-                                           nsIAtom* aPseudoTagOrNull)
-{
-  if (!aPseudoTagOrNull) {
-    return nsLayoutUtils::GetStyleFrame(aElement);
-  }
-
-  if (aPseudoTagOrNull == nsCSSPseudoElements::before) {
-    Element* pseudoElement = nsLayoutUtils::GetBeforePseudo(aElement);
-    return pseudoElement ? nsLayoutUtils::GetStyleFrame(pseudoElement) : nullptr;
-  }
-
-  if (aPseudoTagOrNull == nsCSSPseudoElements::after) {
-    Element* pseudoElement = nsLayoutUtils::GetAfterPseudo(aElement);
-    return pseudoElement ? nsLayoutUtils::GetStyleFrame(pseudoElement) : nullptr;
-  }
-
-  if (aPseudoTagOrNull == nsCSSPseudoElements::firstLetter) {
-    return FindFirstLetterFrameForElement(aElement);
-  }
-
-  if (aPseudoTagOrNull == nsCSSPseudoElements::firstLine) {
-    return FindFirstLineFrameForElement(aElement);
-  }
-
-  MOZ_CRASH("Unkown pseudo-element given to "
-            "ServoRestyleManager::FrameForPseudoElement");
-  return nullptr;
-}
-
 void
 ServoRestyleManager::DoProcessPendingRestyles(ServoTraversalFlags aFlags)
 {
   MOZ_ASSERT(PresContext()->Document(), "No document?  Pshaw!");
   MOZ_ASSERT(!nsContentUtils::IsSafeToRunScript(), "Missing a script blocker!");
   MOZ_ASSERT(!mInStyleRefresh, "Reentrant call?");
 
   if (MOZ_UNLIKELY(!PresContext()->PresShell()->DidInitialize())) {
--- a/layout/base/ServoRestyleManager.h
+++ b/layout/base/ServoRestyleManager.h
@@ -214,25 +214,16 @@ public:
                         const nsAttrValue* aOldValue);
 
   // This is only used to reparent things when moving them in/out of the
   // ::first-line.  Once we get rid of the Gecko style system, we should rename
   // this method accordingly (e.g. to ReparentStyleContextForFirstLine).
   nsresult ReparentStyleContext(nsIFrame* aFrame);
 
   /**
-   * Gets the appropriate frame given a content and a pseudo-element tag.
-   *
-   * Right now only supports a null tag, before or after. If the pseudo-element
-   * is not null, the content needs to be an element.
-   */
-  static nsIFrame* FrameForPseudoElement(const Element* aElement,
-                                         nsIAtom* aPseudoTagOrNull);
-
-  /**
    * Clears the ServoElementData and HasDirtyDescendants from all elements
    * in the subtree rooted at aElement.
    */
   static void ClearServoDataFromSubtree(Element* aElement);
 
   /**
    * Clears HasDirtyDescendants and RestyleData from all elements in the
    * subtree rooted at aElement.
--- a/layout/style/ServoBindings.cpp
+++ b/layout/style/ServoBindings.cpp
@@ -367,40 +367,16 @@ Gecko_NoteDirtyElement(RawGeckoElementBo
 
 void
 Gecko_NoteAnimationOnlyDirtyElement(RawGeckoElementBorrowed aElement)
 {
   MOZ_ASSERT(NS_IsMainThread());
   const_cast<Element*>(aElement)->NoteAnimationOnlyDirtyForServo();
 }
 
-nsStyleContext*
-Gecko_GetStyleContext(RawGeckoElementBorrowed aElement,
-                      nsIAtom* aPseudoTagOrNull)
-{
-  nsIFrame* relevantFrame =
-    ServoRestyleManager::FrameForPseudoElement(aElement, aPseudoTagOrNull);
-  if (relevantFrame) {
-    return relevantFrame->StyleContext();
-  }
-
-  if (aPseudoTagOrNull) {
-    return nullptr;
-  }
-
-  // FIXME(emilio): Is there a shorter path?
-  nsIPresShell* shell = aElement->OwnerDoc()->GetShell();
-  NS_ENSURE_TRUE(shell, nullptr);
-  nsCSSFrameConstructor* fc = shell->GetPresContext()->FrameConstructor();
-
-  // NB: This is only called for CalcStyleDifference, and we handle correctly
-  // the display: none case since Servo still has the older style.
-  return fc->GetDisplayContentsStyleFor(aElement);
-}
-
 CSSPseudoElementType
 Gecko_GetImplementedPseudo(RawGeckoElementBorrowed aElement)
 {
   return aElement->GetPseudoElementType();
 }
 
 uint32_t
 Gecko_CalcStyleDifference(ServoStyleContextBorrowed aOldStyle,
--- a/layout/style/ServoBindings.h
+++ b/layout/style/ServoBindings.h
@@ -379,20 +379,16 @@ nsStyleContentData::CounterFunction* Gec
 
 // Dirtiness tracking.
 void Gecko_SetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
 void Gecko_UnsetNodeFlags(RawGeckoNodeBorrowed node, uint32_t flags);
 void Gecko_NoteDirtyElement(RawGeckoElementBorrowed element);
 void Gecko_NoteAnimationOnlyDirtyElement(RawGeckoElementBorrowed element);
 
 // Incremental restyle.
-// Also, we might want a ComputedValues to ComputedValues API for animations?
-// Not if we do them in Gecko...
-nsStyleContext* Gecko_GetStyleContext(RawGeckoElementBorrowed element,
-                                      nsIAtom* aPseudoTagOrNull);
 mozilla::CSSPseudoElementType Gecko_GetImplementedPseudo(RawGeckoElementBorrowed element);
 // We'd like to return `nsChangeHint` here, but bindgen bitfield enums don't
 // work as return values with the Linux 32-bit ABI at the moment because
 // they wrap the value in a struct.
 uint32_t Gecko_CalcStyleDifference(ServoStyleContextBorrowed old_style,
                                    ServoStyleContextBorrowed new_style,
                                    uint64_t old_style_bits,
                                    bool* any_style_changed);