From 5cad2c420010881b28a5fd85818cf9e61ba03fb6 Mon Sep 17 00:00:00 2001 From: Rik Cabanier Date: Fri, 21 Feb 2014 08:35:14 -0500 Subject: [PATCH] Bug 966591 - Part 1: Put very basic hit region interface in + add runtime flag. r=roc --- content/canvas/src/CanvasRenderingContext2D.cpp | 7 +++++++ content/canvas/src/CanvasRenderingContext2D.h | 3 +++ dom/webidl/CanvasRenderingContext2D.webidl | 10 +++++++--- modules/libpref/src/init/all.js | 1 + 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/content/canvas/src/CanvasRenderingContext2D.cpp b/content/canvas/src/CanvasRenderingContext2D.cpp index 82c8dc52c56f..36c98cf66fc8 100755 --- a/content/canvas/src/CanvasRenderingContext2D.cpp +++ b/content/canvas/src/CanvasRenderingContext2D.cpp @@ -2355,6 +2355,13 @@ CanvasRenderingContext2D::MeasureText(const nsAString& rawText, return new TextMetrics(width); } +void CanvasRenderingContext2D::AddHitRegion(const HitRegionOptions& ) +{} + +void CanvasRenderingContext2D::RemoveHitRegion(const nsAString&) +{} + + /** * Used for nsBidiPresUtils::ProcessText */ diff --git a/content/canvas/src/CanvasRenderingContext2D.h b/content/canvas/src/CanvasRenderingContext2D.h index f39b1658acbf..263058bba7be 100644 --- a/content/canvas/src/CanvasRenderingContext2D.h +++ b/content/canvas/src/CanvasRenderingContext2D.h @@ -186,6 +186,9 @@ public: TextMetrics* MeasureText(const nsAString& rawText, mozilla::ErrorResult& error); + void AddHitRegion(const HitRegionOptions& options); + void RemoveHitRegion(const nsAString& id); + void DrawImage(const HTMLImageOrCanvasOrVideoElement& image, double dx, double dy, mozilla::ErrorResult& error) { diff --git a/dom/webidl/CanvasRenderingContext2D.webidl b/dom/webidl/CanvasRenderingContext2D.webidl index f3c2cf514833..565f34477a73 100644 --- a/dom/webidl/CanvasRenderingContext2D.webidl +++ b/dom/webidl/CanvasRenderingContext2D.webidl @@ -11,8 +11,6 @@ * and create derivative works of this document. */ -interface HitRegionOptions; - enum CanvasWindingRule { "nonzero", "evenodd" }; dictionary ContextAttributes2D { @@ -20,6 +18,11 @@ dictionary ContextAttributes2D { boolean willReadFrequently = false; }; +dictionary HitRegionOptions { + DOMString id = ""; + Element? control = null; +}; + interface CanvasRenderingContext2D { // back-reference to the canvas. Might be null if we're not @@ -113,7 +116,8 @@ interface CanvasRenderingContext2D { void drawImage((HTMLImageElement or HTMLCanvasElement or HTMLVideoElement) image, double sx, double sy, double sw, double sh, double dx, double dy, double dw, double dh); // hit regions -// NOT IMPLEMENTED void addHitRegion(HitRegionOptions options); + [Pref="canvas.hitregions.enabled"] void addHitRegion(optional HitRegionOptions options); + [Pref="canvas.hitregions.enabled"] void removeHitRegion(DOMString id); // pixel manipulation [NewObject, Throws] diff --git a/modules/libpref/src/init/all.js b/modules/libpref/src/init/all.js index c2a51266277a..3e5e0a7c6bcc 100644 --- a/modules/libpref/src/init/all.js +++ b/modules/libpref/src/init/all.js @@ -432,6 +432,7 @@ pref("accessibility.tabfocus_applies_to_xul", true); // provide ability to turn on support for canvas focus rings pref("canvas.focusring.enabled", false); pref("canvas.customfocusring.enabled", false); +pref("canvas.hitregions.enabled", false); // We want the ability to forcibly disable platform a11y, because // some non-a11y-related components attempt to bring it up. See bug