Bug 664130 - Rename GetHittestMask to GetHitTestFlags to avoid confusion about masking. r=longsonr.
authorJonathan Watt <jwatt@jwatt.org>
Fri, 08 Jul 2011 14:20:14 +0100
changeset 73368 f53268a84b23ca67cb6cc5c8c867f0f2c582e37c
parent 73367 0bd82b867cf012b05c1c283341f1ceea2dbe0ebc
child 73369 5a3a13adf235ab0a661cd9525fcd937904b6b459
push id235
push userbzbarsky@mozilla.com
push dateTue, 27 Sep 2011 17:13:04 +0000
treeherdermozilla-beta@2d1e082d176a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslongsonr
bugs664130
milestone8.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 664130 - Rename GetHittestMask to GetHitTestFlags to avoid confusion about masking. r=longsonr.
layout/svg/base/src/nsSVGGeometryFrame.cpp
layout/svg/base/src/nsSVGGeometryFrame.h
layout/svg/base/src/nsSVGGlyphFrame.cpp
layout/svg/base/src/nsSVGImageFrame.cpp
layout/svg/base/src/nsSVGPathGeometryFrame.cpp
--- a/layout/svg/base/src/nsSVGGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGGeometryFrame.cpp
@@ -333,65 +333,65 @@ nsSVGGeometryFrame::SetupCairoStroke(gfx
   // See http://www.w3.org/TR/SVG11/coords.html#ObjectBoundingBox
   SetupFallbackOrPaintColor(aContext, GetStyleContext(),
                             &nsStyleSVG::mStroke, opacity);
 
   return PR_TRUE;
 }
 
 PRUint16
-nsSVGGeometryFrame::GetHittestMask()
+nsSVGGeometryFrame::GetHitTestFlags()
 {
-  PRUint16 mask = 0;
+  PRUint16 flags = 0;
 
   switch(GetStyleVisibility()->mPointerEvents) {
   case NS_STYLE_POINTER_EVENTS_NONE:
     break;
   case NS_STYLE_POINTER_EVENTS_AUTO:
   case NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED:
     if (GetStyleVisibility()->IsVisible()) {
       if (GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None)
-        mask |= HITTEST_MASK_FILL;
+        flags |= SVG_HIT_TEST_FILL;
       if (GetStyleSVG()->mStroke.mType != eStyleSVGPaintType_None)
-        mask |= HITTEST_MASK_STROKE;
+        flags |= SVG_HIT_TEST_STROKE;
       if (GetStyleSVG()->mStrokeOpacity > 0)
-        mask |= HITTEST_MASK_CHECK_MRECT;
+        flags |= SVG_HIT_TEST_CHECK_MRECT;
     }
     break;
   case NS_STYLE_POINTER_EVENTS_VISIBLEFILL:
     if (GetStyleVisibility()->IsVisible()) {
-      mask |= HITTEST_MASK_FILL;
+      flags |= SVG_HIT_TEST_FILL;
     }
     break;
   case NS_STYLE_POINTER_EVENTS_VISIBLESTROKE:
     if (GetStyleVisibility()->IsVisible()) {
-      mask |= HITTEST_MASK_STROKE;
+      flags |= SVG_HIT_TEST_STROKE;
     }
     break;
   case NS_STYLE_POINTER_EVENTS_VISIBLE:
     if (GetStyleVisibility()->IsVisible()) {
-      mask |= HITTEST_MASK_FILL | HITTEST_MASK_STROKE;
+      flags |= SVG_HIT_TEST_FILL | SVG_HIT_TEST_STROKE;
     }
     break;
   case NS_STYLE_POINTER_EVENTS_PAINTED:
     if (GetStyleSVG()->mFill.mType != eStyleSVGPaintType_None)
-      mask |= HITTEST_MASK_FILL;
+      flags |= SVG_HIT_TEST_FILL;
     if (GetStyleSVG()->mStroke.mType != eStyleSVGPaintType_None)
-      mask |= HITTEST_MASK_STROKE;
+      flags |= SVG_HIT_TEST_STROKE;
     if (GetStyleSVG()->mStrokeOpacity)
-      mask |= HITTEST_MASK_CHECK_MRECT;
+      flags |= SVG_HIT_TEST_CHECK_MRECT;
     break;
   case NS_STYLE_POINTER_EVENTS_FILL:
-    mask |= HITTEST_MASK_FILL;
+    flags |= SVG_HIT_TEST_FILL;
     break;
   case NS_STYLE_POINTER_EVENTS_STROKE:
-    mask |= HITTEST_MASK_STROKE;
+    flags |= SVG_HIT_TEST_STROKE;
     break;
   case NS_STYLE_POINTER_EVENTS_ALL:
-    mask |= HITTEST_MASK_FILL | HITTEST_MASK_STROKE;
+    flags |= SVG_HIT_TEST_FILL | SVG_HIT_TEST_STROKE;
     break;
   default:
     NS_ERROR("not reached");
     break;
   }
 
-  return mask;
+  return flags;
 }
