Bug 1111995 - Clip buttons to their border area for event hit testing. r=roc
☠☠ backed out by 1a8b874719fb ☠ ☠
authorMats Palmgren <mats@mozilla.com>
Fri, 19 Dec 2014 18:01:13 +0000
changeset 220563 bac36f6e728f4057400fc04ee655a1690924ae8e
parent 220562 61ca68e746d88b97f635e7a50ba6a5e6d176e699
child 220564 5f7211d4190d3fe89be172a3dad357cddf6b22f1
push id53142
push usermpalmgren@mozilla.com
push dateFri, 19 Dec 2014 18:01:25 +0000
treeherdermozilla-inbound@5f7211d4190d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1111995
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1111995 - Clip buttons to their border area for event hit testing. r=roc
layout/forms/nsHTMLButtonControlFrame.cpp
--- a/layout/forms/nsHTMLButtonControlFrame.cpp
+++ b/layout/forms/nsHTMLButtonControlFrame.cpp
@@ -91,25 +91,36 @@ nsHTMLButtonControlFrame::HandleEvent(ns
 }
 
 
 void
 nsHTMLButtonControlFrame::BuildDisplayList(nsDisplayListBuilder*   aBuilder,
                                            const nsRect&           aDirtyRect,
                                            const nsDisplayListSet& aLists)
 {
+  // Clip to our border area for event hit testing.
+  Maybe<DisplayListClipState::AutoSaveRestore> eventClipState;
+  const bool isForEventDelivery = aBuilder->IsForEventDelivery();
+  if (isForEventDelivery) {
+    eventClipState.emplace(aBuilder);
+    nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
+    nscoord radii[8];
+    bool hasRadii = GetBorderRadii(radii);
+    eventClipState->ClipContainingBlockDescendants(rect, hasRadii ? radii : nullptr);
+  }
+
   nsDisplayList onTop;
   if (IsVisibleForPainting(aBuilder)) {
     mRenderer.DisplayButton(aBuilder, aLists.BorderBackground(), &onTop);
   }
 
   nsDisplayListCollection set;
 
   // Do not allow the child subtree to receive events.
-  if (!aBuilder->IsForEventDelivery()) {
+  if (!isForEventDelivery) {
     DisplayListClipState::AutoSaveRestore clipState(aBuilder);
 
     if (IsInput() || StyleDisplay()->mOverflowX != NS_STYLE_OVERFLOW_VISIBLE) {
       nsMargin border = StyleBorder()->GetComputedBorder();
       nsRect rect(aBuilder->ToReferenceFrame(this), GetSize());
       rect.Deflate(border);
       nscoord radii[8];
       bool hasRadii = GetPaddingBoxBorderRadii(radii);