Bug 1064843 part 1 - Make nsImageFrame inherit nsContainerFrame. r=dholbert
authorXidorn Quan <quanxunzhen@gmail.com>
Thu, 28 Jan 2016 10:11:00 +1100
changeset 282007 708022a7d463a876211e329507eb79795fe9a892
parent 282006 958a7057e1ac0379ee4908b644f4a6b00918ad69
child 282008 c18d1efe3b6336940b698373750a2d27aa77c00a
push id29950
push usercbook@mozilla.com
push dateThu, 28 Jan 2016 11:14:03 +0000
treeherdermozilla-central@2b73b0a4d52b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1064843
milestone47.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 1064843 part 1 - Make nsImageFrame inherit nsContainerFrame. r=dholbert
layout/generic/nsAtomicContainerFrame.h
layout/generic/nsImageFrame.cpp
layout/generic/nsImageFrame.h
new file mode 100644
--- /dev/null
+++ b/layout/generic/nsAtomicContainerFrame.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=8 sts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* base class for rendering objects that need child lists but behave like leaf */
+
+#ifndef nsAtomicContainerFrame_h___
+#define nsAtomicContainerFrame_h___
+
+#include "nsContainerFrame.h"
+
+/**
+ * This class is for frames which need child lists but act like a leaf
+ * frame. In general, all frames of elements laid out according to the
+ * CSS box model would need child list for ::backdrop in case they are
+ * in fullscreen, while some of them still want leaf frame behavior.
+ */
+class nsAtomicContainerFrame : public nsContainerFrame
+{
+public:
+  NS_DECL_ABSTRACT_FRAME(nsAtomicContainerFrame)
+
+  // Bypass the nsContainerFrame/nsSplittableFrame impl of the following
+  // methods so we behave like a leaf frame.
+  bool IsLeaf() const override { return true; }
+  FrameSearchResult PeekOffsetNoAmount(bool aForward, int32_t* aOffset) override
+  {
+    return nsFrame::PeekOffsetNoAmount(aForward, aOffset);
+  }
+  FrameSearchResult PeekOffsetCharacter(bool aForward, int32_t* aOffset,
+                                        bool aRespectClusters = true) override
+  {
+    return nsFrame::PeekOffsetCharacter(aForward, aOffset, aRespectClusters);
+  }
+  nsSplittableType GetSplittableType() const override
+  {
+    return nsFrame::GetSplittableType();
+  }
+
+protected:
+  explicit nsAtomicContainerFrame(nsStyleContext* aContext)
+    : nsContainerFrame(aContext) {}
+};
+
+#endif // nsAtomicContainerFrame_h___
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -214,17 +214,17 @@ nsImageFrame::DestroyFrom(nsIFrame* aDes
   }
   
   mListener = nullptr;
 
   // If we were displaying an icon, take ourselves off the list
   if (mDisplayingIcon)
     gIconLoad->RemoveIconObserver(this);
 
-  nsSplittableFrame::DestroyFrom(aDestructRoot);
+  ImageFrameSuper::DestroyFrom(aDestructRoot);
 }
 
 void
 nsImageFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext)
 {
   ImageFrameSuper::DidSetStyleContext(aOldStyleContext);
 
   if (!mImage) {
@@ -250,17 +250,17 @@ nsImageFrame::DidSetStyleContext(nsStyle
   }
 }
 
 void
 nsImageFrame::Init(nsIContent*       aContent,
                    nsContainerFrame* aParent,
                    nsIFrame*         aPrevInFlow)
 {
-  nsSplittableFrame::Init(aContent, aParent, aPrevInFlow);
+  ImageFrameSuper::Init(aContent, aParent, aPrevInFlow);
 
   mListener = new nsImageListener(this);
 
   nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(aContent);
   if (!imageLoader) {
     NS_RUNTIMEABORT("Why do we have an nsImageFrame here at all?");
   }
 
@@ -2064,17 +2064,17 @@ nsImageFrame::HandleEvent(nsPresContext*
           }
           nsContentUtils::TriggerLink(anchorNode, aPresContext, uri, target,
                                       clicked, true, true);
         }
       }
     }
   }
 
-  return nsSplittableFrame::HandleEvent(aPresContext, aEvent, aEventStatus);
+  return ImageFrameSuper::HandleEvent(aPresContext, aEvent, aEventStatus);
 }
 
 nsresult
 nsImageFrame::GetCursor(const nsPoint& aPoint,
                         nsIFrame::Cursor& aCursor)
 {
   nsImageMap* map = GetImageMap();
   if (nullptr != map) {
@@ -2101,18 +2101,18 @@ nsImageFrame::GetCursor(const nsPoint& a
   return nsFrame::GetCursor(aPoint, aCursor);
 }
 
 nsresult
 nsImageFrame::AttributeChanged(int32_t aNameSpaceID,
                                nsIAtom* aAttribute,
                                int32_t aModType)
 {
-  nsresult rv = nsSplittableFrame::AttributeChanged(aNameSpaceID,
-                                                    aAttribute, aModType);
+  nsresult rv = ImageFrameSuper::AttributeChanged(aNameSpaceID,
+                                                  aAttribute, aModType);
   if (NS_FAILED(rv)) {
     return rv;
   }
   if (nsGkAtoms::alt == aAttribute)
   {
     PresContext()->PresShell()->FrameNeedsReflow(this,
                                                  nsIPresShell::eStyleChange,
                                                  NS_FRAME_IS_DIRTY);
--- a/layout/generic/nsImageFrame.h
+++ b/layout/generic/nsImageFrame.h
@@ -3,17 +3,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* rendering object for replaced elements with image data */
 
 #ifndef nsImageFrame_h___
 #define nsImageFrame_h___
 
-#include "nsSplittableFrame.h"
+#include "nsAtomicContainerFrame.h"
 #include "nsIIOService.h"
 #include "nsIObserver.h"
 
 #include "imgINotificationObserver.h"
 
 #include "nsDisplayList.h"
 #include "imgIContainer.h"
 #include "mozilla/Attributes.h"
@@ -53,17 +53,17 @@ public:
   NS_DECL_IMGINOTIFICATIONOBSERVER
 
   void SetFrame(nsImageFrame *frame) { mFrame = frame; }
 
 private:
   nsImageFrame *mFrame;
 };
 
-typedef nsSplittableFrame ImageFrameSuper;
+typedef nsAtomicContainerFrame ImageFrameSuper;
 
 class nsImageFrame : public ImageFrameSuper,
                      public nsIReflowCallback {
 public:
   typedef mozilla::image::DrawResult DrawResult;
   typedef mozilla::layers::ImageContainer ImageContainer;
   typedef mozilla::layers::ImageLayer ImageLayer;
   typedef mozilla::layers::LayerManager LayerManager;
@@ -116,16 +116,21 @@ public:
   }
 
 #ifdef DEBUG_FRAME_DUMP
   virtual nsresult GetFrameName(nsAString& aResult) const override;
   void List(FILE* out = stderr, const char* aPrefix = "", 
             uint32_t aFlags = 0) const override;
 #endif
 
+  nsSplittableType GetSplittableType() const override
+  {
+    return NS_FRAME_SPLITTABLE;
+  }
+
   virtual LogicalSides GetLogicalSkipSides(const nsHTMLReflowState* aReflowState = nullptr) const override;
 
   nsresult GetIntrinsicImageSize(nsSize& aSize);
 
   static void ReleaseGlobals() {
     if (gIconLoad) {
       gIconLoad->Shutdown();
       NS_RELEASE(gIconLoad);