--- a/layout/svg/base/src/nsSVGGeometryFrame.h
+++ b/layout/svg/base/src/nsSVGGeometryFrame.h
@@ -41,19 +41,19 @@
 #include "nsFrame.h"
 #include "gfxMatrix.h"
 
 class nsSVGPaintServerFrame;
 class gfxContext;
 
 typedef nsFrame nsSVGGeometryFrameBase;
 
-#define HITTEST_MASK_FILL        0x01
-#define HITTEST_MASK_STROKE      0x02
-#define HITTEST_MASK_CHECK_MRECT 0x04
+#define SVG_HIT_TEST_FILL        0x01
+#define SVG_HIT_TEST_STROKE      0x02
+#define SVG_HIT_TEST_CHECK_MRECT 0x04
 
 /* nsSVGGeometryFrame is a base class for SVG objects that directly
  * have geometry (circle, ellipse, line, polyline, polygon, path, and
  * glyph frames).  It knows how to convert the style information into
  * cairo context information and stores the fill/stroke paint
  * servers. */
 
 class nsSVGGeometryFrame : public nsSVGGeometryFrameBase
@@ -101,17 +101,24 @@ public:
    * Set up a cairo context for stroking a path
    * @return PR_FALSE to skip rendering
    */
   PRBool SetupCairoStroke(gfxContext *aContext);
 
 protected:
   nsSVGPaintServerFrame *GetPaintServer(const nsStyleSVGPaint *aPaint,
                                         const FramePropertyDescriptor *aProperty);
