Bug 1302470 Part 3: Fix the case where HTML buttons need to generate display item children when doing opaque hit tests.
MozReview-Commit-ID: HwDYsnMJkM8
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -3278,16 +3278,18 @@ nsLayoutUtils::GetFramesForArea(nsIFrame
if (rootScrollFrame) {
builder.SetIgnoreScrollFrame(rootScrollFrame);
}
}
if (aFlags & IGNORE_CROSS_DOC) {
builder.SetDescendIntoSubdocuments(false);
}
+ builder.SetHitTestShouldStopAtFirstOpaque(aFlags & ONLY_VISIBLE);
+
builder.EnterPresShell(aFrame);
builder.SetDirtyRect(aRect);
aFrame->BuildDisplayListForStackingContext(&builder, &list);
builder.LeavePresShell(aFrame, nullptr);
#ifdef MOZ_DUMP_PAINTING
if (gDumpEventList) {
@@ -3295,17 +3297,16 @@ nsLayoutUtils::GetFramesForArea(nsIFrame
std::stringstream ss;
nsFrame::PrintDisplayList(&builder, list, ss);
print_stderr(ss);
}
#endif
nsDisplayItem::HitTestState hitTestState;
- builder.SetHitTestShouldStopAtFirstOpaque(aFlags & ONLY_VISIBLE);
list.HitTest(&builder, aRect, &hitTestState, &aOutFrames);
list.DeleteAll(&builder);
builder.EndFrame();
return NS_OK;
}
// aScrollFrameAsScrollable must be non-nullptr and queryable to an nsIFrame
FrameMetrics
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -108,17 +108,17 @@ nsHTMLButtonControlFrame::BuildDisplayLi
nsDisplayList onTop;
if (IsVisibleForPainting(aBuilder)) {
mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
}
nsDisplayListCollection set;
// Do not allow the child subtree to receive events.
- if (!isForEventDelivery) {
+ if (!isForEventDelivery || aBuilder->HitTestShouldStopAtFirstOpaque()) {
DisplayListClipState::AutoSaveRestore clipState(aBuilder);
if (ShouldClipPaintingToBorderBox()) {
nsMargin border = StyleBorder()->GetComputedBorder();
nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
rect.Deflate(border);
nscoord radii[8];
bool hasRadii = GetPaddingBoxBorderRadii(radii);