Bug 771551 - Add CSS Media Query for physical home buttons, r=heycam
authorMichael Wu <mwu@mozilla.com>
Wed, 05 Jun 2013 22:42:02 -0400
changeset 134224 3b44958f4b639f80f121c0748a5e3078618d57d3
parent 134223 d377d9d71261270e4b51036cc7b156d5b7411109
child 134225 953b1e4c5c170d0d5281ba46b3b46e0178186bcf
push id29104
push useremorley@mozilla.com
push dateThu, 06 Jun 2013 09:46:57 +0000
treeherdermozilla-inbound@8aa6c4c5dabc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs771551
milestone24.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 771551 - Add CSS Media Query for physical home buttons, r=heycam
content/base/src/nsGkAtomList.h
layout/style/nsCSSRuleProcessor.cpp
layout/style/nsMediaFeatures.cpp
widget/LookAndFeel.h
widget/gonk/nsLookAndFeel.cpp
--- a/content/base/src/nsGkAtomList.h
+++ b/content/base/src/nsGkAtomList.h
@@ -1995,16 +1995,17 @@ GK_ATOM(windows_default_theme, "windows-
 GK_ATOM(mac_graphite_theme, "mac-graphite-theme")
 GK_ATOM(mac_lion_theme, "mac-lion-theme")
 GK_ATOM(windows_compositor, "windows-compositor")
 GK_ATOM(windows_glass, "windows-glass")
 GK_ATOM(touch_enabled, "touch-enabled")
 GK_ATOM(maemo_classic, "maemo-classic")
 GK_ATOM(menubar_drag, "menubar-drag")
 GK_ATOM(swipe_animation_enabled, "swipe-animation-enabled")
+GK_ATOM(physical_home_button, "physical-home-button")
 
 // windows theme selector metrics
 GK_ATOM(windows_classic, "windows-classic")
 GK_ATOM(windows_theme_aero, "windows-theme-aero")
 GK_ATOM(windows_theme_luna_blue, "windows-theme-luna-blue")
 GK_ATOM(windows_theme_luna_olive, "windows-theme-luna-olive")
 GK_ATOM(windows_theme_luna_silver, "windows-theme-luna-silver")
 GK_ATOM(windows_theme_royale, "windows-theme-royale")
@@ -2029,16 +2030,17 @@ GK_ATOM(_moz_windows_glass, "-moz-window
 GK_ATOM(_moz_windows_theme, "-moz-windows-theme")
 GK_ATOM(_moz_touch_enabled, "-moz-touch-enabled")
 GK_ATOM(_moz_maemo_classic, "-moz-maemo-classic")
 GK_ATOM(_moz_menubar_drag, "-moz-menubar-drag")
 GK_ATOM(_moz_device_pixel_ratio, "-moz-device-pixel-ratio")
 GK_ATOM(_moz_device_orientation, "-moz-device-orientation")
 GK_ATOM(_moz_is_resource_document, "-moz-is-resource-document")
 GK_ATOM(_moz_swipe_animation_enabled, "-moz-swipe-animation-enabled")
+GK_ATOM(_moz_physical_home_button, "-moz-physical-home-button")
 
 // application commands
 GK_ATOM(Back, "Back")
 GK_ATOM(Forward, "Forward")
 GK_ATOM(Reload, "Reload")
 GK_ATOM(Stop, "Stop")
 GK_ATOM(Search, "Search")
 GK_ATOM(Bookmarks, "Bookmarks")
--- a/layout/style/nsCSSRuleProcessor.cpp
+++ b/layout/style/nsCSSRuleProcessor.cpp
@@ -1189,16 +1189,22 @@ InitSystemMetrics()
   }
 
   rv = LookAndFeel::GetInt(LookAndFeel::eIntID_SwipeAnimationEnabled,
                            &metricResult);
   if (NS_SUCCEEDED(rv) && metricResult) {
     sSystemMetrics->AppendElement(nsGkAtoms::swipe_animation_enabled);
   }
 
+  rv = LookAndFeel::GetInt(LookAndFeel::eIntID_PhysicalHomeButton,
+                           &metricResult);
+  if (NS_SUCCEEDED(rv) && metricResult) {
+    sSystemMetrics->AppendElement(nsGkAtoms::physical_home_button);
+  }
+
 #ifdef XP_WIN
   if (NS_SUCCEEDED(
         LookAndFeel::GetInt(LookAndFeel::eIntID_WindowsThemeIdentifier,
                             &metricResult))) {
     nsCSSRuleProcessor::SetWindowsThemeIdentifier(static_cast<uint8_t>(metricResult));
     switch(metricResult) {
       case LookAndFeel::eWindowsTheme_Aero:
         sSystemMetrics->AppendElement(nsGkAtoms::windows_theme_aero);
--- a/layout/style/nsMediaFeatures.cpp
+++ b/layout/style/nsMediaFeatures.cpp
@@ -589,16 +589,24 @@ nsMediaFeatures::features[] = {
     {
         &nsGkAtoms::_moz_swipe_animation_enabled,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { &nsGkAtoms::swipe_animation_enabled },
         GetSystemMetric
     },
 
+    {
+        &nsGkAtoms::_moz_physical_home_button,
+        nsMediaFeature::eMinMaxNotAllowed,
+        nsMediaFeature::eBoolInteger,
+        { &nsGkAtoms::physical_home_button },
+        GetSystemMetric
+    },
+
     // Internal -moz-is-glyph media feature: applies only inside SVG glyphs.
     // Internal because it is really only useful in the user agent anyway
     //  and therefore not worth standardizing.
     {
         &nsGkAtoms::_moz_is_glyph,
         nsMediaFeature::eMinMaxNotAllowed,
         nsMediaFeature::eBoolInteger,
         { nullptr },
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -360,17 +360,24 @@ public:
      * Dealy before showing a tooltip.
      */
     eIntID_TooltipDelay,
 
     /*
      * A Boolean value to determine whether Mac OS X Lion style swipe animations
      * should be used.
      */
-    eIntID_SwipeAnimationEnabled
+    eIntID_SwipeAnimationEnabled,
+
+    /*
+     * A boolean value indicating whether or not the device has a hardware
+     * home button. Used on gaia to determine whether a home button
+     * is shown.
+     */
+    eIntID_PhysicalHomeButton
   };
 
   /**
    * Windows themes we currently detect.
    */
   enum WindowsTheme {
     eWindowsTheme_Generic = 0, // unrecognized theme
     eWindowsTheme_Classic,
--- a/widget/gonk/nsLookAndFeel.cpp
+++ b/widget/gonk/nsLookAndFeel.cpp
@@ -12,16 +12,17 @@
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
 
 #include "nsLookAndFeel.h"
 #include "nsStyleConsts.h"
 #include "gfxFont.h"
+#include "cutils/properties.h"
 
 static const PRUnichar UNICODE_BULLET = 0x2022;
 
 nsLookAndFeel::nsLookAndFeel()
     : nsXPLookAndFeel()
 {
 }
 
@@ -361,16 +362,23 @@ nsLookAndFeel::GetIntImpl(IntID aID, int
         case eIntID_SpellCheckerUnderlineStyle:
             aResult = NS_STYLE_TEXT_DECORATION_STYLE_WAVY;
             break;
 
         case eIntID_ScrollbarButtonAutoRepeatBehavior:
             aResult = 0;
             break;
 
+        case eIntID_PhysicalHomeButton: {
+            char propValue[PROPERTY_VALUE_MAX];
+            property_get("ro.moz.has_home_button", propValue, "1");
+            aResult = atoi(propValue);
+            break;
+        }
+
         default:
             aResult = 0;
             rv = NS_ERROR_FAILURE;
     }
 
     return rv;
 }