Bug 1525628 part 1: Add nsIFrame::IsBlockFrameOrSubclass() convenience accessor. r=mats
authorDaniel Holbert <dholbert@cs.stanford.edu>
Fri, 08 Feb 2019 00:38:12 +0000
changeset 458292 91eea845d54eb42a7a54327a652f79681c17a570
parent 458291 286129ec63de146b55a3ef0292c6a927a0f4f698
child 458293 ee8803de7f47e60ed4ab7896de5a332e086fef45
push id77781
push userdholbert@mozilla.com
push dateFri, 08 Feb 2019 18:58:43 +0000
treeherderautoland@ee8803de7f47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmats
bugs1525628
milestone67.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 1525628 part 1: Add nsIFrame::IsBlockFrameOrSubclass() convenience accessor. r=mats Differential Revision: https://phabricator.services.mozilla.com/D19083
layout/generic/nsFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/nsFrame.cpp
+++ b/layout/generic/nsFrame.cpp
@@ -7234,16 +7234,21 @@ bool nsFrame::IsFrameTreeTooDeep(const R
 
 bool nsIFrame::IsBlockWrapper() const {
   nsAtom* pseudoType = Style()->GetPseudo();
   return (pseudoType == nsCSSAnonBoxes::mozBlockInsideInlineWrapper() ||
           pseudoType == nsCSSAnonBoxes::buttonContent() ||
           pseudoType == nsCSSAnonBoxes::cellContent());
 }
 
+bool nsIFrame::IsBlockFrameOrSubclass() {
+  nsBlockFrame* thisAsBlock = do_QueryFrame(this);
+  return !!thisAsBlock;
+}
+
 static nsIFrame* GetNearestBlockContainer(nsIFrame* frame) {
   // The block wrappers we use to wrap blocks inside inlines aren't
   // described in the CSS spec.  We need to make them not be containing
   // blocks.
   // Since the parent of such a block is either a normal block or
   // another such pseudo, this shouldn't cause anything bad to happen.
   // Also the anonymous blocks inside table cells are not containing blocks.
   //
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -2876,16 +2876,28 @@ class nsIFrame : public nsQueryFrame {
   }
 
   /**
    * Returns true if the frame is a block wrapper.
    */
   bool IsBlockWrapper() const;
 
   /**
+   * Returns true if the frame is an instance of nsBlockFrame or one of its
+   * subclasses.
+   *
+   * XXXdholbert this is non-const because it uses nsIFrame::QueryFrame which
+   * is non-const.  If we need this accessor to be 'const' down the road, the
+   * right way to do it would be to make the QueryFrame machinery
+   * const-friendly. But it may not be worth the trouble, because we rarely
+   * handle const frame pointers anyway.
+   */
+  bool IsBlockFrameOrSubclass();
+
+  /**
    * Get this frame's CSS containing block.
    *
    * The algorithm is defined in
    * http://www.w3.org/TR/CSS2/visudet.html#containing-block-details.
    *
    * NOTE: This is guaranteed to return a non-null pointer when invoked on any
    * frame other than the root frame.
    *