Skip to content

Commit

Permalink
Bug 1412179 - Implement non-empty legends for wr r=jrmuizel
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D4963

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Gankra committed Sep 12, 2018
1 parent 8f3f22d commit 7f98514
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions layout/forms/nsFieldSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,27 +164,42 @@ nsDisplayFieldSetBorder::CreateWebRenderCommands(mozilla::wr::DisplayListBuilder
auto frame = static_cast<nsFieldSetFrame*>(mFrame);
auto offset = ToReferenceFrame();
nsRect rect;
bool pushedClip = false;

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;
auto appUnitsPerDevPixel = frame->PresContext()->AppUnitsPerDevPixel();
auto layoutRect = wr::ToLayoutRect(LayoutDeviceRect::FromAppUnits(rect, appUnitsPerDevPixel));

wr::ComplexClipRegion region;
region.rect = wr::ToLayoutRect(LayoutDeviceRect::FromAppUnits(legendRect, appUnitsPerDevPixel));
region.mode = wr::ClipMode::ClipOut;
nsTArray<mozilla::wr::ComplexClipRegion> array{region};

wr::WrClipId clip = aBuilder.DefineClip(Nothing(), layoutRect, &array, nullptr);
aBuilder.PushClip(clip);
pushedClip = true;
}

} else {
rect = nsRect(offset, frame->GetRect().Size());
}

return nsCSSRendering::CreateWebRenderCommandsForBorder(this,
mFrame,
rect,
aBuilder,
aResources,
aSc,
aManager,
aDisplayListBuilder);
bool result = nsCSSRendering::CreateWebRenderCommandsForBorder(this,
mFrame,
rect,
aBuilder,
aResources,
aSc,
aManager,
aDisplayListBuilder);
if (pushedClip) {
aBuilder.PopClip();
}
return result;
};

void
Expand Down

0 comments on commit 7f98514

Please sign in to comment.