From f22175b1974de9e8c0d1e6470e6dd6692a1690e2 Mon Sep 17 00:00:00 2001 From: Kristen Wright Date: Wed, 7 Nov 2018 11:56:17 -0800 Subject: [PATCH 01/13] Bug 1460439 - Conversion from NS_STYLE_BORDER_STYLE_* macro to StyleBorderStyle::* enum class r=emilio Converted NS_STYLE_BORDER_STYLE_* consts to enum class. Updated corresponding values to enum class. reduced BCCornerInfo struct values to fit StyleBorderStyle values inside struct. Added defaults to switches that do not fully cover all instances of StyleBorderStyle. --- dom/html/HTMLHRElement.cpp | 8 +- dom/html/nsGenericHTMLElement.cpp | 8 +- gfx/layers/LayersTypes.h | 3 +- gfx/webrender_bindings/WebRenderTypes.h | 24 +- layout/base/nsLayoutUtils.h | 6 +- layout/forms/nsComboboxControlFrame.cpp | 2 +- layout/generic/nsColumnSetFrame.cpp | 10 +- layout/generic/nsFrame.cpp | 2 +- layout/generic/nsImageFrame.cpp | 4 +- layout/mathml/nsMathMLmtableFrame.cpp | 22 +- layout/painting/nsCSSRendering.cpp | 98 ++++----- layout/painting/nsCSSRendering.h | 4 +- layout/painting/nsCSSRenderingBorders.cpp | 208 +++++++++--------- layout/painting/nsCSSRenderingBorders.h | 8 +- layout/painting/nsDisplayList.cpp | 4 +- layout/style/ServoBindings.toml | 1 + layout/style/nsCSSProps.cpp | 40 ++-- layout/style/nsComputedDOMStyle.cpp | 2 +- layout/style/nsStyleConsts.h | 25 ++- layout/style/nsStyleStruct.cpp | 8 +- layout/style/nsStyleStruct.h | 20 +- layout/tables/nsTableFrame.cpp | 122 +++++----- layout/xul/tree/nsTreeBodyFrame.cpp | 2 +- .../components/style/properties/gecko.mako.rs | 4 +- .../style/properties/longhands/border.mako.rs | 4 +- .../style/properties/longhands/column.mako.rs | 3 +- widget/cocoa/nsNativeThemeCocoa.mm | 16 +- 27 files changed, 335 insertions(+), 323 deletions(-) diff --git a/dom/html/HTMLHRElement.cpp b/dom/html/HTMLHRElement.cpp index 56a52ad78730..9191c9bc4012 100644 --- a/dom/html/HTMLHRElement.cpp +++ b/dom/html/HTMLHRElement.cpp @@ -139,14 +139,14 @@ HTMLHRElement::MapAttributesIntoRule(const nsMappedAttributes* aAttributes, if (!aDecls.PropertyIsSet(eCSSProperty_border_top_style)) aDecls.SetKeywordValue(eCSSProperty_border_top_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); if (allSides) { aDecls.SetKeywordValueIfUnset(eCSSProperty_border_right_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); aDecls.SetKeywordValueIfUnset(eCSSProperty_border_bottom_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); aDecls.SetKeywordValueIfUnset(eCSSProperty_border_left_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); // If it would be noticeable, set the border radius to // 10000px on all corners; this triggers the clamping to make diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index ec023505dac2..b5161af18fb7 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -1442,13 +1442,13 @@ nsGenericHTMLElement::MapImageBorderAttributeInto(const nsMappedAttributes* aAtt aDecls.SetPixelValueIfUnset(eCSSProperty_border_left_width, (float)val); aDecls.SetKeywordValueIfUnset(eCSSProperty_border_top_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); aDecls.SetKeywordValueIfUnset(eCSSProperty_border_right_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); aDecls.SetKeywordValueIfUnset(eCSSProperty_border_bottom_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); aDecls.SetKeywordValueIfUnset(eCSSProperty_border_left_style, - NS_STYLE_BORDER_STYLE_SOLID); + StyleBorderStyle::Solid); aDecls.SetCurrentColorIfUnset(eCSSProperty_border_top_color); aDecls.SetCurrentColorIfUnset(eCSSProperty_border_right_color); diff --git a/gfx/layers/LayersTypes.h b/gfx/layers/LayersTypes.h index a44603833899..1138c220c17f 100644 --- a/gfx/layers/LayersTypes.h +++ b/gfx/layers/LayersTypes.h @@ -15,6 +15,7 @@ #include "mozilla/Maybe.h" #include "mozilla/TypedEnumBits.h" #include "nsRegion.h" +#include "nsStyleConsts.h" #include // FILE #include "mozilla/Logging.h" // for PR_LOG @@ -392,7 +393,7 @@ typedef gfx::Matrix4x4Typed AsyncTra typedef Array BorderColors; typedef Array BorderCorners; typedef Array BorderWidths; -typedef Array BorderStyles; +typedef Array BorderStyles; typedef Maybe MaybeLayerRect; diff --git a/gfx/webrender_bindings/WebRenderTypes.h b/gfx/webrender_bindings/WebRenderTypes.h index 6da2d041b6de..44494113b54d 100644 --- a/gfx/webrender_bindings/WebRenderTypes.h +++ b/gfx/webrender_bindings/WebRenderTypes.h @@ -452,28 +452,28 @@ static inline wr::LayoutTransform ToLayoutTransform(const gfx::Matrix4x4TypedmColor)); nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1); clipRect.width -= onePixel; diff --git a/layout/generic/nsColumnSetFrame.cpp b/layout/generic/nsColumnSetFrame.cpp index fcd71bc8a376..6e22e3cd1db4 100644 --- a/layout/generic/nsColumnSetFrame.cpp +++ b/layout/generic/nsColumnSetFrame.cpp @@ -195,13 +195,13 @@ nsColumnSetFrame::CreateBorderRenderers(nsTArray& aBorderRe WritingMode wm = GetWritingMode(); bool isVertical = wm.IsVertical(); const nsStyleColumn* colStyle = StyleColumn(); - uint8_t ruleStyle; + StyleBorderStyle ruleStyle; // Per spec, inset => ridge and outset => groove - if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_INSET) - ruleStyle = NS_STYLE_BORDER_STYLE_RIDGE; - else if (colStyle->mColumnRuleStyle == NS_STYLE_BORDER_STYLE_OUTSET) - ruleStyle = NS_STYLE_BORDER_STYLE_GROOVE; + if (colStyle->mColumnRuleStyle == StyleBorderStyle::Inset) + ruleStyle = StyleBorderStyle::Ridge; + else if (colStyle->mColumnRuleStyle == StyleBorderStyle::Outset) + ruleStyle = StyleBorderStyle::Groove; else ruleStyle = colStyle->mColumnRuleStyle; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 5222bab2060c..1f9983aad20d 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -9480,7 +9480,7 @@ ComputeAndIncludeOutlineArea(nsIFrame* aFrame, nsOverflowAreas& aOverflowAreas, nsRect outerRect(innerRect); bool useOutlineAuto = false; if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) { - useOutlineAuto = outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO; + useOutlineAuto = outline->mOutlineStyle == StyleBorderStyle::Auto; if (MOZ_UNLIKELY(useOutlineAuto)) { nsPresContext* presContext = aFrame->PresContext(); nsITheme* theme = presContext->GetTheme(); diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index db3b8edef982..b0703ea64c0c 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -1365,7 +1365,7 @@ struct nsRecessedBorder : public nsStyleBorder { mBorder.Side(side) = aBorderWidth; // Note: use SetBorderStyle here because we want to affect // mComputedBorder - SetBorderStyle(side, NS_STYLE_BORDER_STYLE_INSET); + SetBorderStyle(side, StyleBorderStyle::Inset); } } }; @@ -1912,7 +1912,7 @@ nsImageFrame::PaintImage(gfxContext& aRenderingContext, nsPoint aPt, // then dashed black stroke over the top: ColorPattern black(ToDeviceColor(Color(0.f, 0.f, 0.f, 1.f))); StrokeOptions strokeOptions; - nsLayoutUtils::InitDashPattern(strokeOptions, NS_STYLE_BORDER_STYLE_DOTTED); + nsLayoutUtils::InitDashPattern(strokeOptions, StyleBorderStyle::Dotted); map->Draw(this, *drawTarget, black, strokeOptions); } diff --git a/layout/mathml/nsMathMLmtableFrame.cpp b/layout/mathml/nsMathMLmtableFrame.cpp index b6f61c403b12..baf647c6d291 100644 --- a/layout/mathml/nsMathMLmtableFrame.cpp +++ b/layout/mathml/nsMathMLmtableFrame.cpp @@ -51,11 +51,11 @@ ParseStyleValue(nsAtom* aAttribute, const nsAString& aAttributeValue) } else if (aAttribute == nsGkAtoms::rowlines_ || aAttribute == nsGkAtoms::columnlines_) { if (aAttributeValue.EqualsLiteral("solid")) - return NS_STYLE_BORDER_STYLE_SOLID; + return static_cast(StyleBorderStyle::Solid); else if (aAttributeValue.EqualsLiteral("dashed")) - return NS_STYLE_BORDER_STYLE_DASHED; + return static_cast(StyleBorderStyle::Dashed); else - return NS_STYLE_BORDER_STYLE_NONE; + return static_cast(StyleBorderStyle::None); } else { MOZ_CRASH("Unrecognized attribute."); } @@ -200,11 +200,11 @@ ApplyBorderToStyle(const nsMathMLmtdFrame* aFrame, // values, we simply repeat the last value. uint32_t listLength = rowLinesList->Length(); if (rowIndex < listLength) { - aStyleBorder.SetBorderStyle(eSideTop, - rowLinesList->ElementAt(rowIndex - 1)); + aStyleBorder.SetBorderStyle(eSideTop, static_cast( + rowLinesList->ElementAt(rowIndex - 1))); } else { - aStyleBorder.SetBorderStyle(eSideTop, - rowLinesList->ElementAt(listLength - 1)); + aStyleBorder.SetBorderStyle(eSideTop, static_cast( + rowLinesList->ElementAt(listLength - 1))); } aStyleBorder.SetBorderWidth(eSideTop, borderWidth); } @@ -215,11 +215,11 @@ ApplyBorderToStyle(const nsMathMLmtdFrame* aFrame, // values, we simply repeat the last value. uint32_t listLength = columnLinesList->Length(); if (columnIndex < listLength) { - aStyleBorder.SetBorderStyle(eSideLeft, - columnLinesList->ElementAt(columnIndex - 1)); + aStyleBorder.SetBorderStyle(eSideLeft, static_cast( + columnLinesList->ElementAt(columnIndex - 1))); } else { - aStyleBorder.SetBorderStyle(eSideLeft, - columnLinesList->ElementAt(listLength - 1)); + aStyleBorder.SetBorderStyle(eSideLeft, static_cast( + columnLinesList->ElementAt(listLength - 1))); } aStyleBorder.SetBorderWidth(eSideLeft, borderWidth); } diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index e10bea08de9b..32290e6e41c5 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -456,7 +456,7 @@ nsCSSRendering::Shutdown() */ static nscolor MakeBevelColor(mozilla::Side whichSide, - uint8_t style, + StyleBorderStyle style, nscolor aBorderColor) { @@ -467,8 +467,8 @@ MakeBevelColor(mozilla::Side whichSide, // calculate the color used for the shading NS_GetSpecial3DColors(colors, aBorderColor); - if ((style == NS_STYLE_BORDER_STYLE_OUTSET) || - (style == NS_STYLE_BORDER_STYLE_RIDGE)) { + if ((style == StyleBorderStyle::Outset) || + (style == StyleBorderStyle::Ridge)) { // Flip colors for these two border styles switch (whichSide) { case eSideBottom: @@ -894,7 +894,7 @@ ConstructBorderRenderer(nsPresContext* aPresContext, Float(border.left) / oneDevPixel }; Rect dirtyRect = NSRectToRect(aDirtyRect, oneDevPixel); - uint8_t borderStyles[4]; + StyleBorderStyle borderStyles[4]; nscolor borderColors[4]; // pull out styles, colors @@ -905,10 +905,10 @@ ConstructBorderRenderer(nsPresContext* aPresContext, } PrintAsFormatString(" borderStyles: %d %d %d %d\n", - borderStyles[0], - borderStyles[1], - borderStyles[2], - borderStyles[3]); + static_cast(borderStyles[0]), + static_cast(borderStyles[1]), + static_cast(borderStyles[2]), + static_cast(borderStyles[3])); nsIDocument* document = nullptr; nsIContent* content = aForFrame->GetContent(); @@ -1153,8 +1153,8 @@ nsCSSRendering::CreateBorderRendererForOutline(nsPresContext* aPresContext, RectCornerRadii outlineRadii; ComputePixelRadii(twipsRadii, oneDevPixel, &outlineRadii); - uint8_t outlineStyle = ourOutline->mOutlineStyle; - if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO) { + StyleBorderStyle outlineStyle = ourOutline->mOutlineStyle; + if (outlineStyle == StyleBorderStyle::Auto) { if (nsLayoutUtils::IsOutlineStyleAutoEnabled()) { nsITheme* theme = aPresContext->GetTheme(); if (theme && theme->ThemeSupportsWidget( @@ -1172,10 +1172,10 @@ nsCSSRendering::CreateBorderRendererForOutline(nsPresContext* aPresContext, } // http://dev.w3.org/csswg/css-ui/#outline // "User agents may treat 'auto' as 'solid'." - outlineStyle = NS_STYLE_BORDER_STYLE_SOLID; + outlineStyle = StyleBorderStyle::Solid; } - uint8_t outlineStyles[4] = { + StyleBorderStyle outlineStyles[4] = { outlineStyle, outlineStyle, outlineStyle, outlineStyle }; @@ -1263,10 +1263,10 @@ nsCSSRendering::PaintFocus(nsPresContext* aPresContext, Float(oneCSSPixel) / oneDevPixel, Float(oneCSSPixel) / oneDevPixel }; - uint8_t focusStyles[4] = { NS_STYLE_BORDER_STYLE_DOTTED, - NS_STYLE_BORDER_STYLE_DOTTED, - NS_STYLE_BORDER_STYLE_DOTTED, - NS_STYLE_BORDER_STYLE_DOTTED }; + StyleBorderStyle focusStyles[4] = { StyleBorderStyle::Dotted, + StyleBorderStyle::Dotted, + StyleBorderStyle::Dotted, + StyleBorderStyle::Dotted }; nscolor focusColors[4] = { aColor, aColor, aColor, aColor }; // Because this renders a dotted border, the background color @@ -2230,11 +2230,11 @@ IsOpaqueBorderEdge(const nsStyleBorder& aBorder, mozilla::Side aSide) if (aBorder.GetComputedBorder().Side(aSide) == 0) return true; switch (aBorder.GetBorderStyle(aSide)) { - case NS_STYLE_BORDER_STYLE_SOLID: - case NS_STYLE_BORDER_STYLE_GROOVE: - case NS_STYLE_BORDER_STYLE_RIDGE: - case NS_STYLE_BORDER_STYLE_INSET: - case NS_STYLE_BORDER_STYLE_OUTSET: + case StyleBorderStyle::Solid: + case StyleBorderStyle::Groove: + case StyleBorderStyle::Ridge: + case StyleBorderStyle::Inset: + case StyleBorderStyle::Outset: break; default: return false; @@ -3751,7 +3751,7 @@ GetDashInfo(nscoord aBorderLength, void nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget, - uint8_t aBorderStyle, + StyleBorderStyle aBorderStyle, nscolor aBorderColor, const nsRect& aBorder, int32_t aAppUnitsPerDevPixel, @@ -3765,28 +3765,28 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget, nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel); if ((oneDevPixel >= aBorder.width) || (oneDevPixel >= aBorder.height) || - (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) || - (NS_STYLE_BORDER_STYLE_DOTTED == aBorderStyle)) { + (StyleBorderStyle::Dashed == aBorderStyle) || + (StyleBorderStyle::Dotted == aBorderStyle)) { // no beveling for 1 pixel border, dash or dot aStartBevelOffset = 0; aEndBevelOffset = 0; } switch (aBorderStyle) { - case NS_STYLE_BORDER_STYLE_NONE: - case NS_STYLE_BORDER_STYLE_HIDDEN: + case StyleBorderStyle::None: + case StyleBorderStyle::Hidden: // NS_ASSERTION(false, "style of none or hidden"); break; - case NS_STYLE_BORDER_STYLE_DOTTED: - case NS_STYLE_BORDER_STYLE_DASHED: { - nscoord dashLength = (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) + case StyleBorderStyle::Dotted: + case StyleBorderStyle::Dashed: { + nscoord dashLength = (StyleBorderStyle::Dashed == aBorderStyle) ? DASH_LENGTH : DOT_LENGTH; // make the dash length proportional to the border thickness dashLength *= (horizontal) ? aBorder.height : aBorder.width; // make the min dash length for the ends 1/2 the dash length nscoord minDashLength = - (NS_STYLE_BORDER_STYLE_DASHED == aBorderStyle) + (StyleBorderStyle::Dashed == aBorderStyle) ? RoundFloatToPixel(((float)dashLength) / 2.0f, aAppUnitsPerDevPixel) : dashLength; minDashLength = std::max(minDashLength, oneDevPixel); @@ -3874,28 +3874,28 @@ nsCSSRendering::DrawTableBorderSegment(DrawTarget& aDrawTarget, void nsCSSRendering::GetTableBorderSolidSegments( nsTArray& aSegments, - uint8_t aBorderStyle, - nscolor aBorderColor, - const nsRect& aBorder, - int32_t aAppUnitsPerDevPixel, - mozilla::Side aStartBevelSide, - nscoord aStartBevelOffset, - mozilla::Side aEndBevelSide, - nscoord aEndBevelOffset) + StyleBorderStyle aBorderStyle, + nscolor aBorderColor, + const nsRect& aBorder, + int32_t aAppUnitsPerDevPixel, + mozilla::Side aStartBevelSide, + nscoord aStartBevelOffset, + mozilla::Side aEndBevelSide, + nscoord aEndBevelOffset) { const bool horizontal = eSideTop == aStartBevelSide || eSideBottom == aStartBevelSide; const nscoord oneDevPixel = NSIntPixelsToAppUnits(1, aAppUnitsPerDevPixel); switch (aBorderStyle) { - case NS_STYLE_BORDER_STYLE_NONE: - case NS_STYLE_BORDER_STYLE_HIDDEN: + case StyleBorderStyle::None: + case StyleBorderStyle::Hidden: return; - case NS_STYLE_BORDER_STYLE_DOTTED: - case NS_STYLE_BORDER_STYLE_DASHED: + case StyleBorderStyle::Dotted: + case StyleBorderStyle::Dashed: MOZ_ASSERT_UNREACHABLE("Caller should have checked"); return; - case NS_STYLE_BORDER_STYLE_GROOVE: - case NS_STYLE_BORDER_STYLE_RIDGE: + case StyleBorderStyle::Groove: + case StyleBorderStyle::Ridge: if ((horizontal && (oneDevPixel >= aBorder.height)) || (!horizontal && (oneDevPixel >= aBorder.width))) { aSegments.AppendElement(SolidBeveledBorderSegment { @@ -3995,7 +3995,7 @@ nsCSSRendering::GetTableBorderSolidSegments( } } break; - case NS_STYLE_BORDER_STYLE_DOUBLE: + case StyleBorderStyle::Double: // We can only do "double" borders if the thickness of the border // is more than 2px. Otherwise, we fall through to painting a // solid border. @@ -4086,7 +4086,7 @@ nsCSSRendering::GetTableBorderSolidSegments( } // else fall through to solid MOZ_FALLTHROUGH; - case NS_STYLE_BORDER_STYLE_SOLID: + case StyleBorderStyle::Solid: aSegments.AppendElement(SolidBeveledBorderSegment { aBorder, aBorderColor, @@ -4094,11 +4094,11 @@ nsCSSRendering::GetTableBorderSolidSegments( { aEndBevelSide, aEndBevelOffset } }); break; - case NS_STYLE_BORDER_STYLE_OUTSET: - case NS_STYLE_BORDER_STYLE_INSET: + case StyleBorderStyle::Outset: + case StyleBorderStyle::Inset: MOZ_ASSERT_UNREACHABLE("inset, outset should have been converted to groove, ridge"); break; - case NS_STYLE_BORDER_STYLE_AUTO: + case StyleBorderStyle::Auto: MOZ_ASSERT_UNREACHABLE("Unexpected 'auto' table border"); break; } diff --git a/layout/painting/nsCSSRendering.h b/layout/painting/nsCSSRendering.h index 9c7e8b9e43f9..32ccd482045a 100644 --- a/layout/painting/nsCSSRendering.h +++ b/layout/painting/nsCSSRendering.h @@ -595,7 +595,7 @@ struct nsCSSRendering // corners. static void DrawTableBorderSegment( DrawTarget& aDrawTarget, - uint8_t aBorderStyle, + mozilla::StyleBorderStyle aBorderStyle, nscolor aBorderColor, const nsRect& aBorderRect, int32_t aAppUnitsPerDevPixel, @@ -624,7 +624,7 @@ struct nsCSSRendering // dashed / dotted borders, since we don't support beveling those. static void GetTableBorderSolidSegments( nsTArray& aSegments, - uint8_t aBorderStyle, + mozilla::StyleBorderStyle aBorderStyle, nscolor aBorderColor, const nsRect& aBorderRect, int32_t aAppUnitsPerDevPixel, diff --git a/layout/painting/nsCSSRenderingBorders.cpp b/layout/painting/nsCSSRenderingBorders.cpp index 504153e62715..2facb3fff5af 100644 --- a/layout/painting/nsCSSRenderingBorders.cpp +++ b/layout/painting/nsCSSRenderingBorders.cpp @@ -174,7 +174,7 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext* aPresContext, DrawTarget* aDrawTarget, const Rect& aDirtyRect, Rect& aOuterRect, - const uint8_t* aBorderStyles, + const StyleBorderStyle* aBorderStyles, const Float* aBorderWidths, RectCornerRadii& aBorderRadii, const nscolor* aBorderColors, @@ -194,10 +194,10 @@ nsCSSBorderRenderer::nsCSSBorderRenderer(nsPresContext* aPresContext, PodCopy(mBorderColors, aBorderColors, 4); mInnerRect = mOuterRect; mInnerRect.Deflate(Margin( - mBorderStyles[0] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[0] : 0, - mBorderStyles[1] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[1] : 0, - mBorderStyles[2] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[2] : 0, - mBorderStyles[3] != NS_STYLE_BORDER_STYLE_NONE ? mBorderWidths[3] : 0)); + mBorderStyles[0] != StyleBorderStyle::None ? mBorderWidths[0] : 0, + mBorderStyles[1] != StyleBorderStyle::None ? mBorderWidths[1] : 0, + mBorderStyles[2] != StyleBorderStyle::None ? mBorderWidths[2] : 0, + mBorderStyles[3] != StyleBorderStyle::None ? mBorderWidths[3] : 0)); ComputeBorderCornerDimensions( mBorderWidths, mBorderRadii, &mBorderCornerDimensions); @@ -338,34 +338,34 @@ nsCSSBorderRenderer::AreBorderSideFinalStylesSame(uint8_t aSides) /* Then if it's one of the two-tone styles and we're not * just comparing the TL or BR sides */ switch (mBorderStyles[firstStyle]) { - case NS_STYLE_BORDER_STYLE_GROOVE: - case NS_STYLE_BORDER_STYLE_RIDGE: - case NS_STYLE_BORDER_STYLE_INSET: - case NS_STYLE_BORDER_STYLE_OUTSET: + case StyleBorderStyle::Groove: + case StyleBorderStyle::Ridge: + case StyleBorderStyle::Inset: + case StyleBorderStyle::Outset: return ((aSides & ~(eSideBitsTop | eSideBitsLeft)) == 0 || (aSides & ~(eSideBitsBottom | eSideBitsRight)) == 0); + default: + return true; } - - return true; } bool -nsCSSBorderRenderer::IsSolidCornerStyle(uint8_t aStyle, Corner aCorner) +nsCSSBorderRenderer::IsSolidCornerStyle(StyleBorderStyle aStyle, Corner aCorner) { switch (aStyle) { - case NS_STYLE_BORDER_STYLE_SOLID: + case StyleBorderStyle::Solid: return true; - case NS_STYLE_BORDER_STYLE_INSET: - case NS_STYLE_BORDER_STYLE_OUTSET: + case StyleBorderStyle::Inset: + case StyleBorderStyle::Outset: return (aCorner == eCornerTopLeft || aCorner == eCornerBottomRight); - case NS_STYLE_BORDER_STYLE_GROOVE: - case NS_STYLE_BORDER_STYLE_RIDGE: + case StyleBorderStyle::Groove: + case StyleBorderStyle::Ridge: return mOneUnitBorder && (aCorner == eCornerTopLeft || aCorner == eCornerBottomRight); - case NS_STYLE_BORDER_STYLE_DOUBLE: + case StyleBorderStyle::Double: return mOneUnitBorder; default: @@ -406,9 +406,9 @@ nsCSSBorderRenderer::IsCornerMergeable(Corner aCorner) // | | mozilla::Side sideH(GetHorizontalSide(aCorner)); mozilla::Side sideV(GetVerticalSide(aCorner)); - uint8_t styleH = mBorderStyles[sideH]; - uint8_t styleV = mBorderStyles[sideV]; - if (styleH != styleV || styleH != NS_STYLE_BORDER_STYLE_DOTTED) { + StyleBorderStyle styleH = mBorderStyles[sideH]; + StyleBorderStyle styleV = mBorderStyles[sideV]; + if (styleH != styleV || styleH != StyleBorderStyle::Dotted) { return false; } @@ -424,31 +424,33 @@ nsCSSBorderRenderer::IsCornerMergeable(Corner aCorner) } BorderColorStyle -nsCSSBorderRenderer::BorderColorStyleForSolidCorner(uint8_t aStyle, +nsCSSBorderRenderer::BorderColorStyleForSolidCorner(StyleBorderStyle aStyle, Corner aCorner) { // note that this function assumes that the corner is already solid, // as per the earlier function switch (aStyle) { - case NS_STYLE_BORDER_STYLE_SOLID: - case NS_STYLE_BORDER_STYLE_DOUBLE: + case StyleBorderStyle::Solid: + case StyleBorderStyle::Double: return BorderColorStyleSolid; - case NS_STYLE_BORDER_STYLE_INSET: - case NS_STYLE_BORDER_STYLE_GROOVE: + case StyleBorderStyle::Inset: + case StyleBorderStyle::Groove: if (aCorner == eCornerTopLeft) return BorderColorStyleDark; else if (aCorner == eCornerBottomRight) return BorderColorStyleLight; break; - case NS_STYLE_BORDER_STYLE_OUTSET: - case NS_STYLE_BORDER_STYLE_RIDGE: + case StyleBorderStyle::Outset: + case StyleBorderStyle::Ridge: if (aCorner == eCornerTopLeft) return BorderColorStyleLight; else if (aCorner == eCornerBottomRight) return BorderColorStyleDark; break; + default: + return BorderColorStyleNone; } return BorderColorStyleNone; @@ -616,7 +618,7 @@ nsCSSBorderRenderer::GetSideClipSubPath(mozilla::Side aSide) Point start[2]; Point end[2]; -#define IS_DOTTED(_s) ((_s) == NS_STYLE_BORDER_STYLE_DOTTED) +#define IS_DOTTED(_s) ((_s) == StyleBorderStyle::Dotted) bool isDotted = IS_DOTTED(mBorderStyles[aSide]); bool startIsDotted = IS_DOTTED(mBorderStyles[PREV_SIDE(aSide)]); bool endIsDotted = IS_DOTTED(mBorderStyles[NEXT_SIDE(aSide)]); @@ -736,7 +738,7 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide, *aIsUnfilled = false; Point P = mOuterRect.AtCorner(aCorner); - uint8_t style = mBorderStyles[aSide]; + StyleBorderStyle style = mBorderStyles[aSide]; Float borderWidth = mBorderWidths[aSide]; Size dim = mBorderCornerDimensions[aCorner]; bool isHorizontal = IsHorizontalSide(aSide); @@ -750,14 +752,14 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide, // | | mozilla::Side otherSide = ((uint8_t)aSide == (uint8_t)aCorner) ? PREV_SIDE(aSide) : NEXT_SIDE(aSide); - uint8_t otherStyle = mBorderStyles[otherSide]; + StyleBorderStyle otherStyle = mBorderStyles[otherSide]; Float otherBorderWidth = mBorderWidths[otherSide]; Size radius = mBorderRadii[aCorner]; if (IsZeroSize(radius)) { radius.width = 0.0f; radius.height = 0.0f; } - if (style == NS_STYLE_BORDER_STYLE_DOTTED) { + if (style == StyleBorderStyle::Dotted) { // Offset the dot's location along the side toward the corner by a // multiple of its width. if (isHorizontal) { @@ -766,8 +768,8 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide, P.y -= signs[1] * aDotOffset * borderWidth; } } - if (style == NS_STYLE_BORDER_STYLE_DOTTED && - otherStyle == NS_STYLE_BORDER_STYLE_DOTTED) { + if (style == StyleBorderStyle::Dotted && + otherStyle == StyleBorderStyle::Dotted) { if (borderWidth == otherBorderWidth) { if (radius.width < borderWidth / 2.0f && radius.height < borderWidth / 2.0f) { @@ -963,7 +965,7 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide, return P; } - if (style == NS_STYLE_BORDER_STYLE_DOTTED) { + if (style == StyleBorderStyle::Dotted) { // If only this side is dotted, other side draws the corner. // // otherBorderWidth + borderWidth / 2.0 @@ -1024,7 +1026,7 @@ nsCSSBorderRenderer::GetStraightBorderPoint(mozilla::Side aSide, return P; } - if (otherStyle == NS_STYLE_BORDER_STYLE_DOTTED && IsZeroSize(radius)) { + if (otherStyle == StyleBorderStyle::Dotted && IsZeroSize(radius)) { // If other side is dotted and radius=0, draw side to the end of corner. // // +------------------------------- @@ -1290,7 +1292,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) return; } - uint8_t borderRenderStyle = NS_STYLE_BORDER_STYLE_NONE; + StyleBorderStyle borderRenderStyle = StyleBorderStyle::None; nscolor borderRenderColor; uint32_t borderColorStyleCount = 0; @@ -1306,12 +1308,12 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) break; } - if (borderRenderStyle == NS_STYLE_BORDER_STYLE_NONE || - borderRenderStyle == NS_STYLE_BORDER_STYLE_HIDDEN) + if (borderRenderStyle == StyleBorderStyle::None || + borderRenderStyle == StyleBorderStyle::Hidden) return; - if (borderRenderStyle == NS_STYLE_BORDER_STYLE_DASHED || - borderRenderStyle == NS_STYLE_BORDER_STYLE_DOTTED) { + if (borderRenderStyle == StyleBorderStyle::Dashed || + borderRenderStyle == StyleBorderStyle::Dotted) { // Draw each corner separately, with the given side's color. if (aSides & eSideBitsTop) { DrawDashedOrDottedCorner(eSideTop, C_TL); @@ -1344,13 +1346,13 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) // If the border width is 1, we need to change the borderRenderStyle // a bit to make sure that we get the right colors -- e.g. 'ridge' // with a 1px border needs to look like solid, not like 'outset'. - if (mOneUnitBorder && (borderRenderStyle == NS_STYLE_BORDER_STYLE_RIDGE || - borderRenderStyle == NS_STYLE_BORDER_STYLE_GROOVE || - borderRenderStyle == NS_STYLE_BORDER_STYLE_DOUBLE)) - borderRenderStyle = NS_STYLE_BORDER_STYLE_SOLID; + if (mOneUnitBorder && (borderRenderStyle == StyleBorderStyle::Ridge || + borderRenderStyle == StyleBorderStyle::Groove || + borderRenderStyle == StyleBorderStyle::Double)) + borderRenderStyle = StyleBorderStyle::Solid; switch (borderRenderStyle) { - case NS_STYLE_BORDER_STYLE_SOLID: + case StyleBorderStyle::Solid: borderColorStyleTopLeft[0] = BorderColorStyleSolid; borderColorStyleBottomRight[0] = BorderColorStyleSolid; @@ -1358,7 +1360,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) borderColorStyleCount = 1; break; - case NS_STYLE_BORDER_STYLE_GROOVE: + case StyleBorderStyle::Groove: borderColorStyleTopLeft[0] = BorderColorStyleDark; borderColorStyleTopLeft[1] = BorderColorStyleLight; @@ -1368,7 +1370,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) borderColorStyleCount = 2; break; - case NS_STYLE_BORDER_STYLE_RIDGE: + case StyleBorderStyle::Ridge: borderColorStyleTopLeft[0] = BorderColorStyleLight; borderColorStyleTopLeft[1] = BorderColorStyleDark; @@ -1378,7 +1380,7 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) borderColorStyleCount = 2; break; - case NS_STYLE_BORDER_STYLE_DOUBLE: + case StyleBorderStyle::Double: borderColorStyleTopLeft[0] = BorderColorStyleSolid; borderColorStyleTopLeft[1] = BorderColorStyleNone; borderColorStyleTopLeft[2] = BorderColorStyleSolid; @@ -1390,14 +1392,14 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) borderColorStyleCount = 3; break; - case NS_STYLE_BORDER_STYLE_INSET: + case StyleBorderStyle::Inset: borderColorStyleTopLeft[0] = BorderColorStyleDark; borderColorStyleBottomRight[0] = BorderColorStyleLight; borderColorStyleCount = 1; break; - case NS_STYLE_BORDER_STYLE_OUTSET: + case StyleBorderStyle::Outset: borderColorStyleTopLeft[0] = BorderColorStyleLight; borderColorStyleBottomRight[0] = BorderColorStyleDark; @@ -1492,38 +1494,38 @@ nsCSSBorderRenderer::DrawBorderSides(int aSides) // If there is at least one dotted side, every side is rendered separately. if (IsSingleSide(aSides)) { if (aSides == eSideBitsTop) { - if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideRight] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_TR])) { noMarginRight = true; } - if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideLeft] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_TL])) { noMarginLeft = true; } } else if (aSides == eSideBitsRight) { - if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideTop] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_TR])) { noMarginTop = true; } - if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideBottom] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_BR])) { noMarginBottom = true; } } else if (aSides == eSideBitsBottom) { - if (mBorderStyles[eSideRight] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideRight] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_BR])) { noMarginRight = true; } - if (mBorderStyles[eSideLeft] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideLeft] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_BL])) { noMarginLeft = true; } } else { - if (mBorderStyles[eSideTop] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideTop] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_TL])) { noMarginTop = true; } - if (mBorderStyles[eSideBottom] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[eSideBottom] == StyleBorderStyle::Dotted && IsZeroSize(mBorderRadii[C_BL])) { noMarginBottom = true; } @@ -1580,11 +1582,11 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions, Float aBorderLength, bool isCorner) { - MOZ_ASSERT(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED || - mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED, + MOZ_ASSERT(mBorderStyles[aSide] == StyleBorderStyle::Dashed || + mBorderStyles[aSide] == StyleBorderStyle::Dotted, "Style should be dashed or dotted."); - uint8_t style = mBorderStyles[aSide]; + StyleBorderStyle style = mBorderStyles[aSide]; Float borderWidth = mBorderWidths[aSide]; // Dashed line starts and ends with half segment in most case. @@ -1614,7 +1616,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions, // | | | | bool fullStart = false, fullEnd = false; Float halfDash; - if (style == NS_STYLE_BORDER_STYLE_DASHED) { + if (style == StyleBorderStyle::Dashed) { // If either end of the side is not connecting onto a corner then we want a // full dash at that end. // @@ -1626,7 +1628,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions, if (mBorderRadii[GetCCWCorner(aSide)].IsEmpty() && (mBorderCornerDimensions[GetCCWCorner(aSide)].IsEmpty() || - mBorderStyles[PREV_SIDE(aSide)] == NS_STYLE_BORDER_STYLE_DOTTED || + mBorderStyles[PREV_SIDE(aSide)] == StyleBorderStyle::Dotted || // XXX why this <=1 check? borderWidth <= 1.0f)) { fullStart = true; @@ -1634,7 +1636,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions, if (mBorderRadii[GetCWCorner(aSide)].IsEmpty() && (mBorderCornerDimensions[GetCWCorner(aSide)].IsEmpty() || - mBorderStyles[NEXT_SIDE(aSide)] == NS_STYLE_BORDER_STYLE_DOTTED)) { + mBorderStyles[NEXT_SIDE(aSide)] == StyleBorderStyle::Dotted)) { fullEnd = true; } @@ -1643,7 +1645,7 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions, halfDash = borderWidth * DOT_LENGTH / 2.0f; } - if (style == NS_STYLE_BORDER_STYLE_DASHED && aBorderLength > 0.0f) { + if (style == StyleBorderStyle::Dashed && aBorderLength > 0.0f) { // The number of half segments, with maximum dash length. int32_t count = floor(aBorderLength / halfDash); Float minHalfDash = borderWidth * DOT_LENGTH / 2.0f; @@ -1735,12 +1737,12 @@ nsCSSBorderRenderer::SetupDashedOptions(StrokeOptions* aStrokeOptions, aDash[0] = fullDash; aDash[1] = fullDash; - if (style == NS_STYLE_BORDER_STYLE_DASHED && fullDash > 1.0f) { + if (style == StyleBorderStyle::Dashed && fullDash > 1.0f) { if (!fullStart) { // Draw half segments on both ends. aStrokeOptions->mDashOffset = halfDash; } - } else if (style != NS_STYLE_BORDER_STYLE_DOTTED && isCorner) { + } else if (style != StyleBorderStyle::Dotted && isCorner) { // If side ends with filled full segment, corner should start with unfilled // full segment. Not needed for dotted corners, as they overlap one dot with // the side's end. @@ -1809,8 +1811,8 @@ nsCSSBorderRenderer::DrawDashedOrDottedSide(mozilla::Side aSide) // the line ends with unfilled dot. // (see comment for GetStraightBorderPoint for more detail) - NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED || - mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED, + NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed || + mBorderStyles[aSide] == StyleBorderStyle::Dotted, "Style should be dashed or dotted."); Float borderWidth = mBorderWidths[aSide]; @@ -1818,7 +1820,7 @@ nsCSSBorderRenderer::DrawDashedOrDottedSide(mozilla::Side aSide) return; } - if (mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED && + if (mBorderStyles[aSide] == StyleBorderStyle::Dotted && borderWidth > 2.0f) { DrawDottedSideSlow(aSide); return; @@ -1881,7 +1883,7 @@ nsCSSBorderRenderer::DrawDashedOrDottedSide(mozilla::Side aSide) } DrawOptions drawOptions; - if (mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED) { + if (mBorderStyles[aSide] == StyleBorderStyle::Dotted) { drawOptions.mAntialiasMode = AntialiasMode::NONE; } @@ -1898,7 +1900,7 @@ nsCSSBorderRenderer::DrawDottedSideSlow(mozilla::Side aSide) // Draw each circles separately for dotted with borderWidth > 2.0. // Dashed line with CapStyle::ROUND doesn't render perfect circles. - NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED, + NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dotted, "Style should be dotted."); Float borderWidth = mBorderWidths[aSide]; @@ -2302,8 +2304,8 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide, // DrawDashedOrDottedSide. So this may draw no circles if there's no space // between 2 dots at both ends. - NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED || - mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED, + NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed || + mBorderStyles[aSide] == StyleBorderStyle::Dotted, "Style should be dashed or dotted."); if (IsCornerMergeable(aCorner)) { @@ -2319,13 +2321,13 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide, return; } - Float styleH = mBorderStyles[sideH]; - Float styleV = mBorderStyles[sideV]; + StyleBorderStyle styleH = mBorderStyles[sideH]; + StyleBorderStyle styleV = mBorderStyles[sideV]; // Corner between dotted and others with radius=0 is drawn by side. if (IsZeroSize(mBorderRadii[aCorner]) && - (styleV == NS_STYLE_BORDER_STYLE_DOTTED || - styleH == NS_STYLE_BORDER_STYLE_DOTTED)) { + (styleV == StyleBorderStyle::Dotted || + styleH == StyleBorderStyle::Dotted)) { return; } @@ -2337,8 +2339,8 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide, } if (borderWidthH != borderWidthV || borderWidthH > 2.0f) { - uint8_t style = mBorderStyles[aSide]; - if (style == NS_STYLE_BORDER_STYLE_DOTTED) { + StyleBorderStyle style = mBorderStyles[aSide]; + if (style == StyleBorderStyle::Dotted) { DrawDottedCornerSlow(aSide, aCorner); } else { DrawDashedCornerSlow(aSide, aCorner); @@ -2384,7 +2386,7 @@ nsCSSBorderRenderer::DrawDashedOrDottedCorner(mozilla::Side aSide, void nsCSSBorderRenderer::DrawDottedCornerSlow(mozilla::Side aSide, Corner aCorner) { - NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED, + NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dotted, "Style should be dotted."); mozilla::Side sideH(GetHorizontalSide(aCorner)); @@ -2468,7 +2470,7 @@ DashedPathOverlapsRect(Rect& pathRect, void nsCSSBorderRenderer::DrawDashedCornerSlow(mozilla::Side aSide, Corner aCorner) { - NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED, + NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed, "Style should be dashed."); mozilla::Side sideH(GetHorizontalSide(aCorner)); @@ -2589,8 +2591,8 @@ nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::Side aSide, // Render too large dashed or dotted corner with solid style, to avoid hangup // inside DashedCornerFinder and DottedCornerFinder. - NS_ASSERTION(mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DASHED || - mBorderStyles[aSide] == NS_STYLE_BORDER_STYLE_DOTTED, + NS_ASSERTION(mBorderStyles[aSide] == StyleBorderStyle::Dashed || + mBorderStyles[aSide] == StyleBorderStyle::Dotted, "Style should be dashed or dotted."); nscolor borderColor = mBorderColors[aSide]; @@ -2619,7 +2621,7 @@ nsCSSBorderRenderer::DrawFallbackSolidCorner(mozilla::Side aSide, mDocument, nsContentUtils::eCSS_PROPERTIES, mBorderStyles[aSide] == - NS_STYLE_BORDER_STYLE_DASHED + StyleBorderStyle::Dashed ? "TooLargeDashedRadius" : "TooLargeDottedRadius"); } @@ -2643,9 +2645,9 @@ nsCSSBorderRenderer::AllBordersSolid() { NS_FOR_CSS_SIDES(i) { - if (mBorderStyles[i] == NS_STYLE_BORDER_STYLE_SOLID || - mBorderStyles[i] == NS_STYLE_BORDER_STYLE_NONE || - mBorderStyles[i] == NS_STYLE_BORDER_STYLE_HIDDEN) { + if (mBorderStyles[i] == StyleBorderStyle::Solid || + mBorderStyles[i] == StyleBorderStyle::None || + mBorderStyles[i] == StyleBorderStyle::Hidden) { continue; } return false; @@ -2655,10 +2657,10 @@ nsCSSBorderRenderer::AllBordersSolid() } static bool -IsVisible(int aStyle) +IsVisible(StyleBorderStyle aStyle) { - if (aStyle != NS_STYLE_BORDER_STYLE_NONE && - aStyle != NS_STYLE_BORDER_STYLE_HIDDEN) { + if (aStyle != StyleBorderStyle::None && + aStyle != StyleBorderStyle::Hidden) { return true; } return false; @@ -3157,8 +3159,8 @@ void nsCSSBorderRenderer::DrawBorders() { if (mAllBordersSameStyle && - (mBorderStyles[0] == NS_STYLE_BORDER_STYLE_NONE || - mBorderStyles[0] == NS_STYLE_BORDER_STYLE_HIDDEN || + (mBorderStyles[0] == StyleBorderStyle::None || + mBorderStyles[0] == StyleBorderStyle::Hidden || mBorderColors[0] == NS_RGBA(0, 0, 0, 0))) { // All borders are the same style, and the style is either none or hidden, // or the color is transparent. @@ -3206,7 +3208,7 @@ nsCSSBorderRenderer::DrawBorders() // drawing paths, when none of these can be used we move on to the generalized // border drawing code. if (mAllBordersSameStyle && mAllBordersSameWidth && - mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID && mNoBorderRadius && + mBorderStyles[0] == StyleBorderStyle::Solid && mNoBorderRadius && !mAvoidStroke) { // Very simple case. Rect rect = mOuterRect; @@ -3215,7 +3217,7 @@ nsCSSBorderRenderer::DrawBorders() return; } - if (mAllBordersSameStyle && mBorderStyles[0] == NS_STYLE_BORDER_STYLE_SOLID && + if (mAllBordersSameStyle && mBorderStyles[0] == StyleBorderStyle::Solid && !mAvoidStroke && !mNoBorderRadius) { // Relatively simple case. RoundedRect borderInnerRect(mOuterRect, mBorderRadii); @@ -3288,9 +3290,9 @@ nsCSSBorderRenderer::DrawBorders() NS_FOR_CSS_SIDES(i) { - uint8_t style = mBorderStyles[i]; - if (style == NS_STYLE_BORDER_STYLE_DASHED || - style == NS_STYLE_BORDER_STYLE_DOTTED) { + StyleBorderStyle style = mBorderStyles[i]; + if (style == StyleBorderStyle::Dashed || + style == StyleBorderStyle::Dotted) { // we need to draw things separately for dashed/dotting forceSeparateCorners = true; dashedSides |= (1 << i); @@ -3430,13 +3432,13 @@ nsCSSBorderRenderer::DrawBorders() for (int cornerSide = 0; cornerSide < 2; cornerSide++) { mozilla::Side side = mozilla::Side(sides[cornerSide]); - uint8_t style = mBorderStyles[side]; + StyleBorderStyle style = mBorderStyles[side]; PrintAsFormatString("corner: %d cornerSide: %d side: %d style: %d\n", corner, cornerSide, side, - style); + static_cast(style)); RefPtr path = GetSideClipSubPath(side); mDrawTarget->PushClip(path); @@ -3488,8 +3490,8 @@ nsCSSBorderRenderer::DrawBorders() // If there's no border on this side, skip it if (mBorderWidths[side] == 0.0 || - mBorderStyles[side] == NS_STYLE_BORDER_STYLE_HIDDEN || - mBorderStyles[side] == NS_STYLE_BORDER_STYLE_NONE) + mBorderStyles[side] == StyleBorderStyle::Hidden || + mBorderStyles[side] == StyleBorderStyle::None) continue; if (dashedSides & (1 << side)) { diff --git a/layout/painting/nsCSSRenderingBorders.h b/layout/painting/nsCSSRenderingBorders.h index deefed22b622..ef24314e0908 100644 --- a/layout/painting/nsCSSRenderingBorders.h +++ b/layout/painting/nsCSSRenderingBorders.h @@ -92,7 +92,7 @@ public: DrawTarget* aDrawTarget, const Rect& aDirtyRect, Rect& aOuterRect, - const uint8_t* aBorderStyles, + const mozilla::StyleBorderStyle* aBorderStyles, const Float* aBorderWidths, RectCornerRadii& aBorderRadii, const nscolor* aBorderColors, @@ -139,7 +139,7 @@ private: Rect mInnerRect; // the style and size of the border - uint8_t mBorderStyles[4]; + mozilla::StyleBorderStyle mBorderStyles[4]; Float mBorderWidths[4]; RectCornerRadii mBorderRadii; @@ -160,13 +160,13 @@ private: bool AreBorderSideFinalStylesSame(uint8_t aSides); // For the given style, is the given corner a solid color? - bool IsSolidCornerStyle(uint8_t aStyle, mozilla::Corner aCorner); + bool IsSolidCornerStyle(mozilla::StyleBorderStyle aStyle, mozilla::Corner aCorner); // For the given corner, is the given corner mergeable into one dot? bool IsCornerMergeable(mozilla::Corner aCorner); // For the given solid corner, what color style should be used? - BorderColorStyle BorderColorStyleForSolidCorner(uint8_t aStyle, + BorderColorStyle BorderColorStyleForSolidCorner(mozilla::StyleBorderStyle aStyle, mozilla::Corner aCorner); // diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index ded9c0ce549c..87714d615955 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -5263,8 +5263,8 @@ nsDisplayOutline::CreateWebRenderCommands( { ContainerLayerParameters parameter; - uint8_t outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle; - if (outlineStyle == NS_STYLE_BORDER_STYLE_AUTO && + StyleBorderStyle outlineStyle = mFrame->Style()->StyleOutline()->mOutlineStyle; + if (outlineStyle == StyleBorderStyle::Auto && nsLayoutUtils::IsOutlineStyleAutoEnabled()) { nsITheme* theme = mFrame->PresContext()->GetTheme(); if (theme && theme->ThemeSupportsWidget(mFrame->PresContext(), diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 809668a43048..4fb56f546cec 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -133,6 +133,7 @@ rusty-enums = [ "mozilla::StyleImageLayerRepeat", "mozilla::StyleImageLayerAttachment", "mozilla::StyleBoxDecorationBreak", + "mozilla::StyleBorderStyle", "mozilla::StyleRuleInclusion", "mozilla::StyleGridTrackBreadth", "mozilla::StyleOverscrollBehavior", diff --git a/layout/style/nsCSSProps.cpp b/layout/style/nsCSSProps.cpp index b29eb035d349..c401de8c5e6c 100644 --- a/layout/style/nsCSSProps.cpp +++ b/layout/style/nsCSSProps.cpp @@ -189,16 +189,16 @@ nsCSSProps::GetStringValue(nsCSSCounterDesc aCounterDesc) /***************************************************************************/ const KTableEntry nsCSSProps::kBorderStyleKTable[] = { - { eCSSKeyword_none, NS_STYLE_BORDER_STYLE_NONE }, - { eCSSKeyword_hidden, NS_STYLE_BORDER_STYLE_HIDDEN }, - { eCSSKeyword_dotted, NS_STYLE_BORDER_STYLE_DOTTED }, - { eCSSKeyword_dashed, NS_STYLE_BORDER_STYLE_DASHED }, - { eCSSKeyword_solid, NS_STYLE_BORDER_STYLE_SOLID }, - { eCSSKeyword_double, NS_STYLE_BORDER_STYLE_DOUBLE }, - { eCSSKeyword_groove, NS_STYLE_BORDER_STYLE_GROOVE }, - { eCSSKeyword_ridge, NS_STYLE_BORDER_STYLE_RIDGE }, - { eCSSKeyword_inset, NS_STYLE_BORDER_STYLE_INSET }, - { eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET }, + { eCSSKeyword_none, StyleBorderStyle::None }, + { eCSSKeyword_hidden, StyleBorderStyle::Hidden }, + { eCSSKeyword_dotted, StyleBorderStyle::Dotted }, + { eCSSKeyword_dashed, StyleBorderStyle::Dashed }, + { eCSSKeyword_solid, StyleBorderStyle::Solid }, + { eCSSKeyword_double, StyleBorderStyle::Double }, + { eCSSKeyword_groove, StyleBorderStyle::Groove }, + { eCSSKeyword_ridge, StyleBorderStyle::Ridge }, + { eCSSKeyword_inset, StyleBorderStyle::Inset }, + { eCSSKeyword_outset, StyleBorderStyle::Outset }, { eCSSKeyword_UNKNOWN, -1 } }; @@ -498,16 +498,16 @@ const KTableEntry nsCSSProps::kContainKTable[] = { // Same as kBorderStyleKTable except 'hidden'. const KTableEntry nsCSSProps::kOutlineStyleKTable[] = { - { eCSSKeyword_none, NS_STYLE_BORDER_STYLE_NONE }, - { eCSSKeyword_auto, NS_STYLE_BORDER_STYLE_AUTO }, - { eCSSKeyword_dotted, NS_STYLE_BORDER_STYLE_DOTTED }, - { eCSSKeyword_dashed, NS_STYLE_BORDER_STYLE_DASHED }, - { eCSSKeyword_solid, NS_STYLE_BORDER_STYLE_SOLID }, - { eCSSKeyword_double, NS_STYLE_BORDER_STYLE_DOUBLE }, - { eCSSKeyword_groove, NS_STYLE_BORDER_STYLE_GROOVE }, - { eCSSKeyword_ridge, NS_STYLE_BORDER_STYLE_RIDGE }, - { eCSSKeyword_inset, NS_STYLE_BORDER_STYLE_INSET }, - { eCSSKeyword_outset, NS_STYLE_BORDER_STYLE_OUTSET }, + { eCSSKeyword_none, StyleBorderStyle::None }, + { eCSSKeyword_auto, StyleBorderStyle::Auto }, + { eCSSKeyword_dotted, StyleBorderStyle::Dotted }, + { eCSSKeyword_dashed, StyleBorderStyle::Dashed }, + { eCSSKeyword_solid, StyleBorderStyle::Solid }, + { eCSSKeyword_double, StyleBorderStyle::Double }, + { eCSSKeyword_groove, StyleBorderStyle::Groove }, + { eCSSKeyword_ridge, StyleBorderStyle::Ridge }, + { eCSSKeyword_inset, StyleBorderStyle::Inset }, + { eCSSKeyword_outset, StyleBorderStyle::Outset }, { eCSSKeyword_UNKNOWN, -1 } }; diff --git a/layout/style/nsComputedDOMStyle.cpp b/layout/style/nsComputedDOMStyle.cpp index ff0d6d4349eb..4d494f5a0f1d 100644 --- a/layout/style/nsComputedDOMStyle.cpp +++ b/layout/style/nsComputedDOMStyle.cpp @@ -2205,7 +2205,7 @@ nsComputedDOMStyle::DoGetOutlineWidth() const nsStyleOutline* outline = StyleOutline(); nscoord width; - if (outline->mOutlineStyle == NS_STYLE_BORDER_STYLE_NONE) { + if (outline->mOutlineStyle == StyleBorderStyle::None) { NS_ASSERTION(outline->GetOutlineWidth() == 0, "unexpected width"); width = 0; } else { diff --git a/layout/style/nsStyleConsts.h b/layout/style/nsStyleConsts.h index fe862238af62..0e07c8bcff95 100644 --- a/layout/style/nsStyleConsts.h +++ b/layout/style/nsStyleConsts.h @@ -306,18 +306,19 @@ enum class StyleImageLayerRepeat : uint8_t { #define NS_STYLE_BORDER_WIDTH_THICK 2 // XXX chopping block #define NS_STYLE_BORDER_WIDTH_LENGTH_VALUE 3 -// See nsStyleBorder mBorderStyle -#define NS_STYLE_BORDER_STYLE_NONE 0 -#define NS_STYLE_BORDER_STYLE_GROOVE 1 -#define NS_STYLE_BORDER_STYLE_RIDGE 2 -#define NS_STYLE_BORDER_STYLE_DOTTED 3 -#define NS_STYLE_BORDER_STYLE_DASHED 4 -#define NS_STYLE_BORDER_STYLE_SOLID 5 -#define NS_STYLE_BORDER_STYLE_DOUBLE 6 -#define NS_STYLE_BORDER_STYLE_INSET 7 -#define NS_STYLE_BORDER_STYLE_OUTSET 8 -#define NS_STYLE_BORDER_STYLE_HIDDEN 9 -#define NS_STYLE_BORDER_STYLE_AUTO 10 // for outline-style only +enum class StyleBorderStyle : uint8_t { + None, + Groove, + Ridge, + Dotted, + Dashed, + Solid, + Double, + Inset, + Outset, + Hidden, + Auto, // for outline-style only +}; // border-image-repeat enum class StyleBorderImageRepeat : uint8_t { diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e86027c9d872..37d243abbdc6 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -291,7 +291,7 @@ nsStyleBorder::nsStyleBorder(const nsPresContext* aContext) mBorderImageOutset.Set(side, nsStyleCoord(0.0f, eStyleUnit_Factor)); mBorder.Side(side) = medium; - mBorderStyle[side] = NS_STYLE_BORDER_STYLE_NONE; + mBorderStyle[side] = StyleBorderStyle::None; } mTwipsPerPixel = aContext->DevPixelsToAppUnits(1); @@ -449,7 +449,7 @@ nsStyleOutline::nsStyleOutline(const nsPresContext* aContext) ->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM]) , mOutlineOffset(0) , mOutlineColor(StyleComplexColor::CurrentColor()) - , mOutlineStyle(NS_STYLE_BORDER_STYLE_NONE) + , mOutlineStyle(StyleBorderStyle::None) , mActualOutlineWidth(0) , mTwipsPerPixel(aContext->DevPixelsToAppUnits(1)) { @@ -476,7 +476,7 @@ nsStyleOutline::nsStyleOutline(const nsStyleOutline& aSrc) void nsStyleOutline::RecalcData() { - if (NS_STYLE_BORDER_STYLE_NONE == mOutlineStyle) { + if (StyleBorderStyle::None == mOutlineStyle) { mActualOutlineWidth = 0; } else { mActualOutlineWidth = @@ -667,7 +667,7 @@ nsStyleXUL::CalcDifference(const nsStyleXUL& aNewData) const nsStyleColumn::nsStyleColumn(const nsPresContext* aContext) : mColumnWidth(eStyleUnit_Auto) , mColumnRuleColor(StyleComplexColor::CurrentColor()) - , mColumnRuleStyle(NS_STYLE_BORDER_STYLE_NONE) + , mColumnRuleStyle(StyleBorderStyle::None) , mColumnRuleWidth((StaticPresData::Get() ->GetBorderWidthTable())[NS_STYLE_BORDER_WIDTH_MEDIUM]) , mTwipsPerPixel(aContext->AppUnitsPerDevPixel()) diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 662e65667402..f3925bad9494 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -965,10 +965,10 @@ private: ((l) == 0) ? 0 : std::max((tpp), (l) / (tpp) * (tpp)) // Returns if the given border style type is visible or not -static bool IsVisibleBorderStyle(uint8_t aStyle) +static bool IsVisibleBorderStyle(mozilla::StyleBorderStyle aStyle) { - return (aStyle != NS_STYLE_BORDER_STYLE_NONE && - aStyle != NS_STYLE_BORDER_STYLE_HIDDEN); + return (aStyle != mozilla::StyleBorderStyle::None && + aStyle != mozilla::StyleBorderStyle::Hidden); } struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder @@ -1028,13 +1028,13 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleBorder return GetComputedBorder().Side(aSide); } - uint8_t GetBorderStyle(mozilla::Side aSide) const + mozilla::StyleBorderStyle GetBorderStyle(mozilla::Side aSide) const { NS_ASSERTION(aSide <= mozilla::eSideLeft, "bad side"); return mBorderStyle[aSide]; } - void SetBorderStyle(mozilla::Side aSide, uint8_t aStyle) + void SetBorderStyle(mozilla::Side aSide, mozilla::StyleBorderStyle aStyle) { NS_ASSERTION(aSide <= mozilla::eSideLeft, "bad side"); mBorderStyle[aSide] = aStyle; @@ -1071,7 +1071,7 @@ public: mozilla::StyleBoxDecorationBreak mBoxDecorationBreak; protected: - uint8_t mBorderStyle[4]; // NS_STYLE_BORDER_STYLE_* + mozilla::StyleBorderStyle mBorderStyle[4]; // StyleBorderStyle::* public: // the colors to use for a simple border. @@ -1172,7 +1172,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline nscoord mOutlineWidth; nscoord mOutlineOffset; mozilla::StyleComplexColor mOutlineColor; - uint8_t mOutlineStyle; // NS_STYLE_BORDER_STYLE_* + mozilla::StyleBorderStyle mOutlineStyle; // StyleBorderStyle::* nscoord GetOutlineWidth() const { @@ -1181,9 +1181,9 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleOutline bool ShouldPaintOutline() const { - return mOutlineStyle == NS_STYLE_BORDER_STYLE_AUTO || + return mOutlineStyle == mozilla::StyleBorderStyle::Auto || (GetOutlineWidth() > 0 && - mOutlineStyle != NS_STYLE_BORDER_STYLE_NONE); + mOutlineStyle != mozilla::StyleBorderStyle::None); } protected: @@ -2781,7 +2781,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleColumn nsStyleCoord mColumnWidth; // coord, auto mozilla::StyleComplexColor mColumnRuleColor; - uint8_t mColumnRuleStyle; // NS_STYLE_BORDER_STYLE_* + mozilla::StyleBorderStyle mColumnRuleStyle; // StyleborderStyle::* mozilla::StyleColumnFill mColumnFill = mozilla::StyleColumnFill::Balance; mozilla::StyleColumnSpan mColumnSpan = mozilla::StyleColumnSpan::None; diff --git a/layout/tables/nsTableFrame.cpp b/layout/tables/nsTableFrame.cpp index eda849a298f8..adf3206bd862 100644 --- a/layout/tables/nsTableFrame.cpp +++ b/layout/tables/nsTableFrame.cpp @@ -4425,8 +4425,8 @@ struct BCCellBorder void Reset(uint32_t aRowIndex, uint32_t aRowSpan); nscolor color; // border segment color BCPixelSize width; // border segment width in pixel coordinates !! - uint8_t style; // border segment style, possible values are defined - // in nsStyleConsts.h as NS_STYLE_BORDER_STYLE_* + StyleBorderStyle style; // border segment style, possible values are defined + // in nsStyleConsts.h as StyleBorderStyle::* BCBorderOwner owner; // border segment owner, possible values are defined // in celldata.h. In the cellmap for each border // segment we store the owner and later when @@ -4442,7 +4442,7 @@ void BCCellBorder::Reset(uint32_t aRowIndex, uint32_t aRowSpan) { - style = NS_STYLE_BORDER_STYLE_NONE; + style = StyleBorderStyle::None; color = 0; width = 0; owner = eTableOwner; @@ -5002,18 +5002,18 @@ BCMapCellIterator::PeekBEnd(BCMapCellInfo& aRefInfo, aAjaInfo.SetInfo(nextRow, aColIndex, cellData, this, cellMap); } -// Assign priorities to border styles. For example, styleToPriority(NS_STYLE_BORDER_STYLE_SOLID) -// will return the priority of NS_STYLE_BORDER_STYLE_SOLID. -static uint8_t styleToPriority[13] = { 0, // NS_STYLE_BORDER_STYLE_NONE - 2, // NS_STYLE_BORDER_STYLE_GROOVE - 4, // NS_STYLE_BORDER_STYLE_RIDGE - 5, // NS_STYLE_BORDER_STYLE_DOTTED - 6, // NS_STYLE_BORDER_STYLE_DASHED - 7, // NS_STYLE_BORDER_STYLE_SOLID - 8, // NS_STYLE_BORDER_STYLE_DOUBLE - 1, // NS_STYLE_BORDER_STYLE_INSET - 3, // NS_STYLE_BORDER_STYLE_OUTSET - 9 };// NS_STYLE_BORDER_STYLE_HIDDEN +// Assign priorities to border styles. For example, styleToPriority(StyleBorderStyle::Solid) +// will return the priority of StyleBorderStyle::Solid. +static uint8_t styleToPriority[13] = { 0, // StyleBorderStyle::None + 2, // StyleBorderStyle::Groove + 4, // StyleBorderStyle::Ridge + 5, // StyleBorderStyle::Dotted + 6, // StyleBorderStyle::Dashed + 7, // StyleBorderStyle::Solid + 8, // StyleBorderStyle::Double + 1, // StyleBorderStyle::Inset + 3, // StyleBorderStyle::Outset + 9 };// StyleBorderStyle::Hidden // priority rules follow CSS 2.1 spec // 'hidden', 'double', 'solid', 'dashed', 'dotted', 'ridge', 'outset', 'groove', // and the lowest: 'inset'. none is even weaker @@ -5032,7 +5032,7 @@ static void GetColorAndStyle(const nsIFrame* aFrame, WritingMode aTableWM, LogicalSide aSide, - uint8_t* aStyle, + StyleBorderStyle* aStyle, nscolor* aColor, BCPixelSize* aWidth = nullptr) { @@ -5049,8 +5049,8 @@ GetColorAndStyle(const nsIFrame* aFrame, mozilla::Side physicalSide = aTableWM.PhysicalSide(aSide); *aStyle = styleData->GetBorderStyle(physicalSide); - if ((NS_STYLE_BORDER_STYLE_NONE == *aStyle) || - (NS_STYLE_BORDER_STYLE_HIDDEN == *aStyle)) { + if ((StyleBorderStyle::None == *aStyle) || + (StyleBorderStyle::Hidden == *aStyle)) { return; } *aColor = aFrame->Style()-> @@ -5073,14 +5073,14 @@ static void GetPaintStyleInfo(const nsIFrame* aFrame, WritingMode aTableWM, LogicalSide aSide, - uint8_t* aStyle, + StyleBorderStyle* aStyle, nscolor* aColor) { GetColorAndStyle(aFrame, aTableWM, aSide, aStyle, aColor); - if (NS_STYLE_BORDER_STYLE_INSET == *aStyle) { - *aStyle = NS_STYLE_BORDER_STYLE_RIDGE; - } else if (NS_STYLE_BORDER_STYLE_OUTSET == *aStyle) { - *aStyle = NS_STYLE_BORDER_STYLE_GROOVE; + if (StyleBorderStyle::Inset == *aStyle) { + *aStyle = StyleBorderStyle::Ridge; + } else if (StyleBorderStyle::Outset == *aStyle) { + *aStyle = StyleBorderStyle::Groove; } } @@ -5151,20 +5151,22 @@ CompareBorders(bool aIsCorner, // Pass true for corner calculatio { bool firstDominates = true; - if (NS_STYLE_BORDER_STYLE_HIDDEN == aBorder1.style) { + if (StyleBorderStyle::Hidden == aBorder1.style) { firstDominates = (aIsCorner) ? false : true; } - else if (NS_STYLE_BORDER_STYLE_HIDDEN == aBorder2.style) { + else if (StyleBorderStyle::Hidden == aBorder2.style) { firstDominates = (aIsCorner) ? true : false; } else if (aBorder1.width < aBorder2.width) { firstDominates = false; } else if (aBorder1.width == aBorder2.width) { - if (styleToPriority[aBorder1.style] < styleToPriority[aBorder2.style]) { + if (styleToPriority[static_cast(aBorder1.style)] < + styleToPriority[static_cast(aBorder2.style)]) { firstDominates = false; } - else if (styleToPriority[aBorder1.style] == styleToPriority[aBorder2.style]) { + else if (styleToPriority[static_cast(aBorder1.style)] == + styleToPriority[static_cast(aBorder2.style)]) { if (aBorder1.owner == aBorder2.owner) { firstDominates = !aSecondIsInlineDir; } @@ -5220,7 +5222,7 @@ CompareBorders(const nsIFrame* aTableFrame, GetColorAndStyle(aTableFrame, aTableWM, aSide, &border.style, &border.color, &border.width); border.owner = eTableOwner; - if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) { + if (StyleBorderStyle::Hidden == border.style) { return border; } } @@ -5231,7 +5233,7 @@ CompareBorders(const nsIFrame* aTableFrame, tempBorder.owner = aAja && !inlineAxis ? eAjaColGroupOwner : eColGroupOwner; // pass here and below false for aSecondIsInlineDir as it is only used for corner calculations. border = CompareBorders(!CELL_CORNER, border, tempBorder, false); - if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) { + if (StyleBorderStyle::Hidden == border.style) { return border; } } @@ -5241,7 +5243,7 @@ CompareBorders(const nsIFrame* aTableFrame, &tempBorder.style, &tempBorder.color, &tempBorder.width); tempBorder.owner = aAja && !inlineAxis ? eAjaColOwner : eColOwner; border = CompareBorders(!CELL_CORNER, border, tempBorder, false); - if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) { + if (StyleBorderStyle::Hidden == border.style) { return border; } } @@ -5251,7 +5253,7 @@ CompareBorders(const nsIFrame* aTableFrame, &tempBorder.style, &tempBorder.color, &tempBorder.width); tempBorder.owner = aAja && inlineAxis ? eAjaRowGroupOwner : eRowGroupOwner; border = CompareBorders(!CELL_CORNER, border, tempBorder, false); - if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) { + if (StyleBorderStyle::Hidden == border.style) { return border; } } @@ -5261,7 +5263,7 @@ CompareBorders(const nsIFrame* aTableFrame, &tempBorder.style, &tempBorder.color, &tempBorder.width); tempBorder.owner = aAja && inlineAxis ? eAjaRowOwner : eRowOwner; border = CompareBorders(!CELL_CORNER, border, tempBorder, false); - if (NS_STYLE_BORDER_STYLE_HIDDEN == border.style) { + if (StyleBorderStyle::Hidden == border.style) { return border; } } @@ -5283,7 +5285,7 @@ Perpendicular(mozilla::LogicalSide aSide1, } // Initial value indicating that BCCornerInfo's ownerStyle hasn't been set yet. -#define BORDER_STYLE_UNSET 0xF +#define BORDER_STYLE_UNSET static_cast(255) // XXX allocate this as number-of-cols+1 instead of number-of-cols+1 * number-of-rows+1 struct BCCornerInfo @@ -5291,7 +5293,7 @@ struct BCCornerInfo BCCornerInfo() { ownerColor = 0; ownerWidth = subWidth = ownerElem = subSide = subElem = hasDashDot = numSegs = bevel = 0; ownerSide = eLogicalSideBStart; ownerStyle = BORDER_STYLE_UNSET; - subStyle = NS_STYLE_BORDER_STYLE_SOLID; } + subStyle = StyleBorderStyle::Solid; } void Set(mozilla::LogicalSide aSide, BCCellBorder border); @@ -5299,20 +5301,20 @@ struct BCCornerInfo void Update(mozilla::LogicalSide aSide, BCCellBorder border); - nscolor ownerColor; // color of borderOwner - uint16_t ownerWidth; // pixel width of borderOwner - uint16_t subWidth; // pixel width of the largest border intersecting the border perpendicular - // to ownerSide - uint32_t ownerSide:2; // LogicalSide (e.g eLogicalSideBStart, etc) of the border - // owning the corner relative to the corner - uint32_t ownerElem:4; // elem type (e.g. eTable, eGroup, etc) owning the corner - uint32_t ownerStyle:4; // border style of ownerElem - uint32_t subSide:2; // side of border with subWidth relative to the corner - uint32_t subElem:4; // elem type (e.g. eTable, eGroup, etc) of sub owner - uint32_t subStyle:4; // border style of subElem - uint32_t hasDashDot:1; // does a dashed, dotted segment enter the corner, they cannot be beveled - uint32_t numSegs:3; // number of segments entering corner - uint32_t bevel:1; // is the corner beveled (uses the above two fields together with subWidth) + nscolor ownerColor; // color of borderOwner + uint16_t ownerWidth; // pixel width of borderOwner + uint16_t subWidth; // pixel width of the largest border intersecting the border perpendicular + // to ownerSide + StyleBorderStyle subStyle; // border style of subElem + StyleBorderStyle ownerStyle;// border style of ownerElem + uint16_t ownerSide:2; // LogicalSide (e.g eLogicalSideBStart, etc) of the border + // owning the corner relative to the corner + uint16_t ownerElem:4; // elem type (e.g. eTable, eGroup, etc) owning the corner + uint16_t subSide:2; // side of border with subWidth relative to the corner + uint16_t subElem:4; // elem type (e.g. eTable, eGroup, etc) of sub owner + uint16_t hasDashDot:1; // does a dashed, dotted segment enter the corner, they cannot be beveled + uint16_t numSegs:3; // number of segments entering corner + uint16_t bevel:1; // is the corner beveled (uses the above two fields together with subWidth) // 7 bits are unused }; @@ -5332,15 +5334,15 @@ BCCornerInfo::Set(mozilla::LogicalSide aSide, numSegs = 0; if (aBorder.width > 0) { numSegs++; - hasDashDot = (NS_STYLE_BORDER_STYLE_DASHED == aBorder.style) || - (NS_STYLE_BORDER_STYLE_DOTTED == aBorder.style); + hasDashDot = (StyleBorderStyle::Dashed == aBorder.style) || + (StyleBorderStyle::Dotted == aBorder.style); } bevel = 0; subWidth = 0; // the following will get set later subSide = IsInline(aSide) ? eLogicalSideBStart : eLogicalSideIStart; subElem = eTableOwner; - subStyle = NS_STYLE_BORDER_STYLE_SOLID; + subStyle = StyleBorderStyle::Solid; } void @@ -5398,8 +5400,8 @@ BCCornerInfo::Update(mozilla::LogicalSide aSide, } if (aBorder.width > 0) { numSegs++; - if (!hasDashDot && ((NS_STYLE_BORDER_STYLE_DASHED == aBorder.style) || - (NS_STYLE_BORDER_STYLE_DOTTED == aBorder.style))) { + if (!hasDashDot && ((StyleBorderStyle::Dashed == aBorder.style) || + (StyleBorderStyle::Dotted == aBorder.style))) { hasDashDot = 1; } } @@ -6503,7 +6505,7 @@ class BCPaintBorderIterator; struct BCBorderParameters { - uint8_t mBorderStyle; + StyleBorderStyle mBorderStyle; nscolor mBorderColor; nsRect mBorderRect; int32_t mAppUnitsPerDevPixel; @@ -6519,8 +6521,8 @@ struct BCBorderParameters return false; } - if (mBorderStyle == NS_STYLE_BORDER_STYLE_DASHED || - mBorderStyle == NS_STYLE_BORDER_STYLE_DOTTED) { + if (mBorderStyle == StyleBorderStyle::Dashed || + mBorderStyle == StyleBorderStyle::Dotted) { return false; } @@ -7384,7 +7386,7 @@ BCBlockDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter, nsTableColFrame* col = mCol; if (!col) ABORT1(Nothing()); nsTableCellFrame* cell = mFirstCell; // ??? nsIFrame* owner = nullptr; - result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID; + result.mBorderStyle = StyleBorderStyle::Solid; result.mBorderColor = 0xFFFFFFFF; result.mBackfaceIsVisible = true; @@ -7534,7 +7536,7 @@ AdjustAndPushBevel(wr::DisplayListBuilder& aBuilder, wr::LayoutRect bevelRect = aRect; wr::BorderSide bevelBorder[4]; NS_FOR_CSS_SIDES(i) { - bevelBorder[i] = wr::ToBorderSide(ToDeviceColor(aColor), NS_STYLE_BORDER_STYLE_SOLID); + bevelBorder[i] = wr::ToBorderSide(ToDeviceColor(aColor), StyleBorderStyle::Solid); } // We're creating a half-transparent triangle using the border primitive. @@ -7669,7 +7671,7 @@ CreateWRCommandsForBorderSegment(const BCBorderParameters& aBorderParams, wr::LayoutRect roundedRect = wr::ToRoundedLayoutRect(borderRect); wr::BorderSide wrSide[4]; NS_FOR_CSS_SIDES(i) { - wrSide[i] = wr::ToBorderSide(ToDeviceColor(aBorderParams.mBorderColor), NS_STYLE_BORDER_STYLE_NONE); + wrSide[i] = wr::ToBorderSide(ToDeviceColor(aBorderParams.mBorderColor), StyleBorderStyle::None); } const bool horizontal = aBorderParams.mStartBevelSide == eSideTop || aBorderParams.mStartBevelSide == eSideBottom; @@ -7833,7 +7835,7 @@ BCInlineDirSeg::BuildBorderParameters(BCPaintBorderIterator& aIter) nsPresContext* presContext = aIter.mTable->PresContext(); result.mAppUnitsPerDevPixel = presContext->AppUnitsPerDevPixel(); - result.mBorderStyle = NS_STYLE_BORDER_STYLE_SOLID; + result.mBorderStyle = StyleBorderStyle::Solid; result.mBorderColor = 0xFFFFFFFF; switch (mOwner) { diff --git a/layout/xul/tree/nsTreeBodyFrame.cpp b/layout/xul/tree/nsTreeBodyFrame.cpp index 3f50ebf653c7..ce60586de6dd 100644 --- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -3227,7 +3227,7 @@ nsTreeBodyFrame::PaintCell(int32_t aRowIndex, nscolor color = borderStyle->mBorderLeftColor.CalcColor(lineContext); ColorPattern colorPatt(ToDeviceColor(color)); - uint8_t style = borderStyle->GetBorderStyle(eSideLeft); + StyleBorderStyle style = borderStyle->GetBorderStyle(eSideLeft); StrokeOptions strokeOptions; nsLayoutUtils::InitDashPattern(strokeOptions, style); diff --git a/servo/components/style/properties/gecko.mako.rs b/servo/components/style/properties/gecko.mako.rs index f0b8cef22acb..956e324675d4 100644 --- a/servo/components/style/properties/gecko.mako.rs +++ b/servo/components/style/properties/gecko.mako.rs @@ -1516,7 +1516,9 @@ fn static_assert() { <% border_style_keyword = Keyword("border-style", - "none solid double dotted dashed hidden groove ridge inset outset") %> + "none solid double dotted dashed hidden groove ridge inset outset", + gecko_enum_prefix="StyleBorderStyle", + gecko_inexhaustive=True) %> <% skip_border_longhands = " ".join(["border-{0}-{1}".format(x.ident, y) for x in SIDES diff --git a/servo/components/style/properties/longhands/border.mako.rs b/servo/components/style/properties/longhands/border.mako.rs index 81e5fa647b16..6ce48afe6b07 100644 --- a/servo/components/style/properties/longhands/border.mako.rs +++ b/servo/components/style/properties/longhands/border.mako.rs @@ -63,7 +63,9 @@ ${helpers.gecko_keyword_conversion( Keyword('border-style', - "none solid double dotted dashed hidden groove ridge inset outset"), + "none solid double dotted dashed hidden groove ridge inset outset", + gecko_enum_prefix="StyleBorderStyle", + gecko_inexhaustive=True), type="crate::values::specified::BorderStyle", )} diff --git a/servo/components/style/properties/longhands/column.mako.rs b/servo/components/style/properties/longhands/column.mako.rs index d4bae90c96b7..84820f403ce6 100644 --- a/servo/components/style/properties/longhands/column.mako.rs +++ b/servo/components/style/properties/longhands/column.mako.rs @@ -83,7 +83,8 @@ ${helpers.single_keyword( "none hidden dotted dashed solid double groove ridge inset outset", products="gecko", extra_prefixes="moz", - gecko_constant_prefix="NS_STYLE_BORDER_STYLE", + gecko_enum_prefix="StyleBorderStyle", + gecko_inexhaustive=True, animation_value_type="discrete", spec="https://drafts.csswg.org/css-multicol/#propdef-column-rule-style", )} diff --git a/widget/cocoa/nsNativeThemeCocoa.mm b/widget/cocoa/nsNativeThemeCocoa.mm index 06dcab0b15fa..b4b8cbd3b962 100644 --- a/widget/cocoa/nsNativeThemeCocoa.mm +++ b/widget/cocoa/nsNativeThemeCocoa.mm @@ -3925,10 +3925,10 @@ nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBui wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0))); wr::BorderSide side[4] = { - wr::ToBorderSide(kMultilineTextFieldTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID), - wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), - wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), - wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), + wr::ToBorderSide(kMultilineTextFieldTopBorderColor, StyleBorderStyle::Solid), + wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid), + wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid), + wr::ToBorderSide(kMultilineTextFieldSidesAndBottomBorderColor, StyleBorderStyle::Solid), }; wr::BorderRadius borderRadius = wr::EmptyBorderRadius(); @@ -3948,10 +3948,10 @@ nsNativeThemeCocoa::CreateWebRenderCommandsForWidget(mozilla::wr::DisplayListBui wr::ToColorF(Color(1.0, 1.0, 1.0, 1.0))); wr::BorderSide side[4] = { - wr::ToBorderSide(kListboxTopBorderColor, NS_STYLE_BORDER_STYLE_SOLID), - wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), - wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), - wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, NS_STYLE_BORDER_STYLE_SOLID), + wr::ToBorderSide(kListboxTopBorderColor, StyleBorderStyle::Solid), + wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid), + wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid), + wr::ToBorderSide(kListBoxSidesAndBottomBorderColor, StyleBorderStyle::Solid), }; wr::BorderRadius borderRadius = wr::EmptyBorderRadius(); From 974f7da95ae3f7656ec62e25dd111e15cfd4b75f Mon Sep 17 00:00:00 2001 From: Eden Chuang Date: Wed, 21 Nov 2018 11:03:21 +0100 Subject: [PATCH 02/13] bug 1501823 - Force to call PaymentUIService.showPayment() when PaymentRequest.show called with a promise parameter. r=baku 1. Adding a new completeStatus 'initial' for nsIPaymentRequest.completeStatus to indicate the status of the showing PaymentRequest for Payment UI component. 2. Removing the PaymentRequest::mDeferredShow and calling PaymentRequestManager::showPayment() when PaymentRequest::Show() called with a detailsUpdate parameter to inform UI component to support better user experience. --- dom/payments/MerchantValidationEvent.cpp | 4 +-- dom/payments/PaymentRequest.cpp | 30 +++++++------------ dom/payments/PaymentRequest.h | 9 ++---- dom/payments/PaymentRequestManager.cpp | 29 +++++------------- dom/payments/PaymentRequestManager.h | 5 ++-- dom/payments/PaymentRequestService.cpp | 35 +++++++++++----------- dom/payments/PaymentRequestService.h | 2 +- dom/payments/PaymentRequestUpdateEvent.cpp | 10 +++---- dom/payments/ipc/PPaymentRequest.ipdl | 1 + 9 files changed, 49 insertions(+), 76 deletions(-) diff --git a/dom/payments/MerchantValidationEvent.cpp b/dom/payments/MerchantValidationEvent.cpp index 45d4cd947595..f596cfc1a38f 100644 --- a/dom/payments/MerchantValidationEvent.cpp +++ b/dom/payments/MerchantValidationEvent.cpp @@ -134,7 +134,7 @@ MerchantValidationEvent::ResolvedCallback(JSContext* aCx, // conformance, which is why at this point we throw a // NS_ERROR_DOM_NOT_SUPPORTED_ERR. - mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR, false); + mRequest->AbortUpdate(NS_ERROR_DOM_NOT_SUPPORTED_ERR); mRequest->SetUpdating(false); } @@ -147,7 +147,7 @@ MerchantValidationEvent::RejectedCallback(JSContext* aCx, return; } mWaitForUpdate = false; - mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false); + mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR); mRequest->SetUpdating(false); } diff --git a/dom/payments/PaymentRequest.cpp b/dom/payments/PaymentRequest.cpp index 22424aaee174..10efca26fd36 100644 --- a/dom/payments/PaymentRequest.cpp +++ b/dom/payments/PaymentRequest.cpp @@ -664,7 +664,6 @@ PaymentRequest::PaymentRequest(nsPIDOMWindowInner* aWindow, const nsAString& aIn , mShippingAddress(nullptr) , mUpdating(false) , mRequestShipping(false) - , mDeferredShow(false) , mUpdateError(NS_OK) , mState(eCreated) , mIPC(nullptr) @@ -756,7 +755,6 @@ PaymentRequest::Show(const Optional>& aDetailsPromise, if (aDetailsPromise.WasPassed()) { aDetailsPromise.Value().AppendNativeHandler(this); mUpdating = true; - mDeferredShow = true; } RefPtr manager = PaymentRequestManager::GetSingleton(); @@ -858,9 +856,7 @@ PaymentRequest::Abort(ErrorResult& aRv) RefPtr manager = PaymentRequestManager::GetSingleton(); MOZ_ASSERT(manager); - // It's possible to be called between show and its promise resolving. - nsresult rv = manager->AbortPayment(this, mDeferredShow); - mDeferredShow = false; + nsresult rv = manager->AbortPayment(this); if (NS_WARN_IF(NS_FAILED(rv))) { aRv.Throw(NS_ERROR_FAILURE); return nullptr; @@ -905,8 +901,7 @@ PaymentRequest::RespondAbortPayment(bool aSuccess) } nsresult -PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetails, - bool aDeferredShow) +PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetails) { NS_ENSURE_ARG_POINTER(aCx); if (mState != eInteractive) { @@ -916,8 +911,7 @@ PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetai if (NS_WARN_IF(!manager)) { return NS_ERROR_FAILURE; } - nsresult rv = manager->UpdatePayment(aCx, this, aDetails, mRequestShipping, - aDeferredShow); + nsresult rv = manager->UpdatePayment(aCx, this, aDetails, mRequestShipping); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -925,7 +919,7 @@ PaymentRequest::UpdatePayment(JSContext* aCx, const PaymentDetailsUpdate& aDetai } void -PaymentRequest::AbortUpdate(nsresult aRv, bool aDeferredShow) +PaymentRequest::AbortUpdate(nsresult aRv) { MOZ_ASSERT(NS_FAILED(aRv)); @@ -935,7 +929,7 @@ PaymentRequest::AbortUpdate(nsresult aRv, bool aDeferredShow) // Close down any remaining user interface. RefPtr manager = PaymentRequestManager::GetSingleton(); MOZ_ASSERT(manager); - nsresult rv = manager->AbortPayment(this, aDeferredShow); + nsresult rv = manager->AbortPayment(this); if (NS_WARN_IF(NS_FAILED(rv))) { return; } @@ -1138,33 +1132,29 @@ PaymentRequest::ResolvedCallback(JSContext* aCx, JS::Handle aValue) // Converting value to a PaymentDetailsUpdate dictionary PaymentDetailsUpdate details; if (!details.Init(aCx, aValue)) { - AbortUpdate(NS_ERROR_DOM_TYPE_ERR, mDeferredShow); + AbortUpdate(NS_ERROR_DOM_TYPE_ERR); JS_ClearPendingException(aCx); return; } nsresult rv = IsValidDetailsUpdate(details, mRequestShipping); if (NS_FAILED(rv)) { - AbortUpdate(rv, mDeferredShow); + AbortUpdate(rv); return; } // Update the PaymentRequest with the new details - if (NS_FAILED(UpdatePayment(aCx, details, mDeferredShow))) { - AbortUpdate(NS_ERROR_DOM_ABORT_ERR, mDeferredShow); + if (NS_FAILED(UpdatePayment(aCx, details))) { + AbortUpdate(NS_ERROR_DOM_ABORT_ERR); return; } - - mDeferredShow = false; } void PaymentRequest::RejectedCallback(JSContext* aCx, JS::Handle aValue) { - MOZ_ASSERT(mDeferredShow); mUpdating = false; - AbortUpdate(NS_ERROR_DOM_ABORT_ERR, mDeferredShow); - mDeferredShow = false; + AbortUpdate(NS_ERROR_DOM_ABORT_ERR); } void diff --git a/dom/payments/PaymentRequest.h b/dom/payments/PaymentRequest.h index 085602ec1905..1dff862cfe9e 100644 --- a/dom/payments/PaymentRequest.h +++ b/dom/payments/PaymentRequest.h @@ -143,9 +143,8 @@ public: nsresult UpdateShippingOption(const nsAString& aShippingOption); nsresult UpdatePayment(JSContext* aCx, - const PaymentDetailsUpdate& aDetails, - bool aDeferredShow); - void AbortUpdate(nsresult aRv, bool aDeferredShow); + const PaymentDetailsUpdate& aDetails); + void AbortUpdate(nsresult aRv); void SetShippingType(const Nullable& aShippingType); Nullable GetShippingType() const; @@ -210,10 +209,6 @@ protected: // but we don't actually store the full [[options]] internal slot. bool mRequestShipping; - // True if the user passed a promise to show, causing us to defer telling the - // front end about it. - bool mDeferredShow; - // The error is set in AbortUpdate(). The value is NS_OK by default. nsresult mUpdateError; diff --git a/dom/payments/PaymentRequestManager.cpp b/dom/payments/PaymentRequestManager.cpp index 0883ca9fc917..de1409f709b8 100644 --- a/dom/payments/PaymentRequestManager.cpp +++ b/dom/payments/PaymentRequestManager.cpp @@ -537,33 +537,25 @@ PaymentRequestManager::CanMakePayment(PaymentRequest* aRequest) nsAutoString requestId; aRequest->GetInternalId(requestId); IPCPaymentCanMakeActionRequest action(requestId); - return SendRequestPayment(aRequest, action); } nsresult PaymentRequestManager::ShowPayment(PaymentRequest* aRequest) { - nsresult rv = NS_OK; - if (!aRequest->IsUpdating()) { - nsAutoString requestId; - aRequest->GetInternalId(requestId); - IPCPaymentShowActionRequest action(requestId); - rv = SendRequestPayment(aRequest, action); - } - return rv; + nsAutoString requestId; + aRequest->GetInternalId(requestId); + IPCPaymentShowActionRequest action(requestId, aRequest->IsUpdating()); + return SendRequestPayment(aRequest, action); } nsresult -PaymentRequestManager::AbortPayment(PaymentRequest* aRequest, bool aDeferredShow) +PaymentRequestManager::AbortPayment(PaymentRequest* aRequest) { nsAutoString requestId; aRequest->GetInternalId(requestId); IPCPaymentAbortActionRequest action(requestId); - - // If aDeferredShow is true, then show was called with a promise that was - // rejected. In that case, we need to remember that we called show earlier. - return SendRequestPayment(aRequest, action, aDeferredShow); + return SendRequestPayment(aRequest, action); } nsresult @@ -585,7 +577,6 @@ PaymentRequestManager::CompletePayment(PaymentRequest* aRequest, nsAutoString requestId; aRequest->GetInternalId(requestId); IPCPaymentCompleteActionRequest action(requestId, completeStatusString); - return SendRequestPayment(aRequest, action, false); } @@ -593,8 +584,7 @@ nsresult PaymentRequestManager::UpdatePayment(JSContext* aCx, PaymentRequest* aRequest, const PaymentDetailsUpdate& aDetails, - bool aRequestShipping, - bool aDeferredShow) + bool aRequestShipping) { NS_ENSURE_ARG_POINTER(aCx); IPCPaymentDetails details; @@ -613,10 +603,7 @@ PaymentRequestManager::UpdatePayment(JSContext* aCx, nsAutoString requestId; aRequest->GetInternalId(requestId); IPCPaymentUpdateActionRequest action(requestId, details, shippingOption); - - // If aDeferredShow is true, then this call serves as the ShowUpdate call for - // this request. - return SendRequestPayment(aRequest, action, aDeferredShow); + return SendRequestPayment(aRequest, action, false); } nsresult diff --git a/dom/payments/PaymentRequestManager.h b/dom/payments/PaymentRequestManager.h index d0e1cb172a11..aead5cf7e9c5 100644 --- a/dom/payments/PaymentRequestManager.h +++ b/dom/payments/PaymentRequestManager.h @@ -48,15 +48,14 @@ public: nsresult CanMakePayment(PaymentRequest* aRequest); nsresult ShowPayment(PaymentRequest* aRequest); - nsresult AbortPayment(PaymentRequest* aRequest, bool aDeferredShow); + nsresult AbortPayment(PaymentRequest* aRequest); nsresult CompletePayment(PaymentRequest* aRequest, const PaymentComplete& aComplete, bool aTimedOut = false); nsresult UpdatePayment(JSContext* aCx, PaymentRequest* aRequest, const PaymentDetailsUpdate& aDetails, - bool aRequestShipping, - bool aDeferredShow); + bool aRequestShipping); nsresult ClosePayment(PaymentRequest* aRequest); nsresult RetryPayment(JSContext* aCx, PaymentRequest* aRequest, diff --git a/dom/payments/PaymentRequestService.cpp b/dom/payments/PaymentRequestService.cpp index 392272ecc0eb..edbdc862f54e 100644 --- a/dom/payments/PaymentRequestService.cpp +++ b/dom/payments/PaymentRequestService.cpp @@ -279,7 +279,8 @@ PaymentRequestService::RequestPayment(const nsAString& aRequestId, break; } case IPCPaymentActionRequest::TIPCPaymentShowActionRequest: { - rv = ShowPayment(aRequestId); + const IPCPaymentShowActionRequest& action = aAction; + rv = ShowPayment(aRequestId, action.isUpdating()); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } @@ -316,21 +317,18 @@ PaymentRequestService::RequestPayment(const nsAString& aRequestId, if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } - - // mShowingRequest exists and it equals to the updated PaymentRequest - // Call UI::UpdatePayment - if (mShowingRequest && mShowingRequest == request) { - rv = LaunchUIAction(aRequestId, type); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } - } else { - // mShowingRequest does not equal to the updated PaymentRequest, try to - // show the updated one. - rv = ShowPayment(aRequestId); - if (NS_WARN_IF(NS_FAILED(rv))) { - return rv; - } + nsAutoString completeStatus; + rv = request->GetCompleteStatus(completeStatus); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; + } + if (completeStatus.Equals(NS_LITERAL_STRING("initial"))) { + request->SetCompleteStatus(EmptyString()); + } + MOZ_ASSERT(mShowingRequest && mShowingRequest == request); + rv = LaunchUIAction(aRequestId, type); + if (NS_WARN_IF(NS_FAILED(rv))) { + return rv; } break; } @@ -516,7 +514,7 @@ PaymentRequestService::CanMakePayment(const nsAString& aRequestId) } nsresult -PaymentRequestService::ShowPayment(const nsAString& aRequestId) +PaymentRequestService::ShowPayment(const nsAString& aRequestId, bool aIsUpdating) { nsresult rv; RefPtr request; @@ -526,6 +524,9 @@ PaymentRequestService::ShowPayment(const nsAString& aRequestId) } MOZ_ASSERT(request); request->SetState(payments::PaymentRequest::eInteractive); + if (aIsUpdating) { + request->SetCompleteStatus(NS_LITERAL_STRING("initial")); + } if (mShowingRequest || !CanMakePayment(aRequestId)) { uint32_t responseStatus; diff --git a/dom/payments/PaymentRequestService.h b/dom/payments/PaymentRequestService.h index 1305b29fe4be..8b728ae38455 100644 --- a/dom/payments/PaymentRequestService.h +++ b/dom/payments/PaymentRequestService.h @@ -50,7 +50,7 @@ private: CanMakePayment(const nsAString& aRequestId); nsresult - ShowPayment(const nsAString& aRequestId); + ShowPayment(const nsAString& aRequestId, bool aIsUpdating); bool IsBasicCardPayment(const nsAString& aRequestId); diff --git a/dom/payments/PaymentRequestUpdateEvent.cpp b/dom/payments/PaymentRequestUpdateEvent.cpp index d5c631f949d2..4245174297cf 100644 --- a/dom/payments/PaymentRequestUpdateEvent.cpp +++ b/dom/payments/PaymentRequestUpdateEvent.cpp @@ -64,7 +64,7 @@ PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx, JS::HandleAbortUpdate(NS_ERROR_TYPE_ERR, false); + mRequest->AbortUpdate(NS_ERROR_TYPE_ERR); JS_ClearPendingException(aCx); return; } @@ -76,13 +76,13 @@ PaymentRequestUpdateEvent::ResolvedCallback(JSContext* aCx, JS::HandleIsValidDetailsUpdate(details, true/*aRequestShipping*/); if (NS_FAILED(rv)) { - mRequest->AbortUpdate(rv, false); + mRequest->AbortUpdate(rv); return; } // Update the PaymentRequest with the new details - if (NS_FAILED(mRequest->UpdatePayment(aCx, details, false))) { - mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR, false); + if (NS_FAILED(mRequest->UpdatePayment(aCx, details))) { + mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR); return; } mWaitForUpdate = false; @@ -94,7 +94,7 @@ PaymentRequestUpdateEvent::RejectedCallback(JSContext* aCx, JS::HandleAbortUpdate(NS_ERROR_DOM_ABORT_ERR, false); + mRequest->AbortUpdate(NS_ERROR_DOM_ABORT_ERR); mWaitForUpdate = false; mRequest->SetUpdating(false); } diff --git a/dom/payments/ipc/PPaymentRequest.ipdl b/dom/payments/ipc/PPaymentRequest.ipdl index 0a20f91af9e8..cb6de4b4cb1e 100644 --- a/dom/payments/ipc/PPaymentRequest.ipdl +++ b/dom/payments/ipc/PPaymentRequest.ipdl @@ -87,6 +87,7 @@ struct IPCPaymentCanMakeActionRequest struct IPCPaymentShowActionRequest { nsString requestId; + bool isUpdating; }; struct IPCPaymentAbortActionRequest From 7ed3a1055dd2930802e45c74c3bf6027c95faab4 Mon Sep 17 00:00:00 2001 From: Eden Chuang Date: Wed, 21 Nov 2018 11:17:45 +0100 Subject: [PATCH 03/13] Bug 1501823 - mochitest update for bug 1501823. r=baku --- dom/payments/test/ShowPaymentChromeScript.js | 112 +++-- dom/payments/test/test_showPayment.html | 491 ++++++++++--------- 2 files changed, 334 insertions(+), 269 deletions(-) diff --git a/dom/payments/test/ShowPaymentChromeScript.js b/dom/payments/test/ShowPaymentChromeScript.js index 2d980aed0b9e..4d86a4d52074 100644 --- a/dom/payments/test/ShowPaymentChromeScript.js +++ b/dom/payments/test/ShowPaymentChromeScript.js @@ -6,15 +6,12 @@ const { XPCOMUtils } = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); const paymentSrv = Cc["@mozilla.org/dom/payments/payment-request-service;1"].getService(Ci.nsIPaymentRequestService); -let expectedCompleteStatus = null; -let expectedShowAction = "accept"; -let expectedUpdateAction = "accept"; function emitTestFail(message) { - sendAsyncMessage("test-fail", message); + sendAsyncMessage("test-fail", `${DummyUIService.testName}: ${message}`); } function emitTestPass(message) { - sendAsyncMessage("test-pass", message); + sendAsyncMessage("test-pass", `${DummyUIService.testName}: ${message}`); } const shippingAddress = Cc["@mozilla.org/dom/payments/payment-address;1"]. @@ -68,24 +65,29 @@ function rejectShow(requestId) { } function updateShow(requestId) { - if (expectedUpdateAction == "updateaddress") { + if (DummyUIService.expectedUpdateAction == "updateaddress") { paymentSrv.changeShippingAddress(requestId, shippingAddress); - } else if (expectedUpdateAction == "accept" || expectedUpdateAction == "error"){ + } else if (DummyUIService.expectedUpdateAction == "accept" || + DummyUIService.expectedUpdateAction == "error"){ paymentSrv.changeShippingOption(requestId, "FastShipping"); } else { - emitTestFail("Unknown expected update action: " + expectedUpdateAction); + emitTestFail("Unknown expected update action: " + DummyUIService.expectedUpdateAction); } } function showRequest(requestId) { - if (expectedShowAction == "accept") { + const request = paymentSrv.getPaymentRequestById(requestId); + if (request.completeStatus == "initial") { + return; + } + if (DummyUIService.expectedShowAction == "accept") { acceptShow(requestId); - } else if (expectedShowAction == "reject") { + } else if (DummyUIService.expectedShowAction == "reject") { rejectShow(requestId); - } else if (expectedShowAction == "update") { + } else if (DummyUIService.expectedShowAction == "update") { updateShow(requestId); } else { - emitTestFail("Unknown expected show action: " + expectedShowAction); + emitTestFail("Unknown expected show action: " + DummyUIService.expectedShowAction); } } @@ -97,14 +99,14 @@ function abortRequest(requestId) { } function completeRequest(requestId) { - let payRequest = paymentSrv.getPaymentRequestById(requestId); - if (expectedCompleteStatus) { - if (payRequest.completeStatus == expectedCompleteStatus) { + let request = paymentSrv.getPaymentRequestById(requestId); + if (DummyUIService.expectedCompleteStatus) { + if (request.completeStatus == DummyUIService.expectedCompleteStatus) { emitTestPass("request.completeStatus matches expectation of " + - expectedCompleteStatus); + DummyUIService.expectedCompleteStatus); } else { emitTestFail("request.completeStatus incorrect. Expected " + - expectedCompleteStatus + ", got " + payRequest.completeStatus); + DummyUIService.expectedCompleteStatus + ", got " + request.completeStatus); } } let completeResponse = Cc["@mozilla.org/dom/payments/payment-complete-action-response;1"]. @@ -115,7 +117,10 @@ function completeRequest(requestId) { function updateRequest(requestId) { let request = paymentSrv.getPaymentRequestById(requestId); - if (expectedUpdateAction == "accept") { + if (request.completeStatus !== "") { + emitTestFail("request.completeStatus should be empty, but got '" + request.completeStatus + "'."); + } + if (DummyUIService.expectedUpdateAction == "accept") { if (request.paymentDetails.error != "") { emitTestFail("updatedDetails should not have errors(" + request.paymentDetails.error + ")."); } @@ -129,23 +134,27 @@ function updateRequest(requestId) { emitTestFail(shippingOption.label + " should be selected."); } acceptShow(requestId); - } else if (expectedUpdateAction == "error") { + } else if (DummyUIService.expectedUpdateAction == "error") { if (request.paymentDetails.error != "Update with Error") { emitTestFail("details.error should be 'Update with Error', but got " + request.paymentDetails.error + "."); } rejectShow(requestId); - } else if (expectedUpdateAction == "updateaddress") { + } else if (DummyUIService.expectedUpdateAction == "updateaddress") { if (request.paymentDetails.error != "") { emitTestFail("updatedDetails should not have errors(" + request.paymentDetails.error + ")."); } - expectedUpdateAction = "accept"; + DummyUIService.expectedUpdateAction = "accept"; paymentSrv.changeShippingOption(requestId, "FastShipping"); } else { - emitTestFail("Unknown expected update aciton: " + expectedUpdateAction); + emitTestFail("Unknown expected update aciton: " + DummyUIService.expectedUpdateAction); } } const DummyUIService = { + testName: "", + expectedCompleteStatus: null, + expectedShowAction: "accept", + expectedUpdateAction: "accept", showPayment: showRequest, abortPayment: abortRequest, completePayment: completeRequest, @@ -214,48 +223,61 @@ function testShowResponseInit() { sendAsyncMessage("test-show-response-init-complete"); } -addMessageListener("set-simple-ui-service", function() { - expectedCompleteStatus = null; - expectedShowAction = "accept"; - expectedUpdateAction = "accept"; +addMessageListener("set-simple-ui-service", function(testName) { + DummyUIService.testName = testName; + DummyUIService.expectedCompleteStatus = null; + DummyUIService.expectedShowAction = "accept"; + DummyUIService.expectedUpdateAction = "accept"; + sendAsyncMessage("set-simple-ui-service-complete"); }); -addMessageListener("set-normal-ui-service", function() { - expectedCompleteStatus = null; - expectedShowAction = "update"; - expectedUpdateAction = "updateaddress"; +addMessageListener("set-normal-ui-service", function(testName) { + DummyUIService.testName = testName; + DummyUIService.expectedCompleteStatus = null; + DummyUIService.expectedShowAction = "update"; + DummyUIService.expectedUpdateAction = "updateaddress"; + sendAsyncMessage("set-normal-ui-service-complete"); }); -addMessageListener("set-reject-ui-service", function() { - expectedCompleteStatus = null; - expectedShowAction = "reject"; - expectedUpdateAction = "accept"; +addMessageListener("set-reject-ui-service", function(testName) { + DummyUIService.testName = testName; + DummyUIService.expectedCompleteStatus = null; + DummyUIService.expectedShowAction = "reject"; + DummyUIService.expectedUpdateAction = "error"; + sendAsyncMessage("set-reject-ui-service-complete"); }); -addMessageListener("set-update-with-ui-service", function() { - expectedCompleteStatus = null; - expectedShowAction = "update"; - expectedUpdateAction = "accept"; +addMessageListener("set-update-with-ui-service", function(testName) { + DummyUIService.testName = testName; + DummyUIService.expectedCompleteStatus = null; + DummyUIService.expectedShowAction = "update"; + DummyUIService.expectedUpdateAction = "accept"; + sendAsyncMessage("set-update-with-ui-service-complete"); }); -addMessageListener("set-update-with-error-ui-service", function() { - expectedCompleteStatus = null; - expectedShowAction = "update"; - expectedUpdateAction = "error"; +addMessageListener("set-update-with-error-ui-service", function(testName) { + DummyUIService.testName = testName; + DummyUIService.expectedCompleteStatus = null; + DummyUIService.expectedShowAction = "update"; + DummyUIService.expectedUpdateAction = "error"; + sendAsyncMessage("set-update-with-error-ui-service-complete"); }); addMessageListener("test-show-response-init", testShowResponseInit); addMessageListener("set-complete-status-success", function() { - expectedCompleteStatus = "success"; + DummyUIService.expectedCompleteStatus = "success"; + sendAsyncMessage("set-complete-status-success-complete"); }); addMessageListener("set-complete-status-fail", function() { - expectedCompleteStatus = "fail"; + DummyUIService.expectedCompleteStatus = "fail"; + sendAsyncMessage("set-complete-status-fail-complete"); }); addMessageListener("set-complete-status-unknown", function() { - expectedCompleteStatus = "unknown"; + DummyUIService.expectedCompleteStatus = "unknown"; + sendAsyncMessage("set-complete-status-unknown-complete"); }); addMessageListener("teardown", function() { diff --git a/dom/payments/test/test_showPayment.html b/dom/payments/test/test_showPayment.html index de957679c6d0..75c60c8764d0 100644 --- a/dom/payments/test/test_showPayment.html +++ b/dom/payments/test/test_showPayment.html @@ -25,6 +25,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345366 gScript.addMessageListener("test-fail", testFailHandler); gScript.addMessageListener("test-pass", testPassHandler); + async function requestChromeAction(action, params) { + await new Promise(resolve => { + gScript.addMessageListener(`${action}-complete`, function completeListener() { + gScript.removeMessageListener(`${action}-complete`, completeListener); + resolve(); + }); + gScript.sendAsyncMessage(action, params); + }); + } + // testing data declaration // default parameters for PaymentRequest construction const defaultMethods = [{ @@ -127,303 +137,335 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345366 // checking functions - function checkAddress(address, fromEvent) { - is(address.country, "USA", "address.country should be 'USA'."); - is(address.region, "CA", "address.region should be 'CA'."); - is(address.city, "San Bruno", "address.city should be 'San Bruno'."); - is(address.dependentLocality, "Test locality", - "address.dependentLocality should be 'Test locality'."); - is(address.postalCode, "94066", "address.postalCode should be '94066'."); - is(address.sortingCode, "123456", "address.sortingCode should be '123456'."); + function checkAddress(testName, address, fromEvent) { + is(address.country, + "USA", + `${testName}: address.country should be 'USA'.`); + is(address.region, + "CA", + `${testName}: address.region should be 'CA'.`); + is(address.city, + "San Bruno", + `${testName}: address.city should be 'San Bruno'.`); + is(address.dependentLocality, + "Test locality", + `${testName}: address.dependentLocality should be 'Test locality'.`); + is(address.postalCode, + "94066", + `${testName}: address.postalCode should be '94066'.`); + is(address.sortingCode, + "123456", + `${testName}: address.sortingCode should be '123456'.`); if (fromEvent) { - is(address.addressLine.length, 0, "address.addressLine.length should be 0 from event."); - is(address.organization, "", "address.organization should be empty from event."); - is(address.recipient, "", "address.recipient should be empty from event."); - is(address.phone, "", "address.phone should be empty from event."); + is(address.addressLine.length, + 0, + `${testName}: address.addressLine.length should be 0 from event.`); + is(address.organization, + "", + `${testName}: address.organization should be empty from event.`); + is(address.recipient, + "", + `${testName}: address.recipient should be empty from event.`); + is(address.phone, + "", + `${testName}: address.phone should be empty from event.`); } else { - is(address.addressLine.length, 1, "address.addressLine.length should be 1 from promise."); - is(address.addressLine[0], "Easton Ave", "address.addressLine[0] should be 'Easton Ave' from promise."); - is(address.organization, "Testing Org", "address.organization should be 'Testing Org' from promise."); - is(address.recipient, "Bill A. Pacheco", "address.recipient should be 'Bill A. Pacheco' from promise."); - is(address.phone, "+1-434-441-3879", "address.phone should be '+1-434-441-3879' from promise."); + is(address.addressLine.length, + 1, + `${testName}: address.addressLine.length should be 1 from promise.`); + is(address.addressLine[0], + "Easton Ave", + `${testName}: address.addressLine[0] should be 'Easton Ave' from promise.`); + is(address.organization, + "Testing Org", + `${testName}: address.organization should be 'Testing Org' from promise.`); + is(address.recipient, + "Bill A. Pacheco", + `${testName}: address.recipient should be 'Bill A. Pacheco' from promise.`); + is(address.phone, + "+1-434-441-3879", + `${testName}: address.phone should be '+1-434-441-3879' from promise.`); } } - function checkResponse(response) { - is(response.requestId, "test payment", "response.requestId should be 'test payment'."); - is(response.methodName, "testing-payment-method", "response.methodName should be 'testing-payment-method'."); - is(response.details.paymentToken, "6880281f-0df3-4b8e-916f-66575e2457c1", "response.details.paymentToken should be '6880281f-0df3-4b8e-916f-66575e2457c1'."); - checkAddress(response.shippingAddress, false/*fromEvent*/); - is(response.shippingOption, "FastShipping", "response.shippingOption should be 'FastShipping'."); - is(response.payerName, "Bill A. Pacheco", "response.payerName should be 'Bill A. Pacheco'."); - ok(!response.payerEmail, "response.payerEmail should be empty"); - ok(!response.payerPhone, "response.payerPhone should be empty"); + function checkResponse(testName, response) { + is(response.requestId, + "test payment", + `${testName}: response.requestId should be 'test payment'.`); + is(response.methodName, + "testing-payment-method", + `${testName}: response.methodName should be 'testing-payment-method'.`); + is(response.details.paymentToken, + "6880281f-0df3-4b8e-916f-66575e2457c1", + `${testName}: response.details.paymentToken should be '6880281f-0df3-4b8e-916f-66575e2457c1'.`); + checkAddress(testName, response.shippingAddress, false/*fromEvent*/); + is(response.shippingOption, + "FastShipping", + `${testName}: response.shippingOption should be 'FastShipping'.`); + is(response.payerName, + "Bill A. Pacheco", + `${testName}: response.payerName should be 'Bill A. Pacheco'.`); + ok(!response.payerEmail, + `${testName}: response.payerEmail should be empty`); + ok(!response.payerPhone, + `${testName}: response.payerPhone should be empty`); } // testing functions - function testShowNormalFlow() { - gScript.sendAsyncMessage("set-normal-ui-service"); - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); - payRequest.addEventListener("shippingaddresschange", event => { - checkAddress(payRequest.shippingAddress, true/*fromEvent*/); + async function testShowNormalFlow() { + const testName = "testShowNormalFlow"; + await requestChromeAction("set-normal-ui-service", testName); + return new Promise(async (resolve) => { + const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); + request.addEventListener("shippingaddresschange", event => { + checkAddress(testName, request.shippingAddress, true/*fromEvent*/); event.updateWith(updateWithPromise(defaultDetails)); }); - payRequest.addEventListener("shippingoptionchange", event => { + request.addEventListener("shippingoptionchange", event => { event.updateWith(updateWithPromise(updatedShippingOptionsDetails)); }); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); - payRequest.show().then(response => { - checkResponse(response, false); - checkAddress(payRequest.shippingAddress, false); - response.complete().then(() =>{ - resolve(); - }).catch(e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }); - }).catch( e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }).finally(handler.destruct); + try { + let response = await request.show(); + checkResponse(testName, response, false); + await response.complete(); + } catch (error) { + ok(false, `${testName} Unexpected error: ${e.name}`); + } + await handler.destruct(); + resolve(); }); } // testing show with nonsupported methods - function testCannotMakePaymentShow() { - gScript.sendAsyncMessage("set-simple-ui-service"); - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(nonSupportedMethods, defaultDetails); + async function testCannotMakePaymentShow() { + const testName = "testCannotMakePaymentShow"; + await requestChromeAction("set-simple-ui-service", testName); + return new Promise(async (resolve) => { + const request = new PaymentRequest(nonSupportedMethods, defaultDetails); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); - payRequest.canMakePayment().then(result => { - ok(!result, "canMakePayment() should return false, but got " + result + "."); - payRequest.show().then( () => { - ok(false, "Should be rejected with 'NotSupportedError', but got resolved"); - resolve(); - }).catch( e => { - is(e.name, "NotSupportedError", "Should be rejected with 'NotSupportedError', but got " + e.name + "."); - resolve(); - }); - }).finally(handler.destruct); + let result = await request.canMakePayment(); + ok(!result, `${testName}: canMakePayment() should return false.`); + try { + await request.show(); + ok(false, `${testName}: should be rejected with 'NotSupportedError' but got resolved.`); + } catch (error) { + is(error.name, "NotSupportedError", `${testName}: should be rejected with 'NotSupportedError'.`); + } + await handler.destruct(); + resolve(); }); } // testing show rejected by user - function testRejectShow() { - gScript.sendAsyncMessage("set-reject-ui-service"); - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); + async function testRejectShow() { + const testName = "testRejectShow"; + await requestChromeAction("set-reject-ui-service", testName); + return new Promise(async(resolve) => { + const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); - payRequest.show().then((result) => { - ok(false, "Should be rejected with 'AbortError', but got resolved"); - resolve(); - }, (result) => { - is(result.name, "AbortError", "Should be rejected with 'AbortError', but got " + result.name + "."); - resolve(); - }).catch(e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }).finally(handler.destruct); + try { + await request.show(); + ok(false, `${testName}: Should be rejected with 'AbortError' but got resolved.`); + } catch(error) { + is(error.name, "AbortError", `${testName}: Should be rejected with 'AbortError'.`); + } + await handler.destruct(); + resolve(); }); } // testing PaymentResponse.complete() with specified result - function testCompleteStatus(result) { - gScript.sendAsyncMessage("set-simple-ui-service"); + async function testCompleteStatus(testName, result) { + await requestChromeAction("set-simple-ui-service", testName); if (result) { - gScript.sendAsyncMessage("set-complete-status-"+result); + await requestChromeAction(`set-complete-status-${result}`); } else { - gScript.sendAsyncMessage("set-complete-status-unknown"); + await requestChromeAction(`set-complete-status-unknown`); } - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); + return new Promise(async (resolve) => { + const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); - payRequest.show().then(response => { - response.complete(result).then(() => { - resolve(); - }).catch(e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }); - }).catch( e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }).finally(handler.destruct); + try { + let response = await request.show(); + await response.complete(result); + } catch (error) { + ok(false, `${testName}: Unexpected error ${error.name}.`); + } + await handler.destruct(); + resolve(); }); } - function testCompleteFail() { - return testCompleteStatus("fail"); + async function testCompleteFail() { + const testName = "testCompleteFail"; + return testCompleteStatus(testName, "fail"); } - function testCompleteSuccess() { - return testCompleteStatus("success"); + async function testCompleteSuccess() { + const testName = "testCompleteSuccess"; + return testCompleteStatus(testName, "success"); } - function testCompleteUnknown() { - return testCompleteStatus("unknown"); + async function testCompleteUnknown() { + const testName = "testCompleteUnknown" + return testCompleteStatus(testName, "unknown"); } - function testCompleteEmpty() { - return testCompleteStatus(); + async function testCompleteEmpty() { + const testName = "testCompleteEmpty"; + return testCompleteStatus(testName); } // testing PaymentRequestUpdateEvent.updateWith with specified details and error - function testUpdateWith(detailsUpdate, expectedError) { + async function testUpdateWith(testName, detailsUpdate, expectedError) { if (expectedError) { - gScript.sendAsyncMessage("set-update-with-error-ui-service"); + await requestChromeAction("set-update-with-error-ui-service", testName); } else { - gScript.sendAsyncMessage("set-update-with-ui-service"); + await requestChromeAction("set-update-with-ui-service", testName); } - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); - payRequest.addEventListener("shippingaddresschange", event => { + return new Promise(async (resolve) => { + const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); + request.addEventListener("shippingaddresschange", event => { event.updateWith(updateWithPromise(detailsUpdate)); }); - payRequest.addEventListener("shippingoptionchange", event => { + request.addEventListener("shippingoptionchange", event => { event.updateWith(updateWithPromise(detailsUpdate)); }); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); - payRequest.show().then(response => { + try { + const response = await request.show(); if (expectedError) { - ok(false, "Should be rejected with " + expectedError + ", but got resolved"); - resolve(); - } else { - response.complete("success").then(() => { - resolve(); - }) - } - }, response => { + ok(false, `${testName}: Should be rejected with ${expectedError} but got resolved.`); + } else { + await response.complete("success"); + } + } catch(error) { if (expectedError) { - is(response.name, expectedError, - "Should be rejected with " + expectedError + ", but got " + response.name); - } else { - ok(false, "Unexpected error: " + response.name); - } - resolve(); - }).catch(e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }).finally(handler.destruct); + is(error.name, expectedError, `${testName}: Should be rejected with ${expectedError}.`); + } else { + ok(false, `${testName}: Unexpected error ${error.name}.`); + } + } + await handler.destruct(); + resolve(); }); } - function testUpdateWithReject() { - return testUpdateWith(null, "AbortError"); + async function testUpdateWithReject() { + const testName = "testUpdateWithReject"; + return testUpdateWith(testName, null, "AbortError"); } - function testUpdateWithValidDetails() { - return testUpdateWith(updatedShippingOptionsDetails, null); + async function testUpdateWithValidDetails() { + const testName = "testUpdateWithValidDetails"; + return testUpdateWith(testName, updatedShippingOptionsDetails, null); } - function testUpdateWithInvalidDetails() { - return testUpdateWith({total: "invalid details"}, "TypeError"); + async function testUpdateWithInvalidDetails() { + const testName = "testUpdateWithInvalidDetails"; + return testUpdateWith(testName, {total: "invalid details"}, "TypeError"); } - function testUpdateWithError() { - return testUpdateWith(updatedErrorDetails, "AbortError"); + async function testUpdateWithError() { + const testName = "testUpdateWithError"; + return testUpdateWith(testName, updatedErrorDetails, "AbortError"); } // testing show with detailsUpdate promise - function testShowWithDetailsPromise(detailsUpdate, expectedError) { + async function testShowWithDetailsPromise(testName, detailsUpdate, expectedError) { if (expectedError) { - gScript.sendAsyncMessage("set-reject-ui-service"); + await requestChromeAction("set-reject-ui-service", testName); } else { - gScript.sendAsyncMessage("set-simple-ui-service"); + await requestChromeAction("set-simple-ui-service", testName); } - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); - ok(!payRequest.shippingOption, "payRequest.shippingOption should be null."); + return new Promise(async (resolve) => { + const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); + ok(!request.shippingOption, `${testName}: request.shippingOption should be null.`); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); - payRequest.show(updateWithPromise(detailsUpdate)).then(response => { + try { + let response = await request.show(updateWithPromise(detailsUpdate)); if (expectedError) { - ok(false, "Should be rejected with " + expectedError + ", but got resolved"); - resolve(); - } else { - ok(response.shippingOption, "response.shippingOption should not be null."); - response.complete().then(() => { - resolve(); - }) - } - }, response => { + ok(false, `${testName}: Should be rejected with ${expectedError} but got resolved.`); + } else { + ok(response.shippingOption, + `${testName}: response.shippingOption should not be null.`); + } + await response.complete(); + } catch(error) { if (expectedError) { - is(response.name, expectedError, - "Should be rejected with " + expectedError + ", but got " + response.name); - } else { - ok(false, "Unexpected error: " + response.name); - } - resolve(); - }).catch(e => { - ok(false, "Unexpected error: " + e.name); - resolve(); - }).finally(handler.destruct); + is(error.name, expectedError, `${testName}: Should be rejected with ${expectedError}.`); + } else { + ok(false, `${testName}: Unexpected error ${error.name}.`); + } + } + await handler.destruct(); + resolve(); }); } - function testShowWithValidPromise() { - return testShowWithDetailsPromise(updatedShippingOptionsDetails, null); + async function testShowWithValidPromise() { + const testName = "testShowWithValidPromise"; + return testShowWithDetailsPromise(testName, updatedShippingOptionsDetails, null); } - function testShowWithRejectedPromise() { - return testShowWithDetailsPromise(null, "AbortError"); + async function testShowWithRejectedPromise() { + const testName = "testShowWithRejectedPromise"; + return testShowWithDetailsPromise(testName, null, "AbortError"); } - function testShowWithInvalidPromise() { - return testShowWithDetailsPromise({total: "invalid details"}, "TypeError"); + async function testShowWithInvalidPromise() { + const testName = "testShowWithInvalidPromise"; + return testShowWithDetailsPromise(testName, {total: "invalid details"}, "TypeError"); } - function testShowWithErrorPromise() { - return testShowWithDetailsPromise(updatedErrorDetails, "AbortError"); + async function testShowWithErrorPromise() { + const testName = "testShowWithErrorPromise"; + return testShowWithDetailsPromise(testName, updatedErrorDetails, "AbortError"); } - function testShowWithPromiseResolvedByRejectedPromise() { - gScript.sendAsyncMessage("set-reject-ui-service"); - return new Promise((resolve, reject)=> { + async function testShowWithPromiseResolvedByRejectedPromise() { + const testName = "testShowWithPromiseResolvedByRejectedPromise"; + await requestChromeAction("set-reject-ui-service", testName); + return new Promise(async (resolve)=> { const request = new PaymentRequest(defaultMethods, defaultDetails, defaultOptions); const handler = SpecialPowers.getDOMWindowUtils(window).setHandlingUserInput(true); let rejectPromise = Promise.reject(new TypeError()); let detailsUpdatePromise = Promise.resolve(rejectPromise); - request.show(detailsUpdatePromise).then(response => { - ok(false, "should be rejected with 'AbortError', but got resolved."); - resolve(); - }, response => { - is(response.name, "AbortError", "Exepcted 'AbortError', but got " + response.name + "."); - resolve(); - }).catch(error => { - ok(false, "Unexpected error: " + error.name + "."); - }).finally(handler.destruct); + try { + await request.show(detailsUpdatePromise); + ok(false, `${testName}: should be rejected with AbortError but got resolved.`); + } catch(error) { + is(error.name, "AbortError", `${testName}: should be rejected with AbortError.`); + } + await handler.destruct(); + resolve(); }); } // testing show response initialization in chrome process - function testShowResponseInit() { - return new Promise((resolve, reject) => { - gScript.addMessageListener("test-show-response-init-complete", - function showResponseInitCompleteHandler() { - gScript.removeMessageListener("test-show-response-init-complete", - showResponseInitCompleteHandler); - resolve(); - }); - gScript.sendAsyncMessage("test-show-response-init"); - }); + async function testShowResponseInit() { + const testName = "testShowResponseInit"; + await requestChromeAction("test-show-response-init", testName); } // testing show that is not triggered by user. - function testShowNotTriggeredByUser() { - gScript.sendAsyncMessage("set-simple-ui-service"); - return new Promise((resolve, reject) => { - const payRequest = new PaymentRequest(defaultMethods, defaultDetails); - payRequest.show().then(() => { - ok(false, "Expected 'SecurityError', but got resolved") - resolve(); - }).catch((err) => { - is(err.name, "SecurityError", `Should be rejected with 'SecurityError', but got ${err.name}`); - resolve(); - }); + async function testShowNotTriggeredByUser() { + const testName = "testShowNotTriggeredByUser"; + await requestChromeAction("set-simple-ui-service", testName); + return new Promise(async (resolve) => { + const request = new PaymentRequest(defaultMethods, defaultDetails); + try { + await request.show(); + ok(false, `${testName}: should be rejected with SecurityError, but got resolved.`); + } catch (error) { + is(error.name, "SecurityError", `${testName}: should be rejected with SecurityError.`); + } + resolve(); }); } // teardown function - function teardown() { + async function teardown() { gScript.addMessageListener("teardown-complete", function teardownCompleteHandler() { gScript.removeMessageListener("teardown-complete", teardownCompleteHandler); gScript.removeMessageListener("test-fail", testFailHandler); @@ -435,30 +477,31 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345366 } // test main body - function runTests() { - testCannotMakePaymentShow() - .then(testRejectShow) - .then(testShowNormalFlow) - .then(testCompleteSuccess) - .then(testCompleteFail) - .then(testCompleteUnknown) - .then(testCompleteEmpty) - .then(testUpdateWithReject) - .then(testUpdateWithValidDetails) - .then(testUpdateWithInvalidDetails) - .then(testUpdateWithError) - .then(testShowWithValidPromise) - .then(testShowWithInvalidPromise) - .then(testShowWithRejectedPromise) - .then(testShowWithErrorPromise) - .then(testShowWithPromiseResolvedByRejectedPromise) - .then(testShowResponseInit) - .then(testShowNotTriggeredByUser) - .then(teardown) - .catch( e => { - ok(false, "Unexpected error: " + e.name); + async function runTests() { + try { + await testCannotMakePaymentShow(); + await testRejectShow(); + await testShowNormalFlow(); + await testCompleteSuccess(); + await testCompleteFail(); + await testCompleteUnknown(); + await testCompleteEmpty(); + await testUpdateWithReject(); + await testUpdateWithValidDetails(); + await testUpdateWithInvalidDetails(); + await testUpdateWithError(); + await testShowWithValidPromise(); + await testShowWithInvalidPromise(); + await testShowWithRejectedPromise(); + await testShowWithErrorPromise(); + await testShowWithPromiseResolvedByRejectedPromise(); + await testShowResponseInit(); + await testShowNotTriggeredByUser(); + await teardown(); + } catch (error) { + ok(false, `test_showPayment: Unexpected error: ${error.name}`); SimpleTest.finish(); - }); + } } window.addEventListener('load', function() { From b6193df82f4892f4bd71ea501bbafbfefc64e2e7 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Wed, 29 Aug 2018 18:00:05 -0400 Subject: [PATCH 04/13] Bug 1487249 - Part 1: Allow MessageChannel objects to be created within a thread, r=mccr8 To create a more generic interface for interacting both within the main thread of the parent process and between the parent and child processes, it would be nice to support IPDL actors within the main thread of the parent process. This requires the underlying MessageChannel actor to support intra-thread links. This change adds support for intra-thread links to the underlying MessageChannel object using ThreadLink, and an extra boolean flag. Differential Revision: https://phabricator.services.mozilla.com/D4620 --- ipc/glue/MessageChannel.cpp | 43 ++++++++++++++++++++++++++++++++++++- ipc/glue/MessageChannel.h | 28 +++++++++++++++++++++--- ipc/glue/ProtocolUtils.cpp | 7 ++++++ ipc/glue/ProtocolUtils.h | 9 ++++++++ 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index d092ab07b3ef..76242c7a2b79 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -634,7 +634,8 @@ MessageChannel::MessageChannel(const char* aName, mPeerPidSet(false), mPeerPid(-1), mIsPostponingSends(false), - mBuildIDsConfirmedMatch(false) + mBuildIDsConfirmedMatch(false), + mIsSameThreadChannel(false) { MOZ_COUNT_CTOR(ipc::MessageChannel); @@ -966,6 +967,35 @@ MessageChannel::CommonThreadOpenInit(MessageChannel *aTargetChan, Side aSide) mSide = aSide; } +bool +MessageChannel::OpenOnSameThread(MessageChannel* aTargetChan, + mozilla::ipc::Side aSide) +{ + CommonThreadOpenInit(aTargetChan, aSide); + + Side oppSide = UnknownSide; + switch (aSide) { + case ChildSide: oppSide = ParentSide; break; + case ParentSide: oppSide = ChildSide; break; + case UnknownSide: break; + } + mIsSameThreadChannel = true; + + // XXX(nika): Avoid setting up a monitor for same thread channels? We + // shouldn't need it. + mMonitor = new RefCountedMonitor(); + + mChannelState = ChannelOpening; + aTargetChan->CommonThreadOpenInit(this, oppSide); + + aTargetChan->mIsSameThreadChannel = true; + aTargetChan->mMonitor = mMonitor; + + mChannelState = ChannelConnected; + aTargetChan->mChannelState = ChannelConnected; + return true; +} + bool MessageChannel::Echo(Message* aMsg) { @@ -1475,6 +1505,8 @@ MessageChannel::Send(Message* aMsg, Message* aReply) // Sanity checks. AssertWorkerThread(); mMonitor->AssertNotCurrentThreadOwns(); + MOZ_RELEASE_ASSERT(!mIsSameThreadChannel, + "sync send over same-thread channel will deadlock!"); #ifdef OS_WIN SyncStackFrame frame(this, false); @@ -1680,6 +1712,8 @@ MessageChannel::Call(Message* aMsg, Message* aReply) UniquePtr msg(aMsg); AssertWorkerThread(); mMonitor->AssertNotCurrentThreadOwns(); + MOZ_RELEASE_ASSERT(!mIsSameThreadChannel, + "intr call send over same-thread channel will deadlock!"); #ifdef OS_WIN SyncStackFrame frame(this, true); @@ -2456,6 +2490,9 @@ MessageChannel::WaitForSyncNotify(bool /* aHandleWindowsMessages */) } #endif + MOZ_RELEASE_ASSERT(!mIsSameThreadChannel, + "Wait on same-thread channel will deadlock!"); + TimeDuration timeout = (kNoTimeout == mTimeoutMs) ? TimeDuration::Forever() : TimeDuration::FromMilliseconds(mTimeoutMs); @@ -2768,6 +2805,10 @@ MessageChannel::SynchronouslyClose() AssertWorkerThread(); mMonitor->AssertCurrentThreadOwns(); mLink->SendClose(); + + MOZ_RELEASE_ASSERT(!mIsSameThreadChannel || ChannelClosed == mChannelState, + "same-thread channel failed to synchronously close?"); + while (ChannelClosed != mChannelState) mMonitor->Wait(); } diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index 99385e936cd1..983ab56c47a9 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -180,6 +180,15 @@ private: // in MessageChannel.cpp. bool Open(MessageChannel *aTargetChan, nsIEventTarget *aEventTarget, Side aSide); + // "Open" a connection to an actor on the current thread. + // + // Returns true if the transport layer was successfully connected, + // i.e., mChannelState == ChannelConnected. + // + // Same-thread channels may not perform synchronous or blocking message + // sends, to avoid deadlocks. + bool OpenOnSameThread(MessageChannel* aTargetChan, Side aSide); + // Close the underlying transport channel. void Close(); @@ -564,11 +573,20 @@ private: "not on worker thread!"); } - // The "link" thread is either the I/O thread (ProcessLink) or the - // other actor's work thread (ThreadLink). In either case, it is - // NOT our worker thread. + // The "link" thread is either the I/O thread (ProcessLink), the other + // actor's work thread (ThreadLink), or the worker thread (same-thread + // channels). void AssertLinkThread() const { + if (mIsSameThreadChannel) { + // If we're a same-thread channel, we have to be on our worker + // thread. + AssertWorkerThread(); + return; + } + + // If we aren't a same-thread channel, our "link" thread is _not_ our + // worker thread! MOZ_ASSERT(mWorkerThread, "Channel hasn't been opened yet"); MOZ_RELEASE_ASSERT(mWorkerThread != GetCurrentVirtualThread(), "on worker thread but should not be!"); @@ -861,6 +879,10 @@ private: std::vector> mPostponedSends; bool mBuildIDsConfirmedMatch; + + // If this is true, both ends of this message channel have event targets + // on the same thread. + bool mIsSameThreadChannel; }; void diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index ad1d2ba3b7bc..729e16cb7491 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -781,6 +781,13 @@ IToplevelProtocol::OpenWithAsyncPid(mozilla::ipc::Transport* aTransport, return GetIPCChannel()->Open(aTransport, aThread, aSide); } +bool +IToplevelProtocol::OpenOnSameThread(MessageChannel* aChannel, Side aSide) +{ + SetOtherProcessId(base::GetCurrentProcId()); + return GetIPCChannel()->OpenOnSameThread(aChannel, aSide); +} + void IToplevelProtocol::Close() { diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 32e42abc7ed4..66d1bedd77b8 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -514,6 +514,15 @@ public: MessageLoop* aThread = nullptr, mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide); + // Open a toplevel actor such that both ends of the actor's channel are on + // the same thread. This method should be called on the thread to perform + // the link. + // + // WARNING: Attempting to send a sync or intr message on the same thread + // will crash. + bool OpenOnSameThread(MessageChannel* aChannel, + mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide); + void Close(); void SetReplyTimeoutMs(int32_t aTimeoutMs); From 8fe02851a63d78812eda6231feda7e855aa13e08 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Wed, 29 Aug 2018 18:18:04 -0400 Subject: [PATCH 05/13] Bug 1487249 - Part 2: Add a new PInProcess actor to manage intra-thread actors, r=mccr8 This will be useful as a basis for asynchronous actors which would like to exist both when crossing the process boundary (managed by PContent), and when displaying an in-process window. Differential Revision: https://phabricator.services.mozilla.com/D4622 --- ipc/glue/InProcessChild.cpp | 13 +++ ipc/glue/InProcessChild.h | 54 +++++++++ ipc/glue/InProcessImpl.cpp | 210 +++++++++++++++++++++++++++++++++++ ipc/glue/InProcessParent.cpp | 15 +++ ipc/glue/InProcessParent.h | 60 ++++++++++ ipc/glue/PInProcess.ipdl | 23 ++++ ipc/glue/moz.build | 6 + 7 files changed, 381 insertions(+) create mode 100644 ipc/glue/InProcessChild.cpp create mode 100644 ipc/glue/InProcessChild.h create mode 100644 ipc/glue/InProcessImpl.cpp create mode 100644 ipc/glue/InProcessParent.cpp create mode 100644 ipc/glue/InProcessParent.h create mode 100644 ipc/glue/PInProcess.ipdl diff --git a/ipc/glue/InProcessChild.cpp b/ipc/glue/InProcessChild.cpp new file mode 100644 index 000000000000..d0c2e9a98392 --- /dev/null +++ b/ipc/glue/InProcessChild.cpp @@ -0,0 +1,13 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/ipc/InProcessChild.h" + +namespace mozilla { +namespace ipc { + +} // namespace ipc +} // namespace mozilla diff --git a/ipc/glue/InProcessChild.h b/ipc/glue/InProcessChild.h new file mode 100644 index 000000000000..902bd9e5127f --- /dev/null +++ b/ipc/glue/InProcessChild.h @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ipc_InProcessChild_h +#define mozilla_ipc_InProcessChild_h + +#include "mozilla/ipc/PInProcessChild.h" +#include "mozilla/StaticPtr.h" + +namespace mozilla { +namespace ipc { + +class InProcessParent; + +/** + * The `InProcessChild` class represents the child half of a main-thread to + * main-thread actor. + * + * The `PInProcess` actor should be used as an alternate manager to `PContent` + * for async actors which want to communicate uniformly between Content->Chrome + * and Chrome->Chrome situations. + */ +class InProcessChild : public PInProcessChild +{ +public: + friend class InProcessParent; + + NS_INLINE_DECL_REFCOUNTING(InProcessChild) + + // Get the singleton instance of this actor. + static InProcessChild* Singleton(); + + // Get the parent side of the in-process child actor |aActor|. If |aActor| is + // not an in-process actor, or is not connected, this method will return + // |nullptr|. + static IProtocol* ParentActorFor(IProtocol* aActor); + +private: + // NOTE: PInProcess lifecycle management is declared as staic methods and + // state on InProcessParent, and implemented in InProcessImpl.cpp. + virtual void ActorDestroy(ActorDestroyReason aWhy) override; + virtual void DeallocPInProcessChild() override; + ~InProcessChild() = default; + + static StaticRefPtr sSingleton; +}; + +} // namespace ipc +} // namespace mozilla + +#endif // defined(mozilla_ipc_InProcessChild_h) diff --git a/ipc/glue/InProcessImpl.cpp b/ipc/glue/InProcessImpl.cpp new file mode 100644 index 000000000000..cc7e765c724c --- /dev/null +++ b/ipc/glue/InProcessImpl.cpp @@ -0,0 +1,210 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/ipc/InProcessParent.h" +#include "mozilla/ipc/InProcessChild.h" + +// This file contains the implementation of core InProcess lifecycle management +// facilities. + +namespace mozilla { +namespace ipc { + +StaticRefPtr InProcessParent::sSingleton; +StaticRefPtr InProcessChild::sSingleton; +bool InProcessParent::sShutdown = false; + + +////////////////////////////////////////// +// InProcess actor lifecycle management // +////////////////////////////////////////// + +/* static */ InProcessChild* +InProcessChild::Singleton() { + MOZ_ASSERT(NS_IsMainThread()); + + if (!sSingleton) { + InProcessParent::Startup(); + } + return sSingleton; +} + +/* static */ InProcessParent* +InProcessParent::Singleton() { + MOZ_ASSERT(NS_IsMainThread()); + + if (!sSingleton) { + InProcessParent::Startup(); + } + return sSingleton; +} + +/* static */ void +InProcessParent::Startup() +{ + MOZ_ASSERT(NS_IsMainThread()); + + if (sShutdown) { + NS_WARNING("Could not get in-process actor while shutting down!"); + return; + } + + nsCOMPtr obs = mozilla::services::GetObserverService(); + if (!obs) { + sShutdown = true; + NS_WARNING("Failed to get nsIObserverService for in-process actor"); + return; + } + + RefPtr parent = new InProcessParent(); + RefPtr child = new InProcessChild(); + + // Observe the shutdown event to close & clean up after ourselves. + nsresult rv = obs->AddObserver(parent, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); + if (NS_WARN_IF(NS_FAILED(rv))) { + return; + } + + // Link the two actors + if (!child->OpenOnSameThread(parent->GetIPCChannel(), ChildSide)) { + MOZ_CRASH("Failed to open InProcessChild!"); + } + + parent->SetOtherProcessId(base::GetCurrentProcId()); + + // Create references held by the IPC layer which will be freed in + // DeallocPInProcess{Parent,Child}. + parent.get()->AddRef(); + child.get()->AddRef(); + + // Stash global references to fetch the other side of the reference. + InProcessParent::sSingleton = parent.forget(); + InProcessChild::sSingleton = child.forget(); +} + + +/* static */ void +InProcessParent::Shutdown() +{ + MOZ_ASSERT(NS_IsMainThread()); + + if (!sSingleton || sShutdown) { + return; + } + + sShutdown = true; + + RefPtr parent = sSingleton; + InProcessParent::sSingleton = nullptr; + InProcessChild::sSingleton = nullptr; + + // Calling `Close` on the actor will cause the `Dealloc` methods to be called, + // freeing the remaining references. + parent->Close(); +} + +NS_IMETHODIMP +InProcessParent::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) +{ + MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)); + InProcessParent::Shutdown(); + return NS_OK; +} + +void +InProcessParent::ActorDestroy(ActorDestroyReason aWhy) +{ + InProcessParent::Shutdown(); +} + +void +InProcessChild::ActorDestroy(ActorDestroyReason aWhy) +{ + InProcessParent::Shutdown(); +} + +void +InProcessParent::DeallocPInProcessParent() +{ + MOZ_ASSERT(!InProcessParent::sSingleton); + Release(); // Release the reference taken in InProcessParent::Startup. +} + +void +InProcessChild::DeallocPInProcessChild() +{ + MOZ_ASSERT(!InProcessChild::sSingleton); + Release(); // Release the reference taken in InProcessParent::Startup. +} + +//////////////////////////////// +// In-Process Actor Utilities // +//////////////////////////////// + +// Helper method for implementing ParentActorFor and ChildActorFor. +static IProtocol* +GetOtherInProcessActor(IProtocol* aActor) +{ + MOZ_ASSERT(aActor->GetSide() != UnknownSide, "bad unknown side"); + + // Discover the manager of aActor which is PInProcess. + IProtocol* current = aActor; + while (current) { + if (current->GetProtocolTypeId() == PInProcessMsgStart) { + break; // Found the correct actor. + } + current = current->Manager(); + } + if (!current) { + return nullptr; // Not a PInProcess actor, return |nullptr| + } + + MOZ_ASSERT(current->GetSide() == aActor->GetSide(), "side changed?"); + MOZ_ASSERT_IF(aActor->GetSide() == ParentSide, + current == InProcessParent::Singleton()); + MOZ_ASSERT_IF(aActor->GetSide() == ChildSide, + current == InProcessChild::Singleton()); + + // Check whether this is InProcessParent or InProcessChild, and get the other + // side's toplevel actor. + IProtocol* otherRoot = nullptr; + if (aActor->GetSide() == ParentSide) { + otherRoot = InProcessChild::Singleton(); + } else { + otherRoot = InProcessParent::Singleton(); + } + if (NS_WARN_IF(!otherRoot)) { + return nullptr; + } + + // Look up the actor on the other side, and return it. + IProtocol* otherActor = otherRoot->Lookup(aActor->Id()); + if (otherActor) { + MOZ_ASSERT(otherActor->GetSide() != UnknownSide, "bad unknown side"); + MOZ_ASSERT(otherActor->GetSide() != aActor->GetSide(), "Wrong side!"); + MOZ_ASSERT(otherActor->GetProtocolTypeId() == aActor->GetProtocolTypeId(), + "Wrong type of protocol!"); + } + + return otherActor; +} + +/* static */ IProtocol* +InProcessParent::ChildActorFor(IProtocol* aActor) +{ + MOZ_ASSERT(aActor && aActor->GetSide() == ParentSide); + return GetOtherInProcessActor(aActor); +} + +/* static */ IProtocol* +InProcessChild::ParentActorFor(IProtocol* aActor) +{ + MOZ_ASSERT(aActor && aActor->GetSide() == ChildSide); + return GetOtherInProcessActor(aActor); +} + +} // namespace ipc +} // namespace mozilla diff --git a/ipc/glue/InProcessParent.cpp b/ipc/glue/InProcessParent.cpp new file mode 100644 index 000000000000..72e8bd019cdc --- /dev/null +++ b/ipc/glue/InProcessParent.cpp @@ -0,0 +1,15 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/ipc/InProcessParent.h" + +namespace mozilla { +namespace ipc { + +NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver) + +} // namespace ipc +} // namespace mozilla \ No newline at end of file diff --git a/ipc/glue/InProcessParent.h b/ipc/glue/InProcessParent.h new file mode 100644 index 000000000000..2bce679ca759 --- /dev/null +++ b/ipc/glue/InProcessParent.h @@ -0,0 +1,60 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_ipc_InProcessParent_h +#define mozilla_ipc_InProcessParent_h + +#include "mozilla/ipc/PInProcessParent.h" +#include "mozilla/StaticPtr.h" + +namespace mozilla { +namespace ipc { + +class InProcessChild; + +/** + * The `InProcessParent` class represents the parent half of a main-thread to + * main-thread actor. + * + * The `PInProcess` actor should be used as an alternate manager to `PContent` + * for async actors which want to communicate uniformly between Content->Chrome + * and Chrome->Chrome situations. + */ +class InProcessParent : public nsIObserver + , public PInProcessParent +{ +public: + friend class InProcessChild; + + NS_DECL_ISUPPORTS + NS_DECL_NSIOBSERVER + + // Get the singleton instance of this actor. + static InProcessParent* Singleton(); + + // Get the child side of the in-process child actor |aActor|. If |aActor| is + // not an in-process actor, or is not connected, this method will return + // |nullptr|. + static IProtocol* ChildActorFor(IProtocol* aActor); + +private: + // Lifecycle management is implemented in InProcessImpl.cpp + virtual void ActorDestroy(ActorDestroyReason aWhy) override; + virtual void DeallocPInProcessParent() override; + ~InProcessParent() = default; + + static void Startup(); + static void Shutdown(); + + static StaticRefPtr sSingleton; + static bool sShutdown; +}; + + +} // namespace ipc +} // namespace mozilla + +#endif // defined(mozilla_ipc_InProcessParent_h) diff --git a/ipc/glue/PInProcess.ipdl b/ipc/glue/PInProcess.ipdl new file mode 100644 index 000000000000..c00e9d2effbb --- /dev/null +++ b/ipc/glue/PInProcess.ipdl @@ -0,0 +1,23 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +namespace mozilla { +namespace ipc { + +/** + * PInProcess is intended for use as an alternative actor manager to PContent + * for async actors which want to be used uniformly in both Content->Chrome and + * Chrome->Chrome circumstances. + * + * `mozilla::ipc::InProcess{Parent, Child}::Singleton()` should be used to get + * an instance of this actor. + */ +async protocol PInProcess +{ +}; + +} // namespace ipc +} // namespace mozilla diff --git a/ipc/glue/moz.build b/ipc/glue/moz.build index 1851b3b2a03b..f53dedb93a4e 100644 --- a/ipc/glue/moz.build +++ b/ipc/glue/moz.build @@ -27,6 +27,8 @@ EXPORTS.mozilla.ipc += [ 'FileDescriptorSetParent.h', 'FileDescriptorUtils.h', 'GeckoChildProcessHost.h', + 'InProcessChild.h', + 'InProcessParent.h', 'InputStreamUtils.h', 'IOThreadChild.h', 'IPCStreamAlloc.h', @@ -147,6 +149,9 @@ UNIFIED_SOURCES += [ 'CrashReporterMetadataShmem.cpp', 'FileDescriptor.cpp', 'FileDescriptorUtils.cpp', + 'InProcessChild.cpp', + 'InProcessImpl.cpp', + 'InProcessParent.cpp', 'InputStreamUtils.cpp', 'IPCMessageUtils.cpp', 'IPCStreamChild.cpp', @@ -208,6 +213,7 @@ IPDL_SOURCES = [ 'PBackgroundTest.ipdl', 'PChildToParentStream.ipdl', 'PFileDescriptorSet.ipdl', + 'PInProcess.ipdl', 'PParentToChildStream.ipdl', 'ProtocolTypes.ipdlh', 'URIParams.ipdlh', From 759b5812796424f7a463cf3c308f2e111f32ceb6 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Wed, 29 Aug 2018 18:21:25 -0400 Subject: [PATCH 06/13] Bug 1487249 - Part 3: Add the WindowGlobal actor representing a single window global, r=bzbarsky This actor can be used for communicating with individual frames, without depending on walking the tree in the content process. This is not yet complete. No tests have been written for it, the WindowGlobalParent objects need to be exposed to chrome JS, and a form of JS actors should be installed under them. In addition, BrowsingContextChrome objects should be updated to allow access to the current WindowGlobalParent in that context. Differential Revision: https://phabricator.services.mozilla.com/D4623 --- dom/base/nsDocument.cpp | 9 +++ dom/base/nsGlobalWindowInner.cpp | 16 +++++ dom/base/nsPIDOMWindow.h | 12 ++++ dom/ipc/ContentChild.cpp | 8 ++- dom/ipc/DOMTypes.ipdlh | 8 +++ dom/ipc/PBrowser.ipdl | 9 +++ dom/ipc/PWindowGlobal.ipdl | 35 +++++++++++ dom/ipc/TabChild.cpp | 16 +++++ dom/ipc/TabChild.h | 4 ++ dom/ipc/TabParent.cpp | 24 +++++++ dom/ipc/TabParent.h | 10 +++ dom/ipc/WindowGlobalChild.cpp | 81 ++++++++++++++++++++++++ dom/ipc/WindowGlobalChild.h | 65 +++++++++++++++++++ dom/ipc/WindowGlobalParent.cpp | 103 +++++++++++++++++++++++++++++++ dom/ipc/WindowGlobalParent.h | 95 ++++++++++++++++++++++++++++ dom/ipc/moz.build | 5 ++ ipc/glue/InProcessChild.cpp | 18 ++++++ ipc/glue/InProcessChild.h | 12 ++++ ipc/glue/InProcessImpl.cpp | 2 + ipc/glue/InProcessParent.cpp | 26 ++++++++ ipc/glue/InProcessParent.h | 16 +++++ ipc/glue/PInProcess.ipdl | 12 ++++ 22 files changed, 583 insertions(+), 3 deletions(-) create mode 100644 dom/ipc/PWindowGlobal.ipdl create mode 100644 dom/ipc/WindowGlobalChild.cpp create mode 100644 dom/ipc/WindowGlobalChild.h create mode 100644 dom/ipc/WindowGlobalParent.cpp create mode 100644 dom/ipc/WindowGlobalParent.h diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index be942cbf7c1d..452ecb1759d4 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -270,6 +270,8 @@ #include "mozilla/DocLoadingTimelineMarker.h" +#include "mozilla/dom/WindowGlobalChild.h" + #include "nsISpeculativeConnect.h" #include "mozilla/MediaManager.h" @@ -3108,6 +3110,13 @@ nsIDocument::SetDocumentURI(nsIURI* aURI) if (!equalBases) { RefreshLinkHrefs(); } + + // Tell our WindowGlobalParent that the document's URI has been changed. + nsPIDOMWindowInner* inner = GetInnerWindow(); + WindowGlobalChild* wgc = inner ? inner->GetWindowGlobalChild() : nullptr; + if (wgc) { + Unused << wgc->SendUpdateDocumentURI(mDocumentURI); + } } static void diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index 427d8eebd1ef..cb0b1e326b5c 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -258,6 +258,8 @@ #include "mozilla/dom/ClientSource.h" #include "mozilla/dom/ClientState.h" +#include "mozilla/dom/WindowGlobalChild.h" + // Apple system headers seem to have a check() macro. #ifdef check class nsIScriptTimeoutHandler; @@ -1346,6 +1348,11 @@ nsGlobalWindowInner::FreeInnerObjects(bool aForDocumentOpen) } } + if (mWindowGlobalChild && !mWindowGlobalChild->IsClosed()) { + mWindowGlobalChild->Send__delete__(mWindowGlobalChild); + } + mWindowGlobalChild = nullptr; + mIntlUtils = nullptr; } @@ -1736,6 +1743,15 @@ nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument) // out of sync. ClearDocumentDependentSlots(aCx); + // FIXME: Currently, devtools can crete a fallback webextension window global + // in the content process which does not have a corresponding TabChild actor. + // This means we have no actor to be our parent. (Bug 1498293) + MOZ_DIAGNOSTIC_ASSERT(!mWindowGlobalChild, + "Shouldn't have created WindowGlobalChild yet!"); + if (XRE_IsParentProcess() || mTabChild) { + mWindowGlobalChild = WindowGlobalChild::Create(this); + } + #ifdef DEBUG mLastOpenedURI = aDocument->GetDocumentURI(); #endif diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 7fb389749dd9..f4b893708614 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -68,6 +68,7 @@ class ServiceWorker; class ServiceWorkerDescriptor; class Timeout; class TimeoutManager; +class WindowGlobalChild; class CustomElementRegistry; enum class CallerType : uint32_t; } // namespace dom @@ -401,6 +402,11 @@ public: return mDoc; } + mozilla::dom::WindowGlobalChild* GetWindowGlobalChild() + { + return mWindowGlobalChild; + } + virtual PopupControlState GetPopupControlState() const = 0; // Determine if the window is suspended or frozen. Outer windows @@ -755,6 +761,12 @@ protected: // also set as permissions, but it could happen that we need to access them // synchronously in this context, and for this, we need a copy here. nsTArray mStorageAccessGranted; + + // The WindowGlobalChild actor for this window. + // + // This will be non-null during the full lifetime of the window, initialized + // during SetNewDocument, and cleared during FreeInnerObjects. + RefPtr mWindowGlobalChild; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowInner, NS_PIDOMWINDOWINNER_IID) diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index 13a351d3214d..d87efa7ca52b 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -954,9 +954,6 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener, TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext(); RefPtr newChild = new TabChild(this, tabId, tabGroup, newTabContext, aChromeFlags); - if (NS_FAILED(newChild->Init())) { - return NS_ERROR_ABORT; - } if (aTabOpener) { MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext); @@ -972,6 +969,11 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener, tabId, TabId(0), *ipcContext, aChromeFlags, GetID(), IsForBrowser()); + // Now that |newChild| has had its IPC link established, call |Init| to set it up. + if (NS_FAILED(newChild->Init())) { + return NS_ERROR_ABORT; + } + nsCOMPtr parentTopInnerWindow; if (aParent) { nsCOMPtr parentTopWindow = diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index c792f7fec573..f0af011e0e3f 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -26,6 +26,8 @@ using CSSSize from "Units.h"; using mozilla::LayoutDeviceIntPoint from "Units.h"; using hal::ScreenOrientation from "mozilla/HalScreenConfiguration.h"; using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; +using refcounted class nsIPrincipal from "mozilla/dom/PermissionMessageUtils.h"; +using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h"; namespace mozilla { @@ -183,5 +185,11 @@ struct PerformanceInfo CategoryDispatch[] items; }; +struct WindowGlobalInit +{ + nsIPrincipal principal; + BrowsingContextId browsingContextId; +}; + } // namespace dom } // namespace mozilla diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 4b27470a5fd2..05ed7186fe54 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -18,6 +18,7 @@ include protocol PParentToChildStream; include protocol PFileDescriptorSet; include protocol PIPCBlobInputStream; include protocol PPaymentRequest; +include protocol PWindowGlobal; include DOMTypes; include IPCBlob; @@ -86,6 +87,7 @@ using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h"; using mozilla::FontRange from "ipc/nsGUIEventIPC.h"; using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h"; +using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h"; namespace mozilla { namespace dom { @@ -118,6 +120,7 @@ nested(upto inside_cpow) sync protocol PBrowser manages PIndexedDBPermissionRequest; manages PPluginWidget; manages PPaymentRequest; + manages PWindowGlobal; both: async AsyncMessage(nsString aMessage, CpowEntry[] aCpows, @@ -144,6 +147,12 @@ parent: async PPaymentRequest(); + /** + * Construct a new WindowGlobal actor for a window global in the given + * BrowsingContext and with the given principal. + */ + async PWindowGlobal(WindowGlobalInit init); + /** * Sends an NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW to be adopted by the * widget's shareable window on the chrome side. Only used on Windows. diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl new file mode 100644 index 000000000000..5a78829f5e44 --- /dev/null +++ b/dom/ipc/PWindowGlobal.ipdl @@ -0,0 +1,35 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +include protocol PBrowser; +include protocol PInProcess; + +include DOMTypes; + +using refcounted class nsIURI from "mozilla/ipc/URIUtils.h"; + +namespace mozilla { +namespace dom { + +/** + * A PWindowGlobal actor has a lifetime matching that of a single Window Global, + * specifically a |nsGlobalWindowInner|. These actors will form a parent/child + * link either between the chrome/content process, or will be in-process, for + * documents which are loaded in the chrome process. + */ +async protocol PWindowGlobal +{ + manager PBrowser or PInProcess; + +parent: + /// Update the URI of the document in this WindowGlobal. + async UpdateDocumentURI(nsIURI aUri); + + async __delete__(); +}; + +} // namespace dom +} // namespace mozilla diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 8bad6a983220..be1bf294f0a7 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -123,6 +123,7 @@ #include "mozilla/Telemetry.h" #include "nsDocShellLoadState.h" #include "nsWebBrowser.h" +#include "mozilla/dom/WindowGlobalChild.h" #ifdef XP_WIN #include "mozilla/plugins/PluginWidgetChild.h" @@ -3444,6 +3445,21 @@ TabChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor) return true; } +PWindowGlobalChild* +TabChild::AllocPWindowGlobalChild(const WindowGlobalInit&) +{ + MOZ_CRASH("We should never be manually allocating PWindowGlobalChild actors"); + return nullptr; +} + +bool +TabChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) +{ + // This reference was added in WindowGlobalChild::Create. + static_cast(aActor)->Release(); + return true; +} + ScreenIntSize TabChild::GetInnerSize() { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index d60d6b69ae20..f4a03bad7a78 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -705,6 +705,10 @@ public: protected: virtual ~TabChild(); + virtual PWindowGlobalChild* AllocPWindowGlobalChild(const WindowGlobalInit& aInit) override; + + virtual bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) override; + virtual mozilla::ipc::IPCResult RecvDestroy() override; virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive) override; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 0ce850d80400..008bcdea83ea 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -100,6 +100,7 @@ #include "ProcessPriorityManager.h" #include "nsString.h" #include "IHistory.h" +#include "mozilla/dom/WindowGlobalParent.h" #ifdef XP_WIN #include "mozilla/plugins/PluginWidgetParent.h" @@ -1062,6 +1063,29 @@ TabParent::DeallocPIndexedDBPermissionRequestParent( mozilla::dom::indexedDB::DeallocPIndexedDBPermissionRequestParent(aActor); } +IPCResult +TabParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, + const WindowGlobalInit& aInit) +{ + static_cast(aActor)->Init(); + return IPC_OK(); +} + +PWindowGlobalParent* +TabParent::AllocPWindowGlobalParent(const WindowGlobalInit& aInit) +{ + // Reference freed in DeallocPWindowGlobalParent. + return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ false)).take(); +} + +bool +TabParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) +{ + // Free reference from AllocPWindowGlobalParent. + static_cast(aActor)->Release(); + return true; +} + void TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY, int32_t aButton, int32_t aClickCount, diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index cefd6cfe5e1f..329074660da9 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -327,6 +327,16 @@ public: */ a11y::DocAccessibleParent* GetTopLevelDocAccessible() const; + virtual PWindowGlobalParent* + AllocPWindowGlobalParent(const WindowGlobalInit& aInit) override; + + virtual bool + DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) override; + + virtual mozilla::ipc::IPCResult + RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, + const WindowGlobalInit& aInit) override; + void LoadURL(nsIURI* aURI); void InitRendering(); diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp new file mode 100644 index 000000000000..dd2026bb39ae --- /dev/null +++ b/dom/ipc/WindowGlobalChild.cpp @@ -0,0 +1,81 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/WindowGlobalChild.h" +#include "mozilla/ipc/InProcessChild.h" +#include "mozilla/dom/BrowsingContext.h" + +namespace mozilla { +namespace dom { + +WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBrowsingContext) + : mWindowGlobal(aWindow) + , mBrowsingContext(aBrowsingContext) + , mIPCClosed(false) +{ +} + +already_AddRefed +WindowGlobalChild::Create(nsGlobalWindowInner* aWindow) +{ + nsCOMPtr principal = aWindow->GetPrincipal(); + MOZ_ASSERT(principal); + + RefPtr docshell = nsDocShell::Cast(aWindow->GetDocShell()); + MOZ_ASSERT(docshell); + + // Initalize our WindowGlobalChild object. + RefPtr bc = docshell->GetBrowsingContext(); + RefPtr wgc = new WindowGlobalChild(aWindow, bc); + + WindowGlobalInit init(principal, BrowsingContextId(wgc->BrowsingContext()->Id())); + + // Send the link constructor over PInProcessChild or PBrowser. + if (XRE_IsParentProcess()) { + InProcessChild* ipc = InProcessChild::Singleton(); + if (!ipc) { + return nullptr; + } + + // Note: ref is released in DeallocPWindowGlobalChild + ipc->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); + } else { + RefPtr tabChild = TabChild::GetFrom(static_cast(aWindow)); + MOZ_ASSERT(tabChild); + + // Note: ref is released in DeallocPWindowGlobalChild + tabChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); + } + + return wgc.forget(); +} + +already_AddRefed +WindowGlobalChild::GetOtherSide() +{ + if (mIPCClosed) { + return nullptr; + } + IProtocol* otherSide = InProcessChild::ParentActorFor(this); + return do_AddRef(static_cast(otherSide)); +} + +void +WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) +{ + mIPCClosed = true; +} + +WindowGlobalChild::~WindowGlobalChild() +{ +} + +NS_IMPL_CYCLE_COLLECTION(WindowGlobalChild, mWindowGlobal, mBrowsingContext) +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalChild, AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalChild, Release) + +} // namespace dom +} // namespace mozilla diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h new file mode 100644 index 000000000000..cce3f12e73f5 --- /dev/null +++ b/dom/ipc/WindowGlobalChild.h @@ -0,0 +1,65 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_WindowGlobalChild_h +#define mozilla_dom_WindowGlobalChild_h + +#include "mozilla/RefPtr.h" +#include "mozilla/dom/PWindowGlobalChild.h" + +class nsGlobalWindowInner; +class nsDocShell; + +namespace mozilla { +namespace dom { + +class BrowsingContext; +class WindowGlobalParent; + +/** + * Actor for a single nsGlobalWindowInner. This actor is used to communicate + * information to the parent process asynchronously. + */ +class WindowGlobalChild : public PWindowGlobalChild +{ +public: + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalChild) + NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WindowGlobalChild) + + dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; } + nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; } + + // Has this actor been shut down + bool IsClosed() { return mIPCClosed; } + + // Check if this actor is managed by PInProcess, as-in the document is loaded + // in the chrome process. + bool IsInProcess() { return XRE_IsParentProcess(); } + + // Get the other side of this actor if it is an in-process actor. Returns + // |nullptr| if the actor has been torn down, or is not in-process. + already_AddRefed GetOtherSide(); + + // Create and initialize the WindowGlobalChild object. + static already_AddRefed + Create(nsGlobalWindowInner* aWindow); + +protected: + virtual void ActorDestroy(ActorDestroyReason aWhy) override; + +private: + WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBc); + ~WindowGlobalChild(); + + RefPtr mWindowGlobal; + RefPtr mBrowsingContext; + bool mIPCClosed; +}; + +} // namespace dom +} // namespace mozilla + +#endif // !defined(mozilla_dom_WindowGlobalChild_h) diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp new file mode 100644 index 000000000000..c2fbfb81e73e --- /dev/null +++ b/dom/ipc/WindowGlobalParent.cpp @@ -0,0 +1,103 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "mozilla/dom/WindowGlobalParent.h" +#include "mozilla/ipc/InProcessParent.h" +#include "mozilla/dom/BrowsingContext.h" + +using namespace mozilla::ipc; + +namespace mozilla { +namespace dom { + +WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit, + bool aInProcess) + : mBrowsingContextId(aInit.browsingContextId()) + , mDocumentPrincipal(aInit.principal()) + , mInProcess(aInProcess) + , mIPCClosed(false) +{ + MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(), "Parent process only"); + MOZ_RELEASE_ASSERT(mDocumentPrincipal, "Must have a valid principal"); + MOZ_RELEASE_ASSERT(mBrowsingContextId != 0, "Must be made in BrowsingContext"); +} + +void +WindowGlobalParent::Init() +{ + MOZ_ASSERT(Manager(), "Should have a manager!"); + MOZ_ASSERT(!mFrameLoader, "Cannot Init() a WindowGlobalParent twice!"); + + // Determine what toplevel frame element our WindowGlobalParent is being + // embedded in. + RefPtr frameElement; + if (mInProcess) { + // In the in-process case, we can get it from the other side's + // WindowGlobalChild. + MOZ_ASSERT(Manager()->GetProtocolTypeId() == PInProcessMsgStart); + RefPtr otherSide = GetOtherSide(); + if (otherSide && otherSide->WindowGlobal()) { + // Get the toplevel window from the other side. + RefPtr docShell = nsDocShell::Cast(otherSide->WindowGlobal()->GetDocShell()); + if (docShell) { + docShell->GetTopFrameElement(getter_AddRefs(frameElement)); + } + } + } else { + // In the cross-process case, we can get the frame element from our manager. + MOZ_ASSERT(Manager()->GetProtocolTypeId() == PBrowserMsgStart); + frameElement = static_cast(Manager())->GetOwnerElement(); + } + + // Extract the nsFrameLoader from the current frame element. We may not have a + // nsFrameLoader if we are a chrome document. + nsCOMPtr flOwner = do_QueryInterface(frameElement); + if (flOwner) { + mFrameLoader = flOwner->GetFrameLoader(); + } +} + +already_AddRefed +WindowGlobalParent::BrowsingContext() +{ + return dom::BrowsingContext::Get(mBrowsingContextId); +} + +already_AddRefed +WindowGlobalParent::GetOtherSide() +{ + if (mIPCClosed) { + return nullptr; + } + IProtocol* otherSide = InProcessParent::ChildActorFor(this); + return do_AddRef(static_cast(otherSide)); +} + +IPCResult +WindowGlobalParent::RecvUpdateDocumentURI(nsIURI* aURI) +{ + // XXX(nika): Assert that the URI change was one which makes sense (either + // about:blank -> a real URI, or a legal push/popstate URI change?) + mDocumentURI = aURI; + return IPC_OK(); +} + +void +WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) +{ + mIPCClosed = true; +} + +WindowGlobalParent::~WindowGlobalParent() +{ +} + +NS_IMPL_CYCLE_COLLECTION(WindowGlobalParent, mFrameLoader) +NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalParent, AddRef) +NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalParent, Release) + +} // namespace dom +} // namespace mozilla diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h new file mode 100644 index 000000000000..7bc6786d4352 --- /dev/null +++ b/dom/ipc/WindowGlobalParent.h @@ -0,0 +1,95 @@ +/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ +/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_dom_WindowGlobalParent_h +#define mozilla_dom_WindowGlobalParent_h + +#include "mozilla/RefPtr.h" +#include "mozilla/dom/PWindowGlobalParent.h" + +class nsIPrincipal; +class nsIURI; +class nsFrameLoader; + +namespace mozilla { +namespace dom { + +class BrowsingContext; +class WindowGlobalChild; + +/** + * A handle in the parent process to a specific nsGlobalWindowInner object. + */ +class WindowGlobalParent final : public PWindowGlobalParent +{ +public: + NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalParent) + NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WindowGlobalParent) + + // Has this actor been shut down + bool IsClosed() { return mIPCClosed; } + + // Check if this actor is managed by PInProcess, as-in the document is loaded + // in-process. + bool IsInProcess() { return mInProcess; } + + // Get the other side of this actor if it is an in-process actor. Returns + // |nullptr| if the actor has been torn down, or is not in-process. + already_AddRefed GetOtherSide(); + + // The principal of this WindowGlobal. This value will not change over the + // lifetime of the WindowGlobal object, even to reflect changes in + // |document.domain|. + nsIPrincipal* DocumentPrincipal() { return mDocumentPrincipal; } + + // The BrowsingContext which this WindowGlobal has been loaded into. + already_AddRefed BrowsingContext(); + + // Get the root nsFrameLoader object for the tree of BrowsingContext nodes + // which this WindowGlobal is a part of. This will be the nsFrameLoader + // holding the TabParent for remote tabs, and the root content frameloader for + // non-remote tabs. + nsFrameLoader* GetRootFrameLoader() { return mFrameLoader; } + + // The current URI which loaded in the document. + nsIURI* GetDocumentURI() { return mDocumentURI; } + + // Create a WindowGlobalParent from over IPC. This method should not be called + // from outside of the IPC constructors. + WindowGlobalParent(const WindowGlobalInit& aInit, bool aInProcess); + + // Initialize the mFrameLoader fields for a created WindowGlobalParent. Must + // be called after setting the Manager actor. + void Init(); + +protected: + // IPC messages + mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI) override; + + void ActorDestroy(ActorDestroyReason aWhy) override; + +private: + ~WindowGlobalParent(); + + // XXX(nika): We should store the BrowsingContext here. Unfortunately, the + // parent process is not sent down the BrowsingContext object until + // potentially after the WindowGlobalChild has been created. We should change + // this in the future. + uint64_t mBrowsingContextId; + + // NOTE: This document principal doesn't reflect possible |document.domain| + // mutations which may have been made in the actual document. + nsCOMPtr mDocumentPrincipal; + nsCOMPtr mDocumentURI; + RefPtr mFrameLoader; + bool mInProcess; + bool mIPCClosed; +}; + +} // namespace dom +} // namespace mozilla + +#endif // !defined(mozilla_dom_WindowGlobalParent_h) diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index ea8f28ef0313..94bc1778578d 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -50,6 +50,8 @@ EXPORTS.mozilla.dom += [ 'TabParent.h', 'URLClassifierChild.h', 'URLClassifierParent.h', + 'WindowGlobalChild.h', + 'WindowGlobalParent.h', ] EXPORTS.mozilla += [ @@ -85,6 +87,8 @@ UNIFIED_SOURCES += [ 'TabMessageUtils.cpp', 'TabParent.cpp', 'URLClassifierParent.cpp', + 'WindowGlobalChild.cpp', + 'WindowGlobalParent.cpp', ] # ContentChild.cpp cannot be compiled in unified mode on linux due to Time conflict @@ -112,6 +116,7 @@ IPDL_SOURCES += [ 'PURLClassifier.ipdl', 'PURLClassifierInfo.ipdlh', 'PURLClassifierLocal.ipdl', + 'PWindowGlobal.ipdl', 'ServiceWorkerConfiguration.ipdlh', ] diff --git a/ipc/glue/InProcessChild.cpp b/ipc/glue/InProcessChild.cpp index d0c2e9a98392..53d6451b5c53 100644 --- a/ipc/glue/InProcessChild.cpp +++ b/ipc/glue/InProcessChild.cpp @@ -5,9 +5,27 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/ipc/InProcessChild.h" +#include "mozilla/dom/WindowGlobalChild.h" + +using namespace mozilla::dom; namespace mozilla { namespace ipc { +PWindowGlobalChild* +InProcessChild::AllocPWindowGlobalChild(const WindowGlobalInit& aInit) +{ + MOZ_ASSERT_UNREACHABLE("PWindowGlobalChild should not be created manually"); + return nullptr; +} + +bool +InProcessChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) +{ + // Free IPC-held reference + static_cast(aActor)->Release(); + return true; +} + } // namespace ipc } // namespace mozilla diff --git a/ipc/glue/InProcessChild.h b/ipc/glue/InProcessChild.h index 902bd9e5127f..e0001beaeac0 100644 --- a/ipc/glue/InProcessChild.h +++ b/ipc/glue/InProcessChild.h @@ -11,6 +11,11 @@ #include "mozilla/StaticPtr.h" namespace mozilla { +namespace dom { +class PWindowGlobalParent; +class PWindowGlobalChild; +} // namespace dom + namespace ipc { class InProcessParent; @@ -38,6 +43,13 @@ public: // |nullptr|. static IProtocol* ParentActorFor(IProtocol* aActor); +protected: + virtual mozilla::dom::PWindowGlobalChild* + AllocPWindowGlobalChild(const WindowGlobalInit& aInit) override; + + virtual bool + DeallocPWindowGlobalChild(mozilla::dom::PWindowGlobalChild* aActor) override; + private: // NOTE: PInProcess lifecycle management is declared as staic methods and // state on InProcessParent, and implemented in InProcessImpl.cpp. diff --git a/ipc/glue/InProcessImpl.cpp b/ipc/glue/InProcessImpl.cpp index cc7e765c724c..f882bedeae0e 100644 --- a/ipc/glue/InProcessImpl.cpp +++ b/ipc/glue/InProcessImpl.cpp @@ -6,6 +6,8 @@ #include "mozilla/ipc/InProcessParent.h" #include "mozilla/ipc/InProcessChild.h" +#include "nsIObserverService.h" +#include "mozilla/Services.h" // This file contains the implementation of core InProcess lifecycle management // facilities. diff --git a/ipc/glue/InProcessParent.cpp b/ipc/glue/InProcessParent.cpp index 72e8bd019cdc..34eb615c393e 100644 --- a/ipc/glue/InProcessParent.cpp +++ b/ipc/glue/InProcessParent.cpp @@ -5,11 +5,37 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "mozilla/ipc/InProcessParent.h" +#include "mozilla/dom/WindowGlobalParent.h" + +using namespace mozilla::dom; namespace mozilla { namespace ipc { NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver) +IPCResult +InProcessParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, + const WindowGlobalInit& aInit) +{ + static_cast(aActor)->Init(); + return IPC_OK(); +} + +PWindowGlobalParent* +InProcessParent::AllocPWindowGlobalParent(const WindowGlobalInit& aInit) +{ + // Reference freed in DeallocPWindowGlobalParent. + return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ true)).take(); +} + +bool +InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) +{ + // Free IPC-held reference. + static_cast(aActor)->Release(); + return true; +} + } // namespace ipc } // namespace mozilla \ No newline at end of file diff --git a/ipc/glue/InProcessParent.h b/ipc/glue/InProcessParent.h index 2bce679ca759..145adccd14e6 100644 --- a/ipc/glue/InProcessParent.h +++ b/ipc/glue/InProcessParent.h @@ -11,6 +11,11 @@ #include "mozilla/StaticPtr.h" namespace mozilla { +namespace dom { +class PWindowGlobalParent; +class PWindowGlobalChild; +} // namespace dom + namespace ipc { class InProcessChild; @@ -40,6 +45,17 @@ public: // |nullptr|. static IProtocol* ChildActorFor(IProtocol* aActor); +protected: + virtual mozilla::dom::PWindowGlobalParent* + AllocPWindowGlobalParent(const WindowGlobalInit& aInit) override; + + virtual bool + DeallocPWindowGlobalParent(mozilla::dom::PWindowGlobalParent* aActor) override; + + virtual IPCResult + RecvPWindowGlobalConstructor(mozilla::dom::PWindowGlobalParent* aActor, + const WindowGlobalInit& aInit) override; + private: // Lifecycle management is implemented in InProcessImpl.cpp virtual void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/ipc/glue/PInProcess.ipdl b/ipc/glue/PInProcess.ipdl index c00e9d2effbb..9121d10e5964 100644 --- a/ipc/glue/PInProcess.ipdl +++ b/ipc/glue/PInProcess.ipdl @@ -4,6 +4,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +include protocol PWindowGlobal; + +include DOMTypes; + namespace mozilla { namespace ipc { @@ -17,6 +21,14 @@ namespace ipc { */ async protocol PInProcess { + manages PWindowGlobal; + +parent: + /** + * Construct a new WindowGlobal actor for a window global in the given + * BrowsingContext and with the given principal. + */ + async PWindowGlobal(WindowGlobalInit init); }; } // namespace ipc From b6ea50e3f8a25aedfbdc3bb767de488044200587 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Tue, 25 Sep 2018 17:34:53 +0200 Subject: [PATCH 07/13] Bug 1448426 - Wrap windows.h to avoid problematic define statements, r=froydnj,glandium By default, windows.h exposes a large number of problematic define statements which are UpperCamelCase, such as a define from `CreateWindow` to `CreateWindow{A,W}`. As many of these names are generic (e.g. CreateFile, CreateWindow), they can mess up Gecko code that may legitimately have its own methods with the same names. The header also defines some traditional SCREAMING_SNAKE_CASE defines which can mess up our code by conflicting with local values. This patch adds a simple code generator which generates wrappers for these defines, and uses them to wrap the windows.h wrapper using the `stl_wrappers` mechanism, allowing us to use windows.h in more places. Differential Revision: https://phabricator.services.mozilla.com/D10932 --- config/make-stl-wrappers.py | 19 +- config/make-windows-h-wrapper.py | 86 ++ config/moz.build | 13 + config/system_header_util.py | 20 + config/windows-h-constant.decls.h | 57 ++ config/windows-h-unicode.decls.h | 1052 ++++++++++++++++++++ config/windows-h-wrapper.template.h | 55 + dom/base/moz.build | 2 +- dom/base/nsGlobalWindowInner.cpp | 5 +- dom/base/nsGlobalWindowOuter.cpp | 5 +- gfx/cairo/cairo/src/moz.build | 1 + gfx/thebes/gfxDWriteFonts.cpp | 6 +- gfx/vr/service/openvr/moz.build | 3 + python/mozbuild/mozbuild/backend/common.py | 5 +- 14 files changed, 1301 insertions(+), 28 deletions(-) create mode 100644 config/make-windows-h-wrapper.py create mode 100644 config/system_header_util.py create mode 100644 config/windows-h-constant.decls.h create mode 100644 config/windows-h-unicode.decls.h create mode 100644 config/windows-h-wrapper.template.h diff --git a/config/make-stl-wrappers.py b/config/make-stl-wrappers.py index 1f8661fb35bf..7e6da5150bff 100644 --- a/config/make-stl-wrappers.py +++ b/config/make-stl-wrappers.py @@ -5,26 +5,9 @@ from __future__ import print_function import os import string from mozbuild.util import FileAvoidWrite +from system_header_util import header_path -def find_in_path(file, searchpath): - for dir in searchpath.split(os.pathsep): - f = os.path.join(dir, file) - if os.path.exists(f): - return f - return '' - - -def header_path(header, compiler): - if compiler == 'gcc': - # we use include_next on gcc - return header - elif compiler == 'msvc': - return find_in_path(header, os.environ.get('INCLUDE', '')) - else: - # hope someone notices this ... - raise NotImplementedError(compiler) - # The 'unused' arg is the output file from the file_generate action. We actually # generate all the files in header_list diff --git a/config/make-windows-h-wrapper.py b/config/make-windows-h-wrapper.py new file mode 100644 index 000000000000..fca3597e99ce --- /dev/null +++ b/config/make-windows-h-wrapper.py @@ -0,0 +1,86 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import re +import textwrap +import string +from system_header_util import header_path + +comment_re = re.compile(r'//[^\n]*\n|/\*.*\*/', re.S) +decl_re = re.compile(r'''^(.+)\s+ # type + (\w+)\s* # name + (?:\((.*)\))?$ # optional param tys + ''', re.X | re.S) + + +def read_decls(filename): + """Parse & yield C-style decls from an input file""" + with open(filename, 'r') as fd: + # Strip comments from the source text. + text = comment_re.sub('', fd.read()) + + # Parse individual declarations. + raw_decls = [d.strip() for d in text.split(';') if d.strip()] + for raw in raw_decls: + match = decl_re.match(raw) + if match is None: + raise "Invalid decl: %s" % raw + + ty, name, params = match.groups() + if params is not None: + params = [a.strip() for a in params.split(',') if a.strip()] + yield ty, name, params + + +def generate(fd, consts_path, unicodes_path, template_path, compiler): + # Parse the template + with open(template_path, 'r') as template_fd: + template = string.Template(template_fd.read()) + + decls = '' + + # Each constant should be saved to a temporary, and then re-assigned to a + # constant with the correct name, allowing the value to be determined by + # the actual definition. + for ty, name, args in read_decls(consts_path): + assert args is None, "parameters in const decl!" + + decls += textwrap.dedent(""" + #ifdef {name} + constexpr {ty} _tmp_{name} = {name}; + #undef {name} + constexpr {ty} {name} = _tmp_{name}; + #endif + """.format(ty=ty, name=name)) + + # Each unicode declaration defines a static inline function with the + # correct types which calls the 'A' or 'W'-suffixed versions of the + # function. Full types are required here to ensure that '0' to 'nullptr' + # coersions are preserved. + for ty, name, args in read_decls(unicodes_path): + assert args is not None, "argument list required for unicode decl" + + # Parameter & argument string list + params = ', '.join('%s a%d' % (ty, i) for i, ty in enumerate(args)) + args = ', '.join('a%d' % i for i in range(len(args))) + + decls += textwrap.dedent(""" + #ifdef {name} + #undef {name} + static inline {ty} WINAPI + {name}({params}) + {{ + #ifdef UNICODE + return {name}W({args}); + #else + return {name}A({args}); + #endif + }} + #endif + """.format(ty=ty, name=name, params=params, args=args)) + + path = header_path('windows.h', compiler) + + # Write out the resulting file + fd.write(template.substitute(header_path=path, decls=decls)) diff --git a/config/moz.build b/config/moz.build index ce6297393373..8fd459d2fc01 100644 --- a/config/moz.build +++ b/config/moz.build @@ -63,6 +63,19 @@ if CONFIG['WRAP_STL_INCLUDES']: stl.flags = [output_dir, stl_compiler, template_file] stl.flags.extend(stl_headers) + # Wrap to make it easier to use correctly + # NOTE: If we aren't wrapping STL includes, we're building part of the browser + # which won't need this wrapper, such as L10N. Just don't try to generate the + # wrapper in that case. + if CONFIG['OS_ARCH'] == 'WINNT': + GENERATED_FILES += ['../dist/stl_wrappers/windows.h'] + windows_h = GENERATED_FILES['../dist/stl_wrappers/windows.h'] + windows_h.script = 'make-windows-h-wrapper.py:generate' + windows_h.inputs = ['windows-h-constant.decls.h', + 'windows-h-unicode.decls.h', + 'windows-h-wrapper.template.h'] + windows_h.flags = [stl_compiler] + if CONFIG['WRAP_SYSTEM_INCLUDES']: include('system-headers.mozbuild') output_dir = '../dist/system_wrappers' diff --git a/config/system_header_util.py b/config/system_header_util.py new file mode 100644 index 000000000000..6e7b30318f23 --- /dev/null +++ b/config/system_header_util.py @@ -0,0 +1,20 @@ +import os + + +def find_in_path(file, searchpath): + for dir in searchpath.split(os.pathsep): + f = os.path.join(dir, file) + if os.path.exists(f): + return f + return '' + + +def header_path(header, compiler): + if compiler == 'gcc': + # we use include_next on gcc + return header + elif compiler == 'msvc': + return find_in_path(header, os.environ.get('INCLUDE', '')) + else: + # hope someone notices this ... + raise NotImplementedError(compiler) diff --git a/config/windows-h-constant.decls.h b/config/windows-h-constant.decls.h new file mode 100644 index 000000000000..12bc9111e60c --- /dev/null +++ b/config/windows-h-constant.decls.h @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This file contains a series of C-style declarations for constants defined in + * windows.h using #define. Adding a new constant should be a simple as adding + * its name (and optionally type) to this file. + * + * This file is processed by generate-windows-h-wrapper.py to generate a wrapper + * for the header which removes the defines usually implementing these constants. + * + * Wrappers defined in this file will be declared as `constexpr` values, + * and will have their value derived from the windows.h define. + * + * NOTE: This is *NOT* a real C header, but rather an input to the avove script. + * Only basic declarations in the form found here are allowed. + */ + +// XXX(nika): There are a lot of these (>30k)! +// This is just a set of ones I saw in a quick scan which looked problematic. + +auto CREATE_NEW; +auto CREATE_ALWAYS; +auto OPEN_EXISTING; +auto OPEN_ALWAYS; +auto TRUNCATE_EXISTING; +auto INVALID_FILE_SIZE; +auto INVALID_SET_FILE_POINTER; +auto INVALID_FILE_ATTRIBUTES; + +auto ANSI_NULL; +auto UNICODE_NULL; + +auto MINCHAR; +auto MAXCHAR; +auto MINSHORT; +auto MAXSHORT; +auto MINLONG; +auto MAXLONG; +auto MAXBYTE; +auto MAXWORD; +auto MAXDWORD; + +auto DELETE; +auto READ_CONTROL; +auto WRITE_DAC; +auto WRITE_OWNER; +auto SYNCHRONIZE; + +auto MAXIMUM_ALLOWED; +auto GENERIC_READ; +auto GENERIC_WRITE; +auto GENERIC_EXECUTE; +auto GENERIC_ALL; diff --git a/config/windows-h-unicode.decls.h b/config/windows-h-unicode.decls.h new file mode 100644 index 000000000000..7cbe5bc4be37 --- /dev/null +++ b/config/windows-h-unicode.decls.h @@ -0,0 +1,1052 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +/* + * This file contains a series of C-style function prototypes for A/W-suffixed + * Win32 APIs defined by windows.h. + * + * This file is processed by generate-windows-h-wrapper.py to generate a wrapper + * for the header which removes the defines usually implementing these aliases. + * + * Wrappers defined in this file will have the 'stdcall' calling convention, + * will be defined as 'inline', and will only be defined if the corresponding + * #define directive has not been #undef-ed. + * + * NOTE: This is *NOT* a real C header, but rather an input to the avove script. + * Only basic declarations in the form found here are allowed. + */ + +LPTSTR GetCommandLine(); + +BOOL FreeEnvironmentStrings(LPTCH); + +DWORD GetEnvironmentVariable(LPCTSTR, LPTSTR, DWORD); + +BOOL SetEnvironmentVariable(LPCTSTR, LPCTSTR); + +DWORD ExpandEnvironmentStrings(LPCTSTR, LPTSTR, DWORD); + +BOOL SetCurrentDirectory(LPCTSTR); + +DWORD GetCurrentDirectory(DWORD, LPTSTR); + +DWORD SearchPath(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, LPTSTR, LPTSTR*); + +BOOL NeedCurrentDirectoryForExePath(LPCTSTR); + +BOOL CreateDirectory(LPCTSTR, LPSECURITY_ATTRIBUTES); + +HANDLE CreateFile(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE); + +BOOL DeleteFile(LPCTSTR); + +HANDLE FindFirstChangeNotification(LPCTSTR, BOOL, DWORD); + +HANDLE FindFirstFile(LPCTSTR, LPWIN32_FIND_DATA); + +HANDLE FindFirstFileEx(LPCTSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD); + +BOOL FindNextFile(HANDLE, LPWIN32_FIND_DATA); + +BOOL GetDiskFreeSpace(LPCTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD); + +BOOL GetDiskFreeSpaceEx(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); + +UINT GetDriveType(LPCTSTR); + +DWORD GetFileAttributes(LPCTSTR); + +BOOL GetFileAttributesEx(LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID); + +DWORD GetFinalPathNameByHandle(HANDLE, LPTSTR, DWORD, DWORD); + +DWORD GetFullPathName(LPCTSTR, DWORD, LPTSTR, LPTSTR*); + +DWORD GetLongPathName(LPCTSTR, LPTSTR, DWORD); + +BOOL RemoveDirectory(LPCTSTR); + +BOOL SetFileAttributes(LPCTSTR, DWORD); + +DWORD GetCompressedFileSize(LPCTSTR, LPDWORD); + +DWORD GetTempPath(DWORD, LPTSTR); + +BOOL GetVolumeInformation(LPCTSTR, LPTSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPTSTR, DWORD); + +UINT GetTempFileName(LPCTSTR, LPCTSTR, UINT, LPTSTR); + +void OutputDebugString(LPCTSTR); + +void FatalAppExit(UINT, LPCTSTR); + +HANDLE CreateMutex(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR); + +HANDLE CreateEvent(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCTSTR); + +HANDLE OpenEvent(DWORD, BOOL, LPCTSTR); + +HANDLE CreateMutexEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD); + +HANDLE CreateEventEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD); + +BOOL CreateProcess(LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION); + +BOOL CreateProcessAsUser(HANDLE, LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION); + +UINT GetSystemDirectory(LPTSTR, UINT); + +UINT GetWindowsDirectory(LPTSTR, UINT); + +UINT GetSystemWindowsDirectory(LPTSTR, UINT); + +BOOL GetComputerNameEx(COMPUTER_NAME_FORMAT, LPTSTR, LPDWORD); + +BOOL GetVersionEx(LPOSVERSIONINFO); + +BOOL SetComputerName(LPCTSTR); + +BOOL SetComputerNameEx(COMPUTER_NAME_FORMAT, LPCTSTR); + +BOOL LoadEnclaveImage(LPVOID, LPCTSTR); + +UINT GetSystemWow64Directory(LPTSTR, UINT); + +DWORD GetModuleFileName(HMODULE, LPTSTR, DWORD); + +HMODULE GetModuleHandle(LPCTSTR); + +BOOL GetModuleHandleEx(DWORD, LPCTSTR, HMODULE*); + +HMODULE LoadLibraryEx(LPCTSTR, HANDLE, DWORD); + +int LoadString(HINSTANCE, UINT, LPTSTR, int); + +BOOL EnumResourceLanguagesEx(HMODULE, LPCTSTR, LPCTSTR, ENUMRESLANGPROC, LONG_PTR, DWORD, LANGID); + +BOOL EnumResourceNamesEx(HMODULE, LPCTSTR, ENUMRESNAMEPROC, LONG_PTR, DWORD, LANGID); + +BOOL EnumResourceTypesEx(HMODULE, ENUMRESTYPEPROC, LONG_PTR, DWORD, LANGID); + +HMODULE LoadLibrary(LPCTSTR); + +BOOL GetBinaryType(LPCTSTR, LPDWORD); + +DWORD GetShortPathName(LPCTSTR, LPTSTR, DWORD); + +DWORD GetLongPathNameTransacted(LPCTSTR, LPTSTR, DWORD, HANDLE); + +BOOL SetEnvironmentStrings(LPTCH); + +BOOL SetFileShortName(HANDLE, LPCTSTR); + +DWORD FormatMessage(DWORD, LPCVOID, DWORD, DWORD, LPTSTR, DWORD, va_list *); + +HANDLE CreateMailslot(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES); + +BOOL EncryptFile(LPCTSTR); + +BOOL DecryptFile(LPCTSTR, DWORD); + +BOOL FileEncryptionStatus(LPCTSTR, LPDWORD); + +DWORD OpenEncryptedFileRaw(LPCTSTR, ULONG, PVOID *); + +HANDLE OpenMutex(DWORD, BOOL, LPCTSTR); + +HANDLE CreateSemaphore(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCTSTR); + +HANDLE OpenSemaphore(DWORD, BOOL, LPCTSTR); + +HANDLE CreateWaitableTimer(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR); + +HANDLE OpenWaitableTimer(DWORD, BOOL, LPCTSTR); + +HANDLE CreateSemaphoreEx(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCTSTR, DWORD, DWORD); + +HANDLE CreateWaitableTimerEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD); + +HANDLE CreateFileMapping(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCTSTR); + +HANDLE CreateFileMappingNuma(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCTSTR, DWORD); + +HANDLE OpenFileMapping(DWORD, BOOL, LPCTSTR); + +DWORD GetLogicalDriveStrings(DWORD, LPTSTR); + +void GetStartupInfo(LPSTARTUPINFO); + +DWORD GetFirmwareEnvironmentVariable(LPCTSTR, LPCTSTR, PVOID, DWORD); + +BOOL SetFirmwareEnvironmentVariable(LPCTSTR, LPCTSTR, PVOID, DWORD); + +HRSRC FindResource(HMODULE, LPCTSTR, LPCTSTR); + +HRSRC FindResourceEx(HMODULE, LPCTSTR, LPCTSTR, WORD); + +BOOL EnumResourceTypes(HMODULE, ENUMRESTYPEPROC, LONG_PTR); + +BOOL EnumResourceNames(HMODULE, LPCTSTR, ENUMRESNAMEPROC, LONG_PTR); + +BOOL EnumResourceLanguages(HMODULE, LPCTSTR, LPCTSTR, ENUMRESLANGPROC, LONG_PTR); + +HANDLE BeginUpdateResource(LPCTSTR, BOOL); + +BOOL UpdateResource(HANDLE, LPCTSTR, LPCTSTR, WORD, LPVOID, DWORD); + +BOOL EndUpdateResource(HANDLE, BOOL); + +ATOM GlobalAddAtom(LPCTSTR); + +ATOM GlobalAddAtomEx(LPCTSTR, DWORD); + +ATOM GlobalFindAtom(LPCTSTR); + +UINT GlobalGetAtomName(ATOM, LPTSTR, int); + +ATOM AddAtom(LPCTSTR); + +ATOM FindAtom(LPCTSTR); + +UINT GetAtomName(ATOM, LPTSTR, int); + +UINT GetProfileInt(LPCTSTR, LPCTSTR, INT); + +DWORD GetProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD); + +BOOL WriteProfileString(LPCTSTR, LPCTSTR, LPCTSTR); + +DWORD GetProfileSection(LPCTSTR, LPTSTR, DWORD); + +BOOL WriteProfileSection(LPCTSTR, LPCTSTR); + +UINT GetPrivateProfileInt(LPCTSTR, LPCTSTR, INT, LPCTSTR); + +DWORD GetPrivateProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD, LPCTSTR); + +BOOL WritePrivateProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR); + +DWORD GetPrivateProfileSection(LPCTSTR, LPTSTR, DWORD, LPCTSTR); + +BOOL WritePrivateProfileSection(LPCTSTR, LPCTSTR, LPCTSTR); + +DWORD GetPrivateProfileSectionNames(LPTSTR, DWORD, LPCTSTR); + +BOOL GetPrivateProfileStruct(LPCTSTR, LPCTSTR, LPVOID, UINT, LPCTSTR); + +BOOL WritePrivateProfileStruct(LPCTSTR, LPCTSTR, LPVOID, UINT, LPCTSTR); + +BOOL SetDllDirectory(LPCTSTR); + +DWORD GetDllDirectory(DWORD, LPTSTR); + +BOOL CreateDirectoryEx(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES); + +BOOL CreateDirectoryTransacted(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES, HANDLE); + +BOOL RemoveDirectoryTransacted(LPCTSTR, HANDLE); + +DWORD GetFullPathNameTransacted(LPCTSTR, DWORD, LPTSTR, LPTSTR *, HANDLE); + +BOOL DefineDosDevice(DWORD, LPCTSTR, LPCTSTR); + +DWORD QueryDosDevice(LPCTSTR, LPTSTR, DWORD); + +HANDLE CreateFileTransacted(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE, HANDLE, PUSHORT, PVOID); + +BOOL SetFileAttributesTransacted(LPCTSTR, DWORD, HANDLE); + +BOOL GetFileAttributesTransacted(LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID, HANDLE); + +DWORD GetCompressedFileSizeTransacted(LPCTSTR, LPDWORD, HANDLE); + +BOOL DeleteFileTransacted(LPCTSTR, HANDLE); + +BOOL CheckNameLegalDOS8Dot3(LPCTSTR, LPSTR, DWORD, PBOOL, PBOOL); + +HANDLE FindFirstFileTransacted(LPCTSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD, HANDLE); + +BOOL CopyFile(LPCTSTR, LPCTSTR, BOOL); + +BOOL CopyFileEx(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD); + +BOOL CopyFileTransacted(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD, HANDLE); + +BOOL MoveFile(LPCTSTR, LPCTSTR); + +BOOL MoveFileEx(LPCTSTR, LPCTSTR, DWORD); + +BOOL MoveFileWithProgress(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, DWORD); + +BOOL MoveFileTransacted(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, DWORD, HANDLE); + +BOOL ReplaceFile(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, LPVOID, LPVOID); + +BOOL CreateHardLink(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES); + +BOOL CreateHardLinkTransacted(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES, HANDLE); + +HANDLE CreateNamedPipe(LPCTSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES); + +BOOL GetNamedPipeHandleState(HANDLE, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPTSTR, DWORD); + +BOOL CallNamedPipe(LPCTSTR, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, DWORD); + +BOOL WaitNamedPipe(LPCTSTR, DWORD); + +BOOL GetNamedPipeClientComputerName(HANDLE, LPTSTR, ULONG); + +BOOL SetVolumeLabel(LPCTSTR, LPCTSTR); + +BOOL ClearEventLog(HANDLE, LPCTSTR); + +BOOL BackupEventLog(HANDLE, LPCTSTR); + +HANDLE OpenEventLog(LPCTSTR, LPCTSTR); + +HANDLE RegisterEventSource(LPCTSTR, LPCTSTR); + +HANDLE OpenBackupEventLog(LPCTSTR, LPCTSTR); + +BOOL ReadEventLog(HANDLE, DWORD, DWORD, LPVOID, DWORD, DWORD *, DWORD *); + +BOOL ReportEvent(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCTSTR *, LPVOID); + +BOOL AccessCheckAndAuditAlarm(LPCTSTR, LPVOID, LPTSTR, LPTSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPBOOL, LPBOOL); + +BOOL AccessCheckByTypeAndAuditAlarm(LPCTSTR, LPVOID, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPBOOL, LPBOOL); + +BOOL AccessCheckByTypeResultListAndAuditAlarm(LPCTSTR, LPVOID, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPDWORD, LPBOOL); + +BOOL AccessCheckByTypeResultListAndAuditAlarmByHandle(LPCTSTR, LPVOID, HANDLE, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPDWORD, LPBOOL); + +BOOL ObjectOpenAuditAlarm(LPCTSTR, LPVOID, LPTSTR, LPTSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, LPBOOL); + +BOOL ObjectPrivilegeAuditAlarm(LPCTSTR, LPVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL); + +BOOL ObjectCloseAuditAlarm(LPCTSTR, LPVOID, BOOL); + +BOOL ObjectDeleteAuditAlarm(LPCTSTR, LPVOID, BOOL); + +BOOL PrivilegedServiceAuditAlarm(LPCTSTR, LPCTSTR, HANDLE, PPRIVILEGE_SET, BOOL); + +BOOL SetFileSecurity(LPCTSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR); + +BOOL GetFileSecurity(LPCTSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, LPDWORD); + +BOOL IsBadStringPtr(LPCTSTR, UINT_PTR); + +BOOL LookupAccountSid(LPCTSTR, PSID, LPTSTR, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); + +BOOL LookupAccountName(LPCTSTR, LPCTSTR, PSID, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); + +BOOL LookupAccountNameLocal(LPCTSTR, PSID, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); + +BOOL LookupAccountSidLocal(PSID, LPTSTR, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); + +BOOL LookupPrivilegeValue(LPCTSTR, LPCTSTR, PLUID); + +BOOL LookupPrivilegeName(LPCTSTR, PLUID, LPTSTR, LPDWORD); + +BOOL LookupPrivilegeDisplayName(LPCTSTR, LPCTSTR, LPTSTR, LPDWORD, LPDWORD); + +BOOL BuildCommDCB(LPCTSTR, LPDCB); + +BOOL BuildCommDCBAndTimeouts(LPCTSTR, LPDCB, LPCOMMTIMEOUTS); + +BOOL CommConfigDialog(LPCTSTR, HWND, LPCOMMCONFIG); + +BOOL GetDefaultCommConfig(LPCTSTR, LPCOMMCONFIG, LPDWORD); + +BOOL SetDefaultCommConfig(LPCTSTR, LPCOMMCONFIG, DWORD); + +BOOL GetComputerName(LPTSTR, LPDWORD); + +BOOL DnsHostnameToComputerName(LPCTSTR, LPTSTR, LPDWORD); + +BOOL GetUserName(LPTSTR, LPDWORD); + +BOOL LogonUser(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, DWORD, PHANDLE); + +BOOL LogonUserEx(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, DWORD, PHANDLE, PSID *, PVOID *, LPDWORD, PQUOTA_LIMITS); + +HANDLE CreatePrivateNamespace(LPSECURITY_ATTRIBUTES, LPVOID, LPCTSTR); + +HANDLE OpenPrivateNamespace(LPVOID, LPCTSTR); + +HANDLE CreateBoundaryDescriptor(LPCTSTR, ULONG); + +BOOL GetCurrentHwProfile(LPHW_PROFILE_INFO); + +BOOL VerifyVersionInfo(LPOSVERSIONINFOEX, DWORD, DWORDLONG); + +HANDLE CreateJobObject(LPSECURITY_ATTRIBUTES, LPCTSTR); + +HANDLE OpenJobObject(DWORD, BOOL, LPCTSTR); + +HANDLE FindFirstVolume(LPTSTR, DWORD); + +BOOL FindNextVolume(HANDLE, LPTSTR, DWORD); + +HANDLE FindFirstVolumeMountPoint(LPCTSTR, LPTSTR, DWORD); + +BOOL FindNextVolumeMountPoint(HANDLE, LPTSTR, DWORD); + +BOOL SetVolumeMountPoint(LPCTSTR, LPCTSTR); + +BOOL DeleteVolumeMountPoint(LPCTSTR); + +BOOL GetVolumeNameForVolumeMountPoint(LPCTSTR, LPTSTR, DWORD); + +BOOL GetVolumePathName(LPCTSTR, LPTSTR, DWORD); + +BOOL GetVolumePathNamesForVolumeName(LPCTSTR, LPTCH, DWORD, PDWORD); + +HANDLE CreateActCtx(PCACTCTX); + +BOOL FindActCtxSectionString(DWORD, const GUID *, ULONG, LPCTSTR, PACTCTX_SECTION_KEYED_DATA); + +BOOLEAN CreateSymbolicLink(LPCTSTR, LPCTSTR, DWORD); + +BOOLEAN CreateSymbolicLinkTransacted(LPCTSTR, LPCTSTR, DWORD, HANDLE); + +int AddFontResource(LPCTSTR); + +HMETAFILE CopyMetaFile(HMETAFILE, LPCTSTR); + +HDC CreateDC(LPCTSTR, LPCTSTR, LPCTSTR, const DEVMODE *); + +HFONT CreateFontIndirect(const LOGFONT *); + +HFONT CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR); + +HDC CreateIC(LPCTSTR, LPCTSTR, LPCTSTR, const DEVMODE *); + +HDC CreateMetaFile(LPCTSTR); + +BOOL CreateScalableFontResource(DWORD, LPCTSTR, LPCTSTR, LPCTSTR); + +int DeviceCapabilities(LPCTSTR, LPCTSTR, WORD, LPTSTR, const DEVMODE *); + +int EnumFontFamiliesEx(HDC, LPLOGFONT, FONTENUMPROC, LPARAM, DWORD); + +int EnumFontFamilies(HDC, LPCTSTR, FONTENUMPROC, LPARAM); + +int EnumFonts(HDC, LPCTSTR, FONTENUMPROC, LPARAM); + +BOOL GetCharWidth(HDC, UINT, UINT, LPINT); + +BOOL GetCharWidth32(HDC, UINT, UINT, LPINT); + +BOOL GetCharWidthFloat(HDC, UINT, UINT, PFLOAT); + +BOOL GetCharABCWidths(HDC, UINT, UINT, LPABC); + +BOOL GetCharABCWidthsFloat(HDC, UINT, UINT, LPABCFLOAT); + +DWORD GetGlyphOutline(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, LPVOID, const MAT2 *); + +HMETAFILE GetMetaFile(LPCTSTR); + +UINT GetOutlineTextMetrics(HDC, UINT, LPOUTLINETEXTMETRIC); + +BOOL GetTextExtentPoint(HDC, LPCTSTR, int, LPSIZE); + +BOOL GetTextExtentPoint32(HDC, LPCTSTR, int, LPSIZE); + +BOOL GetTextExtentExPoint(HDC, LPCTSTR, int, int, LPINT, LPINT, LPSIZE); + +DWORD GetCharacterPlacement(HDC, LPCTSTR, int, int, LPGCP_RESULTS, DWORD); + +DWORD GetGlyphIndices(HDC, LPCTSTR, int, LPWORD, DWORD); + +int AddFontResourceEx(LPCTSTR, DWORD, PVOID); + +BOOL RemoveFontResourceEx(LPCTSTR, DWORD, PVOID); + +HFONT CreateFontIndirectEx(const ENUMLOGFONTEXDV *); + +HDC ResetDC(HDC, const DEVMODE *); + +BOOL RemoveFontResource(LPCTSTR); + +HENHMETAFILE CopyEnhMetaFile(HENHMETAFILE, LPCTSTR); + +HDC CreateEnhMetaFile(HDC, LPCTSTR, const RECT *, LPCTSTR); + +HENHMETAFILE GetEnhMetaFile(LPCTSTR); + +UINT GetEnhMetaFileDescription(HENHMETAFILE, UINT, LPTSTR); + +BOOL GetTextMetrics(HDC, LPTEXTMETRIC); + +int StartDoc(HDC, const DOCINFO *); + +int GetObject(HANDLE, int, LPVOID); + +BOOL TextOut(HDC, int, int, LPCTSTR, int); + +BOOL ExtTextOut(HDC, int, int, UINT, const RECT *, LPCTSTR, UINT, const INT *); + +BOOL PolyTextOut(HDC, const POLYTEXT *, int); + +int GetTextFace(HDC, int, LPTSTR); + +DWORD GetKerningPairs(HDC, DWORD, LPKERNINGPAIR); + +BOOL GetLogColorSpace(HCOLORSPACE, LPLOGCOLORSPACE, DWORD); + +HCOLORSPACE CreateColorSpace(LPLOGCOLORSPACE); + +BOOL GetICMProfile(HDC, LPDWORD, LPTSTR); + +BOOL SetICMProfile(HDC, LPTSTR); + +int EnumICMProfiles(HDC, ICMENUMPROC, LPARAM); + +BOOL UpdateICMRegKey(DWORD, LPTSTR, LPTSTR, UINT); + +HKL LoadKeyboardLayout(LPCTSTR, UINT); + +BOOL GetKeyboardLayoutName(LPTSTR); + +HDESK CreateDesktop(LPCTSTR, LPCTSTR, DEVMODE*, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES); + +HDESK CreateDesktopEx(LPCTSTR, LPCTSTR, DEVMODE*, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES, ULONG, PVOID); + +HDESK OpenDesktop(LPCTSTR, DWORD, BOOL, ACCESS_MASK); + +BOOL EnumDesktops(HWINSTA, DESKTOPENUMPROC, LPARAM); + +HWINSTA CreateWindowStation(LPCTSTR, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES); + +HWINSTA OpenWindowStation(LPCTSTR, BOOL, ACCESS_MASK); + +BOOL EnumWindowStations(WINSTAENUMPROC, LPARAM); + +BOOL GetUserObjectInformation(HANDLE, int, PVOID, DWORD, LPDWORD); + +BOOL SetUserObjectInformation(HANDLE, int, PVOID, DWORD); + +UINT RegisterWindowMessage(LPCTSTR); + +BOOL GetMessage(LPMSG, HWND, UINT, UINT); + +LRESULT DispatchMessage(const MSG *); + +BOOL PeekMessage(LPMSG, HWND, UINT, UINT, UINT); + +LRESULT SendMessage(HWND, UINT, WPARAM, LPARAM); + +LRESULT SendMessageTimeout(HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR); + +BOOL SendNotifyMessage(HWND, UINT, WPARAM, LPARAM); + +BOOL SendMessageCallback(HWND, UINT, WPARAM, LPARAM, SENDASYNCPROC, ULONG_PTR); + +long BroadcastSystemMessageEx(DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO); + +long BroadcastSystemMessage(DWORD, LPDWORD, UINT, WPARAM, LPARAM); + +HDEVNOTIFY RegisterDeviceNotification(HANDLE, LPVOID, DWORD); + +BOOL PostMessage(HWND, UINT, WPARAM, LPARAM); + +BOOL PostThreadMessage(DWORD, UINT, WPARAM, LPARAM); + +BOOL PostAppMessage(DWORD, UINT, WPARAM, LPARAM); + +LRESULT DefWindowProc(HWND, UINT, WPARAM, LPARAM); + +LRESULT CallWindowProc(WNDPROC, HWND, UINT, WPARAM, LPARAM); + +ATOM RegisterClass(const WNDCLASS *); + +BOOL UnregisterClass(LPCTSTR, HINSTANCE); + +BOOL GetClassInfo(HINSTANCE, LPCTSTR, LPWNDCLASS); + +ATOM RegisterClassEx(const WNDCLASSEX *); + +BOOL GetClassInfoEx(HINSTANCE, LPCTSTR, LPWNDCLASSEX); + +HWND CreateWindowEx(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID); + +HWND CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID); + +HWND CreateDialogParam(HINSTANCE, LPCTSTR, HWND, DLGPROC, LPARAM); + +HWND CreateDialogIndirectParam(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM); + +HWND CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC); + +HWND CreateDialogIndirect(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC); + +INT_PTR DialogBoxParam(HINSTANCE, LPCTSTR, HWND, DLGPROC, LPARAM); + +INT_PTR DialogBoxIndirectParam(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM); + +INT_PTR DialogBox(HINSTANCE, LPCTSTR, HWND, DLGPROC); + +INT_PTR DialogBoxIndirect(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC); + +BOOL SetDlgItemText(HWND, int, LPCTSTR); + +UINT GetDlgItemText(HWND, int, LPTSTR, int); + +LRESULT SendDlgItemMessage(HWND, int, UINT, WPARAM, LPARAM); + +LRESULT DefDlgProc(HWND, UINT, WPARAM, LPARAM); + +BOOL CallMsgFilter(LPMSG, int); + +UINT RegisterClipboardFormat(LPCTSTR); + +int GetClipboardFormatName(UINT, LPTSTR, int); + +BOOL CharToOem(LPCTSTR, LPSTR); + +BOOL OemToChar(LPCSTR, LPTSTR); + +BOOL CharToOemBuff(LPCTSTR, LPSTR, DWORD); + +BOOL OemToCharBuff(LPCSTR, LPTSTR, DWORD); + +LPTSTR CharUpper(LPTSTR); + +DWORD CharUpperBuff(LPTSTR, DWORD); + +LPTSTR CharLower(LPTSTR); + +DWORD CharLowerBuff(LPTSTR, DWORD); + +LPTSTR CharNext(LPCTSTR); + +LPTSTR CharPrev(LPCTSTR, LPCTSTR); + +BOOL IsCharAlpha(CHAR); + +BOOL IsCharAlphaNumeric(CHAR); + +BOOL IsCharUpper(CHAR); + +BOOL IsCharLower(CHAR); + +int GetKeyNameText(LONG, LPTSTR, int); + +SHORT VkKeyScan(CHAR); + +SHORT VkKeyScanEx(CHAR, HKL); + +UINT MapVirtualKey(UINT, UINT); + +UINT MapVirtualKeyEx(UINT, UINT, HKL); + +HACCEL LoadAccelerators(HINSTANCE, LPCTSTR); + +HACCEL CreateAcceleratorTable(LPACCEL, int); + +int CopyAcceleratorTable(HACCEL, LPACCEL, int); + +int TranslateAccelerator(HWND, HACCEL, LPMSG); + +HMENU LoadMenu(HINSTANCE, LPCTSTR); + +HMENU LoadMenuIndirect(const MENUTEMPLATE *); + +BOOL ChangeMenu(HMENU, UINT, LPCTSTR, UINT, UINT); + +int GetMenuString(HMENU, UINT, LPTSTR, int, UINT); + +BOOL InsertMenu(HMENU, UINT, UINT, UINT_PTR, LPCTSTR); + +BOOL AppendMenu(HMENU, UINT, UINT_PTR, LPCTSTR); + +BOOL ModifyMenu(HMENU, UINT, UINT, UINT_PTR, LPCTSTR); + +BOOL InsertMenuItem(HMENU, UINT, BOOL, LPCMENUITEMINFO); + +BOOL GetMenuItemInfo(HMENU, UINT, BOOL, LPMENUITEMINFO); + +BOOL SetMenuItemInfo(HMENU, UINT, BOOL, LPCMENUITEMINFO); + +int DrawText(HDC, LPCTSTR, int, LPRECT, UINT); + +int DrawTextEx(HDC, LPTSTR, int, LPRECT, UINT, LPDRAWTEXTPARAMS); + +BOOL GrayString(HDC, HBRUSH, GRAYSTRINGPROC, LPARAM, int, int, int, int, int); + +BOOL DrawState(HDC, HBRUSH, DRAWSTATEPROC, LPARAM, WPARAM, int, int, int, int, UINT); + +LONG TabbedTextOut(HDC, int, int, LPCTSTR, int, int, const INT *, int); + +DWORD GetTabbedTextExtent(HDC, LPCTSTR, int, int, const INT *); + +BOOL SetProp(HWND, LPCTSTR, HANDLE); + +HANDLE GetProp(HWND, LPCTSTR); + +HANDLE RemoveProp(HWND, LPCTSTR); + +int EnumPropsEx(HWND, PROPENUMPROCEX, LPARAM); + +int EnumProps(HWND, PROPENUMPROC); + +BOOL SetWindowText(HWND, LPCTSTR); + +int GetWindowText(HWND, LPTSTR, int); + +int GetWindowTextLength(HWND); + +int MessageBox(HWND, LPCTSTR, LPCTSTR, UINT); + +int MessageBoxEx(HWND, LPCTSTR, LPCTSTR, UINT, WORD); + +int MessageBoxIndirect(const MSGBOXPARAMS *); + +LONG GetWindowLong(HWND, int); + +LONG SetWindowLong(HWND, int, LONG); + +LONG_PTR GetWindowLongPtr(HWND, int); + +LONG_PTR SetWindowLongPtr(HWND, int, LONG_PTR); + +DWORD GetClassLong(HWND, int); + +DWORD SetClassLong(HWND, int, LONG); + +ULONG_PTR GetClassLongPtr(HWND, int); + +ULONG_PTR SetClassLongPtr(HWND, int, LONG_PTR); + +HWND FindWindow(LPCTSTR, LPCTSTR); + +HWND FindWindowEx(HWND, HWND, LPCTSTR, LPCTSTR); + +int GetClassName(HWND, LPTSTR, int); + +HHOOK SetWindowsHook(int, HOOKPROC); + +HHOOK SetWindowsHookEx(int, HOOKPROC, HINSTANCE, DWORD); + +HBITMAP LoadBitmap(HINSTANCE, LPCTSTR); + +HCURSOR LoadCursor(HINSTANCE, LPCTSTR); + +HCURSOR LoadCursorFromFile(LPCTSTR); + +HICON LoadIcon(HINSTANCE, LPCTSTR); + +UINT PrivateExtractIcons(LPCTSTR, int, int, int, HICON *, UINT *, UINT, UINT); + +HANDLE LoadImage(HINSTANCE, LPCTSTR, UINT, int, int, UINT); + +BOOL GetIconInfoEx(HICON, PICONINFOEX); + +BOOL IsDialogMessage(HWND, LPMSG); + +int DlgDirList(HWND, LPTSTR, int, int, UINT); + +BOOL DlgDirSelectEx(HWND, LPTSTR, int, int); + +int DlgDirListComboBox(HWND, LPTSTR, int, int, UINT); + +BOOL DlgDirSelectComboBoxEx(HWND, LPTSTR, int, int); + +LRESULT DefFrameProc(HWND, HWND, UINT, WPARAM, LPARAM); + +LRESULT DefMDIChildProc(HWND, UINT, WPARAM, LPARAM); + +HWND CreateMDIWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HINSTANCE, LPARAM); + +BOOL WinHelp(HWND, LPCTSTR, UINT, ULONG_PTR); + +LONG ChangeDisplaySettings(DEVMODE*, DWORD); + +LONG ChangeDisplaySettingsEx(LPCTSTR, DEVMODE*, HWND, DWORD, LPVOID); + +BOOL EnumDisplaySettings(LPCTSTR, DWORD, DEVMODE*); + +BOOL EnumDisplaySettingsEx(LPCTSTR, DWORD, DEVMODE*, DWORD); + +BOOL EnumDisplayDevices(LPCTSTR, DWORD, PDISPLAY_DEVICE, DWORD); + +BOOL SystemParametersInfo(UINT, UINT, PVOID, UINT); + +BOOL GetMonitorInfo(HMONITOR, LPMONITORINFO); + +UINT GetWindowModuleFileName(HWND, LPTSTR, UINT); + +UINT RealGetWindowClass(HWND, LPTSTR, UINT); + +BOOL GetAltTabInfo(HWND, int, PALTTABINFO, LPTSTR, UINT); + +UINT GetRawInputDeviceInfo(HANDLE, UINT, LPVOID, PUINT); + +int GetDateFormat(LCID, DWORD, const SYSTEMTIME*, LPCTSTR, LPTSTR, int); + +int GetTimeFormat(LCID, DWORD, const SYSTEMTIME*, LPCTSTR, LPTSTR, int); + +BOOL GetCPInfoEx(UINT, DWORD, LPCPINFOEX); + +int CompareString(LCID, DWORD, PCNZTCH, int, PCNZTCH, int); + +int GetLocaleInfo(LCID, LCTYPE, LPTSTR, int); + +BOOL SetLocaleInfo(LCID, LCTYPE, LPCTSTR); + +int GetCalendarInfo(LCID, CALID, CALTYPE, LPTSTR, int, LPDWORD); + +BOOL SetCalendarInfo(LCID, CALID, CALTYPE, LPCTSTR); + +int GetNumberFormat(LCID, DWORD, LPCTSTR, const NUMBERFMT *, LPTSTR, int); + +int GetCurrencyFormat(LCID, DWORD, LPCTSTR, const CURRENCYFMT *, LPTSTR, int); + +BOOL EnumCalendarInfo(CALINFO_ENUMPROC, LCID, CALID, CALTYPE); + +BOOL EnumCalendarInfoEx(CALINFO_ENUMPROCEX, LCID, CALID, CALTYPE); + +BOOL EnumTimeFormats(TIMEFMT_ENUMPROC, LCID, DWORD); + +BOOL EnumDateFormats(DATEFMT_ENUMPROC, LCID, DWORD); + +BOOL EnumDateFormatsEx(DATEFMT_ENUMPROCEX, LCID, DWORD); + +int GetGeoInfo(GEOID, GEOTYPE, LPTSTR, int, LANGID); + +BOOL GetStringTypeEx(LCID, DWORD, LPCTSTR, int, LPWORD); + +int FoldString(DWORD, LPCTSTR, int, LPTSTR, int); + +BOOL EnumSystemLocales(LOCALE_ENUMPROC, DWORD); + +BOOL EnumSystemLanguageGroups(LANGUAGEGROUP_ENUMPROC, DWORD, LONG_PTR); + +BOOL EnumLanguageGroupLocales(LANGGROUPLOCALE_ENUMPROC, LGRPID, DWORD, LONG_PTR); + +BOOL EnumUILanguages(UILANGUAGE_ENUMPROC, DWORD, LONG_PTR); + +BOOL EnumSystemCodePages(CODEPAGE_ENUMPROC, DWORD); + +BOOL ReadConsoleInput(HANDLE, PINPUT_RECORD, DWORD, LPDWORD); + +BOOL PeekConsoleInput(HANDLE, PINPUT_RECORD, DWORD, LPDWORD); + +BOOL ReadConsole(HANDLE, LPVOID, DWORD, LPDWORD, PCONSOLE_READCONSOLE_CONTROL); + +BOOL WriteConsole(HANDLE, const void*, DWORD, LPDWORD, LPVOID); + +BOOL FillConsoleOutputCharacter(HANDLE, CHAR, DWORD, COORD, LPDWORD); + +BOOL WriteConsoleOutputCharacter(HANDLE, LPCTSTR, DWORD, COORD, LPDWORD); + +BOOL ReadConsoleOutputCharacter(HANDLE, LPTSTR, DWORD, COORD, LPDWORD); + +BOOL WriteConsoleInput(HANDLE, const INPUT_RECORD*, DWORD, LPDWORD); + +BOOL ScrollConsoleScreenBuffer(HANDLE, const SMALL_RECT*, const SMALL_RECT*, COORD, const CHAR_INFO*); + +BOOL WriteConsoleOutput(HANDLE, const CHAR_INFO*, COORD, COORD, PSMALL_RECT); + +BOOL ReadConsoleOutput(HANDLE, PCHAR_INFO, COORD, COORD, PSMALL_RECT); + +DWORD GetConsoleTitle(LPTSTR, DWORD); + +DWORD GetConsoleOriginalTitle(LPTSTR, DWORD); + +BOOL SetConsoleTitle(LPCTSTR); + +BOOL AddConsoleAlias(LPTSTR, LPTSTR, LPTSTR); + +DWORD GetConsoleAlias(LPTSTR, LPTSTR, DWORD, LPTSTR); + +DWORD GetConsoleAliasesLength(LPTSTR); + +DWORD GetConsoleAliasExesLength(); + +DWORD GetConsoleAliases(LPTSTR, DWORD, LPTSTR); + +DWORD GetConsoleAliasExes(LPTSTR, DWORD); + +void ExpungeConsoleCommandHistory(LPTSTR); + +BOOL SetConsoleNumberOfCommands(DWORD, LPTSTR); + +DWORD GetConsoleCommandHistoryLength(LPTSTR); + +DWORD GetConsoleCommandHistory(LPTSTR, DWORD, LPTSTR); + +DWORD VerFindFile(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, PUINT, LPTSTR, PUINT); + +DWORD VerInstallFile(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, PUINT); + +DWORD GetFileVersionInfoSize(LPCTSTR, LPDWORD); + +BOOL GetFileVersionInfo(LPCTSTR, DWORD, DWORD, LPVOID); + +DWORD GetFileVersionInfoSizeEx(DWORD, LPCTSTR, LPDWORD); + +BOOL GetFileVersionInfoEx(DWORD, LPCTSTR, DWORD, DWORD, LPVOID); + +DWORD VerLanguageName(DWORD, LPTSTR, DWORD); + +BOOL VerQueryValue(LPCVOID, LPCTSTR, LPVOID *, PUINT); + +LSTATUS RegConnectRegistry(LPCTSTR, HKEY, PHKEY); + +LSTATUS RegConnectRegistryEx(LPCTSTR, HKEY, ULONG, PHKEY); + +LSTATUS RegCreateKey(HKEY, LPCTSTR, PHKEY); + +LSTATUS RegCreateKeyEx(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, const LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD); + +LSTATUS RegCreateKeyTransacted(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, const LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD, HANDLE, PVOID); + +LSTATUS RegDeleteKey(HKEY, LPCTSTR); + +LSTATUS RegDeleteKeyEx(HKEY, LPCTSTR, REGSAM, DWORD); + +LSTATUS RegDeleteKeyTransacted(HKEY, LPCTSTR, REGSAM, DWORD, HANDLE, PVOID); + +LSTATUS RegDeleteValue(HKEY, LPCTSTR); + +LSTATUS RegEnumKey(HKEY, DWORD, LPTSTR, DWORD); + +LSTATUS RegEnumKeyEx(HKEY, DWORD, LPTSTR, LPDWORD, LPDWORD, LPTSTR, LPDWORD, PFILETIME); + +LSTATUS RegEnumValue(HKEY, DWORD, LPTSTR, LPDWORD, LPDWORD, LPDWORD, LPBYTE, LPDWORD); + +LSTATUS RegLoadKey(HKEY, LPCTSTR, LPCTSTR); + +LSTATUS RegOpenKey(HKEY, LPCTSTR, PHKEY); + +LSTATUS RegOpenKeyEx(HKEY, LPCTSTR, DWORD, REGSAM, PHKEY); + +LSTATUS RegOpenKeyTransacted(HKEY, LPCTSTR, DWORD, REGSAM, PHKEY, HANDLE, PVOID); + +LSTATUS RegQueryInfoKey(HKEY, LPTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, PFILETIME); + +LSTATUS RegQueryValue(HKEY, LPCTSTR, LPTSTR, PLONG); + +LSTATUS RegQueryMultipleValues(HKEY, PVALENT, DWORD, LPTSTR, LPDWORD); + +LSTATUS RegQueryValueEx(HKEY, LPCTSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD); + +LSTATUS RegReplaceKey(HKEY, LPCTSTR, LPCTSTR, LPCTSTR); + +LSTATUS RegRestoreKey(HKEY, LPCTSTR, DWORD); + +LSTATUS RegSaveKey(HKEY, LPCTSTR, const LPSECURITY_ATTRIBUTES); + +LSTATUS RegSetValue(HKEY, LPCTSTR, DWORD, LPCTSTR, DWORD); + +LSTATUS RegSetValueEx(HKEY, LPCTSTR, DWORD, DWORD, const BYTE*, DWORD); + +LSTATUS RegUnLoadKey(HKEY, LPCTSTR); + +LSTATUS RegDeleteKeyValue(HKEY, LPCTSTR, LPCTSTR); + +LSTATUS RegSetKeyValue(HKEY, LPCTSTR, LPCTSTR, DWORD, LPCVOID, DWORD); + +LSTATUS RegDeleteTree(HKEY, LPCTSTR); + +LSTATUS RegCopyTree(HKEY, LPCTSTR, HKEY); + +LSTATUS RegGetValue(HKEY, LPCTSTR, LPCTSTR, DWORD, LPDWORD, PVOID, LPDWORD); + +LSTATUS RegLoadMUIString(HKEY, LPCTSTR, LPTSTR, DWORD, LPDWORD, DWORD, LPCTSTR); + +LSTATUS RegLoadAppKey(LPCTSTR, PHKEY, REGSAM, DWORD, DWORD); + +BOOL InitiateSystemShutdown(LPTSTR, LPTSTR, DWORD, BOOL, BOOL); + +BOOL AbortSystemShutdown(LPTSTR); + +BOOL InitiateSystemShutdownEx(LPTSTR, LPTSTR, DWORD, BOOL, BOOL, DWORD); + +DWORD InitiateShutdown(LPTSTR, LPTSTR, DWORD, DWORD, DWORD); + +LSTATUS RegSaveKeyEx(HKEY, LPCTSTR, const LPSECURITY_ATTRIBUTES, DWORD); + +DWORD MultinetGetConnectionPerformance(LPNETRESOURCE, LPNETCONNECTINFOSTRUCT); + +BOOL ChangeServiceConfig(SC_HANDLE, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR); + +BOOL ChangeServiceConfig2(SC_HANDLE, DWORD, LPVOID); + +SC_HANDLE CreateService(SC_HANDLE, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR); + +BOOL EnumDependentServices(SC_HANDLE, DWORD, LPENUM_SERVICE_STATUS, DWORD, LPDWORD, LPDWORD); + +BOOL EnumServicesStatus(SC_HANDLE, DWORD, DWORD, LPENUM_SERVICE_STATUS, DWORD, LPDWORD, LPDWORD, LPDWORD); + +BOOL EnumServicesStatusEx(SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD, LPDWORD, LPCTSTR); + +BOOL GetServiceKeyName(SC_HANDLE, LPCTSTR, LPTSTR, LPDWORD); + +BOOL GetServiceDisplayName(SC_HANDLE, LPCTSTR, LPTSTR, LPDWORD); + +SC_HANDLE OpenSCManager(LPCTSTR, LPCTSTR, DWORD); + +SC_HANDLE OpenService(SC_HANDLE, LPCTSTR, DWORD); + +BOOL QueryServiceConfig(SC_HANDLE, LPQUERY_SERVICE_CONFIG, DWORD, LPDWORD); + +BOOL QueryServiceConfig2(SC_HANDLE, DWORD, LPBYTE, DWORD, LPDWORD); + +BOOL QueryServiceLockStatus(SC_HANDLE, LPQUERY_SERVICE_LOCK_STATUS, DWORD, LPDWORD); + +SERVICE_STATUS_HANDLE RegisterServiceCtrlHandler(LPCTSTR, LPHANDLER_FUNCTION); + +SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerEx(LPCTSTR, LPHANDLER_FUNCTION_EX, LPVOID); + +BOOL StartServiceCtrlDispatcher(const SERVICE_TABLE_ENTRY *); + +BOOL StartService(SC_HANDLE, DWORD, LPCTSTR *); + +DWORD NotifyServiceStatusChange(SC_HANDLE, DWORD, PSERVICE_NOTIFY); + +BOOL ControlServiceEx(SC_HANDLE, DWORD, DWORD, PVOID); + +HKL ImmInstallIME(LPCTSTR, LPCTSTR); + +UINT ImmGetDescription(HKL, LPTSTR, UINT); + +UINT ImmGetIMEFileName(HKL, LPTSTR, UINT); + +LONG ImmGetCompositionString(HIMC, DWORD, LPVOID, DWORD); + +BOOL ImmSetCompositionString(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD); + +DWORD ImmGetCandidateListCount(HIMC, LPDWORD); + +DWORD ImmGetCandidateList(HIMC, DWORD, LPCANDIDATELIST, DWORD); + +DWORD ImmGetGuideLine(HIMC, DWORD, LPTSTR, DWORD); + +BOOL ImmGetCompositionFont(HIMC, LPLOGFONT); + +BOOL ImmSetCompositionFont(HIMC, LPLOGFONT); + +BOOL ImmConfigureIME(HKL, HWND, DWORD, LPVOID); + +LRESULT ImmEscape(HKL, HIMC, UINT, LPVOID); + +DWORD ImmGetConversionList(HKL, HIMC, LPCTSTR, LPCANDIDATELIST, DWORD, UINT); + +BOOL ImmIsUIMessage(HWND, UINT, WPARAM, LPARAM); + +BOOL ImmRegisterWord(HKL, LPCTSTR, DWORD, LPCTSTR); + +BOOL ImmUnregisterWord(HKL, LPCTSTR, DWORD, LPCTSTR); + +UINT ImmGetRegisterWordStyle(HKL, UINT, LPSTYLEBUF); + +UINT ImmEnumRegisterWord(HKL, REGISTERWORDENUMPROC, LPCTSTR, DWORD, LPCTSTR, LPVOID); + +DWORD ImmGetImeMenuItems(HIMC, DWORD, DWORD, LPIMEMENUITEMINFO, LPIMEMENUITEMINFO, DWORD); diff --git a/config/windows-h-wrapper.template.h b/config/windows-h-wrapper.template.h new file mode 100644 index 000000000000..ece404f4fdf0 --- /dev/null +++ b/config/windows-h-wrapper.template.h @@ -0,0 +1,55 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 et sw=2 tw=80: */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#ifndef mozilla_windows_h +#define mozilla_windows_h + +// Include the "real" windows.h header. On clang/gcc, this can be done with the +// `include_next` feature, however MSVC requires a direct include path. +// +// Also turn off deprecation warnings, as we may be wrapping deprecated fns. + +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC system_header +# include_next + +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#else +# include <${header_path}> + +# pragma warning(push) +# pragma warning(disable: 4996 4995) +#endif // defined(__GNUC__) || defined(__clang__) + +// Check if the header should be disabled +#if defined(MOZ_DISABLE_WINDOWS_WRAPPER) +#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled" + +#elif !defined(__cplusplus) +#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file" + +#elif !defined(__GNUC__) && !defined(__clang__) && !defined(_DLL) +#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-dynamic RTL" + +#else +// We're allowed to wrap in the current context. Define `MOZ_WRAPPED_WINDOWS_H` +// to note that fact, and perform the wrapping. +#define MOZ_WRAPPED_WINDOWS_H +extern "C++" { + +${decls} + +} // extern "C++" +#endif // enabled + +#if defined(__GNUC__) || defined(__clang__) +# pragma GCC diagnostic pop +#else +# pragma warning(pop) +#endif // defined(__GNUC__) || defined(__clang__) + +#endif // !defined(mozilla_windows_h) diff --git a/dom/base/moz.build b/dom/base/moz.build index ce26302f0e3f..8d0944055446 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -425,7 +425,7 @@ SOURCES += [ 'nsDOMWindowUtils.cpp', # Conflicts with windows.h's definition of SendMessage. 'nsFrameMessageManager.cpp', - # These files have a #error "Never include windows.h in this file!" + # These files have a #error "Never include unwrapped windows.h in this file!" 'nsGlobalWindowInner.cpp', 'nsGlobalWindowOuter.cpp', # Conflicts with windows.h's definition of LoadImage. diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index cb0b1e326b5c..a577deef8f9d 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -7867,8 +7867,9 @@ nsGlobalWindowInner::FireOnNewGlobalObject() JS_FireOnNewGlobalObject(aes.cx(), global); } -#ifdef _WINDOWS_ -#error "Never include windows.h in this file!" +#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H) +#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON) +#error "Never include unwrapped windows.h in this file!" #endif already_AddRefed diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index e69e46a53c28..54f936214c16 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -7638,8 +7638,9 @@ nsGlobalWindowOuter::ReportLargeAllocStatus() message); } -#ifdef _WINDOWS_ -#error "Never include windows.h in this file!" +#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H) +#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON) +#error "Never include unwrapped windows.h in this file!" #endif // Helper called by methods that move/resize the window, diff --git a/gfx/cairo/cairo/src/moz.build b/gfx/cairo/cairo/src/moz.build index 48c4a7bfa917..d356a26f7cdb 100755 --- a/gfx/cairo/cairo/src/moz.build +++ b/gfx/cairo/cairo/src/moz.build @@ -34,6 +34,7 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('cocoa', 'uikit'): ] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': + DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True EXPORTS.cairo += [ 'cairo-win32.h', ] diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 63711acfaf6b..846e24983a1f 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -262,7 +262,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) UINT32 ucs = L' '; UINT16 glyph; - HRESULT hr = mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph); + HRESULT hr = mFontFace->GetGlyphIndices(&ucs, 1, &glyph); if (FAILED(hr)) { mMetrics->spaceWidth = 0; } else { @@ -292,7 +292,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) if (mMetrics->aveCharWidth < 1) { ucs = L'x'; - if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) { + if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) { mMetrics->aveCharWidth = MeasureGlyphWidth(glyph); } if (mMetrics->aveCharWidth < 1) { @@ -302,7 +302,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) } ucs = L'0'; - if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) { + if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) { mMetrics->zeroOrAveCharWidth = MeasureGlyphWidth(glyph); } if (mMetrics->zeroOrAveCharWidth < 1) { diff --git a/gfx/vr/service/openvr/moz.build b/gfx/vr/service/openvr/moz.build index 351bf50e6183..5ad6d0b9b457 100644 --- a/gfx/vr/service/openvr/moz.build +++ b/gfx/vr/service/openvr/moz.build @@ -8,6 +8,9 @@ FINAL_LIBRARY = 'xul' DEFINES['VR_API_PUBLIC'] = True +# Windows.h wrappers conflict with internal methods in openvr +DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True + if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['HAVE_64BIT_BUILD']: DEFINES['WIN64'] = True diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 8b696f03ed7b..68fd162ec3ca 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -367,8 +367,9 @@ class CommonBackend(BuildBackend): if poison_windows_h: includeTemplate += ( '\n' - '#ifdef _WINDOWS_\n' - '#error "%(cppfile)s included windows.h"\n' + '#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)\n' + '#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)\n' + '#error "%(cppfile)s included unwrapped windows.h"\n' "#endif") includeTemplate += ( '\n' From 0a27b4b4a7f3deb7fb63fb9934368395821ec5fe Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Fri, 19 Oct 2018 18:00:59 -0400 Subject: [PATCH 08/13] Bug 1500944 - Part 1: Store the set of active WindowGlobalParent objects in ChromeBrowsingContext, r=farre This allows getting the set of all window globals for a given browsing context. This is less useful at the moment as the active window global is not exposed as such. That will be added as a follow-up. Differential Revision: https://phabricator.services.mozilla.com/D9393 --- docshell/base/BrowsingContext.cpp | 2 +- docshell/base/BrowsingContext.h | 7 +++-- docshell/base/ChromeBrowsingContext.cpp | 31 +++++++++++++++++- docshell/base/ChromeBrowsingContext.h | 22 ++++++++++--- dom/ipc/TabParent.cpp | 2 +- dom/ipc/WindowGlobalParent.cpp | 42 +++++++++++++++++-------- dom/ipc/WindowGlobalParent.h | 13 +++----- ipc/glue/InProcessParent.cpp | 2 +- 8 files changed, 87 insertions(+), 34 deletions(-) diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 5afdbda96bee..7affd92b1cbb 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "BrowsingContext.h" +#include "mozilla/dom/BrowsingContext.h" #include "mozilla/dom/ChromeBrowsingContext.h" #include "mozilla/dom/BrowsingContextBinding.h" diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 137d62a91939..c561c05e6204 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef BrowsingContext_h -#define BrowsingContext_h +#ifndef mozilla_dom_BrowsingContext_h +#define mozilla_dom_BrowsingContext_h #include "mozilla/LinkedList.h" #include "mozilla/Maybe.h" @@ -155,4 +155,5 @@ private: } // namespace dom } // namespace mozilla -#endif + +#endif // !defined(mozilla_dom_BrowsingContext_h) diff --git a/docshell/base/ChromeBrowsingContext.cpp b/docshell/base/ChromeBrowsingContext.cpp index ed215e2fc73a..89f1dc5804ec 100644 --- a/docshell/base/ChromeBrowsingContext.cpp +++ b/docshell/base/ChromeBrowsingContext.cpp @@ -4,7 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "ChromeBrowsingContext.h" +#include "mozilla/dom/ChromeBrowsingContext.h" +#include "mozilla/dom/WindowGlobalParent.h" #include "mozilla/dom/ContentParent.h" @@ -63,5 +64,33 @@ ChromeBrowsingContext::Cast(const BrowsingContext* aContext) return static_cast(aContext); } +void +ChromeBrowsingContext::RegisterWindowGlobal(WindowGlobalParent* aGlobal) +{ + MOZ_ASSERT(!mWindowGlobals.Contains(aGlobal), "Global already registered!"); + mWindowGlobals.PutEntry(aGlobal); +} + +void +ChromeBrowsingContext::UnregisterWindowGlobal(WindowGlobalParent* aGlobal) +{ + MOZ_ASSERT(mWindowGlobals.Contains(aGlobal), "Global not registered!"); + mWindowGlobals.RemoveEntry(aGlobal); +} + +void +ChromeBrowsingContext::Traverse(nsCycleCollectionTraversalCallback& cb) +{ + ChromeBrowsingContext* tmp = this; + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowGlobals); +} + +void +ChromeBrowsingContext::Unlink() +{ + ChromeBrowsingContext* tmp = this; + NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowGlobals); +} + } // namespace dom } // namespace mozilla diff --git a/docshell/base/ChromeBrowsingContext.h b/docshell/base/ChromeBrowsingContext.h index 5d34fc231ae7..b8a8db591325 100644 --- a/docshell/base/ChromeBrowsingContext.h +++ b/docshell/base/ChromeBrowsingContext.h @@ -4,19 +4,23 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef ChromeBrowsingContext_h -#define ChromeBrowsingContext_h +#ifndef mozilla_dom_ChromeBrowsingContext_h +#define mozilla_dom_ChromeBrowsingContext_h #include "mozilla/dom/BrowsingContext.h" #include "mozilla/RefPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" +#include "nsTHashtable.h" +#include "nsHashKeys.h" class nsIDocShell; namespace mozilla { namespace dom { +class WindowGlobalParent; + // ChromeBrowsingContext is a BrowsingContext living in the parent // process, with whatever extra data that a BrowsingContext in the // parent needs. @@ -34,9 +38,13 @@ public: return mProcessId == aProcessId; } + // Called by WindowGlobalParent to register and unregister window globals. + void RegisterWindowGlobal(WindowGlobalParent* aGlobal); + void UnregisterWindowGlobal(WindowGlobalParent* aGlobal); + protected: - void Traverse(nsCycleCollectionTraversalCallback& cb) {} - void Unlink() {} + void Traverse(nsCycleCollectionTraversalCallback& cb); + void Unlink(); using Type = BrowsingContext::Type; ChromeBrowsingContext(BrowsingContext* aParent, @@ -51,8 +59,12 @@ private: // XXX(farre): Store a ContentParent pointer here rather than mProcessId? // Indicates which process owns the docshell. uint64_t mProcessId; + + // All live window globals within this browsing context. + nsTHashtable> mWindowGlobals; }; } // namespace dom } // namespace mozilla -#endif + +#endif // !defined(mozilla_dom_ChromeBrowsingContext_h) diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 008bcdea83ea..5cf571179bef 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -1067,7 +1067,7 @@ IPCResult TabParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) { - static_cast(aActor)->Init(); + static_cast(aActor)->Init(aInit); return IPC_OK(); } diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index c2fbfb81e73e..19dcac8c9cb4 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -6,7 +6,7 @@ #include "mozilla/dom/WindowGlobalParent.h" #include "mozilla/ipc/InProcessParent.h" -#include "mozilla/dom/BrowsingContext.h" +#include "mozilla/dom/ChromeBrowsingContext.h" using namespace mozilla::ipc; @@ -15,22 +15,43 @@ namespace dom { WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit, bool aInProcess) - : mBrowsingContextId(aInit.browsingContextId()) - , mDocumentPrincipal(aInit.principal()) + : mDocumentPrincipal(aInit.principal()) , mInProcess(aInProcess) - , mIPCClosed(false) + , mIPCClosed(true) // Closed until WGP::Init { MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(), "Parent process only"); MOZ_RELEASE_ASSERT(mDocumentPrincipal, "Must have a valid principal"); - MOZ_RELEASE_ASSERT(mBrowsingContextId != 0, "Must be made in BrowsingContext"); + + // NOTE: mBrowsingContext initialized in Init() + MOZ_RELEASE_ASSERT(aInit.browsingContextId() != 0, + "Must be made in BrowsingContext"); } void -WindowGlobalParent::Init() +WindowGlobalParent::Init(const WindowGlobalInit& aInit) { MOZ_ASSERT(Manager(), "Should have a manager!"); MOZ_ASSERT(!mFrameLoader, "Cannot Init() a WindowGlobalParent twice!"); + MOZ_ASSERT(mIPCClosed, "IPC shouldn't be open yet"); + mIPCClosed = false; + + // Determine which content process the window global is coming from. + ContentParentId processId(0); + if (!mInProcess) { + processId = static_cast(Manager()->Manager())->ChildID(); + } + + mBrowsingContext = ChromeBrowsingContext::Get(aInit.browsingContextId()); + MOZ_ASSERT(mBrowsingContext); + + // XXX(nika): This won't be the case soon, but for now this is a good + // assertion as we can't switch processes. We should relax this eventually. + MOZ_ASSERT(mBrowsingContext->IsOwnedByProcess(processId)); + + // Attach ourself to the browsing context. + mBrowsingContext->RegisterWindowGlobal(this); + // Determine what toplevel frame element our WindowGlobalParent is being // embedded in. RefPtr frameElement; @@ -60,12 +81,6 @@ WindowGlobalParent::Init() } } -already_AddRefed -WindowGlobalParent::BrowsingContext() -{ - return dom::BrowsingContext::Get(mBrowsingContextId); -} - already_AddRefed WindowGlobalParent::GetOtherSide() { @@ -89,13 +104,14 @@ void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) { mIPCClosed = true; + mBrowsingContext->UnregisterWindowGlobal(this); } WindowGlobalParent::~WindowGlobalParent() { } -NS_IMPL_CYCLE_COLLECTION(WindowGlobalParent, mFrameLoader) +NS_IMPL_CYCLE_COLLECTION(WindowGlobalParent, mFrameLoader, mBrowsingContext) NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalParent, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalParent, Release) diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index 7bc6786d4352..1bed980da5d3 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -17,7 +17,7 @@ class nsFrameLoader; namespace mozilla { namespace dom { -class BrowsingContext; +class ChromeBrowsingContext; class WindowGlobalChild; /** @@ -46,7 +46,7 @@ public: nsIPrincipal* DocumentPrincipal() { return mDocumentPrincipal; } // The BrowsingContext which this WindowGlobal has been loaded into. - already_AddRefed BrowsingContext(); + ChromeBrowsingContext* BrowsingContext() { return mBrowsingContext; } // Get the root nsFrameLoader object for the tree of BrowsingContext nodes // which this WindowGlobal is a part of. This will be the nsFrameLoader @@ -63,7 +63,7 @@ public: // Initialize the mFrameLoader fields for a created WindowGlobalParent. Must // be called after setting the Manager actor. - void Init(); + void Init(const WindowGlobalInit& aInit); protected: // IPC messages @@ -74,17 +74,12 @@ protected: private: ~WindowGlobalParent(); - // XXX(nika): We should store the BrowsingContext here. Unfortunately, the - // parent process is not sent down the BrowsingContext object until - // potentially after the WindowGlobalChild has been created. We should change - // this in the future. - uint64_t mBrowsingContextId; - // NOTE: This document principal doesn't reflect possible |document.domain| // mutations which may have been made in the actual document. nsCOMPtr mDocumentPrincipal; nsCOMPtr mDocumentURI; RefPtr mFrameLoader; + RefPtr mBrowsingContext; bool mInProcess; bool mIPCClosed; }; diff --git a/ipc/glue/InProcessParent.cpp b/ipc/glue/InProcessParent.cpp index 34eb615c393e..4d56eb9d070e 100644 --- a/ipc/glue/InProcessParent.cpp +++ b/ipc/glue/InProcessParent.cpp @@ -18,7 +18,7 @@ IPCResult InProcessParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, const WindowGlobalInit& aInit) { - static_cast(aActor)->Init(); + static_cast(aActor)->Init(aInit); return IPC_OK(); } From ad145bea59d1fb6240ed0bc360781415accebf79 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Fri, 19 Oct 2018 19:02:56 -0400 Subject: [PATCH 09/13] Bug 1500944 - Part 2: Expose WindowGlobal actors to Chrome JS, r=farre This serves 2 purposes: 1. Provides an object corresponding to an inner window which Chrome JS can hold onto. 2. Provides the object to JS which Chrome JS per-window actors will be attached to. 3. Provides useful information to Chrome JS in the parent process. Differential Revision: https://phabricator.services.mozilla.com/D9394 --- docshell/base/BrowsingContext.h | 4 +-- docshell/base/ChromeBrowsingContext.cpp | 16 ++++++++++ docshell/base/ChromeBrowsingContext.h | 5 ++++ dom/chrome-webidl/BrowsingContext.webidl | 5 ++++ dom/chrome-webidl/WindowGlobalActors.webidl | 33 +++++++++++++++++++++ dom/chrome-webidl/moz.build | 1 + dom/ipc/WindowGlobalChild.cpp | 21 +++++++++++-- dom/ipc/WindowGlobalChild.h | 12 ++++++-- dom/ipc/WindowGlobalParent.cpp | 23 ++++++++++++-- dom/ipc/WindowGlobalParent.h | 12 ++++++-- 10 files changed, 119 insertions(+), 13 deletions(-) create mode 100644 dom/chrome-webidl/WindowGlobalActors.webidl diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index c561c05e6204..4e253f9b172b 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -122,8 +122,8 @@ public: nsTArray>& aBrowsingContexts); nsISupports* GetParentObject() const; - virtual JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; MOZ_DECLARE_WEAKREFERENCE_TYPENAME(BrowsingContext) NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BrowsingContext) diff --git a/docshell/base/ChromeBrowsingContext.cpp b/docshell/base/ChromeBrowsingContext.cpp index 89f1dc5804ec..9ec25d922def 100644 --- a/docshell/base/ChromeBrowsingContext.cpp +++ b/docshell/base/ChromeBrowsingContext.cpp @@ -64,6 +64,15 @@ ChromeBrowsingContext::Cast(const BrowsingContext* aContext) return static_cast(aContext); } +void +ChromeBrowsingContext::GetWindowGlobals(nsTArray>& aWindows) +{ + aWindows.SetCapacity(mWindowGlobals.Count()); + for (auto iter = mWindowGlobals.Iter(); !iter.Done(); iter.Next()) { + aWindows.AppendElement(iter.Get()->GetKey()); + } +} + void ChromeBrowsingContext::RegisterWindowGlobal(WindowGlobalParent* aGlobal) { @@ -78,6 +87,13 @@ ChromeBrowsingContext::UnregisterWindowGlobal(WindowGlobalParent* aGlobal) mWindowGlobals.RemoveEntry(aGlobal); } +JSObject* +ChromeBrowsingContext::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) +{ + return ChromeBrowsingContext_Binding::Wrap(aCx, this, aGivenProto); +} + void ChromeBrowsingContext::Traverse(nsCycleCollectionTraversalCallback& cb) { diff --git a/docshell/base/ChromeBrowsingContext.h b/docshell/base/ChromeBrowsingContext.h index b8a8db591325..c3bff2435c3a 100644 --- a/docshell/base/ChromeBrowsingContext.h +++ b/docshell/base/ChromeBrowsingContext.h @@ -38,10 +38,15 @@ public: return mProcessId == aProcessId; } + void GetWindowGlobals(nsTArray>& aWindows); + // Called by WindowGlobalParent to register and unregister window globals. void RegisterWindowGlobal(WindowGlobalParent* aGlobal); void UnregisterWindowGlobal(WindowGlobalParent* aGlobal); + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + protected: void Traverse(nsCycleCollectionTraversalCallback& cb); void Unlink(); diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index 236d51a9ce7e..92c0850d2dcc 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -17,3 +17,8 @@ interface BrowsingContext { readonly attribute BrowsingContext? opener; }; + +[Exposed=Window, ChromeOnly] +interface ChromeBrowsingContext : BrowsingContext { + sequence getWindowGlobals(); +}; diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl new file mode 100644 index 000000000000..4b847720d380 --- /dev/null +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -0,0 +1,33 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +interface Principal; +interface URI; +interface nsIDocShell; + +[Exposed=Window, ChromeOnly] +interface WindowGlobalParent { + readonly attribute boolean isClosed; + readonly attribute boolean isInProcess; + readonly attribute ChromeBrowsingContext browsingContext; + + // XXX(nika): We would want to expose this, but |FrameLoader| isn't exposed on System. + // readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only + + readonly attribute WindowGlobalChild? childActor; // in-process only + + // Information about the currently loaded document. + readonly attribute Principal documentPrincipal; + readonly attribute URI? documentURI; +}; + +[Exposed=Window, ChromeOnly] +interface WindowGlobalChild { + readonly attribute boolean isClosed; + readonly attribute boolean isInProcess; + readonly attribute BrowsingContext browsingContext; + + readonly attribute WindowGlobalParent? parentActor; // in-process only +}; diff --git a/dom/chrome-webidl/moz.build b/dom/chrome-webidl/moz.build index 19947457e13d..8a93ef30f47c 100644 --- a/dom/chrome-webidl/moz.build +++ b/dom/chrome-webidl/moz.build @@ -54,6 +54,7 @@ WEBIDL_FILES = [ 'TelemetryStopwatch.webidl', 'WebExtensionContentScript.webidl', 'WebExtensionPolicy.webidl', + 'WindowGlobalActors.webidl', 'XULFrameElement.webidl', 'XULMenuElement.webidl', 'XULScrollElement.webidl', diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index dd2026bb39ae..f19106c6ae01 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -7,6 +7,7 @@ #include "mozilla/dom/WindowGlobalChild.h" #include "mozilla/ipc/InProcessChild.h" #include "mozilla/dom/BrowsingContext.h" +#include "mozilla/dom/WindowGlobalActorsBinding.h" namespace mozilla { namespace dom { @@ -54,7 +55,7 @@ WindowGlobalChild::Create(nsGlobalWindowInner* aWindow) } already_AddRefed -WindowGlobalChild::GetOtherSide() +WindowGlobalChild::GetParentActor() { if (mIPCClosed) { return nullptr; @@ -73,7 +74,23 @@ WindowGlobalChild::~WindowGlobalChild() { } -NS_IMPL_CYCLE_COLLECTION(WindowGlobalChild, mWindowGlobal, mBrowsingContext) +JSObject* +WindowGlobalChild::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) +{ + return WindowGlobalChild_Binding::Wrap(aCx, this, aGivenProto); +} + +nsISupports* +WindowGlobalChild::GetParentObject() +{ + return xpc::NativeGlobal(xpc::PrivilegedJunkScope()); +} + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalChild, + mWindowGlobal, + mBrowsingContext) + NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalChild, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalChild, Release) diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h index cce3f12e73f5..3dde74ef713b 100644 --- a/dom/ipc/WindowGlobalChild.h +++ b/dom/ipc/WindowGlobalChild.h @@ -9,6 +9,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/dom/PWindowGlobalChild.h" +#include "nsWrapperCache.h" class nsGlobalWindowInner; class nsDocShell; @@ -23,11 +24,12 @@ class WindowGlobalParent; * Actor for a single nsGlobalWindowInner. This actor is used to communicate * information to the parent process asynchronously. */ -class WindowGlobalChild : public PWindowGlobalChild +class WindowGlobalChild : public nsWrapperCache + , public PWindowGlobalChild { public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalChild) - NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WindowGlobalChild) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalChild) dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; } nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; } @@ -41,12 +43,16 @@ public: // Get the other side of this actor if it is an in-process actor. Returns // |nullptr| if the actor has been torn down, or is not in-process. - already_AddRefed GetOtherSide(); + already_AddRefed GetParentActor(); // Create and initialize the WindowGlobalChild object. static already_AddRefed Create(nsGlobalWindowInner* aWindow); + nsISupports* GetParentObject(); + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + protected: virtual void ActorDestroy(ActorDestroyReason aWhy) override; diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 19dcac8c9cb4..480f6c4d81e7 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -7,6 +7,7 @@ #include "mozilla/dom/WindowGlobalParent.h" #include "mozilla/ipc/InProcessParent.h" #include "mozilla/dom/ChromeBrowsingContext.h" +#include "mozilla/dom/WindowGlobalActorsBinding.h" using namespace mozilla::ipc; @@ -59,7 +60,7 @@ WindowGlobalParent::Init(const WindowGlobalInit& aInit) // In the in-process case, we can get it from the other side's // WindowGlobalChild. MOZ_ASSERT(Manager()->GetProtocolTypeId() == PInProcessMsgStart); - RefPtr otherSide = GetOtherSide(); + RefPtr otherSide = GetChildActor(); if (otherSide && otherSide->WindowGlobal()) { // Get the toplevel window from the other side. RefPtr docShell = nsDocShell::Cast(otherSide->WindowGlobal()->GetDocShell()); @@ -82,7 +83,7 @@ WindowGlobalParent::Init(const WindowGlobalInit& aInit) } already_AddRefed -WindowGlobalParent::GetOtherSide() +WindowGlobalParent::GetChildActor() { if (mIPCClosed) { return nullptr; @@ -111,7 +112,23 @@ WindowGlobalParent::~WindowGlobalParent() { } -NS_IMPL_CYCLE_COLLECTION(WindowGlobalParent, mFrameLoader, mBrowsingContext) +JSObject* +WindowGlobalParent::WrapObject(JSContext* aCx, + JS::Handle aGivenProto) +{ + return WindowGlobalParent_Binding::Wrap(aCx, this, aGivenProto); +} + +nsISupports* +WindowGlobalParent::GetParentObject() +{ + return xpc::NativeGlobal(xpc::PrivilegedJunkScope()); +} + +NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalParent, + mFrameLoader, + mBrowsingContext) + NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalParent, AddRef) NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalParent, Release) diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index 1bed980da5d3..6ab6ac8f5985 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -9,6 +9,7 @@ #include "mozilla/RefPtr.h" #include "mozilla/dom/PWindowGlobalParent.h" +#include "nsWrapperCache.h" class nsIPrincipal; class nsIURI; @@ -23,11 +24,12 @@ class WindowGlobalChild; /** * A handle in the parent process to a specific nsGlobalWindowInner object. */ -class WindowGlobalParent final : public PWindowGlobalParent +class WindowGlobalParent final : public nsWrapperCache + , public PWindowGlobalParent { public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalParent) - NS_DECL_CYCLE_COLLECTION_NATIVE_CLASS(WindowGlobalParent) + NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalParent) // Has this actor been shut down bool IsClosed() { return mIPCClosed; } @@ -38,7 +40,7 @@ public: // Get the other side of this actor if it is an in-process actor. Returns // |nullptr| if the actor has been torn down, or is not in-process. - already_AddRefed GetOtherSide(); + already_AddRefed GetChildActor(); // The principal of this WindowGlobal. This value will not change over the // lifetime of the WindowGlobal object, even to reflect changes in @@ -65,6 +67,10 @@ public: // be called after setting the Manager actor. void Init(const WindowGlobalInit& aInit); + nsISupports* GetParentObject(); + JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; + protected: // IPC messages mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI) override; From 1762b9772143fa2459ed0fd32a1763ab0be03ed9 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Fri, 19 Oct 2018 20:02:37 -0400 Subject: [PATCH 10/13] Bug 1500948 - Expose BrowsingContext on nsFrameLoader objects, r=farre This should make BrowsingContext more usable by making it much easier to obtain for a given frame or browser. BrowsingContext and nsFrameLoader should have the same lifetime. Differential Revision: https://phabricator.services.mozilla.com/D9395 --- dom/base/nsFrameLoader.cpp | 14 ++++++++++++++ dom/base/nsFrameLoader.h | 3 +++ dom/ipc/PBrowser.ipdl | 2 ++ dom/ipc/TabChild.cpp | 5 +++++ dom/ipc/TabParent.cpp | 10 ++++++++++ dom/ipc/TabParent.h | 8 ++++++++ dom/webidl/FrameLoader.webidl | 6 ++++++ 7 files changed, 48 insertions(+) diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 77091ac5ca1c..3f8ccc38c275 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -100,6 +100,7 @@ #include "mozilla/dom/PromiseNativeHandler.h" #include "mozilla/dom/ParentSHistory.h" #include "mozilla/dom/ChildSHistory.h" +#include "mozilla/dom/ChromeBrowsingContext.h" #include "mozilla/dom/HTMLBodyElement.h" @@ -3194,6 +3195,19 @@ nsFrameLoader::LoadContext() return loadContext.forget(); } +already_AddRefed +nsFrameLoader::GetBrowsingContext() +{ + RefPtr browsingContext; + if (IsRemoteFrame() && + (mRemoteBrowser || TryRemoteBrowser())) { + browsingContext = mRemoteBrowser->GetBrowsingContext(); + } else if (GetDocShell(IgnoreErrors())) { + browsingContext = nsDocShell::Cast(mDocShell)->GetBrowsingContext(); + } + return browsingContext.forget(); +} + void nsFrameLoader::InitializeBrowserAPI() { diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index ea1da1e70852..3699de9f02d8 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -48,6 +48,7 @@ namespace mozilla { class OriginAttributes; namespace dom { +class BrowsingContext; class ChromeMessageSender; class ContentParent; class InProcessTabChildMessageManager; @@ -121,6 +122,8 @@ public: already_AddRefed LoadContext(); + already_AddRefed GetBrowsingContext(); + /** * Start loading the frame. This method figures out what to load * from the owner content in the frame loader. diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 05ed7186fe54..83e3c040fa47 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -588,6 +588,8 @@ parent: sync SetPrefersReducedMotionOverrideForTest(bool aValue); sync ResetPrefersReducedMotionOverrideForTest(); + async RootBrowsingContext(BrowsingContextId aId); + child: /** * Notify the remote browser that it has been Show()n on this diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index be1bf294f0a7..bf066c621404 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -596,6 +596,11 @@ TabChild::Init() loadContext->SetRemoteTabs( mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW); + // Send our browsing context to the parent process. + RefPtr browsingContext = + nsDocShell::Cast(docShell)->GetBrowsingContext(); + SendRootBrowsingContext(BrowsingContextId(browsingContext->Id())); + // Few lines before, baseWindow->Create() will end up creating a new // window root in nsGlobalWindow::SetDocShell. // Then this chrome event handler, will be inherited to inner windows. diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 5cf571179bef..47584ddc823a 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -101,6 +101,7 @@ #include "nsString.h" #include "IHistory.h" #include "mozilla/dom/WindowGlobalParent.h" +#include "mozilla/dom/ChromeBrowsingContext.h" #ifdef XP_WIN #include "mozilla/plugins/PluginWidgetParent.h" @@ -3747,6 +3748,15 @@ TabParent::RecvGetSystemFont(nsCString* aFontName) return IPC_OK(); } +mozilla::ipc::IPCResult +TabParent::RecvRootBrowsingContext(const BrowsingContextId& aId) +{ + MOZ_ASSERT(!mBrowsingContext, "May only set browsing context once!"); + mBrowsingContext = ChromeBrowsingContext::Get(aId); + MOZ_ASSERT(mBrowsingContext, "Invalid ID!"); + return IPC_OK(); +} + NS_IMETHODIMP FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo) { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index 329074660da9..f194b029df24 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -67,6 +67,7 @@ class DataSourceSurface; namespace dom { +class ChromeBrowsingContext; class ClonedMessageData; class nsIContentParent; class Element; @@ -130,6 +131,8 @@ public: nsIXULBrowserWindow* GetXULBrowserWindow(); + ChromeBrowsingContext* GetBrowsingContext() { return mBrowsingContext; } + void Destroy(); void RemoveWindowListeners(); @@ -633,6 +636,8 @@ protected: virtual mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(const nsCString& aFirstPartyURI) override; + virtual mozilla::ipc::IPCResult RecvRootBrowsingContext(const BrowsingContextId& aId) override; + mozilla::ipc::IPCResult RecvSetSystemFont(const nsCString& aFontName) override; mozilla::ipc::IPCResult @@ -708,6 +713,9 @@ private: // dispatch message manager messages during this time. RefPtr mFrameLoader; + // The root browsing context loaded in this TabParent. + RefPtr mBrowsingContext; + TabId mTabId; // When loading a new tab or window via window.open, the child is diff --git a/dom/webidl/FrameLoader.webidl b/dom/webidl/FrameLoader.webidl index 9f1b0df7bc52..997c3a3d9f44 100644 --- a/dom/webidl/FrameLoader.webidl +++ b/dom/webidl/FrameLoader.webidl @@ -33,6 +33,12 @@ interface FrameLoader { */ readonly attribute LoadContext loadContext; + /** + * Get the root BrowsingContext within the frame. + * This may be null immediately after creating a remote frame. + */ + readonly attribute BrowsingContext? browsingContext; + /** * Get the ParentSHistory for the nsFrameLoader. May return null if this * frameloader is not for a toplevel frame. From e1951d042b94300d09cda168f5e06d7472b0b6fc Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Sat, 20 Oct 2018 16:04:00 -0400 Subject: [PATCH 11/13] Bug 1500949 - Include innerWindowId/outerWindowId in PWindowGlobal, r=farre This will be useful as both an ID for PWindowGlobal, as well as a mechanism for taking advantage of already synchronized information. As an example, LoadInfo objects contain the inner window IDs of the window requesting the load, which can now be used to obtain a reference to the corresponding WindowGlobalParent in the parent process. Differential Revision: https://phabricator.services.mozilla.com/D9396 --- dom/chrome-webidl/WindowGlobalActors.webidl | 10 ++++++ dom/ipc/DOMTypes.ipdlh | 2 ++ dom/ipc/WindowGlobalChild.cpp | 37 +++++++++++++++++++-- dom/ipc/WindowGlobalChild.h | 14 ++++++++ dom/ipc/WindowGlobalParent.cpp | 26 +++++++++++++++ dom/ipc/WindowGlobalParent.h | 14 ++++++++ 6 files changed, 100 insertions(+), 3 deletions(-) diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl index 4b847720d380..5a8590df8547 100644 --- a/dom/chrome-webidl/WindowGlobalActors.webidl +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -13,6 +13,9 @@ interface WindowGlobalParent { readonly attribute boolean isInProcess; readonly attribute ChromeBrowsingContext browsingContext; + readonly attribute unsigned long long innerWindowId; + readonly attribute unsigned long long outerWindowId; + // XXX(nika): We would want to expose this, but |FrameLoader| isn't exposed on System. // readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only @@ -21,6 +24,8 @@ interface WindowGlobalParent { // Information about the currently loaded document. readonly attribute Principal documentPrincipal; readonly attribute URI? documentURI; + + static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId); }; [Exposed=Window, ChromeOnly] @@ -29,5 +34,10 @@ interface WindowGlobalChild { readonly attribute boolean isInProcess; readonly attribute BrowsingContext browsingContext; + readonly attribute unsigned long long innerWindowId; + readonly attribute unsigned long long outerWindowId; + readonly attribute WindowGlobalParent? parentActor; // in-process only + + static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId); }; diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index f0af011e0e3f..d3a98a9e4939 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -189,6 +189,8 @@ struct WindowGlobalInit { nsIPrincipal principal; BrowsingContextId browsingContextId; + uint64_t innerWindowId; + uint64_t outerWindowId; }; } // namespace dom diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp index f19106c6ae01..301819aef2a9 100644 --- a/dom/ipc/WindowGlobalChild.cpp +++ b/dom/ipc/WindowGlobalChild.cpp @@ -12,10 +12,16 @@ namespace mozilla { namespace dom { -WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBrowsingContext) +typedef nsRefPtrHashtable WGCByIdMap; +static StaticAutoPtr gWindowGlobalChildById; + +WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow, + dom::BrowsingContext* aBrowsingContext) : mWindowGlobal(aWindow) , mBrowsingContext(aBrowsingContext) - , mIPCClosed(false) + , mInnerWindowId(aWindow->WindowID()) + , mOuterWindowId(aWindow->GetOuterWindow()->WindowID()) + , mIPCClosed(true) { } @@ -32,7 +38,10 @@ WindowGlobalChild::Create(nsGlobalWindowInner* aWindow) RefPtr bc = docshell->GetBrowsingContext(); RefPtr wgc = new WindowGlobalChild(aWindow, bc); - WindowGlobalInit init(principal, BrowsingContextId(wgc->BrowsingContext()->Id())); + WindowGlobalInit init(principal, + BrowsingContextId(wgc->BrowsingContext()->Id()), + wgc->mInnerWindowId, + wgc->mOuterWindowId); // Send the link constructor over PInProcessChild or PBrowser. if (XRE_IsParentProcess()) { @@ -50,10 +59,29 @@ WindowGlobalChild::Create(nsGlobalWindowInner* aWindow) // Note: ref is released in DeallocPWindowGlobalChild tabChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); } + wgc->mIPCClosed = false; + + // Register this WindowGlobal in the gWindowGlobalParentsById map. + if (!gWindowGlobalChildById) { + gWindowGlobalChildById = new WGCByIdMap(); + ClearOnShutdown(&gWindowGlobalChildById); + } + auto entry = gWindowGlobalChildById->LookupForAdd(wgc->mInnerWindowId); + MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalChild entry for ID!"); + entry.OrInsert([&] { return wgc; }); return wgc.forget(); } +/* static */ already_AddRefed +WindowGlobalChild::GetByInnerWindowId(uint64_t aInnerWindowId) +{ + if (!gWindowGlobalChildById) { + return nullptr; + } + return gWindowGlobalChildById->Get(aInnerWindowId); +} + already_AddRefed WindowGlobalChild::GetParentActor() { @@ -68,10 +96,13 @@ void WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) { mIPCClosed = true; + gWindowGlobalChildById->Remove(mInnerWindowId); } WindowGlobalChild::~WindowGlobalChild() { + MOZ_ASSERT(!gWindowGlobalChildById || + !gWindowGlobalChildById->Contains(mInnerWindowId)); } JSObject* diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h index 3dde74ef713b..ed2bd58bd859 100644 --- a/dom/ipc/WindowGlobalChild.h +++ b/dom/ipc/WindowGlobalChild.h @@ -31,6 +31,14 @@ public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalChild) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalChild) + static already_AddRefed + GetByInnerWindowId(uint64_t aInnerWindowId); + + static already_AddRefed + GetByInnerWindowId(const GlobalObject& aGlobal, uint64_t aInnerWindowId) { + return GetByInnerWindowId(aInnerWindowId); + } + dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; } nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; } @@ -41,6 +49,10 @@ public: // in the chrome process. bool IsInProcess() { return XRE_IsParentProcess(); } + // The Window ID for this WindowGlobal + uint64_t InnerWindowId() { return mInnerWindowId; } + uint64_t OuterWindowId() { return mOuterWindowId; } + // Get the other side of this actor if it is an in-process actor. Returns // |nullptr| if the actor has been torn down, or is not in-process. already_AddRefed GetParentActor(); @@ -62,6 +74,8 @@ private: RefPtr mWindowGlobal; RefPtr mBrowsingContext; + uint64_t mInnerWindowId; + uint64_t mOuterWindowId; bool mIPCClosed; }; diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 480f6c4d81e7..12263ca7c331 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -14,9 +14,14 @@ using namespace mozilla::ipc; namespace mozilla { namespace dom { +typedef nsRefPtrHashtable WGPByIdMap; +static StaticAutoPtr gWindowGlobalParentsById; + WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit, bool aInProcess) : mDocumentPrincipal(aInit.principal()) + , mInnerWindowId(aInit.innerWindowId()) + , mOuterWindowId(aInit.outerWindowId()) , mInProcess(aInProcess) , mIPCClosed(true) // Closed until WGP::Init { @@ -37,6 +42,15 @@ WindowGlobalParent::Init(const WindowGlobalInit& aInit) MOZ_ASSERT(mIPCClosed, "IPC shouldn't be open yet"); mIPCClosed = false; + // Register this WindowGlobal in the gWindowGlobalParentsById map. + if (!gWindowGlobalParentsById) { + gWindowGlobalParentsById = new WGPByIdMap(); + ClearOnShutdown(&gWindowGlobalParentsById); + } + auto entry = gWindowGlobalParentsById->LookupForAdd(mInnerWindowId); + MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalParent entry for ID!"); + entry.OrInsert([&] { return this; }); + // Determine which content process the window global is coming from. ContentParentId processId(0); if (!mInProcess) { @@ -82,6 +96,15 @@ WindowGlobalParent::Init(const WindowGlobalInit& aInit) } } +/* static */ already_AddRefed +WindowGlobalParent::GetByInnerWindowId(uint64_t aInnerWindowId) +{ + if (!gWindowGlobalParentsById) { + return nullptr; + } + return gWindowGlobalParentsById->Get(aInnerWindowId); +} + already_AddRefed WindowGlobalParent::GetChildActor() { @@ -105,11 +128,14 @@ void WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) { mIPCClosed = true; + gWindowGlobalParentsById->Remove(mInnerWindowId); mBrowsingContext->UnregisterWindowGlobal(this); } WindowGlobalParent::~WindowGlobalParent() { + MOZ_ASSERT(!gWindowGlobalParentsById || + !gWindowGlobalParentsById->Contains(mInnerWindowId)); } JSObject* diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h index 6ab6ac8f5985..aaae9bff08f3 100644 --- a/dom/ipc/WindowGlobalParent.h +++ b/dom/ipc/WindowGlobalParent.h @@ -31,6 +31,14 @@ public: NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalParent) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalParent) + static already_AddRefed + GetByInnerWindowId(uint64_t aInnerWindowId); + + static already_AddRefed + GetByInnerWindowId(const GlobalObject& aGlobal, uint64_t aInnerWindowId) { + return GetByInnerWindowId(aInnerWindowId); + } + // Has this actor been shut down bool IsClosed() { return mIPCClosed; } @@ -59,6 +67,10 @@ public: // The current URI which loaded in the document. nsIURI* GetDocumentURI() { return mDocumentURI; } + // Window IDs for inner/outer windows. + uint64_t OuterWindowId() { return mOuterWindowId; } + uint64_t InnerWindowId() { return mInnerWindowId; } + // Create a WindowGlobalParent from over IPC. This method should not be called // from outside of the IPC constructors. WindowGlobalParent(const WindowGlobalInit& aInit, bool aInProcess); @@ -86,6 +98,8 @@ private: nsCOMPtr mDocumentURI; RefPtr mFrameLoader; RefPtr mBrowsingContext; + uint64_t mInnerWindowId; + uint64_t mOuterWindowId; bool mInProcess; bool mIPCClosed; }; From 1b19f641b32049741f629a4de7d2210361959aa6 Mon Sep 17 00:00:00 2001 From: Nika Layzell Date: Sat, 20 Oct 2018 19:39:02 -0400 Subject: [PATCH 12/13] Bug 1500950 - Expose rootFrameLoader on WindowGlobalParent, r=farre This attribute was not exposed due to Bug 1489301. Differential Revision: https://phabricator.services.mozilla.com/D9404 --- dom/chrome-webidl/WindowGlobalActors.webidl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl index 5a8590df8547..9bbd502c74cd 100644 --- a/dom/chrome-webidl/WindowGlobalActors.webidl +++ b/dom/chrome-webidl/WindowGlobalActors.webidl @@ -16,8 +16,7 @@ interface WindowGlobalParent { readonly attribute unsigned long long innerWindowId; readonly attribute unsigned long long outerWindowId; - // XXX(nika): We would want to expose this, but |FrameLoader| isn't exposed on System. - // readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only + readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only readonly attribute WindowGlobalChild? childActor; // in-process only From 14322dd0bd055a1a55f98ec72a6519312d8e223f Mon Sep 17 00:00:00 2001 From: "arthur.iakab" Date: Thu, 22 Nov 2018 07:57:52 +0200 Subject: [PATCH 13/13] Backed out 9 changesets (bug 1500948, bug 1500949, bug 1448426, bug 1487249, bug 1500950, bug 1500944) for causing talos crashes on ts_paint | application crashed [@ MOZ_CrashOOL(char const*, int, char const*)] Backed out changeset 429776feea6b (bug 1500950) Backed out changeset a300e9ae7a01 (bug 1500949) Backed out changeset fed1a518579a (bug 1500948) Backed out changeset a71376319ad7 (bug 1500944) Backed out changeset 9c5c35cb10aa (bug 1500944) Backed out changeset b6c97b4db60a (bug 1448426) Backed out changeset 160a1dbe0be5 (bug 1487249) Backed out changeset 8caf55928df2 (bug 1487249) Backed out changeset 176131b18cb4 (bug 1487249) --- config/make-stl-wrappers.py | 19 +- config/make-windows-h-wrapper.py | 86 -- config/moz.build | 13 - config/system_header_util.py | 20 - config/windows-h-constant.decls.h | 57 - config/windows-h-unicode.decls.h | 1052 ------------------- config/windows-h-wrapper.template.h | 55 - docshell/base/BrowsingContext.cpp | 2 +- docshell/base/BrowsingContext.h | 11 +- docshell/base/ChromeBrowsingContext.cpp | 47 +- docshell/base/ChromeBrowsingContext.h | 27 +- dom/base/moz.build | 2 +- dom/base/nsDocument.cpp | 9 - dom/base/nsFrameLoader.cpp | 14 - dom/base/nsFrameLoader.h | 3 - dom/base/nsGlobalWindowInner.cpp | 21 +- dom/base/nsGlobalWindowOuter.cpp | 5 +- dom/base/nsPIDOMWindow.h | 12 - dom/chrome-webidl/BrowsingContext.webidl | 5 - dom/chrome-webidl/WindowGlobalActors.webidl | 42 - dom/chrome-webidl/moz.build | 1 - dom/ipc/ContentChild.cpp | 8 +- dom/ipc/DOMTypes.ipdlh | 10 - dom/ipc/PBrowser.ipdl | 11 - dom/ipc/PWindowGlobal.ipdl | 35 - dom/ipc/TabChild.cpp | 21 - dom/ipc/TabChild.h | 4 - dom/ipc/TabParent.cpp | 34 - dom/ipc/TabParent.h | 18 - dom/ipc/WindowGlobalChild.cpp | 129 --- dom/ipc/WindowGlobalChild.h | 85 -- dom/ipc/WindowGlobalParent.cpp | 162 --- dom/ipc/WindowGlobalParent.h | 110 -- dom/ipc/moz.build | 5 - dom/webidl/FrameLoader.webidl | 6 - gfx/cairo/cairo/src/moz.build | 1 - gfx/thebes/gfxDWriteFonts.cpp | 6 +- gfx/vr/service/openvr/moz.build | 3 - ipc/glue/InProcessChild.cpp | 31 - ipc/glue/InProcessChild.h | 66 -- ipc/glue/InProcessImpl.cpp | 212 ---- ipc/glue/InProcessParent.cpp | 41 - ipc/glue/InProcessParent.h | 76 -- ipc/glue/MessageChannel.cpp | 43 +- ipc/glue/MessageChannel.h | 28 +- ipc/glue/PInProcess.ipdl | 35 - ipc/glue/ProtocolUtils.cpp | 7 - ipc/glue/ProtocolUtils.h | 9 - ipc/glue/moz.build | 6 - python/mozbuild/mozbuild/backend/common.py | 5 +- 50 files changed, 47 insertions(+), 2663 deletions(-) delete mode 100644 config/make-windows-h-wrapper.py delete mode 100644 config/system_header_util.py delete mode 100644 config/windows-h-constant.decls.h delete mode 100644 config/windows-h-unicode.decls.h delete mode 100644 config/windows-h-wrapper.template.h delete mode 100644 dom/chrome-webidl/WindowGlobalActors.webidl delete mode 100644 dom/ipc/PWindowGlobal.ipdl delete mode 100644 dom/ipc/WindowGlobalChild.cpp delete mode 100644 dom/ipc/WindowGlobalChild.h delete mode 100644 dom/ipc/WindowGlobalParent.cpp delete mode 100644 dom/ipc/WindowGlobalParent.h delete mode 100644 ipc/glue/InProcessChild.cpp delete mode 100644 ipc/glue/InProcessChild.h delete mode 100644 ipc/glue/InProcessImpl.cpp delete mode 100644 ipc/glue/InProcessParent.cpp delete mode 100644 ipc/glue/InProcessParent.h delete mode 100644 ipc/glue/PInProcess.ipdl diff --git a/config/make-stl-wrappers.py b/config/make-stl-wrappers.py index 7e6da5150bff..1f8661fb35bf 100644 --- a/config/make-stl-wrappers.py +++ b/config/make-stl-wrappers.py @@ -5,9 +5,26 @@ from __future__ import print_function import os import string from mozbuild.util import FileAvoidWrite -from system_header_util import header_path +def find_in_path(file, searchpath): + for dir in searchpath.split(os.pathsep): + f = os.path.join(dir, file) + if os.path.exists(f): + return f + return '' + + +def header_path(header, compiler): + if compiler == 'gcc': + # we use include_next on gcc + return header + elif compiler == 'msvc': + return find_in_path(header, os.environ.get('INCLUDE', '')) + else: + # hope someone notices this ... + raise NotImplementedError(compiler) + # The 'unused' arg is the output file from the file_generate action. We actually # generate all the files in header_list diff --git a/config/make-windows-h-wrapper.py b/config/make-windows-h-wrapper.py deleted file mode 100644 index fca3597e99ce..000000000000 --- a/config/make-windows-h-wrapper.py +++ /dev/null @@ -1,86 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -import re -import textwrap -import string -from system_header_util import header_path - -comment_re = re.compile(r'//[^\n]*\n|/\*.*\*/', re.S) -decl_re = re.compile(r'''^(.+)\s+ # type - (\w+)\s* # name - (?:\((.*)\))?$ # optional param tys - ''', re.X | re.S) - - -def read_decls(filename): - """Parse & yield C-style decls from an input file""" - with open(filename, 'r') as fd: - # Strip comments from the source text. - text = comment_re.sub('', fd.read()) - - # Parse individual declarations. - raw_decls = [d.strip() for d in text.split(';') if d.strip()] - for raw in raw_decls: - match = decl_re.match(raw) - if match is None: - raise "Invalid decl: %s" % raw - - ty, name, params = match.groups() - if params is not None: - params = [a.strip() for a in params.split(',') if a.strip()] - yield ty, name, params - - -def generate(fd, consts_path, unicodes_path, template_path, compiler): - # Parse the template - with open(template_path, 'r') as template_fd: - template = string.Template(template_fd.read()) - - decls = '' - - # Each constant should be saved to a temporary, and then re-assigned to a - # constant with the correct name, allowing the value to be determined by - # the actual definition. - for ty, name, args in read_decls(consts_path): - assert args is None, "parameters in const decl!" - - decls += textwrap.dedent(""" - #ifdef {name} - constexpr {ty} _tmp_{name} = {name}; - #undef {name} - constexpr {ty} {name} = _tmp_{name}; - #endif - """.format(ty=ty, name=name)) - - # Each unicode declaration defines a static inline function with the - # correct types which calls the 'A' or 'W'-suffixed versions of the - # function. Full types are required here to ensure that '0' to 'nullptr' - # coersions are preserved. - for ty, name, args in read_decls(unicodes_path): - assert args is not None, "argument list required for unicode decl" - - # Parameter & argument string list - params = ', '.join('%s a%d' % (ty, i) for i, ty in enumerate(args)) - args = ', '.join('a%d' % i for i in range(len(args))) - - decls += textwrap.dedent(""" - #ifdef {name} - #undef {name} - static inline {ty} WINAPI - {name}({params}) - {{ - #ifdef UNICODE - return {name}W({args}); - #else - return {name}A({args}); - #endif - }} - #endif - """.format(ty=ty, name=name, params=params, args=args)) - - path = header_path('windows.h', compiler) - - # Write out the resulting file - fd.write(template.substitute(header_path=path, decls=decls)) diff --git a/config/moz.build b/config/moz.build index 8fd459d2fc01..ce6297393373 100644 --- a/config/moz.build +++ b/config/moz.build @@ -63,19 +63,6 @@ if CONFIG['WRAP_STL_INCLUDES']: stl.flags = [output_dir, stl_compiler, template_file] stl.flags.extend(stl_headers) - # Wrap to make it easier to use correctly - # NOTE: If we aren't wrapping STL includes, we're building part of the browser - # which won't need this wrapper, such as L10N. Just don't try to generate the - # wrapper in that case. - if CONFIG['OS_ARCH'] == 'WINNT': - GENERATED_FILES += ['../dist/stl_wrappers/windows.h'] - windows_h = GENERATED_FILES['../dist/stl_wrappers/windows.h'] - windows_h.script = 'make-windows-h-wrapper.py:generate' - windows_h.inputs = ['windows-h-constant.decls.h', - 'windows-h-unicode.decls.h', - 'windows-h-wrapper.template.h'] - windows_h.flags = [stl_compiler] - if CONFIG['WRAP_SYSTEM_INCLUDES']: include('system-headers.mozbuild') output_dir = '../dist/system_wrappers' diff --git a/config/system_header_util.py b/config/system_header_util.py deleted file mode 100644 index 6e7b30318f23..000000000000 --- a/config/system_header_util.py +++ /dev/null @@ -1,20 +0,0 @@ -import os - - -def find_in_path(file, searchpath): - for dir in searchpath.split(os.pathsep): - f = os.path.join(dir, file) - if os.path.exists(f): - return f - return '' - - -def header_path(header, compiler): - if compiler == 'gcc': - # we use include_next on gcc - return header - elif compiler == 'msvc': - return find_in_path(header, os.environ.get('INCLUDE', '')) - else: - # hope someone notices this ... - raise NotImplementedError(compiler) diff --git a/config/windows-h-constant.decls.h b/config/windows-h-constant.decls.h deleted file mode 100644 index 12bc9111e60c..000000000000 --- a/config/windows-h-constant.decls.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * This file contains a series of C-style declarations for constants defined in - * windows.h using #define. Adding a new constant should be a simple as adding - * its name (and optionally type) to this file. - * - * This file is processed by generate-windows-h-wrapper.py to generate a wrapper - * for the header which removes the defines usually implementing these constants. - * - * Wrappers defined in this file will be declared as `constexpr` values, - * and will have their value derived from the windows.h define. - * - * NOTE: This is *NOT* a real C header, but rather an input to the avove script. - * Only basic declarations in the form found here are allowed. - */ - -// XXX(nika): There are a lot of these (>30k)! -// This is just a set of ones I saw in a quick scan which looked problematic. - -auto CREATE_NEW; -auto CREATE_ALWAYS; -auto OPEN_EXISTING; -auto OPEN_ALWAYS; -auto TRUNCATE_EXISTING; -auto INVALID_FILE_SIZE; -auto INVALID_SET_FILE_POINTER; -auto INVALID_FILE_ATTRIBUTES; - -auto ANSI_NULL; -auto UNICODE_NULL; - -auto MINCHAR; -auto MAXCHAR; -auto MINSHORT; -auto MAXSHORT; -auto MINLONG; -auto MAXLONG; -auto MAXBYTE; -auto MAXWORD; -auto MAXDWORD; - -auto DELETE; -auto READ_CONTROL; -auto WRITE_DAC; -auto WRITE_OWNER; -auto SYNCHRONIZE; - -auto MAXIMUM_ALLOWED; -auto GENERIC_READ; -auto GENERIC_WRITE; -auto GENERIC_EXECUTE; -auto GENERIC_ALL; diff --git a/config/windows-h-unicode.decls.h b/config/windows-h-unicode.decls.h deleted file mode 100644 index 7cbe5bc4be37..000000000000 --- a/config/windows-h-unicode.decls.h +++ /dev/null @@ -1,1052 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * This file contains a series of C-style function prototypes for A/W-suffixed - * Win32 APIs defined by windows.h. - * - * This file is processed by generate-windows-h-wrapper.py to generate a wrapper - * for the header which removes the defines usually implementing these aliases. - * - * Wrappers defined in this file will have the 'stdcall' calling convention, - * will be defined as 'inline', and will only be defined if the corresponding - * #define directive has not been #undef-ed. - * - * NOTE: This is *NOT* a real C header, but rather an input to the avove script. - * Only basic declarations in the form found here are allowed. - */ - -LPTSTR GetCommandLine(); - -BOOL FreeEnvironmentStrings(LPTCH); - -DWORD GetEnvironmentVariable(LPCTSTR, LPTSTR, DWORD); - -BOOL SetEnvironmentVariable(LPCTSTR, LPCTSTR); - -DWORD ExpandEnvironmentStrings(LPCTSTR, LPTSTR, DWORD); - -BOOL SetCurrentDirectory(LPCTSTR); - -DWORD GetCurrentDirectory(DWORD, LPTSTR); - -DWORD SearchPath(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, LPTSTR, LPTSTR*); - -BOOL NeedCurrentDirectoryForExePath(LPCTSTR); - -BOOL CreateDirectory(LPCTSTR, LPSECURITY_ATTRIBUTES); - -HANDLE CreateFile(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE); - -BOOL DeleteFile(LPCTSTR); - -HANDLE FindFirstChangeNotification(LPCTSTR, BOOL, DWORD); - -HANDLE FindFirstFile(LPCTSTR, LPWIN32_FIND_DATA); - -HANDLE FindFirstFileEx(LPCTSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD); - -BOOL FindNextFile(HANDLE, LPWIN32_FIND_DATA); - -BOOL GetDiskFreeSpace(LPCTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD); - -BOOL GetDiskFreeSpaceEx(LPCTSTR, PULARGE_INTEGER, PULARGE_INTEGER, PULARGE_INTEGER); - -UINT GetDriveType(LPCTSTR); - -DWORD GetFileAttributes(LPCTSTR); - -BOOL GetFileAttributesEx(LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID); - -DWORD GetFinalPathNameByHandle(HANDLE, LPTSTR, DWORD, DWORD); - -DWORD GetFullPathName(LPCTSTR, DWORD, LPTSTR, LPTSTR*); - -DWORD GetLongPathName(LPCTSTR, LPTSTR, DWORD); - -BOOL RemoveDirectory(LPCTSTR); - -BOOL SetFileAttributes(LPCTSTR, DWORD); - -DWORD GetCompressedFileSize(LPCTSTR, LPDWORD); - -DWORD GetTempPath(DWORD, LPTSTR); - -BOOL GetVolumeInformation(LPCTSTR, LPTSTR, DWORD, LPDWORD, LPDWORD, LPDWORD, LPTSTR, DWORD); - -UINT GetTempFileName(LPCTSTR, LPCTSTR, UINT, LPTSTR); - -void OutputDebugString(LPCTSTR); - -void FatalAppExit(UINT, LPCTSTR); - -HANDLE CreateMutex(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR); - -HANDLE CreateEvent(LPSECURITY_ATTRIBUTES, BOOL, BOOL, LPCTSTR); - -HANDLE OpenEvent(DWORD, BOOL, LPCTSTR); - -HANDLE CreateMutexEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD); - -HANDLE CreateEventEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD); - -BOOL CreateProcess(LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION); - -BOOL CreateProcessAsUser(HANDLE, LPCTSTR, LPTSTR, LPSECURITY_ATTRIBUTES, LPSECURITY_ATTRIBUTES, BOOL, DWORD, LPVOID, LPCTSTR, LPSTARTUPINFO, LPPROCESS_INFORMATION); - -UINT GetSystemDirectory(LPTSTR, UINT); - -UINT GetWindowsDirectory(LPTSTR, UINT); - -UINT GetSystemWindowsDirectory(LPTSTR, UINT); - -BOOL GetComputerNameEx(COMPUTER_NAME_FORMAT, LPTSTR, LPDWORD); - -BOOL GetVersionEx(LPOSVERSIONINFO); - -BOOL SetComputerName(LPCTSTR); - -BOOL SetComputerNameEx(COMPUTER_NAME_FORMAT, LPCTSTR); - -BOOL LoadEnclaveImage(LPVOID, LPCTSTR); - -UINT GetSystemWow64Directory(LPTSTR, UINT); - -DWORD GetModuleFileName(HMODULE, LPTSTR, DWORD); - -HMODULE GetModuleHandle(LPCTSTR); - -BOOL GetModuleHandleEx(DWORD, LPCTSTR, HMODULE*); - -HMODULE LoadLibraryEx(LPCTSTR, HANDLE, DWORD); - -int LoadString(HINSTANCE, UINT, LPTSTR, int); - -BOOL EnumResourceLanguagesEx(HMODULE, LPCTSTR, LPCTSTR, ENUMRESLANGPROC, LONG_PTR, DWORD, LANGID); - -BOOL EnumResourceNamesEx(HMODULE, LPCTSTR, ENUMRESNAMEPROC, LONG_PTR, DWORD, LANGID); - -BOOL EnumResourceTypesEx(HMODULE, ENUMRESTYPEPROC, LONG_PTR, DWORD, LANGID); - -HMODULE LoadLibrary(LPCTSTR); - -BOOL GetBinaryType(LPCTSTR, LPDWORD); - -DWORD GetShortPathName(LPCTSTR, LPTSTR, DWORD); - -DWORD GetLongPathNameTransacted(LPCTSTR, LPTSTR, DWORD, HANDLE); - -BOOL SetEnvironmentStrings(LPTCH); - -BOOL SetFileShortName(HANDLE, LPCTSTR); - -DWORD FormatMessage(DWORD, LPCVOID, DWORD, DWORD, LPTSTR, DWORD, va_list *); - -HANDLE CreateMailslot(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES); - -BOOL EncryptFile(LPCTSTR); - -BOOL DecryptFile(LPCTSTR, DWORD); - -BOOL FileEncryptionStatus(LPCTSTR, LPDWORD); - -DWORD OpenEncryptedFileRaw(LPCTSTR, ULONG, PVOID *); - -HANDLE OpenMutex(DWORD, BOOL, LPCTSTR); - -HANDLE CreateSemaphore(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCTSTR); - -HANDLE OpenSemaphore(DWORD, BOOL, LPCTSTR); - -HANDLE CreateWaitableTimer(LPSECURITY_ATTRIBUTES, BOOL, LPCTSTR); - -HANDLE OpenWaitableTimer(DWORD, BOOL, LPCTSTR); - -HANDLE CreateSemaphoreEx(LPSECURITY_ATTRIBUTES, LONG, LONG, LPCTSTR, DWORD, DWORD); - -HANDLE CreateWaitableTimerEx(LPSECURITY_ATTRIBUTES, LPCTSTR, DWORD, DWORD); - -HANDLE CreateFileMapping(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCTSTR); - -HANDLE CreateFileMappingNuma(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCTSTR, DWORD); - -HANDLE OpenFileMapping(DWORD, BOOL, LPCTSTR); - -DWORD GetLogicalDriveStrings(DWORD, LPTSTR); - -void GetStartupInfo(LPSTARTUPINFO); - -DWORD GetFirmwareEnvironmentVariable(LPCTSTR, LPCTSTR, PVOID, DWORD); - -BOOL SetFirmwareEnvironmentVariable(LPCTSTR, LPCTSTR, PVOID, DWORD); - -HRSRC FindResource(HMODULE, LPCTSTR, LPCTSTR); - -HRSRC FindResourceEx(HMODULE, LPCTSTR, LPCTSTR, WORD); - -BOOL EnumResourceTypes(HMODULE, ENUMRESTYPEPROC, LONG_PTR); - -BOOL EnumResourceNames(HMODULE, LPCTSTR, ENUMRESNAMEPROC, LONG_PTR); - -BOOL EnumResourceLanguages(HMODULE, LPCTSTR, LPCTSTR, ENUMRESLANGPROC, LONG_PTR); - -HANDLE BeginUpdateResource(LPCTSTR, BOOL); - -BOOL UpdateResource(HANDLE, LPCTSTR, LPCTSTR, WORD, LPVOID, DWORD); - -BOOL EndUpdateResource(HANDLE, BOOL); - -ATOM GlobalAddAtom(LPCTSTR); - -ATOM GlobalAddAtomEx(LPCTSTR, DWORD); - -ATOM GlobalFindAtom(LPCTSTR); - -UINT GlobalGetAtomName(ATOM, LPTSTR, int); - -ATOM AddAtom(LPCTSTR); - -ATOM FindAtom(LPCTSTR); - -UINT GetAtomName(ATOM, LPTSTR, int); - -UINT GetProfileInt(LPCTSTR, LPCTSTR, INT); - -DWORD GetProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD); - -BOOL WriteProfileString(LPCTSTR, LPCTSTR, LPCTSTR); - -DWORD GetProfileSection(LPCTSTR, LPTSTR, DWORD); - -BOOL WriteProfileSection(LPCTSTR, LPCTSTR); - -UINT GetPrivateProfileInt(LPCTSTR, LPCTSTR, INT, LPCTSTR); - -DWORD GetPrivateProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPTSTR, DWORD, LPCTSTR); - -BOOL WritePrivateProfileString(LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR); - -DWORD GetPrivateProfileSection(LPCTSTR, LPTSTR, DWORD, LPCTSTR); - -BOOL WritePrivateProfileSection(LPCTSTR, LPCTSTR, LPCTSTR); - -DWORD GetPrivateProfileSectionNames(LPTSTR, DWORD, LPCTSTR); - -BOOL GetPrivateProfileStruct(LPCTSTR, LPCTSTR, LPVOID, UINT, LPCTSTR); - -BOOL WritePrivateProfileStruct(LPCTSTR, LPCTSTR, LPVOID, UINT, LPCTSTR); - -BOOL SetDllDirectory(LPCTSTR); - -DWORD GetDllDirectory(DWORD, LPTSTR); - -BOOL CreateDirectoryEx(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES); - -BOOL CreateDirectoryTransacted(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES, HANDLE); - -BOOL RemoveDirectoryTransacted(LPCTSTR, HANDLE); - -DWORD GetFullPathNameTransacted(LPCTSTR, DWORD, LPTSTR, LPTSTR *, HANDLE); - -BOOL DefineDosDevice(DWORD, LPCTSTR, LPCTSTR); - -DWORD QueryDosDevice(LPCTSTR, LPTSTR, DWORD); - -HANDLE CreateFileTransacted(LPCTSTR, DWORD, DWORD, LPSECURITY_ATTRIBUTES, DWORD, DWORD, HANDLE, HANDLE, PUSHORT, PVOID); - -BOOL SetFileAttributesTransacted(LPCTSTR, DWORD, HANDLE); - -BOOL GetFileAttributesTransacted(LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID, HANDLE); - -DWORD GetCompressedFileSizeTransacted(LPCTSTR, LPDWORD, HANDLE); - -BOOL DeleteFileTransacted(LPCTSTR, HANDLE); - -BOOL CheckNameLegalDOS8Dot3(LPCTSTR, LPSTR, DWORD, PBOOL, PBOOL); - -HANDLE FindFirstFileTransacted(LPCTSTR, FINDEX_INFO_LEVELS, LPVOID, FINDEX_SEARCH_OPS, LPVOID, DWORD, HANDLE); - -BOOL CopyFile(LPCTSTR, LPCTSTR, BOOL); - -BOOL CopyFileEx(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD); - -BOOL CopyFileTransacted(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, LPBOOL, DWORD, HANDLE); - -BOOL MoveFile(LPCTSTR, LPCTSTR); - -BOOL MoveFileEx(LPCTSTR, LPCTSTR, DWORD); - -BOOL MoveFileWithProgress(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, DWORD); - -BOOL MoveFileTransacted(LPCTSTR, LPCTSTR, LPPROGRESS_ROUTINE, LPVOID, DWORD, HANDLE); - -BOOL ReplaceFile(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, LPVOID, LPVOID); - -BOOL CreateHardLink(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES); - -BOOL CreateHardLinkTransacted(LPCTSTR, LPCTSTR, LPSECURITY_ATTRIBUTES, HANDLE); - -HANDLE CreateNamedPipe(LPCTSTR, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPSECURITY_ATTRIBUTES); - -BOOL GetNamedPipeHandleState(HANDLE, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPTSTR, DWORD); - -BOOL CallNamedPipe(LPCTSTR, LPVOID, DWORD, LPVOID, DWORD, LPDWORD, DWORD); - -BOOL WaitNamedPipe(LPCTSTR, DWORD); - -BOOL GetNamedPipeClientComputerName(HANDLE, LPTSTR, ULONG); - -BOOL SetVolumeLabel(LPCTSTR, LPCTSTR); - -BOOL ClearEventLog(HANDLE, LPCTSTR); - -BOOL BackupEventLog(HANDLE, LPCTSTR); - -HANDLE OpenEventLog(LPCTSTR, LPCTSTR); - -HANDLE RegisterEventSource(LPCTSTR, LPCTSTR); - -HANDLE OpenBackupEventLog(LPCTSTR, LPCTSTR); - -BOOL ReadEventLog(HANDLE, DWORD, DWORD, LPVOID, DWORD, DWORD *, DWORD *); - -BOOL ReportEvent(HANDLE, WORD, WORD, DWORD, PSID, WORD, DWORD, LPCTSTR *, LPVOID); - -BOOL AccessCheckAndAuditAlarm(LPCTSTR, LPVOID, LPTSTR, LPTSTR, PSECURITY_DESCRIPTOR, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPBOOL, LPBOOL); - -BOOL AccessCheckByTypeAndAuditAlarm(LPCTSTR, LPVOID, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPBOOL, LPBOOL); - -BOOL AccessCheckByTypeResultListAndAuditAlarm(LPCTSTR, LPVOID, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPDWORD, LPBOOL); - -BOOL AccessCheckByTypeResultListAndAuditAlarmByHandle(LPCTSTR, LPVOID, HANDLE, LPCTSTR, LPCTSTR, PSECURITY_DESCRIPTOR, PSID, DWORD, AUDIT_EVENT_TYPE, DWORD, POBJECT_TYPE_LIST, DWORD, PGENERIC_MAPPING, BOOL, LPDWORD, LPDWORD, LPBOOL); - -BOOL ObjectOpenAuditAlarm(LPCTSTR, LPVOID, LPTSTR, LPTSTR, PSECURITY_DESCRIPTOR, HANDLE, DWORD, DWORD, PPRIVILEGE_SET, BOOL, BOOL, LPBOOL); - -BOOL ObjectPrivilegeAuditAlarm(LPCTSTR, LPVOID, HANDLE, DWORD, PPRIVILEGE_SET, BOOL); - -BOOL ObjectCloseAuditAlarm(LPCTSTR, LPVOID, BOOL); - -BOOL ObjectDeleteAuditAlarm(LPCTSTR, LPVOID, BOOL); - -BOOL PrivilegedServiceAuditAlarm(LPCTSTR, LPCTSTR, HANDLE, PPRIVILEGE_SET, BOOL); - -BOOL SetFileSecurity(LPCTSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR); - -BOOL GetFileSecurity(LPCTSTR, SECURITY_INFORMATION, PSECURITY_DESCRIPTOR, DWORD, LPDWORD); - -BOOL IsBadStringPtr(LPCTSTR, UINT_PTR); - -BOOL LookupAccountSid(LPCTSTR, PSID, LPTSTR, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); - -BOOL LookupAccountName(LPCTSTR, LPCTSTR, PSID, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); - -BOOL LookupAccountNameLocal(LPCTSTR, PSID, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); - -BOOL LookupAccountSidLocal(PSID, LPTSTR, LPDWORD, LPTSTR, LPDWORD, PSID_NAME_USE); - -BOOL LookupPrivilegeValue(LPCTSTR, LPCTSTR, PLUID); - -BOOL LookupPrivilegeName(LPCTSTR, PLUID, LPTSTR, LPDWORD); - -BOOL LookupPrivilegeDisplayName(LPCTSTR, LPCTSTR, LPTSTR, LPDWORD, LPDWORD); - -BOOL BuildCommDCB(LPCTSTR, LPDCB); - -BOOL BuildCommDCBAndTimeouts(LPCTSTR, LPDCB, LPCOMMTIMEOUTS); - -BOOL CommConfigDialog(LPCTSTR, HWND, LPCOMMCONFIG); - -BOOL GetDefaultCommConfig(LPCTSTR, LPCOMMCONFIG, LPDWORD); - -BOOL SetDefaultCommConfig(LPCTSTR, LPCOMMCONFIG, DWORD); - -BOOL GetComputerName(LPTSTR, LPDWORD); - -BOOL DnsHostnameToComputerName(LPCTSTR, LPTSTR, LPDWORD); - -BOOL GetUserName(LPTSTR, LPDWORD); - -BOOL LogonUser(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, DWORD, PHANDLE); - -BOOL LogonUserEx(LPCTSTR, LPCTSTR, LPCTSTR, DWORD, DWORD, PHANDLE, PSID *, PVOID *, LPDWORD, PQUOTA_LIMITS); - -HANDLE CreatePrivateNamespace(LPSECURITY_ATTRIBUTES, LPVOID, LPCTSTR); - -HANDLE OpenPrivateNamespace(LPVOID, LPCTSTR); - -HANDLE CreateBoundaryDescriptor(LPCTSTR, ULONG); - -BOOL GetCurrentHwProfile(LPHW_PROFILE_INFO); - -BOOL VerifyVersionInfo(LPOSVERSIONINFOEX, DWORD, DWORDLONG); - -HANDLE CreateJobObject(LPSECURITY_ATTRIBUTES, LPCTSTR); - -HANDLE OpenJobObject(DWORD, BOOL, LPCTSTR); - -HANDLE FindFirstVolume(LPTSTR, DWORD); - -BOOL FindNextVolume(HANDLE, LPTSTR, DWORD); - -HANDLE FindFirstVolumeMountPoint(LPCTSTR, LPTSTR, DWORD); - -BOOL FindNextVolumeMountPoint(HANDLE, LPTSTR, DWORD); - -BOOL SetVolumeMountPoint(LPCTSTR, LPCTSTR); - -BOOL DeleteVolumeMountPoint(LPCTSTR); - -BOOL GetVolumeNameForVolumeMountPoint(LPCTSTR, LPTSTR, DWORD); - -BOOL GetVolumePathName(LPCTSTR, LPTSTR, DWORD); - -BOOL GetVolumePathNamesForVolumeName(LPCTSTR, LPTCH, DWORD, PDWORD); - -HANDLE CreateActCtx(PCACTCTX); - -BOOL FindActCtxSectionString(DWORD, const GUID *, ULONG, LPCTSTR, PACTCTX_SECTION_KEYED_DATA); - -BOOLEAN CreateSymbolicLink(LPCTSTR, LPCTSTR, DWORD); - -BOOLEAN CreateSymbolicLinkTransacted(LPCTSTR, LPCTSTR, DWORD, HANDLE); - -int AddFontResource(LPCTSTR); - -HMETAFILE CopyMetaFile(HMETAFILE, LPCTSTR); - -HDC CreateDC(LPCTSTR, LPCTSTR, LPCTSTR, const DEVMODE *); - -HFONT CreateFontIndirect(const LOGFONT *); - -HFONT CreateFont(int, int, int, int, int, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, LPCTSTR); - -HDC CreateIC(LPCTSTR, LPCTSTR, LPCTSTR, const DEVMODE *); - -HDC CreateMetaFile(LPCTSTR); - -BOOL CreateScalableFontResource(DWORD, LPCTSTR, LPCTSTR, LPCTSTR); - -int DeviceCapabilities(LPCTSTR, LPCTSTR, WORD, LPTSTR, const DEVMODE *); - -int EnumFontFamiliesEx(HDC, LPLOGFONT, FONTENUMPROC, LPARAM, DWORD); - -int EnumFontFamilies(HDC, LPCTSTR, FONTENUMPROC, LPARAM); - -int EnumFonts(HDC, LPCTSTR, FONTENUMPROC, LPARAM); - -BOOL GetCharWidth(HDC, UINT, UINT, LPINT); - -BOOL GetCharWidth32(HDC, UINT, UINT, LPINT); - -BOOL GetCharWidthFloat(HDC, UINT, UINT, PFLOAT); - -BOOL GetCharABCWidths(HDC, UINT, UINT, LPABC); - -BOOL GetCharABCWidthsFloat(HDC, UINT, UINT, LPABCFLOAT); - -DWORD GetGlyphOutline(HDC, UINT, UINT, LPGLYPHMETRICS, DWORD, LPVOID, const MAT2 *); - -HMETAFILE GetMetaFile(LPCTSTR); - -UINT GetOutlineTextMetrics(HDC, UINT, LPOUTLINETEXTMETRIC); - -BOOL GetTextExtentPoint(HDC, LPCTSTR, int, LPSIZE); - -BOOL GetTextExtentPoint32(HDC, LPCTSTR, int, LPSIZE); - -BOOL GetTextExtentExPoint(HDC, LPCTSTR, int, int, LPINT, LPINT, LPSIZE); - -DWORD GetCharacterPlacement(HDC, LPCTSTR, int, int, LPGCP_RESULTS, DWORD); - -DWORD GetGlyphIndices(HDC, LPCTSTR, int, LPWORD, DWORD); - -int AddFontResourceEx(LPCTSTR, DWORD, PVOID); - -BOOL RemoveFontResourceEx(LPCTSTR, DWORD, PVOID); - -HFONT CreateFontIndirectEx(const ENUMLOGFONTEXDV *); - -HDC ResetDC(HDC, const DEVMODE *); - -BOOL RemoveFontResource(LPCTSTR); - -HENHMETAFILE CopyEnhMetaFile(HENHMETAFILE, LPCTSTR); - -HDC CreateEnhMetaFile(HDC, LPCTSTR, const RECT *, LPCTSTR); - -HENHMETAFILE GetEnhMetaFile(LPCTSTR); - -UINT GetEnhMetaFileDescription(HENHMETAFILE, UINT, LPTSTR); - -BOOL GetTextMetrics(HDC, LPTEXTMETRIC); - -int StartDoc(HDC, const DOCINFO *); - -int GetObject(HANDLE, int, LPVOID); - -BOOL TextOut(HDC, int, int, LPCTSTR, int); - -BOOL ExtTextOut(HDC, int, int, UINT, const RECT *, LPCTSTR, UINT, const INT *); - -BOOL PolyTextOut(HDC, const POLYTEXT *, int); - -int GetTextFace(HDC, int, LPTSTR); - -DWORD GetKerningPairs(HDC, DWORD, LPKERNINGPAIR); - -BOOL GetLogColorSpace(HCOLORSPACE, LPLOGCOLORSPACE, DWORD); - -HCOLORSPACE CreateColorSpace(LPLOGCOLORSPACE); - -BOOL GetICMProfile(HDC, LPDWORD, LPTSTR); - -BOOL SetICMProfile(HDC, LPTSTR); - -int EnumICMProfiles(HDC, ICMENUMPROC, LPARAM); - -BOOL UpdateICMRegKey(DWORD, LPTSTR, LPTSTR, UINT); - -HKL LoadKeyboardLayout(LPCTSTR, UINT); - -BOOL GetKeyboardLayoutName(LPTSTR); - -HDESK CreateDesktop(LPCTSTR, LPCTSTR, DEVMODE*, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES); - -HDESK CreateDesktopEx(LPCTSTR, LPCTSTR, DEVMODE*, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES, ULONG, PVOID); - -HDESK OpenDesktop(LPCTSTR, DWORD, BOOL, ACCESS_MASK); - -BOOL EnumDesktops(HWINSTA, DESKTOPENUMPROC, LPARAM); - -HWINSTA CreateWindowStation(LPCTSTR, DWORD, ACCESS_MASK, LPSECURITY_ATTRIBUTES); - -HWINSTA OpenWindowStation(LPCTSTR, BOOL, ACCESS_MASK); - -BOOL EnumWindowStations(WINSTAENUMPROC, LPARAM); - -BOOL GetUserObjectInformation(HANDLE, int, PVOID, DWORD, LPDWORD); - -BOOL SetUserObjectInformation(HANDLE, int, PVOID, DWORD); - -UINT RegisterWindowMessage(LPCTSTR); - -BOOL GetMessage(LPMSG, HWND, UINT, UINT); - -LRESULT DispatchMessage(const MSG *); - -BOOL PeekMessage(LPMSG, HWND, UINT, UINT, UINT); - -LRESULT SendMessage(HWND, UINT, WPARAM, LPARAM); - -LRESULT SendMessageTimeout(HWND, UINT, WPARAM, LPARAM, UINT, UINT, PDWORD_PTR); - -BOOL SendNotifyMessage(HWND, UINT, WPARAM, LPARAM); - -BOOL SendMessageCallback(HWND, UINT, WPARAM, LPARAM, SENDASYNCPROC, ULONG_PTR); - -long BroadcastSystemMessageEx(DWORD, LPDWORD, UINT, WPARAM, LPARAM, PBSMINFO); - -long BroadcastSystemMessage(DWORD, LPDWORD, UINT, WPARAM, LPARAM); - -HDEVNOTIFY RegisterDeviceNotification(HANDLE, LPVOID, DWORD); - -BOOL PostMessage(HWND, UINT, WPARAM, LPARAM); - -BOOL PostThreadMessage(DWORD, UINT, WPARAM, LPARAM); - -BOOL PostAppMessage(DWORD, UINT, WPARAM, LPARAM); - -LRESULT DefWindowProc(HWND, UINT, WPARAM, LPARAM); - -LRESULT CallWindowProc(WNDPROC, HWND, UINT, WPARAM, LPARAM); - -ATOM RegisterClass(const WNDCLASS *); - -BOOL UnregisterClass(LPCTSTR, HINSTANCE); - -BOOL GetClassInfo(HINSTANCE, LPCTSTR, LPWNDCLASS); - -ATOM RegisterClassEx(const WNDCLASSEX *); - -BOOL GetClassInfoEx(HINSTANCE, LPCTSTR, LPWNDCLASSEX); - -HWND CreateWindowEx(DWORD, LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID); - -HWND CreateWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HMENU, HINSTANCE, LPVOID); - -HWND CreateDialogParam(HINSTANCE, LPCTSTR, HWND, DLGPROC, LPARAM); - -HWND CreateDialogIndirectParam(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM); - -HWND CreateDialog(HINSTANCE, LPCTSTR, HWND, DLGPROC); - -HWND CreateDialogIndirect(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC); - -INT_PTR DialogBoxParam(HINSTANCE, LPCTSTR, HWND, DLGPROC, LPARAM); - -INT_PTR DialogBoxIndirectParam(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC, LPARAM); - -INT_PTR DialogBox(HINSTANCE, LPCTSTR, HWND, DLGPROC); - -INT_PTR DialogBoxIndirect(HINSTANCE, LPCDLGTEMPLATE, HWND, DLGPROC); - -BOOL SetDlgItemText(HWND, int, LPCTSTR); - -UINT GetDlgItemText(HWND, int, LPTSTR, int); - -LRESULT SendDlgItemMessage(HWND, int, UINT, WPARAM, LPARAM); - -LRESULT DefDlgProc(HWND, UINT, WPARAM, LPARAM); - -BOOL CallMsgFilter(LPMSG, int); - -UINT RegisterClipboardFormat(LPCTSTR); - -int GetClipboardFormatName(UINT, LPTSTR, int); - -BOOL CharToOem(LPCTSTR, LPSTR); - -BOOL OemToChar(LPCSTR, LPTSTR); - -BOOL CharToOemBuff(LPCTSTR, LPSTR, DWORD); - -BOOL OemToCharBuff(LPCSTR, LPTSTR, DWORD); - -LPTSTR CharUpper(LPTSTR); - -DWORD CharUpperBuff(LPTSTR, DWORD); - -LPTSTR CharLower(LPTSTR); - -DWORD CharLowerBuff(LPTSTR, DWORD); - -LPTSTR CharNext(LPCTSTR); - -LPTSTR CharPrev(LPCTSTR, LPCTSTR); - -BOOL IsCharAlpha(CHAR); - -BOOL IsCharAlphaNumeric(CHAR); - -BOOL IsCharUpper(CHAR); - -BOOL IsCharLower(CHAR); - -int GetKeyNameText(LONG, LPTSTR, int); - -SHORT VkKeyScan(CHAR); - -SHORT VkKeyScanEx(CHAR, HKL); - -UINT MapVirtualKey(UINT, UINT); - -UINT MapVirtualKeyEx(UINT, UINT, HKL); - -HACCEL LoadAccelerators(HINSTANCE, LPCTSTR); - -HACCEL CreateAcceleratorTable(LPACCEL, int); - -int CopyAcceleratorTable(HACCEL, LPACCEL, int); - -int TranslateAccelerator(HWND, HACCEL, LPMSG); - -HMENU LoadMenu(HINSTANCE, LPCTSTR); - -HMENU LoadMenuIndirect(const MENUTEMPLATE *); - -BOOL ChangeMenu(HMENU, UINT, LPCTSTR, UINT, UINT); - -int GetMenuString(HMENU, UINT, LPTSTR, int, UINT); - -BOOL InsertMenu(HMENU, UINT, UINT, UINT_PTR, LPCTSTR); - -BOOL AppendMenu(HMENU, UINT, UINT_PTR, LPCTSTR); - -BOOL ModifyMenu(HMENU, UINT, UINT, UINT_PTR, LPCTSTR); - -BOOL InsertMenuItem(HMENU, UINT, BOOL, LPCMENUITEMINFO); - -BOOL GetMenuItemInfo(HMENU, UINT, BOOL, LPMENUITEMINFO); - -BOOL SetMenuItemInfo(HMENU, UINT, BOOL, LPCMENUITEMINFO); - -int DrawText(HDC, LPCTSTR, int, LPRECT, UINT); - -int DrawTextEx(HDC, LPTSTR, int, LPRECT, UINT, LPDRAWTEXTPARAMS); - -BOOL GrayString(HDC, HBRUSH, GRAYSTRINGPROC, LPARAM, int, int, int, int, int); - -BOOL DrawState(HDC, HBRUSH, DRAWSTATEPROC, LPARAM, WPARAM, int, int, int, int, UINT); - -LONG TabbedTextOut(HDC, int, int, LPCTSTR, int, int, const INT *, int); - -DWORD GetTabbedTextExtent(HDC, LPCTSTR, int, int, const INT *); - -BOOL SetProp(HWND, LPCTSTR, HANDLE); - -HANDLE GetProp(HWND, LPCTSTR); - -HANDLE RemoveProp(HWND, LPCTSTR); - -int EnumPropsEx(HWND, PROPENUMPROCEX, LPARAM); - -int EnumProps(HWND, PROPENUMPROC); - -BOOL SetWindowText(HWND, LPCTSTR); - -int GetWindowText(HWND, LPTSTR, int); - -int GetWindowTextLength(HWND); - -int MessageBox(HWND, LPCTSTR, LPCTSTR, UINT); - -int MessageBoxEx(HWND, LPCTSTR, LPCTSTR, UINT, WORD); - -int MessageBoxIndirect(const MSGBOXPARAMS *); - -LONG GetWindowLong(HWND, int); - -LONG SetWindowLong(HWND, int, LONG); - -LONG_PTR GetWindowLongPtr(HWND, int); - -LONG_PTR SetWindowLongPtr(HWND, int, LONG_PTR); - -DWORD GetClassLong(HWND, int); - -DWORD SetClassLong(HWND, int, LONG); - -ULONG_PTR GetClassLongPtr(HWND, int); - -ULONG_PTR SetClassLongPtr(HWND, int, LONG_PTR); - -HWND FindWindow(LPCTSTR, LPCTSTR); - -HWND FindWindowEx(HWND, HWND, LPCTSTR, LPCTSTR); - -int GetClassName(HWND, LPTSTR, int); - -HHOOK SetWindowsHook(int, HOOKPROC); - -HHOOK SetWindowsHookEx(int, HOOKPROC, HINSTANCE, DWORD); - -HBITMAP LoadBitmap(HINSTANCE, LPCTSTR); - -HCURSOR LoadCursor(HINSTANCE, LPCTSTR); - -HCURSOR LoadCursorFromFile(LPCTSTR); - -HICON LoadIcon(HINSTANCE, LPCTSTR); - -UINT PrivateExtractIcons(LPCTSTR, int, int, int, HICON *, UINT *, UINT, UINT); - -HANDLE LoadImage(HINSTANCE, LPCTSTR, UINT, int, int, UINT); - -BOOL GetIconInfoEx(HICON, PICONINFOEX); - -BOOL IsDialogMessage(HWND, LPMSG); - -int DlgDirList(HWND, LPTSTR, int, int, UINT); - -BOOL DlgDirSelectEx(HWND, LPTSTR, int, int); - -int DlgDirListComboBox(HWND, LPTSTR, int, int, UINT); - -BOOL DlgDirSelectComboBoxEx(HWND, LPTSTR, int, int); - -LRESULT DefFrameProc(HWND, HWND, UINT, WPARAM, LPARAM); - -LRESULT DefMDIChildProc(HWND, UINT, WPARAM, LPARAM); - -HWND CreateMDIWindow(LPCTSTR, LPCTSTR, DWORD, int, int, int, int, HWND, HINSTANCE, LPARAM); - -BOOL WinHelp(HWND, LPCTSTR, UINT, ULONG_PTR); - -LONG ChangeDisplaySettings(DEVMODE*, DWORD); - -LONG ChangeDisplaySettingsEx(LPCTSTR, DEVMODE*, HWND, DWORD, LPVOID); - -BOOL EnumDisplaySettings(LPCTSTR, DWORD, DEVMODE*); - -BOOL EnumDisplaySettingsEx(LPCTSTR, DWORD, DEVMODE*, DWORD); - -BOOL EnumDisplayDevices(LPCTSTR, DWORD, PDISPLAY_DEVICE, DWORD); - -BOOL SystemParametersInfo(UINT, UINT, PVOID, UINT); - -BOOL GetMonitorInfo(HMONITOR, LPMONITORINFO); - -UINT GetWindowModuleFileName(HWND, LPTSTR, UINT); - -UINT RealGetWindowClass(HWND, LPTSTR, UINT); - -BOOL GetAltTabInfo(HWND, int, PALTTABINFO, LPTSTR, UINT); - -UINT GetRawInputDeviceInfo(HANDLE, UINT, LPVOID, PUINT); - -int GetDateFormat(LCID, DWORD, const SYSTEMTIME*, LPCTSTR, LPTSTR, int); - -int GetTimeFormat(LCID, DWORD, const SYSTEMTIME*, LPCTSTR, LPTSTR, int); - -BOOL GetCPInfoEx(UINT, DWORD, LPCPINFOEX); - -int CompareString(LCID, DWORD, PCNZTCH, int, PCNZTCH, int); - -int GetLocaleInfo(LCID, LCTYPE, LPTSTR, int); - -BOOL SetLocaleInfo(LCID, LCTYPE, LPCTSTR); - -int GetCalendarInfo(LCID, CALID, CALTYPE, LPTSTR, int, LPDWORD); - -BOOL SetCalendarInfo(LCID, CALID, CALTYPE, LPCTSTR); - -int GetNumberFormat(LCID, DWORD, LPCTSTR, const NUMBERFMT *, LPTSTR, int); - -int GetCurrencyFormat(LCID, DWORD, LPCTSTR, const CURRENCYFMT *, LPTSTR, int); - -BOOL EnumCalendarInfo(CALINFO_ENUMPROC, LCID, CALID, CALTYPE); - -BOOL EnumCalendarInfoEx(CALINFO_ENUMPROCEX, LCID, CALID, CALTYPE); - -BOOL EnumTimeFormats(TIMEFMT_ENUMPROC, LCID, DWORD); - -BOOL EnumDateFormats(DATEFMT_ENUMPROC, LCID, DWORD); - -BOOL EnumDateFormatsEx(DATEFMT_ENUMPROCEX, LCID, DWORD); - -int GetGeoInfo(GEOID, GEOTYPE, LPTSTR, int, LANGID); - -BOOL GetStringTypeEx(LCID, DWORD, LPCTSTR, int, LPWORD); - -int FoldString(DWORD, LPCTSTR, int, LPTSTR, int); - -BOOL EnumSystemLocales(LOCALE_ENUMPROC, DWORD); - -BOOL EnumSystemLanguageGroups(LANGUAGEGROUP_ENUMPROC, DWORD, LONG_PTR); - -BOOL EnumLanguageGroupLocales(LANGGROUPLOCALE_ENUMPROC, LGRPID, DWORD, LONG_PTR); - -BOOL EnumUILanguages(UILANGUAGE_ENUMPROC, DWORD, LONG_PTR); - -BOOL EnumSystemCodePages(CODEPAGE_ENUMPROC, DWORD); - -BOOL ReadConsoleInput(HANDLE, PINPUT_RECORD, DWORD, LPDWORD); - -BOOL PeekConsoleInput(HANDLE, PINPUT_RECORD, DWORD, LPDWORD); - -BOOL ReadConsole(HANDLE, LPVOID, DWORD, LPDWORD, PCONSOLE_READCONSOLE_CONTROL); - -BOOL WriteConsole(HANDLE, const void*, DWORD, LPDWORD, LPVOID); - -BOOL FillConsoleOutputCharacter(HANDLE, CHAR, DWORD, COORD, LPDWORD); - -BOOL WriteConsoleOutputCharacter(HANDLE, LPCTSTR, DWORD, COORD, LPDWORD); - -BOOL ReadConsoleOutputCharacter(HANDLE, LPTSTR, DWORD, COORD, LPDWORD); - -BOOL WriteConsoleInput(HANDLE, const INPUT_RECORD*, DWORD, LPDWORD); - -BOOL ScrollConsoleScreenBuffer(HANDLE, const SMALL_RECT*, const SMALL_RECT*, COORD, const CHAR_INFO*); - -BOOL WriteConsoleOutput(HANDLE, const CHAR_INFO*, COORD, COORD, PSMALL_RECT); - -BOOL ReadConsoleOutput(HANDLE, PCHAR_INFO, COORD, COORD, PSMALL_RECT); - -DWORD GetConsoleTitle(LPTSTR, DWORD); - -DWORD GetConsoleOriginalTitle(LPTSTR, DWORD); - -BOOL SetConsoleTitle(LPCTSTR); - -BOOL AddConsoleAlias(LPTSTR, LPTSTR, LPTSTR); - -DWORD GetConsoleAlias(LPTSTR, LPTSTR, DWORD, LPTSTR); - -DWORD GetConsoleAliasesLength(LPTSTR); - -DWORD GetConsoleAliasExesLength(); - -DWORD GetConsoleAliases(LPTSTR, DWORD, LPTSTR); - -DWORD GetConsoleAliasExes(LPTSTR, DWORD); - -void ExpungeConsoleCommandHistory(LPTSTR); - -BOOL SetConsoleNumberOfCommands(DWORD, LPTSTR); - -DWORD GetConsoleCommandHistoryLength(LPTSTR); - -DWORD GetConsoleCommandHistory(LPTSTR, DWORD, LPTSTR); - -DWORD VerFindFile(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, PUINT, LPTSTR, PUINT); - -DWORD VerInstallFile(DWORD, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, LPTSTR, PUINT); - -DWORD GetFileVersionInfoSize(LPCTSTR, LPDWORD); - -BOOL GetFileVersionInfo(LPCTSTR, DWORD, DWORD, LPVOID); - -DWORD GetFileVersionInfoSizeEx(DWORD, LPCTSTR, LPDWORD); - -BOOL GetFileVersionInfoEx(DWORD, LPCTSTR, DWORD, DWORD, LPVOID); - -DWORD VerLanguageName(DWORD, LPTSTR, DWORD); - -BOOL VerQueryValue(LPCVOID, LPCTSTR, LPVOID *, PUINT); - -LSTATUS RegConnectRegistry(LPCTSTR, HKEY, PHKEY); - -LSTATUS RegConnectRegistryEx(LPCTSTR, HKEY, ULONG, PHKEY); - -LSTATUS RegCreateKey(HKEY, LPCTSTR, PHKEY); - -LSTATUS RegCreateKeyEx(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, const LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD); - -LSTATUS RegCreateKeyTransacted(HKEY, LPCTSTR, DWORD, LPTSTR, DWORD, REGSAM, const LPSECURITY_ATTRIBUTES, PHKEY, LPDWORD, HANDLE, PVOID); - -LSTATUS RegDeleteKey(HKEY, LPCTSTR); - -LSTATUS RegDeleteKeyEx(HKEY, LPCTSTR, REGSAM, DWORD); - -LSTATUS RegDeleteKeyTransacted(HKEY, LPCTSTR, REGSAM, DWORD, HANDLE, PVOID); - -LSTATUS RegDeleteValue(HKEY, LPCTSTR); - -LSTATUS RegEnumKey(HKEY, DWORD, LPTSTR, DWORD); - -LSTATUS RegEnumKeyEx(HKEY, DWORD, LPTSTR, LPDWORD, LPDWORD, LPTSTR, LPDWORD, PFILETIME); - -LSTATUS RegEnumValue(HKEY, DWORD, LPTSTR, LPDWORD, LPDWORD, LPDWORD, LPBYTE, LPDWORD); - -LSTATUS RegLoadKey(HKEY, LPCTSTR, LPCTSTR); - -LSTATUS RegOpenKey(HKEY, LPCTSTR, PHKEY); - -LSTATUS RegOpenKeyEx(HKEY, LPCTSTR, DWORD, REGSAM, PHKEY); - -LSTATUS RegOpenKeyTransacted(HKEY, LPCTSTR, DWORD, REGSAM, PHKEY, HANDLE, PVOID); - -LSTATUS RegQueryInfoKey(HKEY, LPTSTR, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, LPDWORD, PFILETIME); - -LSTATUS RegQueryValue(HKEY, LPCTSTR, LPTSTR, PLONG); - -LSTATUS RegQueryMultipleValues(HKEY, PVALENT, DWORD, LPTSTR, LPDWORD); - -LSTATUS RegQueryValueEx(HKEY, LPCTSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD); - -LSTATUS RegReplaceKey(HKEY, LPCTSTR, LPCTSTR, LPCTSTR); - -LSTATUS RegRestoreKey(HKEY, LPCTSTR, DWORD); - -LSTATUS RegSaveKey(HKEY, LPCTSTR, const LPSECURITY_ATTRIBUTES); - -LSTATUS RegSetValue(HKEY, LPCTSTR, DWORD, LPCTSTR, DWORD); - -LSTATUS RegSetValueEx(HKEY, LPCTSTR, DWORD, DWORD, const BYTE*, DWORD); - -LSTATUS RegUnLoadKey(HKEY, LPCTSTR); - -LSTATUS RegDeleteKeyValue(HKEY, LPCTSTR, LPCTSTR); - -LSTATUS RegSetKeyValue(HKEY, LPCTSTR, LPCTSTR, DWORD, LPCVOID, DWORD); - -LSTATUS RegDeleteTree(HKEY, LPCTSTR); - -LSTATUS RegCopyTree(HKEY, LPCTSTR, HKEY); - -LSTATUS RegGetValue(HKEY, LPCTSTR, LPCTSTR, DWORD, LPDWORD, PVOID, LPDWORD); - -LSTATUS RegLoadMUIString(HKEY, LPCTSTR, LPTSTR, DWORD, LPDWORD, DWORD, LPCTSTR); - -LSTATUS RegLoadAppKey(LPCTSTR, PHKEY, REGSAM, DWORD, DWORD); - -BOOL InitiateSystemShutdown(LPTSTR, LPTSTR, DWORD, BOOL, BOOL); - -BOOL AbortSystemShutdown(LPTSTR); - -BOOL InitiateSystemShutdownEx(LPTSTR, LPTSTR, DWORD, BOOL, BOOL, DWORD); - -DWORD InitiateShutdown(LPTSTR, LPTSTR, DWORD, DWORD, DWORD); - -LSTATUS RegSaveKeyEx(HKEY, LPCTSTR, const LPSECURITY_ATTRIBUTES, DWORD); - -DWORD MultinetGetConnectionPerformance(LPNETRESOURCE, LPNETCONNECTINFOSTRUCT); - -BOOL ChangeServiceConfig(SC_HANDLE, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR, LPCTSTR); - -BOOL ChangeServiceConfig2(SC_HANDLE, DWORD, LPVOID); - -SC_HANDLE CreateService(SC_HANDLE, LPCTSTR, LPCTSTR, DWORD, DWORD, DWORD, DWORD, LPCTSTR, LPCTSTR, LPDWORD, LPCTSTR, LPCTSTR, LPCTSTR); - -BOOL EnumDependentServices(SC_HANDLE, DWORD, LPENUM_SERVICE_STATUS, DWORD, LPDWORD, LPDWORD); - -BOOL EnumServicesStatus(SC_HANDLE, DWORD, DWORD, LPENUM_SERVICE_STATUS, DWORD, LPDWORD, LPDWORD, LPDWORD); - -BOOL EnumServicesStatusEx(SC_HANDLE, SC_ENUM_TYPE, DWORD, DWORD, LPBYTE, DWORD, LPDWORD, LPDWORD, LPDWORD, LPCTSTR); - -BOOL GetServiceKeyName(SC_HANDLE, LPCTSTR, LPTSTR, LPDWORD); - -BOOL GetServiceDisplayName(SC_HANDLE, LPCTSTR, LPTSTR, LPDWORD); - -SC_HANDLE OpenSCManager(LPCTSTR, LPCTSTR, DWORD); - -SC_HANDLE OpenService(SC_HANDLE, LPCTSTR, DWORD); - -BOOL QueryServiceConfig(SC_HANDLE, LPQUERY_SERVICE_CONFIG, DWORD, LPDWORD); - -BOOL QueryServiceConfig2(SC_HANDLE, DWORD, LPBYTE, DWORD, LPDWORD); - -BOOL QueryServiceLockStatus(SC_HANDLE, LPQUERY_SERVICE_LOCK_STATUS, DWORD, LPDWORD); - -SERVICE_STATUS_HANDLE RegisterServiceCtrlHandler(LPCTSTR, LPHANDLER_FUNCTION); - -SERVICE_STATUS_HANDLE RegisterServiceCtrlHandlerEx(LPCTSTR, LPHANDLER_FUNCTION_EX, LPVOID); - -BOOL StartServiceCtrlDispatcher(const SERVICE_TABLE_ENTRY *); - -BOOL StartService(SC_HANDLE, DWORD, LPCTSTR *); - -DWORD NotifyServiceStatusChange(SC_HANDLE, DWORD, PSERVICE_NOTIFY); - -BOOL ControlServiceEx(SC_HANDLE, DWORD, DWORD, PVOID); - -HKL ImmInstallIME(LPCTSTR, LPCTSTR); - -UINT ImmGetDescription(HKL, LPTSTR, UINT); - -UINT ImmGetIMEFileName(HKL, LPTSTR, UINT); - -LONG ImmGetCompositionString(HIMC, DWORD, LPVOID, DWORD); - -BOOL ImmSetCompositionString(HIMC, DWORD, LPVOID, DWORD, LPVOID, DWORD); - -DWORD ImmGetCandidateListCount(HIMC, LPDWORD); - -DWORD ImmGetCandidateList(HIMC, DWORD, LPCANDIDATELIST, DWORD); - -DWORD ImmGetGuideLine(HIMC, DWORD, LPTSTR, DWORD); - -BOOL ImmGetCompositionFont(HIMC, LPLOGFONT); - -BOOL ImmSetCompositionFont(HIMC, LPLOGFONT); - -BOOL ImmConfigureIME(HKL, HWND, DWORD, LPVOID); - -LRESULT ImmEscape(HKL, HIMC, UINT, LPVOID); - -DWORD ImmGetConversionList(HKL, HIMC, LPCTSTR, LPCANDIDATELIST, DWORD, UINT); - -BOOL ImmIsUIMessage(HWND, UINT, WPARAM, LPARAM); - -BOOL ImmRegisterWord(HKL, LPCTSTR, DWORD, LPCTSTR); - -BOOL ImmUnregisterWord(HKL, LPCTSTR, DWORD, LPCTSTR); - -UINT ImmGetRegisterWordStyle(HKL, UINT, LPSTYLEBUF); - -UINT ImmEnumRegisterWord(HKL, REGISTERWORDENUMPROC, LPCTSTR, DWORD, LPCTSTR, LPVOID); - -DWORD ImmGetImeMenuItems(HIMC, DWORD, DWORD, LPIMEMENUITEMINFO, LPIMEMENUITEMINFO, DWORD); diff --git a/config/windows-h-wrapper.template.h b/config/windows-h-wrapper.template.h deleted file mode 100644 index ece404f4fdf0..000000000000 --- a/config/windows-h-wrapper.template.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_windows_h -#define mozilla_windows_h - -// Include the "real" windows.h header. On clang/gcc, this can be done with the -// `include_next` feature, however MSVC requires a direct include path. -// -// Also turn off deprecation warnings, as we may be wrapping deprecated fns. - -#if defined(__GNUC__) || defined(__clang__) -# pragma GCC system_header -# include_next - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -#else -# include <${header_path}> - -# pragma warning(push) -# pragma warning(disable: 4996 4995) -#endif // defined(__GNUC__) || defined(__clang__) - -// Check if the header should be disabled -#if defined(MOZ_DISABLE_WINDOWS_WRAPPER) -#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "explicitly disabled" - -#elif !defined(__cplusplus) -#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-C++ source file" - -#elif !defined(__GNUC__) && !defined(__clang__) && !defined(_DLL) -#define MOZ_WINDOWS_WRAPPER_DISABLED_REASON "non-dynamic RTL" - -#else -// We're allowed to wrap in the current context. Define `MOZ_WRAPPED_WINDOWS_H` -// to note that fact, and perform the wrapping. -#define MOZ_WRAPPED_WINDOWS_H -extern "C++" { - -${decls} - -} // extern "C++" -#endif // enabled - -#if defined(__GNUC__) || defined(__clang__) -# pragma GCC diagnostic pop -#else -# pragma warning(pop) -#endif // defined(__GNUC__) || defined(__clang__) - -#endif // !defined(mozilla_windows_h) diff --git a/docshell/base/BrowsingContext.cpp b/docshell/base/BrowsingContext.cpp index 7affd92b1cbb..5afdbda96bee 100644 --- a/docshell/base/BrowsingContext.cpp +++ b/docshell/base/BrowsingContext.cpp @@ -4,7 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/dom/BrowsingContext.h" +#include "BrowsingContext.h" #include "mozilla/dom/ChromeBrowsingContext.h" #include "mozilla/dom/BrowsingContextBinding.h" diff --git a/docshell/base/BrowsingContext.h b/docshell/base/BrowsingContext.h index 4e253f9b172b..137d62a91939 100644 --- a/docshell/base/BrowsingContext.h +++ b/docshell/base/BrowsingContext.h @@ -4,8 +4,8 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozilla_dom_BrowsingContext_h -#define mozilla_dom_BrowsingContext_h +#ifndef BrowsingContext_h +#define BrowsingContext_h #include "mozilla/LinkedList.h" #include "mozilla/Maybe.h" @@ -122,8 +122,8 @@ public: nsTArray>& aBrowsingContexts); nsISupports* GetParentObject() const; - JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; + virtual JSObject* WrapObject(JSContext* aCx, + JS::Handle aGivenProto) override; MOZ_DECLARE_WEAKREFERENCE_TYPENAME(BrowsingContext) NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(BrowsingContext) @@ -155,5 +155,4 @@ private: } // namespace dom } // namespace mozilla - -#endif // !defined(mozilla_dom_BrowsingContext_h) +#endif diff --git a/docshell/base/ChromeBrowsingContext.cpp b/docshell/base/ChromeBrowsingContext.cpp index 9ec25d922def..ed215e2fc73a 100644 --- a/docshell/base/ChromeBrowsingContext.cpp +++ b/docshell/base/ChromeBrowsingContext.cpp @@ -4,8 +4,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include "mozilla/dom/ChromeBrowsingContext.h" -#include "mozilla/dom/WindowGlobalParent.h" +#include "ChromeBrowsingContext.h" #include "mozilla/dom/ContentParent.h" @@ -64,49 +63,5 @@ ChromeBrowsingContext::Cast(const BrowsingContext* aContext) return static_cast(aContext); } -void -ChromeBrowsingContext::GetWindowGlobals(nsTArray>& aWindows) -{ - aWindows.SetCapacity(mWindowGlobals.Count()); - for (auto iter = mWindowGlobals.Iter(); !iter.Done(); iter.Next()) { - aWindows.AppendElement(iter.Get()->GetKey()); - } -} - -void -ChromeBrowsingContext::RegisterWindowGlobal(WindowGlobalParent* aGlobal) -{ - MOZ_ASSERT(!mWindowGlobals.Contains(aGlobal), "Global already registered!"); - mWindowGlobals.PutEntry(aGlobal); -} - -void -ChromeBrowsingContext::UnregisterWindowGlobal(WindowGlobalParent* aGlobal) -{ - MOZ_ASSERT(mWindowGlobals.Contains(aGlobal), "Global not registered!"); - mWindowGlobals.RemoveEntry(aGlobal); -} - -JSObject* -ChromeBrowsingContext::WrapObject(JSContext* aCx, - JS::Handle aGivenProto) -{ - return ChromeBrowsingContext_Binding::Wrap(aCx, this, aGivenProto); -} - -void -ChromeBrowsingContext::Traverse(nsCycleCollectionTraversalCallback& cb) -{ - ChromeBrowsingContext* tmp = this; - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindowGlobals); -} - -void -ChromeBrowsingContext::Unlink() -{ - ChromeBrowsingContext* tmp = this; - NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindowGlobals); -} - } // namespace dom } // namespace mozilla diff --git a/docshell/base/ChromeBrowsingContext.h b/docshell/base/ChromeBrowsingContext.h index c3bff2435c3a..5d34fc231ae7 100644 --- a/docshell/base/ChromeBrowsingContext.h +++ b/docshell/base/ChromeBrowsingContext.h @@ -4,23 +4,19 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#ifndef mozilla_dom_ChromeBrowsingContext_h -#define mozilla_dom_ChromeBrowsingContext_h +#ifndef ChromeBrowsingContext_h +#define ChromeBrowsingContext_h #include "mozilla/dom/BrowsingContext.h" #include "mozilla/RefPtr.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" -#include "nsTHashtable.h" -#include "nsHashKeys.h" class nsIDocShell; namespace mozilla { namespace dom { -class WindowGlobalParent; - // ChromeBrowsingContext is a BrowsingContext living in the parent // process, with whatever extra data that a BrowsingContext in the // parent needs. @@ -38,18 +34,9 @@ public: return mProcessId == aProcessId; } - void GetWindowGlobals(nsTArray>& aWindows); - - // Called by WindowGlobalParent to register and unregister window globals. - void RegisterWindowGlobal(WindowGlobalParent* aGlobal); - void UnregisterWindowGlobal(WindowGlobalParent* aGlobal); - - JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - protected: - void Traverse(nsCycleCollectionTraversalCallback& cb); - void Unlink(); + void Traverse(nsCycleCollectionTraversalCallback& cb) {} + void Unlink() {} using Type = BrowsingContext::Type; ChromeBrowsingContext(BrowsingContext* aParent, @@ -64,12 +51,8 @@ private: // XXX(farre): Store a ContentParent pointer here rather than mProcessId? // Indicates which process owns the docshell. uint64_t mProcessId; - - // All live window globals within this browsing context. - nsTHashtable> mWindowGlobals; }; } // namespace dom } // namespace mozilla - -#endif // !defined(mozilla_dom_ChromeBrowsingContext_h) +#endif diff --git a/dom/base/moz.build b/dom/base/moz.build index 8d0944055446..ce26302f0e3f 100644 --- a/dom/base/moz.build +++ b/dom/base/moz.build @@ -425,7 +425,7 @@ SOURCES += [ 'nsDOMWindowUtils.cpp', # Conflicts with windows.h's definition of SendMessage. 'nsFrameMessageManager.cpp', - # These files have a #error "Never include unwrapped windows.h in this file!" + # These files have a #error "Never include windows.h in this file!" 'nsGlobalWindowInner.cpp', 'nsGlobalWindowOuter.cpp', # Conflicts with windows.h's definition of LoadImage. diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 452ecb1759d4..be942cbf7c1d 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -270,8 +270,6 @@ #include "mozilla/DocLoadingTimelineMarker.h" -#include "mozilla/dom/WindowGlobalChild.h" - #include "nsISpeculativeConnect.h" #include "mozilla/MediaManager.h" @@ -3110,13 +3108,6 @@ nsIDocument::SetDocumentURI(nsIURI* aURI) if (!equalBases) { RefreshLinkHrefs(); } - - // Tell our WindowGlobalParent that the document's URI has been changed. - nsPIDOMWindowInner* inner = GetInnerWindow(); - WindowGlobalChild* wgc = inner ? inner->GetWindowGlobalChild() : nullptr; - if (wgc) { - Unused << wgc->SendUpdateDocumentURI(mDocumentURI); - } } static void diff --git a/dom/base/nsFrameLoader.cpp b/dom/base/nsFrameLoader.cpp index 3f8ccc38c275..77091ac5ca1c 100644 --- a/dom/base/nsFrameLoader.cpp +++ b/dom/base/nsFrameLoader.cpp @@ -100,7 +100,6 @@ #include "mozilla/dom/PromiseNativeHandler.h" #include "mozilla/dom/ParentSHistory.h" #include "mozilla/dom/ChildSHistory.h" -#include "mozilla/dom/ChromeBrowsingContext.h" #include "mozilla/dom/HTMLBodyElement.h" @@ -3195,19 +3194,6 @@ nsFrameLoader::LoadContext() return loadContext.forget(); } -already_AddRefed -nsFrameLoader::GetBrowsingContext() -{ - RefPtr browsingContext; - if (IsRemoteFrame() && - (mRemoteBrowser || TryRemoteBrowser())) { - browsingContext = mRemoteBrowser->GetBrowsingContext(); - } else if (GetDocShell(IgnoreErrors())) { - browsingContext = nsDocShell::Cast(mDocShell)->GetBrowsingContext(); - } - return browsingContext.forget(); -} - void nsFrameLoader::InitializeBrowserAPI() { diff --git a/dom/base/nsFrameLoader.h b/dom/base/nsFrameLoader.h index 3699de9f02d8..ea1da1e70852 100644 --- a/dom/base/nsFrameLoader.h +++ b/dom/base/nsFrameLoader.h @@ -48,7 +48,6 @@ namespace mozilla { class OriginAttributes; namespace dom { -class BrowsingContext; class ChromeMessageSender; class ContentParent; class InProcessTabChildMessageManager; @@ -122,8 +121,6 @@ public: already_AddRefed LoadContext(); - already_AddRefed GetBrowsingContext(); - /** * Start loading the frame. This method figures out what to load * from the owner content in the frame loader. diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index a577deef8f9d..427d8eebd1ef 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -258,8 +258,6 @@ #include "mozilla/dom/ClientSource.h" #include "mozilla/dom/ClientState.h" -#include "mozilla/dom/WindowGlobalChild.h" - // Apple system headers seem to have a check() macro. #ifdef check class nsIScriptTimeoutHandler; @@ -1348,11 +1346,6 @@ nsGlobalWindowInner::FreeInnerObjects(bool aForDocumentOpen) } } - if (mWindowGlobalChild && !mWindowGlobalChild->IsClosed()) { - mWindowGlobalChild->Send__delete__(mWindowGlobalChild); - } - mWindowGlobalChild = nullptr; - mIntlUtils = nullptr; } @@ -1743,15 +1736,6 @@ nsGlobalWindowInner::InnerSetNewDocument(JSContext* aCx, nsIDocument* aDocument) // out of sync. ClearDocumentDependentSlots(aCx); - // FIXME: Currently, devtools can crete a fallback webextension window global - // in the content process which does not have a corresponding TabChild actor. - // This means we have no actor to be our parent. (Bug 1498293) - MOZ_DIAGNOSTIC_ASSERT(!mWindowGlobalChild, - "Shouldn't have created WindowGlobalChild yet!"); - if (XRE_IsParentProcess() || mTabChild) { - mWindowGlobalChild = WindowGlobalChild::Create(this); - } - #ifdef DEBUG mLastOpenedURI = aDocument->GetDocumentURI(); #endif @@ -7867,9 +7851,8 @@ nsGlobalWindowInner::FireOnNewGlobalObject() JS_FireOnNewGlobalObject(aes.cx(), global); } -#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H) -#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON) -#error "Never include unwrapped windows.h in this file!" +#ifdef _WINDOWS_ +#error "Never include windows.h in this file!" #endif already_AddRefed diff --git a/dom/base/nsGlobalWindowOuter.cpp b/dom/base/nsGlobalWindowOuter.cpp index 54f936214c16..e69e46a53c28 100644 --- a/dom/base/nsGlobalWindowOuter.cpp +++ b/dom/base/nsGlobalWindowOuter.cpp @@ -7638,9 +7638,8 @@ nsGlobalWindowOuter::ReportLargeAllocStatus() message); } -#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H) -#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON) -#error "Never include unwrapped windows.h in this file!" +#ifdef _WINDOWS_ +#error "Never include windows.h in this file!" #endif // Helper called by methods that move/resize the window, diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index f4b893708614..7fb389749dd9 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -68,7 +68,6 @@ class ServiceWorker; class ServiceWorkerDescriptor; class Timeout; class TimeoutManager; -class WindowGlobalChild; class CustomElementRegistry; enum class CallerType : uint32_t; } // namespace dom @@ -402,11 +401,6 @@ public: return mDoc; } - mozilla::dom::WindowGlobalChild* GetWindowGlobalChild() - { - return mWindowGlobalChild; - } - virtual PopupControlState GetPopupControlState() const = 0; // Determine if the window is suspended or frozen. Outer windows @@ -761,12 +755,6 @@ protected: // also set as permissions, but it could happen that we need to access them // synchronously in this context, and for this, we need a copy here. nsTArray mStorageAccessGranted; - - // The WindowGlobalChild actor for this window. - // - // This will be non-null during the full lifetime of the window, initialized - // during SetNewDocument, and cleared during FreeInnerObjects. - RefPtr mWindowGlobalChild; }; NS_DEFINE_STATIC_IID_ACCESSOR(nsPIDOMWindowInner, NS_PIDOMWINDOWINNER_IID) diff --git a/dom/chrome-webidl/BrowsingContext.webidl b/dom/chrome-webidl/BrowsingContext.webidl index 92c0850d2dcc..236d51a9ce7e 100644 --- a/dom/chrome-webidl/BrowsingContext.webidl +++ b/dom/chrome-webidl/BrowsingContext.webidl @@ -17,8 +17,3 @@ interface BrowsingContext { readonly attribute BrowsingContext? opener; }; - -[Exposed=Window, ChromeOnly] -interface ChromeBrowsingContext : BrowsingContext { - sequence getWindowGlobals(); -}; diff --git a/dom/chrome-webidl/WindowGlobalActors.webidl b/dom/chrome-webidl/WindowGlobalActors.webidl deleted file mode 100644 index 9bbd502c74cd..000000000000 --- a/dom/chrome-webidl/WindowGlobalActors.webidl +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -interface Principal; -interface URI; -interface nsIDocShell; - -[Exposed=Window, ChromeOnly] -interface WindowGlobalParent { - readonly attribute boolean isClosed; - readonly attribute boolean isInProcess; - readonly attribute ChromeBrowsingContext browsingContext; - - readonly attribute unsigned long long innerWindowId; - readonly attribute unsigned long long outerWindowId; - - readonly attribute FrameLoader? rootFrameLoader; // Embedded (browser) only - - readonly attribute WindowGlobalChild? childActor; // in-process only - - // Information about the currently loaded document. - readonly attribute Principal documentPrincipal; - readonly attribute URI? documentURI; - - static WindowGlobalParent? getByInnerWindowId(unsigned long long innerWindowId); -}; - -[Exposed=Window, ChromeOnly] -interface WindowGlobalChild { - readonly attribute boolean isClosed; - readonly attribute boolean isInProcess; - readonly attribute BrowsingContext browsingContext; - - readonly attribute unsigned long long innerWindowId; - readonly attribute unsigned long long outerWindowId; - - readonly attribute WindowGlobalParent? parentActor; // in-process only - - static WindowGlobalChild? getByInnerWindowId(unsigned long long innerWIndowId); -}; diff --git a/dom/chrome-webidl/moz.build b/dom/chrome-webidl/moz.build index 8a93ef30f47c..19947457e13d 100644 --- a/dom/chrome-webidl/moz.build +++ b/dom/chrome-webidl/moz.build @@ -54,7 +54,6 @@ WEBIDL_FILES = [ 'TelemetryStopwatch.webidl', 'WebExtensionContentScript.webidl', 'WebExtensionPolicy.webidl', - 'WindowGlobalActors.webidl', 'XULFrameElement.webidl', 'XULMenuElement.webidl', 'XULScrollElement.webidl', diff --git a/dom/ipc/ContentChild.cpp b/dom/ipc/ContentChild.cpp index d87efa7ca52b..13a351d3214d 100644 --- a/dom/ipc/ContentChild.cpp +++ b/dom/ipc/ContentChild.cpp @@ -954,6 +954,9 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener, TabContext newTabContext = aTabOpener ? *aTabOpener : TabContext(); RefPtr newChild = new TabChild(this, tabId, tabGroup, newTabContext, aChromeFlags); + if (NS_FAILED(newChild->Init())) { + return NS_ERROR_ABORT; + } if (aTabOpener) { MOZ_ASSERT(ipcContext->type() == IPCTabContext::TPopupIPCTabContext); @@ -969,11 +972,6 @@ ContentChild::ProvideWindowCommon(TabChild* aTabOpener, tabId, TabId(0), *ipcContext, aChromeFlags, GetID(), IsForBrowser()); - // Now that |newChild| has had its IPC link established, call |Init| to set it up. - if (NS_FAILED(newChild->Init())) { - return NS_ERROR_ABORT; - } - nsCOMPtr parentTopInnerWindow; if (aParent) { nsCOMPtr parentTopWindow = diff --git a/dom/ipc/DOMTypes.ipdlh b/dom/ipc/DOMTypes.ipdlh index d3a98a9e4939..c792f7fec573 100644 --- a/dom/ipc/DOMTypes.ipdlh +++ b/dom/ipc/DOMTypes.ipdlh @@ -26,8 +26,6 @@ using CSSSize from "Units.h"; using mozilla::LayoutDeviceIntPoint from "Units.h"; using hal::ScreenOrientation from "mozilla/HalScreenConfiguration.h"; using mozilla::gfx::SurfaceFormat from "mozilla/gfx/Types.h"; -using refcounted class nsIPrincipal from "mozilla/dom/PermissionMessageUtils.h"; -using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h"; namespace mozilla { @@ -185,13 +183,5 @@ struct PerformanceInfo CategoryDispatch[] items; }; -struct WindowGlobalInit -{ - nsIPrincipal principal; - BrowsingContextId browsingContextId; - uint64_t innerWindowId; - uint64_t outerWindowId; -}; - } // namespace dom } // namespace mozilla diff --git a/dom/ipc/PBrowser.ipdl b/dom/ipc/PBrowser.ipdl index 83e3c040fa47..4b27470a5fd2 100644 --- a/dom/ipc/PBrowser.ipdl +++ b/dom/ipc/PBrowser.ipdl @@ -18,7 +18,6 @@ include protocol PParentToChildStream; include protocol PFileDescriptorSet; include protocol PIPCBlobInputStream; include protocol PPaymentRequest; -include protocol PWindowGlobal; include DOMTypes; include IPCBlob; @@ -87,7 +86,6 @@ using class mozilla::NativeEventData from "ipc/nsGUIEventIPC.h"; using mozilla::FontRange from "ipc/nsGUIEventIPC.h"; using mozilla::a11y::IAccessibleHolder from "mozilla/a11y/IPCTypes.h"; using mozilla::OriginAttributes from "mozilla/ipc/BackgroundUtils.h"; -using mozilla::dom::BrowsingContextId from "mozilla/dom/ipc/IdType.h"; namespace mozilla { namespace dom { @@ -120,7 +118,6 @@ nested(upto inside_cpow) sync protocol PBrowser manages PIndexedDBPermissionRequest; manages PPluginWidget; manages PPaymentRequest; - manages PWindowGlobal; both: async AsyncMessage(nsString aMessage, CpowEntry[] aCpows, @@ -147,12 +144,6 @@ parent: async PPaymentRequest(); - /** - * Construct a new WindowGlobal actor for a window global in the given - * BrowsingContext and with the given principal. - */ - async PWindowGlobal(WindowGlobalInit init); - /** * Sends an NS_NATIVE_CHILD_OF_SHAREABLE_WINDOW to be adopted by the * widget's shareable window on the chrome side. Only used on Windows. @@ -588,8 +579,6 @@ parent: sync SetPrefersReducedMotionOverrideForTest(bool aValue); sync ResetPrefersReducedMotionOverrideForTest(); - async RootBrowsingContext(BrowsingContextId aId); - child: /** * Notify the remote browser that it has been Show()n on this diff --git a/dom/ipc/PWindowGlobal.ipdl b/dom/ipc/PWindowGlobal.ipdl deleted file mode 100644 index 5a78829f5e44..000000000000 --- a/dom/ipc/PWindowGlobal.ipdl +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -include protocol PBrowser; -include protocol PInProcess; - -include DOMTypes; - -using refcounted class nsIURI from "mozilla/ipc/URIUtils.h"; - -namespace mozilla { -namespace dom { - -/** - * A PWindowGlobal actor has a lifetime matching that of a single Window Global, - * specifically a |nsGlobalWindowInner|. These actors will form a parent/child - * link either between the chrome/content process, or will be in-process, for - * documents which are loaded in the chrome process. - */ -async protocol PWindowGlobal -{ - manager PBrowser or PInProcess; - -parent: - /// Update the URI of the document in this WindowGlobal. - async UpdateDocumentURI(nsIURI aUri); - - async __delete__(); -}; - -} // namespace dom -} // namespace mozilla diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index bf066c621404..8bad6a983220 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -123,7 +123,6 @@ #include "mozilla/Telemetry.h" #include "nsDocShellLoadState.h" #include "nsWebBrowser.h" -#include "mozilla/dom/WindowGlobalChild.h" #ifdef XP_WIN #include "mozilla/plugins/PluginWidgetChild.h" @@ -596,11 +595,6 @@ TabChild::Init() loadContext->SetRemoteTabs( mChromeFlags & nsIWebBrowserChrome::CHROME_REMOTE_WINDOW); - // Send our browsing context to the parent process. - RefPtr browsingContext = - nsDocShell::Cast(docShell)->GetBrowsingContext(); - SendRootBrowsingContext(BrowsingContextId(browsingContext->Id())); - // Few lines before, baseWindow->Create() will end up creating a new // window root in nsGlobalWindow::SetDocShell. // Then this chrome event handler, will be inherited to inner windows. @@ -3450,21 +3444,6 @@ TabChild::DeallocPPaymentRequestChild(PPaymentRequestChild* actor) return true; } -PWindowGlobalChild* -TabChild::AllocPWindowGlobalChild(const WindowGlobalInit&) -{ - MOZ_CRASH("We should never be manually allocating PWindowGlobalChild actors"); - return nullptr; -} - -bool -TabChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) -{ - // This reference was added in WindowGlobalChild::Create. - static_cast(aActor)->Release(); - return true; -} - ScreenIntSize TabChild::GetInnerSize() { diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index f4a03bad7a78..d60d6b69ae20 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -705,10 +705,6 @@ public: protected: virtual ~TabChild(); - virtual PWindowGlobalChild* AllocPWindowGlobalChild(const WindowGlobalInit& aInit) override; - - virtual bool DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) override; - virtual mozilla::ipc::IPCResult RecvDestroy() override; virtual mozilla::ipc::IPCResult RecvSetDocShellIsActive(const bool& aIsActive) override; diff --git a/dom/ipc/TabParent.cpp b/dom/ipc/TabParent.cpp index 47584ddc823a..0ce850d80400 100644 --- a/dom/ipc/TabParent.cpp +++ b/dom/ipc/TabParent.cpp @@ -100,8 +100,6 @@ #include "ProcessPriorityManager.h" #include "nsString.h" #include "IHistory.h" -#include "mozilla/dom/WindowGlobalParent.h" -#include "mozilla/dom/ChromeBrowsingContext.h" #ifdef XP_WIN #include "mozilla/plugins/PluginWidgetParent.h" @@ -1064,29 +1062,6 @@ TabParent::DeallocPIndexedDBPermissionRequestParent( mozilla::dom::indexedDB::DeallocPIndexedDBPermissionRequestParent(aActor); } -IPCResult -TabParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, - const WindowGlobalInit& aInit) -{ - static_cast(aActor)->Init(aInit); - return IPC_OK(); -} - -PWindowGlobalParent* -TabParent::AllocPWindowGlobalParent(const WindowGlobalInit& aInit) -{ - // Reference freed in DeallocPWindowGlobalParent. - return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ false)).take(); -} - -bool -TabParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) -{ - // Free reference from AllocPWindowGlobalParent. - static_cast(aActor)->Release(); - return true; -} - void TabParent::SendMouseEvent(const nsAString& aType, float aX, float aY, int32_t aButton, int32_t aClickCount, @@ -3748,15 +3723,6 @@ TabParent::RecvGetSystemFont(nsCString* aFontName) return IPC_OK(); } -mozilla::ipc::IPCResult -TabParent::RecvRootBrowsingContext(const BrowsingContextId& aId) -{ - MOZ_ASSERT(!mBrowsingContext, "May only set browsing context once!"); - mBrowsingContext = ChromeBrowsingContext::Get(aId); - MOZ_ASSERT(mBrowsingContext, "Invalid ID!"); - return IPC_OK(); -} - NS_IMETHODIMP FakeChannel::OnAuthAvailable(nsISupports *aContext, nsIAuthInformation *aAuthInfo) { diff --git a/dom/ipc/TabParent.h b/dom/ipc/TabParent.h index f194b029df24..cefd6cfe5e1f 100644 --- a/dom/ipc/TabParent.h +++ b/dom/ipc/TabParent.h @@ -67,7 +67,6 @@ class DataSourceSurface; namespace dom { -class ChromeBrowsingContext; class ClonedMessageData; class nsIContentParent; class Element; @@ -131,8 +130,6 @@ public: nsIXULBrowserWindow* GetXULBrowserWindow(); - ChromeBrowsingContext* GetBrowsingContext() { return mBrowsingContext; } - void Destroy(); void RemoveWindowListeners(); @@ -330,16 +327,6 @@ public: */ a11y::DocAccessibleParent* GetTopLevelDocAccessible() const; - virtual PWindowGlobalParent* - AllocPWindowGlobalParent(const WindowGlobalInit& aInit) override; - - virtual bool - DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) override; - - virtual mozilla::ipc::IPCResult - RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, - const WindowGlobalInit& aInit) override; - void LoadURL(nsIURI* aURI); void InitRendering(); @@ -636,8 +623,6 @@ protected: virtual mozilla::ipc::IPCResult RecvShowCanvasPermissionPrompt(const nsCString& aFirstPartyURI) override; - virtual mozilla::ipc::IPCResult RecvRootBrowsingContext(const BrowsingContextId& aId) override; - mozilla::ipc::IPCResult RecvSetSystemFont(const nsCString& aFontName) override; mozilla::ipc::IPCResult @@ -713,9 +698,6 @@ private: // dispatch message manager messages during this time. RefPtr mFrameLoader; - // The root browsing context loaded in this TabParent. - RefPtr mBrowsingContext; - TabId mTabId; // When loading a new tab or window via window.open, the child is diff --git a/dom/ipc/WindowGlobalChild.cpp b/dom/ipc/WindowGlobalChild.cpp deleted file mode 100644 index 301819aef2a9..000000000000 --- a/dom/ipc/WindowGlobalChild.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/WindowGlobalChild.h" -#include "mozilla/ipc/InProcessChild.h" -#include "mozilla/dom/BrowsingContext.h" -#include "mozilla/dom/WindowGlobalActorsBinding.h" - -namespace mozilla { -namespace dom { - -typedef nsRefPtrHashtable WGCByIdMap; -static StaticAutoPtr gWindowGlobalChildById; - -WindowGlobalChild::WindowGlobalChild(nsGlobalWindowInner* aWindow, - dom::BrowsingContext* aBrowsingContext) - : mWindowGlobal(aWindow) - , mBrowsingContext(aBrowsingContext) - , mInnerWindowId(aWindow->WindowID()) - , mOuterWindowId(aWindow->GetOuterWindow()->WindowID()) - , mIPCClosed(true) -{ -} - -already_AddRefed -WindowGlobalChild::Create(nsGlobalWindowInner* aWindow) -{ - nsCOMPtr principal = aWindow->GetPrincipal(); - MOZ_ASSERT(principal); - - RefPtr docshell = nsDocShell::Cast(aWindow->GetDocShell()); - MOZ_ASSERT(docshell); - - // Initalize our WindowGlobalChild object. - RefPtr bc = docshell->GetBrowsingContext(); - RefPtr wgc = new WindowGlobalChild(aWindow, bc); - - WindowGlobalInit init(principal, - BrowsingContextId(wgc->BrowsingContext()->Id()), - wgc->mInnerWindowId, - wgc->mOuterWindowId); - - // Send the link constructor over PInProcessChild or PBrowser. - if (XRE_IsParentProcess()) { - InProcessChild* ipc = InProcessChild::Singleton(); - if (!ipc) { - return nullptr; - } - - // Note: ref is released in DeallocPWindowGlobalChild - ipc->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); - } else { - RefPtr tabChild = TabChild::GetFrom(static_cast(aWindow)); - MOZ_ASSERT(tabChild); - - // Note: ref is released in DeallocPWindowGlobalChild - tabChild->SendPWindowGlobalConstructor(do_AddRef(wgc).take(), init); - } - wgc->mIPCClosed = false; - - // Register this WindowGlobal in the gWindowGlobalParentsById map. - if (!gWindowGlobalChildById) { - gWindowGlobalChildById = new WGCByIdMap(); - ClearOnShutdown(&gWindowGlobalChildById); - } - auto entry = gWindowGlobalChildById->LookupForAdd(wgc->mInnerWindowId); - MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalChild entry for ID!"); - entry.OrInsert([&] { return wgc; }); - - return wgc.forget(); -} - -/* static */ already_AddRefed -WindowGlobalChild::GetByInnerWindowId(uint64_t aInnerWindowId) -{ - if (!gWindowGlobalChildById) { - return nullptr; - } - return gWindowGlobalChildById->Get(aInnerWindowId); -} - -already_AddRefed -WindowGlobalChild::GetParentActor() -{ - if (mIPCClosed) { - return nullptr; - } - IProtocol* otherSide = InProcessChild::ParentActorFor(this); - return do_AddRef(static_cast(otherSide)); -} - -void -WindowGlobalChild::ActorDestroy(ActorDestroyReason aWhy) -{ - mIPCClosed = true; - gWindowGlobalChildById->Remove(mInnerWindowId); -} - -WindowGlobalChild::~WindowGlobalChild() -{ - MOZ_ASSERT(!gWindowGlobalChildById || - !gWindowGlobalChildById->Contains(mInnerWindowId)); -} - -JSObject* -WindowGlobalChild::WrapObject(JSContext* aCx, - JS::Handle aGivenProto) -{ - return WindowGlobalChild_Binding::Wrap(aCx, this, aGivenProto); -} - -nsISupports* -WindowGlobalChild::GetParentObject() -{ - return xpc::NativeGlobal(xpc::PrivilegedJunkScope()); -} - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalChild, - mWindowGlobal, - mBrowsingContext) - -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalChild, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalChild, Release) - -} // namespace dom -} // namespace mozilla diff --git a/dom/ipc/WindowGlobalChild.h b/dom/ipc/WindowGlobalChild.h deleted file mode 100644 index ed2bd58bd859..000000000000 --- a/dom/ipc/WindowGlobalChild.h +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_WindowGlobalChild_h -#define mozilla_dom_WindowGlobalChild_h - -#include "mozilla/RefPtr.h" -#include "mozilla/dom/PWindowGlobalChild.h" -#include "nsWrapperCache.h" - -class nsGlobalWindowInner; -class nsDocShell; - -namespace mozilla { -namespace dom { - -class BrowsingContext; -class WindowGlobalParent; - -/** - * Actor for a single nsGlobalWindowInner. This actor is used to communicate - * information to the parent process asynchronously. - */ -class WindowGlobalChild : public nsWrapperCache - , public PWindowGlobalChild -{ -public: - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalChild) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalChild) - - static already_AddRefed - GetByInnerWindowId(uint64_t aInnerWindowId); - - static already_AddRefed - GetByInnerWindowId(const GlobalObject& aGlobal, uint64_t aInnerWindowId) { - return GetByInnerWindowId(aInnerWindowId); - } - - dom::BrowsingContext* BrowsingContext() { return mBrowsingContext; } - nsGlobalWindowInner* WindowGlobal() { return mWindowGlobal; } - - // Has this actor been shut down - bool IsClosed() { return mIPCClosed; } - - // Check if this actor is managed by PInProcess, as-in the document is loaded - // in the chrome process. - bool IsInProcess() { return XRE_IsParentProcess(); } - - // The Window ID for this WindowGlobal - uint64_t InnerWindowId() { return mInnerWindowId; } - uint64_t OuterWindowId() { return mOuterWindowId; } - - // Get the other side of this actor if it is an in-process actor. Returns - // |nullptr| if the actor has been torn down, or is not in-process. - already_AddRefed GetParentActor(); - - // Create and initialize the WindowGlobalChild object. - static already_AddRefed - Create(nsGlobalWindowInner* aWindow); - - nsISupports* GetParentObject(); - JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - -protected: - virtual void ActorDestroy(ActorDestroyReason aWhy) override; - -private: - WindowGlobalChild(nsGlobalWindowInner* aWindow, dom::BrowsingContext* aBc); - ~WindowGlobalChild(); - - RefPtr mWindowGlobal; - RefPtr mBrowsingContext; - uint64_t mInnerWindowId; - uint64_t mOuterWindowId; - bool mIPCClosed; -}; - -} // namespace dom -} // namespace mozilla - -#endif // !defined(mozilla_dom_WindowGlobalChild_h) diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp deleted file mode 100644 index 12263ca7c331..000000000000 --- a/dom/ipc/WindowGlobalParent.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/dom/WindowGlobalParent.h" -#include "mozilla/ipc/InProcessParent.h" -#include "mozilla/dom/ChromeBrowsingContext.h" -#include "mozilla/dom/WindowGlobalActorsBinding.h" - -using namespace mozilla::ipc; - -namespace mozilla { -namespace dom { - -typedef nsRefPtrHashtable WGPByIdMap; -static StaticAutoPtr gWindowGlobalParentsById; - -WindowGlobalParent::WindowGlobalParent(const WindowGlobalInit& aInit, - bool aInProcess) - : mDocumentPrincipal(aInit.principal()) - , mInnerWindowId(aInit.innerWindowId()) - , mOuterWindowId(aInit.outerWindowId()) - , mInProcess(aInProcess) - , mIPCClosed(true) // Closed until WGP::Init -{ - MOZ_DIAGNOSTIC_ASSERT(XRE_IsParentProcess(), "Parent process only"); - MOZ_RELEASE_ASSERT(mDocumentPrincipal, "Must have a valid principal"); - - // NOTE: mBrowsingContext initialized in Init() - MOZ_RELEASE_ASSERT(aInit.browsingContextId() != 0, - "Must be made in BrowsingContext"); -} - -void -WindowGlobalParent::Init(const WindowGlobalInit& aInit) -{ - MOZ_ASSERT(Manager(), "Should have a manager!"); - MOZ_ASSERT(!mFrameLoader, "Cannot Init() a WindowGlobalParent twice!"); - - MOZ_ASSERT(mIPCClosed, "IPC shouldn't be open yet"); - mIPCClosed = false; - - // Register this WindowGlobal in the gWindowGlobalParentsById map. - if (!gWindowGlobalParentsById) { - gWindowGlobalParentsById = new WGPByIdMap(); - ClearOnShutdown(&gWindowGlobalParentsById); - } - auto entry = gWindowGlobalParentsById->LookupForAdd(mInnerWindowId); - MOZ_RELEASE_ASSERT(!entry, "Duplicate WindowGlobalParent entry for ID!"); - entry.OrInsert([&] { return this; }); - - // Determine which content process the window global is coming from. - ContentParentId processId(0); - if (!mInProcess) { - processId = static_cast(Manager()->Manager())->ChildID(); - } - - mBrowsingContext = ChromeBrowsingContext::Get(aInit.browsingContextId()); - MOZ_ASSERT(mBrowsingContext); - - // XXX(nika): This won't be the case soon, but for now this is a good - // assertion as we can't switch processes. We should relax this eventually. - MOZ_ASSERT(mBrowsingContext->IsOwnedByProcess(processId)); - - // Attach ourself to the browsing context. - mBrowsingContext->RegisterWindowGlobal(this); - - // Determine what toplevel frame element our WindowGlobalParent is being - // embedded in. - RefPtr frameElement; - if (mInProcess) { - // In the in-process case, we can get it from the other side's - // WindowGlobalChild. - MOZ_ASSERT(Manager()->GetProtocolTypeId() == PInProcessMsgStart); - RefPtr otherSide = GetChildActor(); - if (otherSide && otherSide->WindowGlobal()) { - // Get the toplevel window from the other side. - RefPtr docShell = nsDocShell::Cast(otherSide->WindowGlobal()->GetDocShell()); - if (docShell) { - docShell->GetTopFrameElement(getter_AddRefs(frameElement)); - } - } - } else { - // In the cross-process case, we can get the frame element from our manager. - MOZ_ASSERT(Manager()->GetProtocolTypeId() == PBrowserMsgStart); - frameElement = static_cast(Manager())->GetOwnerElement(); - } - - // Extract the nsFrameLoader from the current frame element. We may not have a - // nsFrameLoader if we are a chrome document. - nsCOMPtr flOwner = do_QueryInterface(frameElement); - if (flOwner) { - mFrameLoader = flOwner->GetFrameLoader(); - } -} - -/* static */ already_AddRefed -WindowGlobalParent::GetByInnerWindowId(uint64_t aInnerWindowId) -{ - if (!gWindowGlobalParentsById) { - return nullptr; - } - return gWindowGlobalParentsById->Get(aInnerWindowId); -} - -already_AddRefed -WindowGlobalParent::GetChildActor() -{ - if (mIPCClosed) { - return nullptr; - } - IProtocol* otherSide = InProcessParent::ChildActorFor(this); - return do_AddRef(static_cast(otherSide)); -} - -IPCResult -WindowGlobalParent::RecvUpdateDocumentURI(nsIURI* aURI) -{ - // XXX(nika): Assert that the URI change was one which makes sense (either - // about:blank -> a real URI, or a legal push/popstate URI change?) - mDocumentURI = aURI; - return IPC_OK(); -} - -void -WindowGlobalParent::ActorDestroy(ActorDestroyReason aWhy) -{ - mIPCClosed = true; - gWindowGlobalParentsById->Remove(mInnerWindowId); - mBrowsingContext->UnregisterWindowGlobal(this); -} - -WindowGlobalParent::~WindowGlobalParent() -{ - MOZ_ASSERT(!gWindowGlobalParentsById || - !gWindowGlobalParentsById->Contains(mInnerWindowId)); -} - -JSObject* -WindowGlobalParent::WrapObject(JSContext* aCx, - JS::Handle aGivenProto) -{ - return WindowGlobalParent_Binding::Wrap(aCx, this, aGivenProto); -} - -nsISupports* -WindowGlobalParent::GetParentObject() -{ - return xpc::NativeGlobal(xpc::PrivilegedJunkScope()); -} - -NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(WindowGlobalParent, - mFrameLoader, - mBrowsingContext) - -NS_IMPL_CYCLE_COLLECTION_ROOT_NATIVE(WindowGlobalParent, AddRef) -NS_IMPL_CYCLE_COLLECTION_UNROOT_NATIVE(WindowGlobalParent, Release) - -} // namespace dom -} // namespace mozilla diff --git a/dom/ipc/WindowGlobalParent.h b/dom/ipc/WindowGlobalParent.h deleted file mode 100644 index aaae9bff08f3..000000000000 --- a/dom/ipc/WindowGlobalParent.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_dom_WindowGlobalParent_h -#define mozilla_dom_WindowGlobalParent_h - -#include "mozilla/RefPtr.h" -#include "mozilla/dom/PWindowGlobalParent.h" -#include "nsWrapperCache.h" - -class nsIPrincipal; -class nsIURI; -class nsFrameLoader; - -namespace mozilla { -namespace dom { - -class ChromeBrowsingContext; -class WindowGlobalChild; - -/** - * A handle in the parent process to a specific nsGlobalWindowInner object. - */ -class WindowGlobalParent final : public nsWrapperCache - , public PWindowGlobalParent -{ -public: - NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(WindowGlobalParent) - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(WindowGlobalParent) - - static already_AddRefed - GetByInnerWindowId(uint64_t aInnerWindowId); - - static already_AddRefed - GetByInnerWindowId(const GlobalObject& aGlobal, uint64_t aInnerWindowId) { - return GetByInnerWindowId(aInnerWindowId); - } - - // Has this actor been shut down - bool IsClosed() { return mIPCClosed; } - - // Check if this actor is managed by PInProcess, as-in the document is loaded - // in-process. - bool IsInProcess() { return mInProcess; } - - // Get the other side of this actor if it is an in-process actor. Returns - // |nullptr| if the actor has been torn down, or is not in-process. - already_AddRefed GetChildActor(); - - // The principal of this WindowGlobal. This value will not change over the - // lifetime of the WindowGlobal object, even to reflect changes in - // |document.domain|. - nsIPrincipal* DocumentPrincipal() { return mDocumentPrincipal; } - - // The BrowsingContext which this WindowGlobal has been loaded into. - ChromeBrowsingContext* BrowsingContext() { return mBrowsingContext; } - - // Get the root nsFrameLoader object for the tree of BrowsingContext nodes - // which this WindowGlobal is a part of. This will be the nsFrameLoader - // holding the TabParent for remote tabs, and the root content frameloader for - // non-remote tabs. - nsFrameLoader* GetRootFrameLoader() { return mFrameLoader; } - - // The current URI which loaded in the document. - nsIURI* GetDocumentURI() { return mDocumentURI; } - - // Window IDs for inner/outer windows. - uint64_t OuterWindowId() { return mOuterWindowId; } - uint64_t InnerWindowId() { return mInnerWindowId; } - - // Create a WindowGlobalParent from over IPC. This method should not be called - // from outside of the IPC constructors. - WindowGlobalParent(const WindowGlobalInit& aInit, bool aInProcess); - - // Initialize the mFrameLoader fields for a created WindowGlobalParent. Must - // be called after setting the Manager actor. - void Init(const WindowGlobalInit& aInit); - - nsISupports* GetParentObject(); - JSObject* WrapObject(JSContext* aCx, - JS::Handle aGivenProto) override; - -protected: - // IPC messages - mozilla::ipc::IPCResult RecvUpdateDocumentURI(nsIURI* aURI) override; - - void ActorDestroy(ActorDestroyReason aWhy) override; - -private: - ~WindowGlobalParent(); - - // NOTE: This document principal doesn't reflect possible |document.domain| - // mutations which may have been made in the actual document. - nsCOMPtr mDocumentPrincipal; - nsCOMPtr mDocumentURI; - RefPtr mFrameLoader; - RefPtr mBrowsingContext; - uint64_t mInnerWindowId; - uint64_t mOuterWindowId; - bool mInProcess; - bool mIPCClosed; -}; - -} // namespace dom -} // namespace mozilla - -#endif // !defined(mozilla_dom_WindowGlobalParent_h) diff --git a/dom/ipc/moz.build b/dom/ipc/moz.build index 94bc1778578d..ea8f28ef0313 100644 --- a/dom/ipc/moz.build +++ b/dom/ipc/moz.build @@ -50,8 +50,6 @@ EXPORTS.mozilla.dom += [ 'TabParent.h', 'URLClassifierChild.h', 'URLClassifierParent.h', - 'WindowGlobalChild.h', - 'WindowGlobalParent.h', ] EXPORTS.mozilla += [ @@ -87,8 +85,6 @@ UNIFIED_SOURCES += [ 'TabMessageUtils.cpp', 'TabParent.cpp', 'URLClassifierParent.cpp', - 'WindowGlobalChild.cpp', - 'WindowGlobalParent.cpp', ] # ContentChild.cpp cannot be compiled in unified mode on linux due to Time conflict @@ -116,7 +112,6 @@ IPDL_SOURCES += [ 'PURLClassifier.ipdl', 'PURLClassifierInfo.ipdlh', 'PURLClassifierLocal.ipdl', - 'PWindowGlobal.ipdl', 'ServiceWorkerConfiguration.ipdlh', ] diff --git a/dom/webidl/FrameLoader.webidl b/dom/webidl/FrameLoader.webidl index 997c3a3d9f44..9f1b0df7bc52 100644 --- a/dom/webidl/FrameLoader.webidl +++ b/dom/webidl/FrameLoader.webidl @@ -33,12 +33,6 @@ interface FrameLoader { */ readonly attribute LoadContext loadContext; - /** - * Get the root BrowsingContext within the frame. - * This may be null immediately after creating a remote frame. - */ - readonly attribute BrowsingContext? browsingContext; - /** * Get the ParentSHistory for the nsFrameLoader. May return null if this * frameloader is not for a toplevel frame. diff --git a/gfx/cairo/cairo/src/moz.build b/gfx/cairo/cairo/src/moz.build index d356a26f7cdb..48c4a7bfa917 100755 --- a/gfx/cairo/cairo/src/moz.build +++ b/gfx/cairo/cairo/src/moz.build @@ -34,7 +34,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] not in ('cocoa', 'uikit'): ] if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'windows': - DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True EXPORTS.cairo += [ 'cairo-win32.h', ] diff --git a/gfx/thebes/gfxDWriteFonts.cpp b/gfx/thebes/gfxDWriteFonts.cpp index 846e24983a1f..63711acfaf6b 100644 --- a/gfx/thebes/gfxDWriteFonts.cpp +++ b/gfx/thebes/gfxDWriteFonts.cpp @@ -262,7 +262,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) UINT32 ucs = L' '; UINT16 glyph; - HRESULT hr = mFontFace->GetGlyphIndices(&ucs, 1, &glyph); + HRESULT hr = mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph); if (FAILED(hr)) { mMetrics->spaceWidth = 0; } else { @@ -292,7 +292,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) if (mMetrics->aveCharWidth < 1) { ucs = L'x'; - if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) { + if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) { mMetrics->aveCharWidth = MeasureGlyphWidth(glyph); } if (mMetrics->aveCharWidth < 1) { @@ -302,7 +302,7 @@ gfxDWriteFont::ComputeMetrics(AntialiasOption anAAOption) } ucs = L'0'; - if (SUCCEEDED(mFontFace->GetGlyphIndices(&ucs, 1, &glyph))) { + if (SUCCEEDED(mFontFace->GetGlyphIndicesW(&ucs, 1, &glyph))) { mMetrics->zeroOrAveCharWidth = MeasureGlyphWidth(glyph); } if (mMetrics->zeroOrAveCharWidth < 1) { diff --git a/gfx/vr/service/openvr/moz.build b/gfx/vr/service/openvr/moz.build index 5ad6d0b9b457..351bf50e6183 100644 --- a/gfx/vr/service/openvr/moz.build +++ b/gfx/vr/service/openvr/moz.build @@ -8,9 +8,6 @@ FINAL_LIBRARY = 'xul' DEFINES['VR_API_PUBLIC'] = True -# Windows.h wrappers conflict with internal methods in openvr -DEFINES['MOZ_DISABLE_WINDOWS_WRAPPER'] = True - if CONFIG['OS_ARCH'] == 'WINNT': if CONFIG['HAVE_64BIT_BUILD']: DEFINES['WIN64'] = True diff --git a/ipc/glue/InProcessChild.cpp b/ipc/glue/InProcessChild.cpp deleted file mode 100644 index 53d6451b5c53..000000000000 --- a/ipc/glue/InProcessChild.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ipc/InProcessChild.h" -#include "mozilla/dom/WindowGlobalChild.h" - -using namespace mozilla::dom; - -namespace mozilla { -namespace ipc { - -PWindowGlobalChild* -InProcessChild::AllocPWindowGlobalChild(const WindowGlobalInit& aInit) -{ - MOZ_ASSERT_UNREACHABLE("PWindowGlobalChild should not be created manually"); - return nullptr; -} - -bool -InProcessChild::DeallocPWindowGlobalChild(PWindowGlobalChild* aActor) -{ - // Free IPC-held reference - static_cast(aActor)->Release(); - return true; -} - -} // namespace ipc -} // namespace mozilla diff --git a/ipc/glue/InProcessChild.h b/ipc/glue/InProcessChild.h deleted file mode 100644 index e0001beaeac0..000000000000 --- a/ipc/glue/InProcessChild.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_ipc_InProcessChild_h -#define mozilla_ipc_InProcessChild_h - -#include "mozilla/ipc/PInProcessChild.h" -#include "mozilla/StaticPtr.h" - -namespace mozilla { -namespace dom { -class PWindowGlobalParent; -class PWindowGlobalChild; -} // namespace dom - -namespace ipc { - -class InProcessParent; - -/** - * The `InProcessChild` class represents the child half of a main-thread to - * main-thread actor. - * - * The `PInProcess` actor should be used as an alternate manager to `PContent` - * for async actors which want to communicate uniformly between Content->Chrome - * and Chrome->Chrome situations. - */ -class InProcessChild : public PInProcessChild -{ -public: - friend class InProcessParent; - - NS_INLINE_DECL_REFCOUNTING(InProcessChild) - - // Get the singleton instance of this actor. - static InProcessChild* Singleton(); - - // Get the parent side of the in-process child actor |aActor|. If |aActor| is - // not an in-process actor, or is not connected, this method will return - // |nullptr|. - static IProtocol* ParentActorFor(IProtocol* aActor); - -protected: - virtual mozilla::dom::PWindowGlobalChild* - AllocPWindowGlobalChild(const WindowGlobalInit& aInit) override; - - virtual bool - DeallocPWindowGlobalChild(mozilla::dom::PWindowGlobalChild* aActor) override; - -private: - // NOTE: PInProcess lifecycle management is declared as staic methods and - // state on InProcessParent, and implemented in InProcessImpl.cpp. - virtual void ActorDestroy(ActorDestroyReason aWhy) override; - virtual void DeallocPInProcessChild() override; - ~InProcessChild() = default; - - static StaticRefPtr sSingleton; -}; - -} // namespace ipc -} // namespace mozilla - -#endif // defined(mozilla_ipc_InProcessChild_h) diff --git a/ipc/glue/InProcessImpl.cpp b/ipc/glue/InProcessImpl.cpp deleted file mode 100644 index f882bedeae0e..000000000000 --- a/ipc/glue/InProcessImpl.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ipc/InProcessParent.h" -#include "mozilla/ipc/InProcessChild.h" -#include "nsIObserverService.h" -#include "mozilla/Services.h" - -// This file contains the implementation of core InProcess lifecycle management -// facilities. - -namespace mozilla { -namespace ipc { - -StaticRefPtr InProcessParent::sSingleton; -StaticRefPtr InProcessChild::sSingleton; -bool InProcessParent::sShutdown = false; - - -////////////////////////////////////////// -// InProcess actor lifecycle management // -////////////////////////////////////////// - -/* static */ InProcessChild* -InProcessChild::Singleton() { - MOZ_ASSERT(NS_IsMainThread()); - - if (!sSingleton) { - InProcessParent::Startup(); - } - return sSingleton; -} - -/* static */ InProcessParent* -InProcessParent::Singleton() { - MOZ_ASSERT(NS_IsMainThread()); - - if (!sSingleton) { - InProcessParent::Startup(); - } - return sSingleton; -} - -/* static */ void -InProcessParent::Startup() -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (sShutdown) { - NS_WARNING("Could not get in-process actor while shutting down!"); - return; - } - - nsCOMPtr obs = mozilla::services::GetObserverService(); - if (!obs) { - sShutdown = true; - NS_WARNING("Failed to get nsIObserverService for in-process actor"); - return; - } - - RefPtr parent = new InProcessParent(); - RefPtr child = new InProcessChild(); - - // Observe the shutdown event to close & clean up after ourselves. - nsresult rv = obs->AddObserver(parent, NS_XPCOM_SHUTDOWN_OBSERVER_ID, false); - if (NS_WARN_IF(NS_FAILED(rv))) { - return; - } - - // Link the two actors - if (!child->OpenOnSameThread(parent->GetIPCChannel(), ChildSide)) { - MOZ_CRASH("Failed to open InProcessChild!"); - } - - parent->SetOtherProcessId(base::GetCurrentProcId()); - - // Create references held by the IPC layer which will be freed in - // DeallocPInProcess{Parent,Child}. - parent.get()->AddRef(); - child.get()->AddRef(); - - // Stash global references to fetch the other side of the reference. - InProcessParent::sSingleton = parent.forget(); - InProcessChild::sSingleton = child.forget(); -} - - -/* static */ void -InProcessParent::Shutdown() -{ - MOZ_ASSERT(NS_IsMainThread()); - - if (!sSingleton || sShutdown) { - return; - } - - sShutdown = true; - - RefPtr parent = sSingleton; - InProcessParent::sSingleton = nullptr; - InProcessChild::sSingleton = nullptr; - - // Calling `Close` on the actor will cause the `Dealloc` methods to be called, - // freeing the remaining references. - parent->Close(); -} - -NS_IMETHODIMP -InProcessParent::Observe(nsISupports* aSubject, const char* aTopic, const char16_t* aData) -{ - MOZ_ASSERT(!strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID)); - InProcessParent::Shutdown(); - return NS_OK; -} - -void -InProcessParent::ActorDestroy(ActorDestroyReason aWhy) -{ - InProcessParent::Shutdown(); -} - -void -InProcessChild::ActorDestroy(ActorDestroyReason aWhy) -{ - InProcessParent::Shutdown(); -} - -void -InProcessParent::DeallocPInProcessParent() -{ - MOZ_ASSERT(!InProcessParent::sSingleton); - Release(); // Release the reference taken in InProcessParent::Startup. -} - -void -InProcessChild::DeallocPInProcessChild() -{ - MOZ_ASSERT(!InProcessChild::sSingleton); - Release(); // Release the reference taken in InProcessParent::Startup. -} - -//////////////////////////////// -// In-Process Actor Utilities // -//////////////////////////////// - -// Helper method for implementing ParentActorFor and ChildActorFor. -static IProtocol* -GetOtherInProcessActor(IProtocol* aActor) -{ - MOZ_ASSERT(aActor->GetSide() != UnknownSide, "bad unknown side"); - - // Discover the manager of aActor which is PInProcess. - IProtocol* current = aActor; - while (current) { - if (current->GetProtocolTypeId() == PInProcessMsgStart) { - break; // Found the correct actor. - } - current = current->Manager(); - } - if (!current) { - return nullptr; // Not a PInProcess actor, return |nullptr| - } - - MOZ_ASSERT(current->GetSide() == aActor->GetSide(), "side changed?"); - MOZ_ASSERT_IF(aActor->GetSide() == ParentSide, - current == InProcessParent::Singleton()); - MOZ_ASSERT_IF(aActor->GetSide() == ChildSide, - current == InProcessChild::Singleton()); - - // Check whether this is InProcessParent or InProcessChild, and get the other - // side's toplevel actor. - IProtocol* otherRoot = nullptr; - if (aActor->GetSide() == ParentSide) { - otherRoot = InProcessChild::Singleton(); - } else { - otherRoot = InProcessParent::Singleton(); - } - if (NS_WARN_IF(!otherRoot)) { - return nullptr; - } - - // Look up the actor on the other side, and return it. - IProtocol* otherActor = otherRoot->Lookup(aActor->Id()); - if (otherActor) { - MOZ_ASSERT(otherActor->GetSide() != UnknownSide, "bad unknown side"); - MOZ_ASSERT(otherActor->GetSide() != aActor->GetSide(), "Wrong side!"); - MOZ_ASSERT(otherActor->GetProtocolTypeId() == aActor->GetProtocolTypeId(), - "Wrong type of protocol!"); - } - - return otherActor; -} - -/* static */ IProtocol* -InProcessParent::ChildActorFor(IProtocol* aActor) -{ - MOZ_ASSERT(aActor && aActor->GetSide() == ParentSide); - return GetOtherInProcessActor(aActor); -} - -/* static */ IProtocol* -InProcessChild::ParentActorFor(IProtocol* aActor) -{ - MOZ_ASSERT(aActor && aActor->GetSide() == ChildSide); - return GetOtherInProcessActor(aActor); -} - -} // namespace ipc -} // namespace mozilla diff --git a/ipc/glue/InProcessParent.cpp b/ipc/glue/InProcessParent.cpp deleted file mode 100644 index 4d56eb9d070e..000000000000 --- a/ipc/glue/InProcessParent.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "mozilla/ipc/InProcessParent.h" -#include "mozilla/dom/WindowGlobalParent.h" - -using namespace mozilla::dom; - -namespace mozilla { -namespace ipc { - -NS_IMPL_ISUPPORTS(InProcessParent, nsIObserver) - -IPCResult -InProcessParent::RecvPWindowGlobalConstructor(PWindowGlobalParent* aActor, - const WindowGlobalInit& aInit) -{ - static_cast(aActor)->Init(aInit); - return IPC_OK(); -} - -PWindowGlobalParent* -InProcessParent::AllocPWindowGlobalParent(const WindowGlobalInit& aInit) -{ - // Reference freed in DeallocPWindowGlobalParent. - return do_AddRef(new WindowGlobalParent(aInit, /* inproc */ true)).take(); -} - -bool -InProcessParent::DeallocPWindowGlobalParent(PWindowGlobalParent* aActor) -{ - // Free IPC-held reference. - static_cast(aActor)->Release(); - return true; -} - -} // namespace ipc -} // namespace mozilla \ No newline at end of file diff --git a/ipc/glue/InProcessParent.h b/ipc/glue/InProcessParent.h deleted file mode 100644 index 145adccd14e6..000000000000 --- a/ipc/glue/InProcessParent.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_ipc_InProcessParent_h -#define mozilla_ipc_InProcessParent_h - -#include "mozilla/ipc/PInProcessParent.h" -#include "mozilla/StaticPtr.h" - -namespace mozilla { -namespace dom { -class PWindowGlobalParent; -class PWindowGlobalChild; -} // namespace dom - -namespace ipc { - -class InProcessChild; - -/** - * The `InProcessParent` class represents the parent half of a main-thread to - * main-thread actor. - * - * The `PInProcess` actor should be used as an alternate manager to `PContent` - * for async actors which want to communicate uniformly between Content->Chrome - * and Chrome->Chrome situations. - */ -class InProcessParent : public nsIObserver - , public PInProcessParent -{ -public: - friend class InProcessChild; - - NS_DECL_ISUPPORTS - NS_DECL_NSIOBSERVER - - // Get the singleton instance of this actor. - static InProcessParent* Singleton(); - - // Get the child side of the in-process child actor |aActor|. If |aActor| is - // not an in-process actor, or is not connected, this method will return - // |nullptr|. - static IProtocol* ChildActorFor(IProtocol* aActor); - -protected: - virtual mozilla::dom::PWindowGlobalParent* - AllocPWindowGlobalParent(const WindowGlobalInit& aInit) override; - - virtual bool - DeallocPWindowGlobalParent(mozilla::dom::PWindowGlobalParent* aActor) override; - - virtual IPCResult - RecvPWindowGlobalConstructor(mozilla::dom::PWindowGlobalParent* aActor, - const WindowGlobalInit& aInit) override; - -private: - // Lifecycle management is implemented in InProcessImpl.cpp - virtual void ActorDestroy(ActorDestroyReason aWhy) override; - virtual void DeallocPInProcessParent() override; - ~InProcessParent() = default; - - static void Startup(); - static void Shutdown(); - - static StaticRefPtr sSingleton; - static bool sShutdown; -}; - - -} // namespace ipc -} // namespace mozilla - -#endif // defined(mozilla_ipc_InProcessParent_h) diff --git a/ipc/glue/MessageChannel.cpp b/ipc/glue/MessageChannel.cpp index 76242c7a2b79..d092ab07b3ef 100644 --- a/ipc/glue/MessageChannel.cpp +++ b/ipc/glue/MessageChannel.cpp @@ -634,8 +634,7 @@ MessageChannel::MessageChannel(const char* aName, mPeerPidSet(false), mPeerPid(-1), mIsPostponingSends(false), - mBuildIDsConfirmedMatch(false), - mIsSameThreadChannel(false) + mBuildIDsConfirmedMatch(false) { MOZ_COUNT_CTOR(ipc::MessageChannel); @@ -967,35 +966,6 @@ MessageChannel::CommonThreadOpenInit(MessageChannel *aTargetChan, Side aSide) mSide = aSide; } -bool -MessageChannel::OpenOnSameThread(MessageChannel* aTargetChan, - mozilla::ipc::Side aSide) -{ - CommonThreadOpenInit(aTargetChan, aSide); - - Side oppSide = UnknownSide; - switch (aSide) { - case ChildSide: oppSide = ParentSide; break; - case ParentSide: oppSide = ChildSide; break; - case UnknownSide: break; - } - mIsSameThreadChannel = true; - - // XXX(nika): Avoid setting up a monitor for same thread channels? We - // shouldn't need it. - mMonitor = new RefCountedMonitor(); - - mChannelState = ChannelOpening; - aTargetChan->CommonThreadOpenInit(this, oppSide); - - aTargetChan->mIsSameThreadChannel = true; - aTargetChan->mMonitor = mMonitor; - - mChannelState = ChannelConnected; - aTargetChan->mChannelState = ChannelConnected; - return true; -} - bool MessageChannel::Echo(Message* aMsg) { @@ -1505,8 +1475,6 @@ MessageChannel::Send(Message* aMsg, Message* aReply) // Sanity checks. AssertWorkerThread(); mMonitor->AssertNotCurrentThreadOwns(); - MOZ_RELEASE_ASSERT(!mIsSameThreadChannel, - "sync send over same-thread channel will deadlock!"); #ifdef OS_WIN SyncStackFrame frame(this, false); @@ -1712,8 +1680,6 @@ MessageChannel::Call(Message* aMsg, Message* aReply) UniquePtr msg(aMsg); AssertWorkerThread(); mMonitor->AssertNotCurrentThreadOwns(); - MOZ_RELEASE_ASSERT(!mIsSameThreadChannel, - "intr call send over same-thread channel will deadlock!"); #ifdef OS_WIN SyncStackFrame frame(this, true); @@ -2490,9 +2456,6 @@ MessageChannel::WaitForSyncNotify(bool /* aHandleWindowsMessages */) } #endif - MOZ_RELEASE_ASSERT(!mIsSameThreadChannel, - "Wait on same-thread channel will deadlock!"); - TimeDuration timeout = (kNoTimeout == mTimeoutMs) ? TimeDuration::Forever() : TimeDuration::FromMilliseconds(mTimeoutMs); @@ -2805,10 +2768,6 @@ MessageChannel::SynchronouslyClose() AssertWorkerThread(); mMonitor->AssertCurrentThreadOwns(); mLink->SendClose(); - - MOZ_RELEASE_ASSERT(!mIsSameThreadChannel || ChannelClosed == mChannelState, - "same-thread channel failed to synchronously close?"); - while (ChannelClosed != mChannelState) mMonitor->Wait(); } diff --git a/ipc/glue/MessageChannel.h b/ipc/glue/MessageChannel.h index 983ab56c47a9..99385e936cd1 100644 --- a/ipc/glue/MessageChannel.h +++ b/ipc/glue/MessageChannel.h @@ -180,15 +180,6 @@ private: // in MessageChannel.cpp. bool Open(MessageChannel *aTargetChan, nsIEventTarget *aEventTarget, Side aSide); - // "Open" a connection to an actor on the current thread. - // - // Returns true if the transport layer was successfully connected, - // i.e., mChannelState == ChannelConnected. - // - // Same-thread channels may not perform synchronous or blocking message - // sends, to avoid deadlocks. - bool OpenOnSameThread(MessageChannel* aTargetChan, Side aSide); - // Close the underlying transport channel. void Close(); @@ -573,20 +564,11 @@ private: "not on worker thread!"); } - // The "link" thread is either the I/O thread (ProcessLink), the other - // actor's work thread (ThreadLink), or the worker thread (same-thread - // channels). + // The "link" thread is either the I/O thread (ProcessLink) or the + // other actor's work thread (ThreadLink). In either case, it is + // NOT our worker thread. void AssertLinkThread() const { - if (mIsSameThreadChannel) { - // If we're a same-thread channel, we have to be on our worker - // thread. - AssertWorkerThread(); - return; - } - - // If we aren't a same-thread channel, our "link" thread is _not_ our - // worker thread! MOZ_ASSERT(mWorkerThread, "Channel hasn't been opened yet"); MOZ_RELEASE_ASSERT(mWorkerThread != GetCurrentVirtualThread(), "on worker thread but should not be!"); @@ -879,10 +861,6 @@ private: std::vector> mPostponedSends; bool mBuildIDsConfirmedMatch; - - // If this is true, both ends of this message channel have event targets - // on the same thread. - bool mIsSameThreadChannel; }; void diff --git a/ipc/glue/PInProcess.ipdl b/ipc/glue/PInProcess.ipdl deleted file mode 100644 index 9121d10e5964..000000000000 --- a/ipc/glue/PInProcess.ipdl +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 8 -*- */ -/* vim: set sw=2 ts=8 et tw=80 ft=cpp : */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -include protocol PWindowGlobal; - -include DOMTypes; - -namespace mozilla { -namespace ipc { - -/** - * PInProcess is intended for use as an alternative actor manager to PContent - * for async actors which want to be used uniformly in both Content->Chrome and - * Chrome->Chrome circumstances. - * - * `mozilla::ipc::InProcess{Parent, Child}::Singleton()` should be used to get - * an instance of this actor. - */ -async protocol PInProcess -{ - manages PWindowGlobal; - -parent: - /** - * Construct a new WindowGlobal actor for a window global in the given - * BrowsingContext and with the given principal. - */ - async PWindowGlobal(WindowGlobalInit init); -}; - -} // namespace ipc -} // namespace mozilla diff --git a/ipc/glue/ProtocolUtils.cpp b/ipc/glue/ProtocolUtils.cpp index 729e16cb7491..ad1d2ba3b7bc 100644 --- a/ipc/glue/ProtocolUtils.cpp +++ b/ipc/glue/ProtocolUtils.cpp @@ -781,13 +781,6 @@ IToplevelProtocol::OpenWithAsyncPid(mozilla::ipc::Transport* aTransport, return GetIPCChannel()->Open(aTransport, aThread, aSide); } -bool -IToplevelProtocol::OpenOnSameThread(MessageChannel* aChannel, Side aSide) -{ - SetOtherProcessId(base::GetCurrentProcId()); - return GetIPCChannel()->OpenOnSameThread(aChannel, aSide); -} - void IToplevelProtocol::Close() { diff --git a/ipc/glue/ProtocolUtils.h b/ipc/glue/ProtocolUtils.h index 66d1bedd77b8..32e42abc7ed4 100644 --- a/ipc/glue/ProtocolUtils.h +++ b/ipc/glue/ProtocolUtils.h @@ -514,15 +514,6 @@ public: MessageLoop* aThread = nullptr, mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide); - // Open a toplevel actor such that both ends of the actor's channel are on - // the same thread. This method should be called on the thread to perform - // the link. - // - // WARNING: Attempting to send a sync or intr message on the same thread - // will crash. - bool OpenOnSameThread(MessageChannel* aChannel, - mozilla::ipc::Side aSide = mozilla::ipc::UnknownSide); - void Close(); void SetReplyTimeoutMs(int32_t aTimeoutMs); diff --git a/ipc/glue/moz.build b/ipc/glue/moz.build index f53dedb93a4e..1851b3b2a03b 100644 --- a/ipc/glue/moz.build +++ b/ipc/glue/moz.build @@ -27,8 +27,6 @@ EXPORTS.mozilla.ipc += [ 'FileDescriptorSetParent.h', 'FileDescriptorUtils.h', 'GeckoChildProcessHost.h', - 'InProcessChild.h', - 'InProcessParent.h', 'InputStreamUtils.h', 'IOThreadChild.h', 'IPCStreamAlloc.h', @@ -149,9 +147,6 @@ UNIFIED_SOURCES += [ 'CrashReporterMetadataShmem.cpp', 'FileDescriptor.cpp', 'FileDescriptorUtils.cpp', - 'InProcessChild.cpp', - 'InProcessImpl.cpp', - 'InProcessParent.cpp', 'InputStreamUtils.cpp', 'IPCMessageUtils.cpp', 'IPCStreamChild.cpp', @@ -213,7 +208,6 @@ IPDL_SOURCES = [ 'PBackgroundTest.ipdl', 'PChildToParentStream.ipdl', 'PFileDescriptorSet.ipdl', - 'PInProcess.ipdl', 'PParentToChildStream.ipdl', 'ProtocolTypes.ipdlh', 'URIParams.ipdlh', diff --git a/python/mozbuild/mozbuild/backend/common.py b/python/mozbuild/mozbuild/backend/common.py index 68fd162ec3ca..8b696f03ed7b 100644 --- a/python/mozbuild/mozbuild/backend/common.py +++ b/python/mozbuild/mozbuild/backend/common.py @@ -367,9 +367,8 @@ class CommonBackend(BuildBackend): if poison_windows_h: includeTemplate += ( '\n' - '#if defined(_WINDOWS_) && !defined(MOZ_WRAPPED_WINDOWS_H)\n' - '#pragma message("wrapper failure reason: " MOZ_WINDOWS_WRAPPER_DISABLED_REASON)\n' - '#error "%(cppfile)s included unwrapped windows.h"\n' + '#ifdef _WINDOWS_\n' + '#error "%(cppfile)s included windows.h"\n' "#endif") includeTemplate += ( '\n'