diff --git a/layout/base/nsDisplayList.cpp b/layout/base/nsDisplayList.cpp index bebe5c9e3e57..725ee4b0b5bd 100644 --- a/layout/base/nsDisplayList.cpp +++ b/layout/base/nsDisplayList.cpp @@ -3436,12 +3436,16 @@ nsDisplayLayerEventRegions::AddFrame(nsDisplayListBuilder* aBuilder, // are the event targets for any regions viewport frames may cover. return; } + uint8_t pointerEvents = aFrame->StyleVisibility()->GetEffectivePointerEvents(aFrame); if (pointerEvents == NS_STYLE_POINTER_EVENTS_NONE) { return; } - if (!aFrame->StyleVisibility()->IsVisible()) { - return; + bool simpleRegions = aFrame->HasAnyStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS); + if (!simpleRegions) { + if (!aFrame->StyleVisibility()->IsVisible()) { + return; + } } // XXX handle other pointerEvents values for SVG @@ -3460,15 +3464,23 @@ nsDisplayLayerEventRegions::AddFrame(nsDisplayListBuilder* aBuilder, } borderBox += aBuilder->ToReferenceFrame(aFrame); + bool borderBoxHasRoundedCorners = false; + if (!simpleRegions) { + if (nsLayoutUtils::HasNonZeroCorner(aFrame->StyleBorder()->mBorderRadius)) { + borderBoxHasRoundedCorners = true; + } else { + aFrame->AddStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS); + } + } + const DisplayItemClip* clip = aBuilder->ClipState().GetCurrentCombinedClip(aBuilder); - bool borderBoxHasRoundedCorners = - nsLayoutUtils::HasNonZeroCorner(aFrame->StyleBorder()->mBorderRadius); if (clip) { borderBox = clip->ApplyNonRoundedIntersection(borderBox); if (clip->GetRoundedRectCount() > 0) { borderBoxHasRoundedCorners = true; } } + if (borderBoxHasRoundedCorners || (aFrame->GetStateBits() & NS_FRAME_SVG_LAYOUT)) { mMaybeHitRegion.Or(mMaybeHitRegion, borderBox); diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index f2cc01f400a2..9508837c8ec9 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -902,6 +902,8 @@ nsFrame::DidSetStyleContext(nsStyleContext* aOldStyleContext) if (StyleVisibility()->mDirection == NS_STYLE_DIRECTION_RTL) { PresContext()->SetBidiEnabled(); } + + RemoveStateBits(NS_FRAME_SIMPLE_EVENT_REGIONS); } // MSVC fails with link error "one or more multiply defined symbols found", diff --git a/layout/generic/nsFrameStateBits.h b/layout/generic/nsFrameStateBits.h index b22a3feaf2f2..0b73b453b6a9 100644 --- a/layout/generic/nsFrameStateBits.h +++ b/layout/generic/nsFrameStateBits.h @@ -180,6 +180,12 @@ FRAME_STATE_BIT(Generic, 33, NS_FRAME_DRAWING_AS_PAINTSERVER) // situation (possibly the frame itself). FRAME_STATE_BIT(Generic, 34, NS_FRAME_DESCENDANT_INTRINSIC_ISIZE_DEPENDS_ON_BSIZE) +// A flag that tells us we can take the common path with respect to style +// properties for this frame when building event regions. This flag is cleared +// when any styles are changed and then we recompute it on the next build +// of the event regions. +FRAME_STATE_BIT(Generic, 35, NS_FRAME_SIMPLE_EVENT_REGIONS) + // Frame is a display root and the retained layer tree needs to be updated // at the next paint via display list construction. // Only meaningful for display roots, so we don't really need a global state