Bug 1287492 - Part 1. Implement nsLayoutUtils::HasCSSBoxLayout.
There is no direct relation between this patch and the bug. Read through the code
and think we may reuse some logic.
MozReview-Commit-ID: HGEvDNGoIBS
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9343,15 +9343,22 @@ ComputeHTMLReferenceRect(nsIFrame* aFram
/* static */ nsRect
nsLayoutUtils::ComputeGeometryBox(nsIFrame* aFrame,
StyleGeometryBox aGeometryBox)
{
// We use ComputeSVGReferenceRect for all SVG elements, except <svg>
// element, which does have an associated CSS layout box. In this case we
// should still use ComputeHTMLReferenceRect for region computing.
- nsRect r = aFrame->IsFrameOfType(nsIFrame::eSVG) &&
- (aFrame->GetType() != nsGkAtoms::svgOuterSVGFrame)
- ? ComputeSVGReferenceRect(aFrame, aGeometryBox)
- : ComputeHTMLReferenceRect(aFrame, aGeometryBox);
+ nsRect r = HasCSSBoxLayout(aFrame)
+ ? ComputeHTMLReferenceRect(aFrame, aGeometryBox)
+ : ComputeSVGReferenceRect(aFrame, aGeometryBox);
return r;
}
+
+/* static */ bool
+nsLayoutUtils::HasCSSBoxLayout(nsIFrame* aFrame)
+{
+ // Except SVG outer element, all SVG element does not have CSS box layout.
+ return !aFrame->IsFrameOfType(nsIFrame::eSVG) ||
+ aFrame->GetType() == nsGkAtoms::svgOuterSVGFrame;
+}
\ No newline at end of file
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2893,16 +2893,21 @@ public:
* @param aNextLineFrame assigned to first frame on the next line if such a
* next line exists, null otherwise.
*/
static bool IsInvisibleBreak(nsINode* aNode, nsIFrame** aNextLineFrame = nullptr);
static nsRect ComputeGeometryBox(nsIFrame* aFrame,
StyleGeometryBox aGeometryBox);
+ /*
+ * Check whether aFrame is associated with CSS layout box.
+ */
+ static bool HasCSSBoxLayout(nsIFrame* aFrame);
+
private:
static uint32_t sFontSizeInflationEmPerLine;
static uint32_t sFontSizeInflationMinTwips;
static uint32_t sFontSizeInflationLineThreshold;
static int32_t sFontSizeInflationMappingIntercept;
static uint32_t sFontSizeInflationMaxRatio;
static bool sFontSizeInflationForceEnabled;
static bool sFontSizeInflationDisabledInMasterProcess;
--- a/layout/painting/nsCSSRendering.cpp
+++ b/layout/painting/nsCSSRendering.cpp
@@ -1920,30 +1920,28 @@ IsHTMLStyleGeometryBox(StyleGeometryBox
aBox == StyleGeometryBox::Padding ||
aBox == StyleGeometryBox::Border ||
aBox == StyleGeometryBox::Margin);
}
static StyleGeometryBox
ComputeBoxValue(nsIFrame* aForFrame, StyleGeometryBox aBox)
{
- // Except <svg>, all svg elements are not associate with CSS layout box.
- if (aForFrame->IsFrameOfType(nsIFrame::eSVG) &&
- (aForFrame->GetType() != nsGkAtoms::svgOuterSVGFrame)) {
+ if (nsLayoutUtils::HasCSSBoxLayout(aForFrame)) {
+ // For elements with associated CSS layout box, the values fill-box,
+ // stroke-box and view-box compute to the initial value of mask-clip.
+ if (IsSVGStyleGeometryBox(aBox)) {
+ return StyleGeometryBox::Border;
+ }
+ } else {
// For SVG elements without associated CSS layout box, the values
// content-box, padding-box, border-box and margin-box compute to fill-box.
if (IsHTMLStyleGeometryBox(aBox)) {
return StyleGeometryBox::Fill;
}
- } else {
- // For elements with associated CSS layout box, the values fill-box,
- // stroke-box and view-box compute to the initial value of mask-clip.
- if (IsSVGStyleGeometryBox(aBox)) {
- return StyleGeometryBox::Border;
- }
}
return aBox;
}
/* static */ void
nsCSSRendering::GetImageLayerClip(const nsStyleImageLayers::Layer& aLayer,
nsIFrame* aForFrame, const nsStyleBorder& aBorder,