Bug 1407753 - Port nsFieldSetFrame to webrender. r?jrmuizel
Falls back if a legend is present, as this is blocked on upstream
webrender exposing ClipMode.
MozReview-Commit-ID: At8kX4vQn3X
--- a/layout/forms/nsFieldSetFrame.cpp
+++ b/layout/forms/nsFieldSetFrame.cpp
@@ -91,16 +91,21 @@ public:
}
#endif
virtual void Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx) override;
virtual nsDisplayItemGeometry* AllocateGeometry(nsDisplayListBuilder* aBuilder) override;
virtual void ComputeInvalidationRegion(nsDisplayListBuilder* aBuilder,
const nsDisplayItemGeometry* aGeometry,
nsRegion *aInvalidRegion) const override;
+ bool CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+ mozilla::wr::IpcResourceUpdateQueue& aResources,
+ const StackingContextHelper& aSc,
+ mozilla::layers::WebRenderLayerManager* aManager,
+ nsDisplayListBuilder* aDisplayListBuilder) override;
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder,
bool* aSnap) const override;
NS_DISPLAY_DECL_NAME("FieldSetBorder", TYPE_FIELDSET_BORDER_BACKGROUND)
};
void
nsDisplayFieldSetBorder::Paint(nsDisplayListBuilder* aBuilder,
gfxContext* aCtx)
@@ -142,16 +147,53 @@ nsDisplayFieldSetBorder::GetBounds(nsDis
// may have border-image-outset or other features that cause borders to extend
// outside the border rect. We could try to duplicate all the complexity
// nsDisplayBorder has here, but keeping things in sync would be a pain, and
// this code is not typically performance-sensitive.
*aSnap = false;
return Frame()->GetVisualOverflowRectRelativeToSelf() + ToReferenceFrame();
}
+bool
+nsDisplayFieldSetBorder::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder& aBuilder,
+ mozilla::wr::IpcResourceUpdateQueue& aResources,
+ const StackingContextHelper& aSc,
+ mozilla::layers::WebRenderLayerManager* aManager,
+ nsDisplayListBuilder* aDisplayListBuilder)
+{
+ if (!ShouldUseAdvancedLayer(aManager, gfxPrefs::LayersAllowBorderLayers)) {
+ return false;
+ }
+
+ auto frame = static_cast<nsFieldSetFrame*>(mFrame);
+ auto offset = ToReferenceFrame();
+ nsRect rect;
+
+ if (nsIFrame* legend = frame->GetLegend()) {
+ rect = frame->VisualBorderRectRelativeToSelf() + offset;
+
+ // Legends require a "negative" clip around the text, which WR doesn't support yet.
+ nsRect legendRect = legend->GetNormalRect() + offset;
+ if (!legendRect.IsEmpty()) {
+ return false;
+ }
+ } else {
+ rect = nsRect(offset, frame->GetRect().Size());
+ }
+
+ return nsCSSRendering::CreateWebRenderCommandsForBorder(this,
+ mFrame,
+ rect,
+ aBuilder,
+ aResources,
+ aSc,
+ aManager,
+ aDisplayListBuilder);
+};
+
void
nsFieldSetFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsDisplayListSet& aLists) {
// Paint our background and border in a special way.
// REVIEW: We don't really need to check frame emptiness here; if it's empty,
// the background/border display item won't do anything, and if it isn't empty,
// we need to paint the outline
if (!(GetStateBits() & NS_FRAME_IS_OVERFLOW_CONTAINER) &&