author | Ting-Yu Lin <tlin@mozilla.com> |
Thu, 16 Feb 2017 10:51:48 +0800 | |
changeset 343237 | b0af1a8bdcaf6952ba6be848bf83248e6fb455c4 |
parent 343236 | 2b9a5fad30b78c77860a5418b8db96b56edab11b |
child 343238 | 366e6522665c6dfff386d76798d1ffbf232cc0c8 |
push id | 31372 |
push user | cbook@mozilla.com |
push date | Thu, 16 Feb 2017 12:16:10 +0000 |
treeherder | mozilla-central@2737f66ad6ac [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dbaron |
bugs | 1326407 |
milestone | 54.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
|
layout/generic/nsFloatManager.cpp | file | annotate | diff | comparison | revisions | |
layout/generic/nsFloatManager.h | file | annotate | diff | comparison | revisions |
--- a/layout/generic/nsFloatManager.cpp +++ b/layout/generic/nsFloatManager.cpp @@ -666,53 +666,38 @@ nsFloatManager::FloatInfo::FloatInfo(nsI if (shapeOutside.GetType() == StyleShapeSourceType::URL) { // Bug 1265343: Implement 'shape-image-threshold'. Early return // here because shape-outside with url() value doesn't have a // reference box, and GetReferenceBox() asserts that. return; } // Initialize <shape-box>'s reference rect. - LogicalRect rect = aMarginRect; - - switch (shapeOutside.GetReferenceBox()) { - case StyleShapeOutsideShapeBox::Content: - rect.Deflate(aWM, mFrame->GetLogicalUsedPadding(aWM)); - MOZ_FALLTHROUGH; - case StyleShapeOutsideShapeBox::Padding: - rect.Deflate(aWM, mFrame->GetLogicalUsedBorder(aWM)); - MOZ_FALLTHROUGH; - case StyleShapeOutsideShapeBox::Border: - rect.Deflate(aWM, mFrame->GetLogicalUsedMargin(aWM)); - break; - case StyleShapeOutsideShapeBox::Margin: - // Do nothing. rect is already a margin rect. - break; - case StyleShapeOutsideShapeBox::NoBox: - MOZ_ASSERT(shapeOutside.GetType() != StyleShapeSourceType::Box, - "Box source type must have <shape-box> specified!"); - break; - } + LogicalRect shapeBoxRect = + ShapeInfo::ComputeShapeBoxRect(shapeOutside, mFrame, aMarginRect, aWM); if (shapeOutside.GetType() == StyleShapeSourceType::Box) { - nsRect shapeBoxRect(rect.LineLeft(aWM, aContainerSize), rect.BStart(aWM), - rect.ISize(aWM), rect.BSize(aWM)); - mShapeInfo = MakeUnique<BoxShapeInfo>(shapeBoxRect, mFrame); + nsRect rect(shapeBoxRect.LineLeft(aWM, aContainerSize), + shapeBoxRect.BStart(aWM), + shapeBoxRect.ISize(aWM), + shapeBoxRect.BSize(aWM)); + mShapeInfo = MakeUnique<BoxShapeInfo>(rect, mFrame); } else if (shapeOutside.GetType() == StyleShapeSourceType::Shape) { StyleBasicShape* const basicShape = shapeOutside.GetBasicShape(); switch (basicShape->GetShapeType()) { case StyleBasicShapeType::Polygon: // Bug 1326409 - Implement the rendering of basic shape polygon() // for CSS shape-outside. return; case StyleBasicShapeType::Circle: case StyleBasicShapeType::Ellipse: mShapeInfo = - ShapeInfo::CreateCircleOrEllipse(basicShape, rect, aWM, aContainerSize); + ShapeInfo::CreateCircleOrEllipse(basicShape, shapeBoxRect, aWM, + aContainerSize); break; case StyleBasicShapeType::Inset: // Bug 1326407 - Implement the rendering of basic shape inset() for // CSS shape-outside. return; } } else { MOZ_ASSERT_UNREACHABLE("Unknown StyleShapeSourceType!"); @@ -823,16 +808,47 @@ nsFloatManager::FloatInfo::IsEmpty(Shape return IsEmpty(); } return mShapeInfo->IsEmpty(); } ///////////////////////////////////////////////////////////////////////////// // ShapeInfo +/* static */ LogicalRect +nsFloatManager::ShapeInfo::ComputeShapeBoxRect( + const StyleShapeOutside& aShapeOutside, + nsIFrame* const aFrame, + const mozilla::LogicalRect& aMarginRect, + mozilla::WritingMode aWM) +{ + LogicalRect rect = aMarginRect; + + switch (aShapeOutside.GetReferenceBox()) { + case StyleShapeOutsideShapeBox::Content: + rect.Deflate(aWM, aFrame->GetLogicalUsedPadding(aWM)); + MOZ_FALLTHROUGH; + case StyleShapeOutsideShapeBox::Padding: + rect.Deflate(aWM, aFrame->GetLogicalUsedBorder(aWM)); + MOZ_FALLTHROUGH; + case StyleShapeOutsideShapeBox::Border: + rect.Deflate(aWM, aFrame->GetLogicalUsedMargin(aWM)); + break; + case StyleShapeOutsideShapeBox::Margin: + // Do nothing. rect is already a margin rect. + break; + case StyleShapeOutsideShapeBox::NoBox: + MOZ_ASSERT(aShapeOutside.GetType() != StyleShapeSourceType::Box, + "Box source type must have <shape-box> specified!"); + break; + } + + return rect; +} + /* static */ UniquePtr<nsFloatManager::ShapeInfo> nsFloatManager::ShapeInfo::CreateCircleOrEllipse( StyleBasicShape* const aBasicShape, const LogicalRect& aShapeBoxRect, WritingMode aWM, const nsSize& aContainerSize) { // Use physical coordinates to compute the center of circle() or ellipse()
--- a/layout/generic/nsFloatManager.h +++ b/layout/generic/nsFloatManager.h @@ -356,16 +356,22 @@ private: const nscoord aBEnd) const = 0; virtual nscoord BStart() const = 0; virtual nscoord BEnd() const = 0; virtual bool IsEmpty() const = 0; // Translate the current origin by the specified offsets. virtual void Translate(nscoord aLineLeft, nscoord aBlockStart) = 0; + static mozilla::LogicalRect ComputeShapeBoxRect( + const mozilla::StyleShapeOutside& aShapeOutside, + nsIFrame* const aFrame, + const mozilla::LogicalRect& aMarginRect, + mozilla::WritingMode aWM); + static mozilla::UniquePtr<ShapeInfo> CreateCircleOrEllipse( mozilla::StyleBasicShape* const aBasicShape, const mozilla::LogicalRect& aShapeBoxRect, mozilla::WritingMode aWM, const nsSize& aContainerSize); protected: // Compute the minimum line-axis difference between the bounding shape