Bug 811301. Part 2: Remove saved state IDs now that the root scroll frame state is captured normally. r=mats
authorRobert O'Callahan <robert@ocallahan.org>
Wed, 14 Nov 2012 22:40:17 -0800
changeset 121286 3493741d8e8df82bc46a6b074ff277003cf40d61
parent 121285 58a64dbc9e83fdd33119784a617dfe7f8ffce4d8
child 121287 34a4de5feafe590343d1346e51f969909fbf51d4
push id1997
push userakeybl@mozilla.com
push dateMon, 07 Jan 2013 21:25:26 +0000
treeherdermozilla-beta@4baf45cdcf21 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs811301
milestone19.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 811301. Part 2: Remove saved state IDs now that the root scroll frame state is captured normally. r=mats
content/base/public/nsContentUtils.h
content/base/src/nsContentUtils.cpp
content/html/content/src/nsGenericHTMLElement.cpp
docshell/base/nsDocShell.cpp
layout/base/nsFrameManager.cpp
layout/base/nsFrameManager.h
layout/forms/nsComboboxControlFrame.cpp
layout/forms/nsComboboxControlFrame.h
layout/forms/nsTextControlFrame.cpp
layout/forms/nsTextControlFrame.h
layout/generic/nsGfxScrollFrame.cpp
layout/generic/nsGfxScrollFrame.h
layout/generic/nsIStatefulFrame.h
--- a/content/base/public/nsContentUtils.h
+++ b/content/base/public/nsContentUtils.h
@@ -14,17 +14,16 @@
 #include <float.h>
 #endif
 
 #if defined(SOLARIS)
 #include <ieeefp.h>
 #endif
 
 #include "nsAString.h"
-#include "nsIStatefulFrame.h"
 #include "nsNodeInfoManager.h"
 #include "nsIXPCScriptable.h"
 #include "nsDataHashtable.h"
 #include "nsIDOMEvent.h"
 #include "nsTArray.h"
 #include "nsReadableUtils.h"
 #include "nsINode.h"
 #include "nsIDOMNode.h"
