Backed out changeset 8517afe50156 (bug 540456) for reftest failures.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 09 Oct 2013 15:12:21 -0400
changeset 164086 541e79e84ce97fe041ab94a885d632c78f8f1d24
parent 164085 3eefb8a63b65e1a65d49dc59c528832059809b94
child 164087 aa986b6ce882b4d2fcd6e4d857cb619cffe480ea
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs540456
milestone27.0a1
backs out8517afe501565e937bb4addc39f460496274513f
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
Backed out changeset 8517afe50156 (bug 540456) for reftest failures. CLOSED TREE
content/canvas/src/CanvasRenderingContext2D.cpp
content/canvas/src/CanvasRenderingContext2D.h
content/canvas/test/reftest/drawCustomFocusRing-ref.html
content/canvas/test/reftest/drawCustomFocusRing.html
content/canvas/test/reftest/drawSystemFocusRing-ref.html
content/canvas/test/reftest/drawSystemFocusRing.html
content/canvas/test/reftest/reftest.list
content/canvas/test/test_canvas.html
dom/webidl/CanvasRenderingContext2D.webidl
modules/libpref/src/init/all.js
--- a/content/canvas/src/CanvasRenderingContext2D.cpp
+++ b/content/canvas/src/CanvasRenderingContext2D.cpp
@@ -33,17 +33,16 @@
 #include "nsReadableUtils.h"
 
 #include "nsColor.h"
 #include "nsGfxCIID.h"
 #include "nsIDocShell.h"
 #include "nsIDOMWindow.h"
 #include "nsPIDOMWindow.h"
 #include "nsDisplayList.h"
-#include "nsFocusManager.h"
 
 #include "nsTArray.h"
 
 #include "imgIEncoder.h"
 
 #include "gfxContext.h"
 #include "gfxASurface.h"
 #include "gfxImageSurface.h"
@@ -1724,100 +1723,16 @@ CanvasRenderingContext2D::Stroke()
 
   AdjustedTarget(this, bounds.IsEmpty() ? nullptr : &bounds)->
     Stroke(mPath, CanvasGeneralPattern().ForStyle(this, STYLE_STROKE, mTarget),
            strokeOptions, DrawOptions(state.globalAlpha, UsedOperation()));
 
   Redraw();
 }
 
