Skip to content

Commit

Permalink
Bug 1412179 - implement fieldsets with nonempty legends. r=kats
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D27350

--HG--
extra : moz-landing-system : lando
  • Loading branch information
Gankra committed Apr 15, 2019
1 parent 99e4403 commit b4a27bb
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 8 deletions.
8 changes: 8 additions & 0 deletions gfx/webrender_bindings/WebRenderAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,14 @@ class MOZ_RAII SpaceAndClipChainHelper final {
aBuilder.mCurrentSpaceAndClipChain.space = aSpatialId;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}
SpaceAndClipChainHelper(DisplayListBuilder& aBuilder,
wr::WrClipChainId aClipChainId
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
: mBuilder(aBuilder),
mOldSpaceAndClipChain(aBuilder.mCurrentSpaceAndClipChain) {
aBuilder.mCurrentSpaceAndClipChain.clip_chain = aClipChainId.id;
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
}

~SpaceAndClipChainHelper() {
mBuilder.mCurrentSpaceAndClipChain = mOldSpaceAndClipChain;
Expand Down
27 changes: 24 additions & 3 deletions layout/forms/nsFieldSetFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,36 @@ bool nsDisplayFieldSetBorder::CreateWebRenderCommands(
auto frame = static_cast<nsFieldSetFrame*>(mFrame);
auto offset = ToReferenceFrame();
nsRect rect;
Maybe<wr::SpaceAndClipChainHelper> clipOut;

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;

// Make sure we clip all of the border in case the legend is smaller.
nscoord borderTopWidth = frame->GetUsedBorder().top;
if (legendRect.height < borderTopWidth) {
legendRect.height = borderTopWidth;
legendRect.y = offset.y;
}

if (!legendRect.IsEmpty()) {
return false;
// We need to clip out the part of the border where the legend would go
auto appUnitsPerDevPixel = frame->PresContext()->AppUnitsPerDevPixel();
auto layoutRect = wr::ToRoundedLayoutRect(
LayoutDeviceRect::FromAppUnits(rect, appUnitsPerDevPixel));

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

auto clip = aBuilder.DefineClip(Nothing(), layoutRect, &array, nullptr);
auto clipChain = aBuilder.DefineClipChain({clip});
clipOut.emplace(aBuilder, clipChain);
}
} else {
rect = nsRect(offset, frame->GetRect().Size());
Expand Down
2 changes: 1 addition & 1 deletion layout/reftests/box-shadow/reftest.list
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fuzzy(0-13,0-9445) fuzzy-if(d2d,0-13,0-10926) fuzzy-if(webrender,14-15,11263-132
== overflow-not-scrollable-2.html overflow-not-scrollable-2-ref.html
fuzzy-if(webrender,0-1,0-655) == 611574-1.html 611574-1-ref.html
fuzzy-if(webrender,0-4,0-144) == 611574-2.html 611574-2-ref.html
fuzzy-if(winWidget,0-5,0-30) fuzzy-if(skiaContent,0-16,0-10) fuzzy-if(webrender,20-34,82-84) == fieldset.html fieldset-ref.html # minor anti-aliasing problem on Windows
fuzzy-if(winWidget,0-5,0-30) fuzzy-if(skiaContent,0-16,0-10) == fieldset.html fieldset-ref.html # minor anti-aliasing problem on Windows
fuzzy-if(winWidget,0-5,0-30) fuzzy-if(skiaContent,0-16,0-10) fails-if(webrender) == fieldset-inset.html fieldset-inset-ref.html # minor anti-aliasing problem on Windows
== 1178575.html 1178575-ref.html
== 1178575-2.html 1178575-2-ref.html
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[legend-auto-margins.html]
fuzzy:
if webrender and (os == "linux"): legend-auto-margins-ref.html:maxDifference=8;totalPixels=8-10

0 comments on commit b4a27bb

Please sign in to comment.