Bug 1320815 - Make nsIFrame::IsSelectable non-virtual, and move implementation from nsFrame to nsIFrame. r?xidorn draft
authorL. David Baron <dbaron@dbaron.org>
Mon, 28 Nov 2016 15:31:29 -0800
changeset 444877 60d40894e16323b11a7ce3a3082aa485f005cc73
parent 444876 756713ac1804df262718024930db1fa761f8da23
child 444878 a69b688bffa48696fd65177d61146561d31db6bb
push id37385
push userdbaron@mozilla.com
push dateMon, 28 Nov 2016 23:37:47 +0000
reviewersxidorn
bugs1320815
milestone53.0a1
Bug 1320815 - Make nsIFrame::IsSelectable non-virtual, and move implementation from nsFrame to nsIFrame. r?xidorn MozReview-Commit-ID: HphEFug7EbQ
layout/generic/nsFrame.cpp
layout/generic/nsFrame.h
layout/generic/nsIFrame.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -3159,17 +3159,17 @@ nsFrame::GetDataForTableSelection(const 
     *aTarget = nsISelectionPrivate::TABLESELECTION_CELL;
   else if (foundTable)
     *aTarget = nsISelectionPrivate::TABLESELECTION_TABLE;
 
   return NS_OK;
 }
 
 nsresult
-nsFrame::IsSelectable(bool* aSelectable, StyleUserSelect* aSelectStyle) const
+nsIFrame::IsSelectable(bool* aSelectable, StyleUserSelect* aSelectStyle) const
 {
   if (!aSelectable) //it's ok if aSelectStyle is null
     return NS_ERROR_NULL_POINTER;
 
   // Like 'visibility', we must check all the parents: if a parent
   // is not selectable, none of its children is selectable.
   //
   // The -moz-all value acts similarly: if a frame has 'user-select:-moz-all',
@@ -3186,17 +3186,17 @@ nsFrame::IsSelectable(bool* aSelectable,
   //    AUTO     -> _MOZ_ALL  -> NONE -> TEXT,      the returned value is ALL
   //    AUTO     -> _MOZ_ALL  -> NONE -> _MOZ_TEXT, the returned value is TEXT.
   //    TEXT     -> NONE      -> AUTO -> _MOZ_ALL,  the returned value is TEXT
   //    _MOZ_ALL -> TEXT      -> AUTO -> AUTO,      the returned value is ALL
   //    _MOZ_ALL -> _MOZ_TEXT -> AUTO -> AUTO,      the returned value is TEXT.
   //    AUTO     -> CELL      -> TEXT -> AUTO,      the returned value is TEXT
   //
   StyleUserSelect selectStyle  = StyleUserSelect::Auto;
-  nsIFrame* frame              = const_cast<nsFrame*>(this);
+  nsIFrame* frame              = const_cast<nsIFrame*>(this);
   bool containsEditable        = false;
 
   while (frame) {
     const nsStyleUIReset* userinterface = frame->StyleUIReset();
     switch (userinterface->mUserSelect) {
       case StyleUserSelect::All:
       case StyleUserSelect::MozAll:
       {
--- a/layout/generic/nsFrame.h
+++ b/layout/generic/nsFrame.h
@@ -195,19 +195,16 @@ public:
   virtual nsIFrame* GetNextContinuation() const override;
   virtual void SetNextContinuation(nsIFrame*) override;
   virtual nsIFrame* GetPrevInFlowVirtual() const override;
   virtual void SetPrevInFlow(nsIFrame*) override;
   virtual nsIFrame* GetNextInFlowVirtual() const override;
   virtual void SetNextInFlow(nsIFrame*) override;
   virtual nsIAtom* GetType() const override;
 
-  virtual nsresult IsSelectable(bool* aIsSelectable,
-                      mozilla::StyleUserSelect* aSelectStyle) const override;
-
   virtual nsresult  GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon) override;
 
   virtual FrameSearchResult PeekOffsetNoAmount(bool aForward, int32_t* aOffset) override;
   virtual FrameSearchResult PeekOffsetCharacter(bool aForward, int32_t* aOffset,
                                      bool aRespectClusters = true) override;
   virtual FrameSearchResult PeekOffsetWord(bool aForward, bool aWordSelectEatSpace, bool aIsKeyboardSelect,
                                 int32_t* aOffset, PeekWordState *aState) override;
   /**
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2776,24 +2776,24 @@ public:
   /**
    * @returns true if this frame is selected.
    */
   bool IsSelected() const;
 
   /**
    *  called to discover where this frame, or a parent frame has user-select style
    *  applied, which affects that way that it is selected.
-   *    
+   *
    *  @param aIsSelectable out param. Set to true if the frame can be selected
    *                       (i.e. is not affected by user-select: none)
    *  @param aSelectStyle  out param. Returns the type of selection style found
    *                        (using values defined in nsStyleConsts.h).
    */
-  virtual nsresult IsSelectable(bool* aIsSelectable,
-                            mozilla::StyleUserSelect* aSelectStyle) const = 0;
+  nsresult IsSelectable(bool* aIsSelectable,
+                        mozilla::StyleUserSelect* aSelectStyle) const;
 
   /** 
    *  Called to retrieve the SelectionController associated with the frame.
    *  @param aSelCon will contain the selection controller associated with
    *  the frame.
    */
   virtual nsresult  GetSelectionController(nsPresContext *aPresContext, nsISelectionController **aSelCon) = 0;