From f3f1e4c96465a911ce10c5fd67a19eaecf94f1a0 Mon Sep 17 00:00:00 2001 From: Simon Montagu Date: Wed, 16 Apr 2014 01:03:30 -0700 Subject: [PATCH] Add some more logical getters to nsIFrame.h. Bug 735577, r=jfkthame --- layout/generic/WritingModes.h | 18 ++++++++++++++++++ layout/generic/nsIFrame.h | 23 +++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/layout/generic/WritingModes.h b/layout/generic/WritingModes.h index 46bc4b83530c..3d574e58a23f 100644 --- a/layout/generic/WritingModes.h +++ b/layout/generic/WritingModes.h @@ -839,6 +839,24 @@ public: mMargin.right == 0 && mMargin.bottom == 0); } + LogicalMargin operator+(const LogicalMargin& aMargin) { + 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) { + CHECK_WRITING_MODE(aMargin.GetWritingMode()); + return LogicalMargin(GetWritingMode(), + BStart() - aMargin.BStart(), + IEnd() - aMargin.IEnd(), + BEnd() - aMargin.BEnd(), + IStart() - aMargin.IStart()); + } + private: friend class LogicalRect; diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index 9d9970e5e23a..9eedf76f1aab 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -811,6 +811,13 @@ public: * Return frame's position without relative positioning */ nsPoint GetNormalPosition() const; + mozilla::LogicalPoint + GetLogicalNormalPosition(mozilla::WritingMode aWritingMode, + nscoord aContainerWidth) const + { + return mozilla::LogicalPoint(aWritingMode, + GetNormalPosition(), aContainerWidth); + } virtual nsPoint GetPositionOfChildIgnoringScrolling(nsIFrame* aChild) { return aChild->GetPosition(); } @@ -908,6 +915,10 @@ public: * having their original values. */ virtual nsMargin GetUsedMargin() const; + virtual mozilla::LogicalMargin + GetLogicalUsedMargin(mozilla::WritingMode aWritingMode) const { + return mozilla::LogicalMargin(aWritingMode, GetUsedMargin()); + } /** * Return the distance between the border edge of the frame (which is @@ -920,6 +931,10 @@ public: * for tables, particularly border-collapse tables. */ virtual nsMargin GetUsedBorder() const; + virtual mozilla::LogicalMargin + GetLogicalUsedBorder(mozilla::WritingMode aWritingMode) const { + return mozilla::LogicalMargin(aWritingMode, GetUsedBorder()); + } /** * Return the distance between the padding edge of the frame and the @@ -927,10 +942,18 @@ public: * as of the most recent reflow. */ virtual nsMargin GetUsedPadding() const; + virtual mozilla::LogicalMargin + GetLogicalUsedPadding(mozilla::WritingMode aWritingMode) const { + return mozilla::LogicalMargin(aWritingMode, GetUsedPadding()); + } nsMargin GetUsedBorderAndPadding() const { return GetUsedBorder() + GetUsedPadding(); } + mozilla::LogicalMargin + GetLogicalUsedBorderAndPadding(mozilla::WritingMode aWritingMode) const { + return mozilla::LogicalMargin(aWritingMode, GetUsedBorderAndPadding()); + } /** * Apply the result of GetSkipSides() on this frame to an nsMargin by