-  virtual PRUint16 GetHittestMask();
+
+  /**
+   * This function returns a set of bit flags indicating which parts of the
+   * element (fill, stroke, bounds) should intercept pointer events. It takes
+   * into account the type of element and the value of the 'pointer-events'
+   * property on the element.
+   */
+  virtual PRUint16 GetHitTestFlags();
 
 private:
   nsresult GetStrokeDashArray(double **arr, PRUint32 *count);
   float GetStrokeDashoffset();
 
   /**
    * Returns the given 'fill-opacity' or 'stroke-opacity' value multiplied by
    * the value of the 'opacity' property if it's possible to avoid the expense
--- a/layout/svg/base/src/nsSVGGlyphFrame.cpp
+++ b/layout/svg/base/src/nsSVGGlyphFrame.cpp
@@ -410,50 +410,50 @@ nsSVGGlyphFrame::PaintSVG(nsSVGRenderSta
   gfx->Restore();
 
   return NS_OK;
 }
 
 NS_IMETHODIMP_(nsIFrame*)
 nsSVGGlyphFrame::GetFrameForPoint(const nsPoint &aPoint)
 {
-  PRUint16 mask = GetHittestMask();
-  if (!mask) {
+  PRUint16 hitTestFlags = GetHitTestFlags();
+  if (!hitTestFlags) {
     return nsnull;
   }
 
   nsRefPtr<gfxContext> context = MakeTmpCtx();
   SetupGlobalTransform(context);
   CharacterIterator iter(this, PR_TRUE);
   iter.SetInitialMatrix(context);
 
   // The SVG 1.1 spec says that text is hit tested against the character cells
   // of the text, not the fill and stroke. See the section starting "For text
   // elements..." here:
   //
   //   http://www.w3.org/TR/SVG11/interact.html#PointerEventsProperty
   //
-  // Currently we just test the character cells if GetHittestMask says we're
+  // Currently we just test the character cells if GetHitTestFlags says we're
   // supposed to be testing either the fill OR the stroke:
 
   PRInt32 i;
   while ((i = iter.NextCluster()) >= 0) {
     gfxTextRun::Metrics metrics =
     mTextRun->MeasureText(i, iter.ClusterLength(),
                           gfxFont::LOOSE_INK_EXTENTS, nsnull, nsnull);
     iter.SetupForMetrics(context);
     context->Rectangle(metrics.mBoundingBox);
   }
 
   gfxPoint userSpacePoint =
     context->DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
                                    PresContext()->AppUnitsToGfxUnits(aPoint.y)));
 
   PRBool isHit = PR_FALSE;
-  if (mask & HITTEST_MASK_FILL || mask & HITTEST_MASK_STROKE) {
+  if (hitTestFlags & SVG_HIT_TEST_FILL || hitTestFlags & SVG_HIT_TEST_STROKE) {
     isHit = context->PointInFill(userSpacePoint);
   }
 
   // If isHit is false, we may also want to fill and stroke the text to check
   // whether the pointer is over an area of fill or stroke that lies outside
   // the character cells. (With a thick stroke, or with fonts like Zapfino, such
   // areas may be very significant.) This is what Opera appears to do, but
   // currently we do not.
--- a/layout/svg/base/src/nsSVGImageFrame.cpp
+++ b/layout/svg/base/src/nsSVGImageFrame.cpp
@@ -86,17 +86,17 @@ public:
   NS_DECL_FRAMEARENA_HELPERS
 
   // nsISVGChildFrame interface:
   NS_IMETHOD PaintSVG(nsSVGRenderState *aContext, const nsIntRect *aDirtyRect);
   NS_IMETHOD_(nsIFrame*) GetFrameForPoint(const nsPoint &aPoint);
 
   // nsSVGPathGeometryFrame methods:
   NS_IMETHOD UpdateCoveredRegion();
-  virtual PRUint16 GetHittestMask();
+  virtual PRUint16 GetHitTestFlags();
 
   // nsIFrame interface:
   NS_IMETHOD  AttributeChanged(PRInt32         aNameSpaceID,
                                nsIAtom*        aAttribute,
                                PRInt32         aModType);
   NS_IMETHOD Init(nsIContent*      aContent,
                   nsIFrame*        aParent,
                   nsIFrame*        aPrevInFlow);
@@ -455,52 +455,52 @@ nsSVGImageFrame::UpdateCoveredRegion()
   if (!extent.IsEmpty()) {
     mRect = nsSVGUtils::ToAppPixelRect(PresContext(), extent);
   }
 
   return NS_OK;
 }
 
 PRUint16
-nsSVGImageFrame::GetHittestMask()
+nsSVGImageFrame::GetHitTestFlags()
 {
-  PRUint16 mask = 0;
+  PRUint16 flags = 0;
 
   switch(GetStyleVisibility()->mPointerEvents) {
     case NS_STYLE_POINTER_EVENTS_NONE:
       break;
     case NS_STYLE_POINTER_EVENTS_VISIBLEPAINTED:
     case NS_STYLE_POINTER_EVENTS_AUTO:
       if (GetStyleVisibility()->IsVisible()) {
         /* XXX: should check pixel transparency */
