Bug 1699327 - Add nsIFrame::GetMarginRect(), and comparison operators for LogicalMargin. r=dholbert
authorTing-Yu Lin <tlin@mozilla.com>
Thu, 18 Mar 2021 01:06:03 +0000
changeset 571732 973d2593ee6bac646928b3d33a82abc9672dfc5e
parent 571731 97fd6b8a9ac29cdfbb84ce14d3dcb76442e7afb8
child 571733 1e574d5e2fb241cb73fabd98b7018eeea509fb11
push id138860
push useraethanyc@gmail.com
push dateThu, 18 Mar 2021 01:08:28 +0000
treeherderautoland@973d2593ee6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1699327
milestone88.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 1699327 - Add nsIFrame::GetMarginRect(), and comparison operators for LogicalMargin. r=dholbert Differential Revision: https://phabricator.services.mozilla.com/D107935
layout/generic/WritingModes.h
layout/generic/nsIFrame.cpp
layout/generic/nsIFrame.h
--- a/layout/generic/WritingModes.h
+++ b/layout/generic/WritingModes.h
@@ -1424,16 +1424,26 @@ class LogicalMargin {
     return *this;
   }
 
   bool IsAllZero() const {
     return (mMargin.left == 0 && mMargin.top == 0 && mMargin.right == 0 &&
             mMargin.bottom == 0);
   }
 
+  bool operator==(const LogicalMargin& aMargin) const {
+    CHECK_WRITING_MODE(aMargin.GetWritingMode());
+    return mMargin == aMargin.mMargin;
+  }
+
+  bool operator!=(const LogicalMargin& aMargin) const {
+    CHECK_WRITING_MODE(aMargin.GetWritingMode());
+    return mMargin != aMargin.mMargin;
+  }
+
   LogicalMargin operator+(const LogicalMargin& aMargin) const {
     CHECK_WRITING_MODE(aMargin.GetWritingMode());
     return LogicalMargin(GetWritingMode(), BStart() + aMargin.BStart(),
                          IEnd() + aMargin.IEnd(), BEnd() + aMargin.BEnd(),
                          IStart() + aMargin.IStart());
   }
 
   LogicalMargin operator+=(const LogicalMargin& aMargin) {
--- a/layout/generic/nsIFrame.cpp
+++ b/layout/generic/nsIFrame.cpp
@@ -1687,16 +1687,20 @@ WritingMode nsIFrame::WritingModeForLine
   if (StyleTextReset()->mUnicodeBidi & NS_STYLE_UNICODE_BIDI_PLAINTEXT) {
     nsBidiLevel frameLevel = nsBidiPresUtils::GetFrameBaseLevel(aSubFrame);
     writingMode.SetDirectionFromBidiLevel(frameLevel);
   }
 
   return writingMode;
 }
 
+nsRect nsIFrame::GetMarginRect() const {
+  return GetMarginRectRelativeToSelf() + GetPosition();
+}
+
 nsRect nsIFrame::GetMarginRectRelativeToSelf() const {
   nsMargin m = GetUsedMargin().ApplySkipSides(GetSkipSides());
   nsRect r(0, 0, mRect.width, mRect.height);
   r.Inflate(m);
   return r;
 }
 
 bool nsIFrame::IsTransformed(const nsStyleDisplay* aStyleDisplay) const {
--- a/layout/generic/nsIFrame.h
+++ b/layout/generic/nsIFrame.h
@@ -1066,16 +1066,17 @@ class nsIFrame : public nsQueryFrame {
   /**
    * Like the frame's rect (see |GetRect|), which is the border rect,
    * other rectangles of the frame, in app units, relative to the parent.
    */
   nsRect GetPaddingRect() const;
   nsRect GetPaddingRectRelativeToSelf() const;
   nsRect GetContentRect() const;
   nsRect GetContentRectRelativeToSelf() const;
+  nsRect GetMarginRect() const;
   nsRect GetMarginRectRelativeToSelf() const;
 
   /**
    * Dimensions and position in logical coordinates in the frame's writing mode
    *  or another writing mode
    */
   mozilla::LogicalRect GetLogicalRect(const nsSize& aContainerSize) const {
     return GetLogicalRect(GetWritingMode(), aContainerSize);