-void CanvasRenderingContext2D::DrawSystemFocusRing(mozilla::dom::Element& aElement)
-{
-  EnsureUserSpacePath();
-
-  if (!mPath) {
-    return;
-  }
-
-  if(DrawCustomFocusRing(aElement)) {
-    Save();
-
-    // set state to conforming focus state
-    ContextState& state = CurrentState();
-    state.globalAlpha = 1.0;
-    state.shadowBlur = 0;
-    state.shadowOffset.x = 0;
-    state.shadowOffset.y = 0;
-    state.op = mozilla::gfx::OP_OVER;
-
-    state.lineCap = CAP_BUTT;
-    state.lineJoin = mozilla::gfx::JOIN_MITER_OR_BEVEL;
-    state.lineWidth = 1;
-    CurrentState().dash.Clear();
-
-    // color and style of the rings is the same as for image maps
-    // set the background focus color
-    CurrentState().SetColorStyle(STYLE_STROKE, NS_RGBA(255, 255, 255, 255));
-    // draw the focus ring
-    Stroke();
-
-    // set dashing for foreground
-    FallibleTArray<mozilla::gfx::Float>& dash = CurrentState().dash;
-    dash.AppendElement(1);
-    dash.AppendElement(1);
-
-    // set the foreground focus color
-    CurrentState().SetColorStyle(STYLE_STROKE, NS_RGBA(0,0,0, 255));
-    // draw the focus ring
-    Stroke();
-
-    Restore();
-  }
-}
-
-bool CanvasRenderingContext2D::DrawCustomFocusRing(mozilla::dom::Element& aElement)
-{
-  EnsureUserSpacePath();
-
-  HTMLCanvasElement* canvas = GetCanvas();
-
-  if (!canvas|| !nsContentUtils::ContentIsDescendantOf(&aElement, canvas)) {
-    return false;
-  }
-
-  nsIFocusManager* fm = nsFocusManager::GetFocusManager();
-  if (fm) {
-    // check that the element i focused
-    nsCOMPtr<nsIDOMElement> focusedElement;
-    fm->GetFocusedElement(getter_AddRefs(focusedElement));
-    if (SameCOMIdentity(aElement.AsDOMNode(), focusedElement)) {
-      // get the bounds of the current path
-      mgfx::Rect bounds;
-      bounds = mPath->GetBounds(mTarget->GetTransform());
-
-      // and set them as the accessible area
-      nsRect rect(canvas->ClientLeft() + bounds.x, canvas->ClientTop() + bounds.y,
-               bounds.width, bounds.height);
-      rect.x *= AppUnitsPerCSSPixel();
-      rect.y *= AppUnitsPerCSSPixel();
-      rect.width *= AppUnitsPerCSSPixel();
-      rect.height *= AppUnitsPerCSSPixel();
-
-      nsIFrame* frame = aElement.GetPrimaryFrame();
-      if(frame) {
-        frame->SetRect(rect);
-      }
-
-      return true;
-    }
-  }
-
-  return false;
-}
-
 void
 CanvasRenderingContext2D::Clip(const CanvasWindingRule& winding)
 {
   EnsureUserSpacePath(winding);
 
   if (!mPath) {
     return;
   }
--- a/content/canvas/src/CanvasRenderingContext2D.h
+++ b/content/canvas/src/CanvasRenderingContext2D.h
@@ -164,18 +164,16 @@ public:
 
   void SetShadowColor(const nsAString& shadowColor);
   void ClearRect(double x, double y, double w, double h);
   void FillRect(double x, double y, double w, double h);
   void StrokeRect(double x, double y, double w, double h);
   void BeginPath();
   void Fill(const CanvasWindingRule& winding);
   void Stroke();
-  void DrawSystemFocusRing(mozilla::dom::Element& element);
-  bool DrawCustomFocusRing(mozilla::dom::Element& element);
   void Clip(const CanvasWindingRule& winding);
   bool IsPointInPath(double x, double y, const CanvasWindingRule& winding);
   bool IsPointInStroke(double x, double y);
   void FillText(const nsAString& text, double x, double y,
                 const Optional<double>& maxWidth,
                 mozilla::ErrorResult& error);
   void StrokeText(const nsAString& text, double x, double y,
                   const Optional<double>& maxWidth,
deleted file mode 100644
--- a/content/canvas/test/reftest/drawCustomFocusRing-ref.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--docytpe html-->
-<html><head>
-<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-<meta charset="UTF-8">
-<script>
-window.onload=function(){
-var c=document.getElementById("myCanvas").getContext("2d");
-c.beginPath();
-c.strokeRect(10, 10, 200, 200);
-}
-</script>
-</head>
-<body>
-<canvas id="myCanvas" height="500" width="500" style="border:1px solid black">
-
-</canvas>
-
-</body></html>
deleted file mode 100644
--- a/content/canvas/test/reftest/drawCustomFocusRing.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!--docytpe html-->
-<html><head>
-<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-<meta charset="UTF-8">
-<script>
-window.onload=function(){
-var c=document.getElementById("myCanvas").getContext("2d");
-var in1=document.getElementById("in1");
-var in2=document.getElementById("in2");
-in1.focus();
-if(c.drawCustomFocusRing(in1)) {
-   c.beginPath();
-   c.strokeRect(10, 10, 200, 200);
-}
-if(c.drawCustomFocusRing(in2)) {
-   c.beginPath();
-   c.strokeRect(10, 220, 200, 200);
-}
-}
-</script>
-</head>
-<body>
-<canvas id="myCanvas" height="500" width="500" style="border:1px solid black">
-   <input id="in1" type="range" min="1" max="12">
-   <input id="in2" type="range" min="1" max="12">
-</canvas>
-
-</body></html>
deleted file mode 100644
--- a/content/canvas/test/reftest/drawSystemFocusRing-ref.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--docytpe html-->
-<html><head>
-<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-<meta charset="UTF-8">
-<script>
-window.onload=function(){
-var c=document.getElementById("myCanvas").getContext("2d");
-c.beginPath();
-c.mozDash = [1,1];
-c.strokeRect(10, 10, 200, 200);
-}
-</script>
-</head>
-<body>
-<canvas id="myCanvas" height="500" width="500" style="border:1px solid black">
-</canvas>
-
-</body></html>
deleted file mode 100644
--- a/content/canvas/test/reftest/drawSystemFocusRing.html
+++ /dev/null
@@ -1,26 +0,0 @@
-<!--docytpe html-->
-<html><head>
-<meta http-equiv="content-type" content="text/html; charset=UTF-8">
-<meta charset="UTF-8">
-<script>
-window.onload=function(){
-var c=document.getElementById("myCanvas").getContext("2d");
-var in1=document.getElementById("in1");
-var in2=document.getElementById("in2");
-in1.focus();
-c.beginPath();
-c.rect(10, 10, 200, 200);
-c.drawSystemFocusRing(in1);
-c.beginPath();
-c.rect(10, 220, 200, 200);
-c.drawSystemFocusRing(in2);
-}
-</script>
-</head>
-<body>
-<canvas id="myCanvas" height="500" width="500" style="border:1px solid black">
-   <input id="in1" type="range" min="1" max="12">
-   <input id="in2" type="range" min="1" max="12">
-</canvas>
-
-</body></html>
--- a/content/canvas/test/reftest/reftest.list
+++ b/content/canvas/test/reftest/reftest.list
@@ -183,12 +183,8 @@ skip-if(!winWidget) pref(webgl.prefer-na
 
 # Non-WebGL Reftests!
 
 # Do we correctly handle multiple clip paths?
 != clip-multiple-paths.html clip-multiple-paths-badref.html
 
 # Bug 815648
 == stroketext-shadow.html stroketext-shadow-ref.html
-
-# focus rings
-pref(canvas.focusring.enabled,true) == drawSystemFocusRing.html drawSystemFocusRing-ref.html
-pref(canvas.focusring.enabled,true) == drawCustomFocusRing.html drawCustomFocusRing-ref.html
--- a/content/canvas/test/test_canvas.html
+++ b/content/canvas/test/test_canvas.html
@@ -3,17 +3,16 @@
 <script src="/tests/SimpleTest/SimpleTest.js"></script>
 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
 <body>
 <script>
 
 SimpleTest.waitForExplicitFinish();
 const Cc = SpecialPowers.Cc;
 const Cr = SpecialPowers.Cr;
-SpecialPowers.setBoolPref("canvas.focusring.enabled", true);
 
 function IsD2DEnabled() {
     var enabled = false;
 
     try {
         enabled = Cc["@mozilla.org/gfx/info;1"].getService(SpecialPowers.Ci.nsIGfxInfo).D2DEnabled;
     } catch(e) {}
     
@@ -21484,76 +21483,16 @@ function test_getImageData_after_zero_ca
     var same = false;
     ok(imgdata.data.length === oldimgdata.data.length, "not the same length");
     for (var i = 0; i < imgdata.data.length; ++i)
         same = imgdata.data[i] === oldimgdata.data[i];
     ok(same, "changing dimensions broke canvas");
 }
 </script>
 
-<p>Canvas test: drawCustomFocusRing</p>
-<canvas id="c687" class="output" width="100" height="50">
-    <input id="button1" type="range" min="1" max="12"></input>
-    <input id="button2" type="range" min="1" max="12"></input>
-</canvas>
-<script type="text/javascript">
-function test_drawCustomFocusRing_canvas() {
-   var c = document.getElementById("c687");
-   var ctx = c.getContext("2d");
-   ctx.beginPath();
-   var b1 = document.getElementById('button1');
-   var b2 = document.getElementById('button2');
-   ok(!ctx.drawCustomFocusRing(b1), "button 1 is focused");
-   ok(!ctx.drawCustomFocusRing(b2), "button 2 is focused");
-   b1.focus();
-   ok(ctx.drawCustomFocusRing(b1), "button 1 should not be focused");
-}
-</script>
-
-<p>Canvas test: drawSystemFocusRing</p>
-<canvas id="c688" class="output" width="50" height="25">
-    <input id="button3" type="range" min="1" max="12"></input>
-    <input id="button4" type="range" min="1" max="12"></input>
-</canvas>
-<script type="text/javascript">
-function isEmptyCanvas(ctx, w, h) {
-  var imgdata = ctx.getImageData(0, 0, w, h);
-  for(var x = 0; x < w*h*4; x++)
-    if(imgdata.data[x] != 0)
-      return false;
-  return true;
-}
-
-function test_drawSystemFocusRing_canvas() {
-  var c = document.getElementById("c688");
-  var ctx = c.getContext("2d");
-  var b1 = document.getElementById('button3');
-  var b2 = document.getElementById('button4');
-
-  ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-  ctx.beginPath();
-  ctx.rect(10, 10, 30, 30);
-  ctx.drawSystemFocusRing(b1);
-  ok(isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height), "focus of button 1 is drawn");
-
-  ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-  ctx.beginPath();
-  ctx.rect(50, 10, 30, 30);
-  ctx.drawSystemFocusRing(b2);
-  ok(isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height), "focus of button 2 is drawn");
-
-  b1.focus();
-  ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
-  ctx.beginPath();
-  ctx.rect(10, 10, 30, 30);
-  ctx.drawSystemFocusRing(b1);
-  ok(!isEmptyCanvas(ctx, ctx.canvas.width, ctx.canvas.height) , "focus of button 1 is not drawn");
-}
-</script>
-
 <script>
 
 function asyncTestsDone() {
 	if (isDone_test_2d_drawImage_animated_apng &&
 		isDone_test_2d_drawImage_animated_gif) {
 		SimpleTest.finish();
 	} else {
 		setTimeout(asyncTestsDone, 500);
@@ -24840,40 +24779,27 @@ function runTests() {
   ok(false, "unexpected exception thrown in: test_getImageData_after_zero_canvas");
  }
  try {
   // run this test last since it replaces the getContext method
   test_type_replace();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_type_replace");
  }
- try {
-  test_drawCustomFocusRing_canvas();
- } catch(e) {
-  throw e;
-  ok(false, "unexpected exception thrown in: test_drawCustomFocusRing_canvas");
- }
-  try {
-  test_drawSystemFocusRing_canvas();
- } catch(e) {
-  throw e;
-  ok(false, "unexpected exception thrown in: test_drawSystemFocusRing_canvas");
- }
-
+ 
  //run the asynchronous tests
  try {
   test_2d_drawImage_animated_apng();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_drawImage_animated_apng");
  }
  try {
   test_2d_drawImage_animated_gif();
  } catch (e) {
   ok(false, "unexpected exception thrown in: test_2d_drawImage_animated_gif");
  }
  
  setTimeout(asyncTestsDone, 500);
- SpecialPowers.setBoolPref("canvas.focusring.enabled", false);
 }
 
 addLoadEvent(runTests);
 
 </script>
--- a/dom/webidl/CanvasRenderingContext2D.webidl
+++ b/dom/webidl/CanvasRenderingContext2D.webidl
@@ -73,20 +73,20 @@ interface CanvasRenderingContext2D {
   void strokeRect(double x, double y, double w, double h);
 
   // path API (see also CanvasPathMethods)
   void beginPath();
   void fill([TreatUndefinedAs=Missing] optional CanvasWindingRule winding = "nonzero");
 // NOT IMPLEMENTED  void fill(Path path);
   void stroke();
 // NOT IMPLEMENTED  void stroke(Path path);
-  [Pref="canvas.focusring.enabled"] void drawSystemFocusRing(Element element);
-// NOT IMPLEMENTED  void drawSystemFocusRing(Path path, HTMLElement element);
-  [Pref="canvas.focusring.enabled"] boolean drawCustomFocusRing(Element element);
-// NOT IMPLEMENTED  boolean drawCustomFocusRing(Path path, HTMLElement element);
+// NOT IMPLEMENTED  void drawSystemFocusRing(Element element);
+// NOT IMPLEMENTED  void drawSystemFocusRing(Path path, Element element);
+// NOT IMPLEMENTED  boolean drawCustomFocusRing(Element element);
+// NOT IMPLEMENTED  boolean drawCustomFocusRing(Path path, Element element);
 // NOT IMPLEMENTED  void scrollPathIntoView();
 // NOT IMPLEMENTED  void scrollPathIntoView(Path path);
   void clip([TreatUndefinedAs=Missing] optional CanvasWindingRule winding = "nonzero");
 // NOT IMPLEMENTED  void clip(Path path);
 // NOT IMPLEMENTED  void resetClip();
   boolean isPointInPath(unrestricted double x, unrestricted double y, [TreatUndefinedAs=Missing] optional CanvasWindingRule winding = "nonzero");
 // NOT IMPLEMENTED  boolean isPointInPath(Path path, unrestricted double x, unrestricted double y);
   boolean isPointInStroke(double x, double y);
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -408,19 +408,16 @@ pref("accessibility.tabfocus_applies_to_
 // unless this preference was set manually
 pref("ui.scrollToClick", 0);
 
 #else
 // Only on mac tabfocus is expected to handle UI widgets as well as web content
 pref("accessibility.tabfocus_applies_to_xul", true);
 #endif
 
-// provide ability to turn on support for canvas focus rings
-pref("canvas.focusring.enabled", false);
-
 // We want the ability to forcibly disable platform a11y, because
 // some non-a11y-related components attempt to bring it up.  See bug
 // 538530 for details about Windows; we have a pref here that allows it
 // to be disabled for performance and testing resons.
 // See bug 761589 for the crossplatform aspect.
 //
 // This pref is checked only once, and the browser needs a restart to
 // pick up any changes.