-        mask |= HITTEST_MASK_FILL;
+        flags |= SVG_HIT_TEST_FILL;
       }
       break;
     case NS_STYLE_POINTER_EVENTS_VISIBLEFILL:
     case NS_STYLE_POINTER_EVENTS_VISIBLESTROKE:
     case NS_STYLE_POINTER_EVENTS_VISIBLE:
       if (GetStyleVisibility()->IsVisible()) {
-        mask |= HITTEST_MASK_FILL;
+        flags |= SVG_HIT_TEST_FILL;
       }
       break;
     case NS_STYLE_POINTER_EVENTS_PAINTED:
       /* XXX: should check pixel transparency */
-      mask |= HITTEST_MASK_FILL;
+      flags |= SVG_HIT_TEST_FILL;
       break;
     case NS_STYLE_POINTER_EVENTS_FILL:
     case NS_STYLE_POINTER_EVENTS_STROKE:
     case NS_STYLE_POINTER_EVENTS_ALL:
-      mask |= HITTEST_MASK_FILL;
+      flags |= SVG_HIT_TEST_FILL;
       break;
     default:
       NS_ERROR("not reached");
       break;
   }
 
-  return mask;
+  return flags;
 }
 
 //----------------------------------------------------------------------
 // nsSVGImageListener implementation
 
 NS_IMPL_ISUPPORTS2(nsSVGImageListener,
                    imgIDecoderObserver,
                    imgIContainerObserver)
--- a/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
+++ b/layout/svg/base/src/nsSVGPathGeometryFrame.cpp
@@ -148,24 +148,24 @@ nsSVGPathGeometryFrame::PaintSVG(nsSVGRe
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP_(nsIFrame*)
 nsSVGPathGeometryFrame::GetFrameForPoint(const nsPoint &aPoint)
 {
-  PRUint16 fillRule, mask;
+  PRUint16 fillRule, hitTestFlags;
   if (GetStateBits() & NS_STATE_SVG_CLIPPATH_CHILD) {
-    mask = HITTEST_MASK_FILL;
+    hitTestFlags = SVG_HIT_TEST_FILL;
     fillRule = GetClipRule();
   } else {
-    mask = GetHittestMask();
-    if (!mask || ((mask & HITTEST_MASK_CHECK_MRECT) &&
-                  !mRect.Contains(aPoint)))
+    hitTestFlags = GetHitTestFlags();
+    if (!hitTestFlags || ((hitTestFlags & SVG_HIT_TEST_CHECK_MRECT) &&
+                          !mRect.Contains(aPoint)))
       return nsnull;
     fillRule = GetStyleSVG()->mFillRule;
   }
 
   PRBool isHit = PR_FALSE;
 
   nsRefPtr<gfxContext> context =
     new gfxContext(gfxPlatform::GetPlatform()->ScreenReferenceSurface());
@@ -175,19 +175,19 @@ nsSVGPathGeometryFrame::GetFrameForPoint
     context->DeviceToUser(gfxPoint(PresContext()->AppUnitsToGfxUnits(aPoint.x),
                                    PresContext()->AppUnitsToGfxUnits(aPoint.y)));
 
   if (fillRule == NS_STYLE_FILL_RULE_EVENODD)
     context->SetFillRule(gfxContext::FILL_RULE_EVEN_ODD);
   else
     context->SetFillRule(gfxContext::FILL_RULE_WINDING);
 
-  if (mask & HITTEST_MASK_FILL)
+  if (hitTestFlags & SVG_HIT_TEST_FILL)
     isHit = context->PointInFill(userSpacePoint);
-  if (!isHit && (mask & HITTEST_MASK_STROKE)) {
+  if (!isHit && (hitTestFlags & SVG_HIT_TEST_STROKE)) {
     SetupCairoStrokeHitGeometry(context);
     isHit = context->PointInStroke(userSpacePoint);
   }
 
   if (isHit && nsSVGUtils::HitTestClip(this, aPoint))
     return this;
 
   return nsnull;