@@ -477,17 +476,16 @@ public:
   }
 
   // Returns the subject principal. Guaranteed to return non-null. May only
   // be called when nsContentUtils is initialized.
   static nsIPrincipal* GetSubjectPrincipal();
 
   static nsresult GenerateStateKey(nsIContent* aContent,
                                    const nsIDocument* aDocument,
-                                   nsIStatefulFrame::SpecialStateID aID,
                                    nsACString& aKey);
 
   /**
    * Create a new nsIURI from aSpec, using aBaseURI as the base.  The
    * origin charset of the new nsIURI will be the document charset of
    * aDocument.
    */
   static nsresult NewURIWithDocumentCharset(nsIURI** aResult,
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -2167,49 +2167,37 @@ static inline bool IsAutocompleteOff(con
 {
   return aElement->AttrValueIs(kNameSpaceID_None, nsGkAtoms::autocomplete,
                                NS_LITERAL_STRING("off"), eIgnoreCase);
 }
 
 /*static*/ nsresult
 nsContentUtils::GenerateStateKey(nsIContent* aContent,
                                  const nsIDocument* aDocument,
-                                 nsIStatefulFrame::SpecialStateID aID,
                                  nsACString& aKey)
 {
   aKey.Truncate();
 
   uint32_t partID = aDocument ? aDocument->GetPartID() : 0;
 
-  // SpecialStateID case - e.g. scrollbars around the content window
-  // The key in this case is a special state id
-  if (nsIStatefulFrame::eNoID != aID) {
-    KeyAppendInt(partID, aKey);  // first append a partID
-    KeyAppendInt(aID, aKey);
-    return NS_OK;
-  }
-
   // We must have content if we're not using a special state id
   NS_ENSURE_TRUE(aContent, NS_ERROR_FAILURE);
 
   // Don't capture state for anonymous content
   if (aContent->IsInAnonymousSubtree()) {
     return NS_OK;
   }
 
   if (IsAutocompleteOff(aContent)) {
     return NS_OK;
   }
 
   nsCOMPtr<nsIHTMLDocument> htmlDocument(do_QueryInterface(aContent->GetCurrentDoc()));
 
   KeyAppendInt(partID, aKey);  // first append a partID
-  // Make sure we can't possibly collide with an nsIStatefulFrame
-  // special id of some sort
-  KeyAppendInt(nsIStatefulFrame::eNoID, aKey);
   bool generatedUniqueKey = false;
 
   if (htmlDocument) {
     // Flush our content model so it'll be up to date
     // If this becomes unnecessary and the following line is removed,
     // please also remove the corresponding flush operation from
     // nsHtml5TreeBuilderCppSupplement.h. (Look for "See bug 497861." there.)
     aContent->GetCurrentDoc()->FlushPendingNotifications(Flush_Content);
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -2064,19 +2064,17 @@ nsGenericHTMLElement::GetLayoutHistoryAn
 
   if (aRead && !history->HasStates()) {
     return nullptr;
   }
 
   //
   // Get the state key
   //
-  nsresult rv = nsContentUtils::GenerateStateKey(aContent, doc,
-                                                 nsIStatefulFrame::eNoID,
-                                                 aKey);
+  nsresult rv = nsContentUtils::GenerateStateKey(aContent, doc, aKey);
   if (NS_FAILED(rv)) {
     return nullptr;
   }
 
   // If the state key is blank, this is anonymous content or for
   // whatever reason we are not supposed to save/restore state.
   if (aKey.IsEmpty()) {
     return nullptr;
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10610,18 +10610,17 @@ NS_IMETHODIMP nsDocShell::PersistLayoutH
 {
     nsresult  rv = NS_OK;
     
     if (mOSHE) {
         nsCOMPtr<nsIPresShell> shell;
         rv = GetPresShell(getter_AddRefs(shell));
         if (NS_SUCCEEDED(rv) && shell) {
             nsCOMPtr<nsILayoutHistoryState> layoutState;
-            rv = shell->CaptureHistoryState(getter_AddRefs(layoutState),
-                                            true);
+            rv = shell->CaptureHistoryState(getter_AddRefs(layoutState));
         }
     }
 
     return rv;
 }
 
 /* static */ nsresult
 nsDocShell::WalkHistoryEntries(nsISHEntry *aRootEntry,
--- a/layout/base/nsFrameManager.cpp
+++ b/layout/base/nsFrameManager.cpp
@@ -1718,43 +1718,42 @@ nsFrameManager::ComputeStyleChangeFor(ns
     frame = frame2;
   } while (frame2);
 }
 
 // Capture state for a given frame.
 // Accept a content id here, in some cases we may not have content (scroll position)
 void
 nsFrameManager::CaptureFrameStateFor(nsIFrame* aFrame,
-                                     nsILayoutHistoryState* aState,
-                                     nsIStatefulFrame::SpecialStateID aID)
+                                     nsILayoutHistoryState* aState)
 {
   if (!aFrame || !aState) {
     NS_WARNING("null frame, or state");
     return;
   }
 
   // Only capture state for stateful frames
   nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame);
   if (!statefulFrame) {
     return;
   }
 
   // Capture the state, exit early if we get null (nothing to save)
   nsAutoPtr<nsPresState> frameState;
-  nsresult rv = statefulFrame->SaveState(aID, getter_Transfers(frameState));
+  nsresult rv = statefulFrame->SaveState(getter_Transfers(frameState));
   if (!frameState) {
     return;
   }
 
   // Generate the hash key to store the state under
   // Exit early if we get empty key
   nsAutoCString stateKey;
   nsIContent* content = aFrame->GetContent();
   nsIDocument* doc = content ? content->GetCurrentDoc() : nullptr;
-  rv = nsContentUtils::GenerateStateKey(content, doc, aID, stateKey);
+  rv = nsContentUtils::GenerateStateKey(content, doc, stateKey);
   if(NS_FAILED(rv) || stateKey.IsEmpty()) {
     return;
   }
 
   // Store the state
   rv = aState->AddState(stateKey, frameState);
   if (NS_SUCCEEDED(rv)) {
     // aState owns frameState now.
@@ -1787,18 +1786,17 @@ nsFrameManager::CaptureFrameState(nsIFra
     }
   }
 }
 
 // Restore state for a given frame.
 // Accept a content id here, in some cases we may not have content (scroll position)
 void
 nsFrameManager::RestoreFrameStateFor(nsIFrame* aFrame,
-                                     nsILayoutHistoryState* aState,
-                                     nsIStatefulFrame::SpecialStateID aID)
+                                     nsILayoutHistoryState* aState)
 {
   if (!aFrame || !aState) {
     NS_WARNING("null frame or state");
     return;
   }
 
   // Only restore state for stateful frames
   nsIStatefulFrame* statefulFrame = do_QueryFrame(aFrame);
@@ -1812,17 +1810,17 @@ nsFrameManager::RestoreFrameStateFor(nsI
   // If we don't have content, we can't generate a hash
   // key and there's probably no state information for us.
   if (!content) {
     return;
   }
 
   nsAutoCString stateKey;
   nsIDocument* doc = content->GetCurrentDoc();
-  nsresult rv = nsContentUtils::GenerateStateKey(content, doc, aID, stateKey);
+  nsresult rv = nsContentUtils::GenerateStateKey(content, doc, stateKey);
   if (NS_FAILED(rv) || stateKey.IsEmpty()) {
     return;
   }
 
   // Get the state from the hash
   nsPresState *frameState;
   rv = aState->GetState(stateKey, &frameState);
   if (!frameState) {
--- a/layout/base/nsFrameManager.h
+++ b/layout/base/nsFrameManager.h
@@ -137,27 +137,22 @@ public:
   NS_HIDDEN_(void) CaptureFrameState(nsIFrame*              aFrame,
                                      nsILayoutHistoryState* aState);
 
   NS_HIDDEN_(void) RestoreFrameState(nsIFrame*              aFrame,
                                      nsILayoutHistoryState* aState);
 
   /*
    * Add/restore state for one frame
-   * (special, global type, like scroll position)
    */
   NS_HIDDEN_(void) CaptureFrameStateFor(nsIFrame*              aFrame,
-                                        nsILayoutHistoryState* aState,
-                                        nsIStatefulFrame::SpecialStateID aID =
-                                                      nsIStatefulFrame::eNoID);
+                                        nsILayoutHistoryState* aState);
 
   NS_HIDDEN_(void) RestoreFrameStateFor(nsIFrame*              aFrame,
-                                        nsILayoutHistoryState* aState,
-                                        nsIStatefulFrame::SpecialStateID aID =
-                                                      nsIStatefulFrame::eNoID);
+                                        nsILayoutHistoryState* aState);
 
 #ifdef DEBUG
   /**
    * DEBUG ONLY method to verify integrity of style tree versus frame tree
    */
   NS_HIDDEN_(void) DebugVerifyStyleTree(nsIFrame* aFrame);
 #endif
 
--- a/layout/forms/nsComboboxControlFrame.cpp
+++ b/layout/forms/nsComboboxControlFrame.cpp
@@ -1707,24 +1707,23 @@ nsComboboxControlFrame::OnContentReset()
   }
 }
 
 
 //--------------------------------------------------------
 // nsIStatefulFrame
 //--------------------------------------------------------
 NS_IMETHODIMP
-nsComboboxControlFrame::SaveState(SpecialStateID aStateID,
-                                  nsPresState** aState)
+nsComboboxControlFrame::SaveState(nsPresState** aState)
 {
   if (!mListControlFrame)
     return NS_ERROR_FAILURE;
 
   nsIStatefulFrame* stateful = do_QueryFrame(mListControlFrame);
-  return stateful->SaveState(aStateID, aState);
+  return stateful->SaveState(aState);
 }
 
 NS_IMETHODIMP
 nsComboboxControlFrame::RestoreState(nsPresState* aState)
 {
   if (!mListControlFrame)
     return NS_ERROR_FAILURE;
 
--- a/layout/forms/nsComboboxControlFrame.h
+++ b/layout/forms/nsComboboxControlFrame.h
@@ -186,17 +186,17 @@ public:
     { return false; }
 
   virtual uint32_t GetSubmenuWidgetChain(nsTArray<nsIWidget*> *aWidgetChain)
     { return 0; }
 
   virtual nsIWidget* GetRollupWidget();
 
   //nsIStatefulFrame
-  NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) MOZ_OVERRIDE;
+  NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE;
   NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE;
 
   static bool ToolkitHasNativePopup();
 
 protected:
   friend class RedisplayTextEvent;
   friend class nsAsyncResize;
   friend class nsResizeDropdownAtFinalPosition;
--- a/layout/forms/nsTextControlFrame.cpp
+++ b/layout/forms/nsTextControlFrame.cpp
@@ -1400,31 +1400,31 @@ nsTextControlFrame::GetOwnedFrameSelecti
 {
   nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
   NS_ASSERTION(txtCtrl, "Content not a text control element");
 
   return txtCtrl->GetConstFrameSelection();
 }
 
 NS_IMETHODIMP
-nsTextControlFrame::SaveState(nsIStatefulFrame::SpecialStateID aStateID, nsPresState** aState)
+nsTextControlFrame::SaveState(nsPresState** aState)
 {
   NS_ENSURE_ARG_POINTER(aState);
 
   *aState = nullptr;
 
   nsCOMPtr<nsITextControlElement> txtCtrl = do_QueryInterface(GetContent());
   NS_ASSERTION(txtCtrl, "Content not a text control element");
 
   nsIContent* rootNode = txtCtrl->GetRootEditorNode();
   if (rootNode) {
     // Query the nsIStatefulFrame from the HTMLScrollFrame
     nsIStatefulFrame* scrollStateFrame = do_QueryFrame(rootNode->GetPrimaryFrame());
     if (scrollStateFrame) {
-      return scrollStateFrame->SaveState(aStateID, aState);
+      return scrollStateFrame->SaveState(aState);
     }
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsTextControlFrame::RestoreState(nsPresState* aState)
--- a/layout/forms/nsTextControlFrame.h
+++ b/layout/forms/nsTextControlFrame.h
@@ -133,17 +133,17 @@ public:
    * @throws various and sundry other things
    */
   virtual nsresult EnsureEditorInitialized() MOZ_OVERRIDE;
 
 //==== END NSITEXTCONTROLFRAME
 
 //==== NSISTATEFULFRAME
 
-  NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) MOZ_OVERRIDE;
+  NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE;
   NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE;
 
 //=== END NSISTATEFULFRAME
 
 //==== OVERLOAD of nsIFrame
   virtual nsIAtom* GetType() const;
 
   /** handler for attribute changes to mContent */
--- a/layout/generic/nsGfxScrollFrame.cpp
+++ b/layout/generic/nsGfxScrollFrame.cpp
@@ -3857,17 +3857,17 @@ nsGfxScrollFrameInner::GetCoordAttribute
 
   // Only this exact default value is allowed.
   *aRangeStart = aDefaultValue;
   *aRangeLength = 0;
   return aDefaultValue;
 }
 
 nsPresState*
-nsGfxScrollFrameInner::SaveState(nsIStatefulFrame::SpecialStateID aStateID)
+nsGfxScrollFrameInner::SaveState()
 {
   nsIScrollbarMediator* mediator = do_QueryFrame(GetScrolledFrame());
   if (mediator) {
     // child handles its own scroll state, so don't bother saving state here
     return nullptr;
   }
 
   nsPoint scrollPos = GetLogicalScrollPosition();
--- a/layout/generic/nsGfxScrollFrame.h
+++ b/layout/generic/nsGfxScrollFrame.h
@@ -171,17 +171,17 @@ public:
   void ScrollToImpl(nsPoint aScrollPosition, const nsRect& aRange);
   void ScrollVisual(nsPoint aOldScrolledFramePosition);
   void ScrollBy(nsIntPoint aDelta, nsIScrollableFrame::ScrollUnit aUnit,
                 nsIScrollableFrame::ScrollMode aMode, nsIntPoint* aOverflow, nsIAtom *aOrigin = nullptr);
   void ScrollToRestoredPosition();
   nsSize GetLineScrollAmount() const;
   nsSize GetPageScrollAmount() const;
 
-  nsPresState* SaveState(nsIStatefulFrame::SpecialStateID aStateID);
+  nsPresState* SaveState();
   void RestoreState(nsPresState* aState);
 
   nsIFrame* GetScrolledFrame() const { return mScrolledFrame; }
   nsIFrame* GetScrollbarBox(bool aVertical) const {
     return aVertical ? mVScrollbarBox : mHScrollbarBox;
   }
 
   void AddScrollPositionListener(nsIScrollPositionListener* aListener) {
@@ -518,19 +518,19 @@ public:
   virtual void ResetScrollPositionForLayerPixelAlignment() {
     mInner.ResetScrollPositionForLayerPixelAlignment();
   }
   virtual bool UpdateOverflow() {
     return mInner.UpdateOverflow();
   }
 
   // nsIStatefulFrame
-  NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) MOZ_OVERRIDE {
+  NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE {
     NS_ENSURE_ARG_POINTER(aState);
-    *aState = mInner.SaveState(aStateID);
+    *aState = mInner.SaveState();
     return NS_OK;
   }
   NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE {
     NS_ENSURE_ARG_POINTER(aState);
     mInner.RestoreState(aState);
     return NS_OK;
   }
 
@@ -765,19 +765,19 @@ public:
   virtual void ResetScrollPositionForLayerPixelAlignment() {
     mInner.ResetScrollPositionForLayerPixelAlignment();
   }
   virtual bool UpdateOverflow() {
     return mInner.UpdateOverflow();
   }
 
   // nsIStatefulFrame
-  NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) MOZ_OVERRIDE {
+  NS_IMETHOD SaveState(nsPresState** aState) MOZ_OVERRIDE {
     NS_ENSURE_ARG_POINTER(aState);
-    *aState = mInner.SaveState(aStateID);
+    *aState = mInner.SaveState();
     return NS_OK;
   }
   NS_IMETHOD RestoreState(nsPresState* aState) MOZ_OVERRIDE {
     NS_ENSURE_ARG_POINTER(aState);
     mInner.RestoreState(aState);
     return NS_OK;
   }
 
--- a/layout/generic/nsIStatefulFrame.h
+++ b/layout/generic/nsIStatefulFrame.h
@@ -14,24 +14,17 @@
 
 class nsPresState;
 
 class nsIStatefulFrame
 {
  public: 
   NS_DECL_QUERYFRAME_TARGET(nsIStatefulFrame)
 
-  // If you create a special type stateful frame (e.g. scroll) that needs
-  // to be captured outside of the standard pass through the frames, you'll need
-  // a special ID by which to refer to that type.
-  enum SpecialStateID {eNoID=0, eDocumentScrollState};
-
-  // Save the state for this frame.  Some implementations may choose to return
-  // different states depending on the value of aStateID.  If this method
-  // succeeds, the caller is responsible for deleting the resulting state when
-  // done with it.
-  NS_IMETHOD SaveState(SpecialStateID aStateID, nsPresState** aState) = 0;
+  // Save the state for this frame.  If this method succeeds, the caller is
+  // responsible for deleting the resulting state when done with it.
+  NS_IMETHOD SaveState(nsPresState** aState) = 0;
 
   // Restore the state for this frame from aState
   NS_IMETHOD RestoreState(nsPresState* aState) = 0;
 };
 
 #endif /* _nsIStatefulFrame_h */