Bug 1432950 - Remove the scrollbar-base binding to prevent XBL JS from running on scrollbars in content;r=smaug;r=dao draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 14 Feb 2018 09:12:56 -0800
changeset 754929 d6bc69f4b2ffaea1789618bf7c3dd8122e84e91d
parent 754399 38b3c1d03a594664c6b32c35533734283c258f43
push id99059
push userbgrinstead@mozilla.com
push dateWed, 14 Feb 2018 17:13:12 +0000
reviewerssmaug, dao
bugs1432950
milestone60.0a1
Bug 1432950 - Remove the scrollbar-base binding to prevent XBL JS from running on scrollbars in content;r=smaug;r=dao The events that get silenced here are already covered for native anonymous content by IsEventStoppedFromAnonymousScrollbar. In trees, where <xul:scrollbar> and <xul:scrollcorner> are part of the DOM, copy the handlers over into attributes on each instance. MozReview-Commit-ID: Huk5nFC7Qua
toolkit/content/widgets/scrollbar.xml
toolkit/content/widgets/tree.xml
toolkit/themes/osx/global/nativescrollbars.css
toolkit/themes/windows/global/xulscrollbars.css
--- a/toolkit/content/widgets/scrollbar.xml
+++ b/toolkit/content/widgets/scrollbar.xml
@@ -6,26 +6,17 @@
 
 <bindings id="scrollbarBindings"
    xmlns="http://www.mozilla.org/xbl"
    xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    xmlns:xbl="http://www.mozilla.org/xbl">
   
   <binding id="thumb" extends="xul:button" />
 
-  <binding id="scrollbar-base" bindToUntrustedContent="true">
-    <handlers>
-      <handler event="contextmenu" preventdefault="true" action="event.stopPropagation();"/>
-      <handler event="click" preventdefault="true" action="event.stopPropagation();"/>
-      <handler event="dblclick" action="event.stopPropagation();"/>
-      <handler event="command" action="event.stopPropagation();"/>
-    </handlers>
-  </binding>
-
-  <binding id="scrollbar" bindToUntrustedContent="true" extends="chrome://global/content/bindings/scrollbar.xml#scrollbar-base">
+  <binding id="scrollbar" bindToUntrustedContent="true">
     <content clickthrough="always">
       <xul:scrollbarbutton sbattr="scrollbar-up-top" type="decrement" xbl:inherits="curpos,maxpos,disabled,sborient=orient"/>
       <xul:scrollbarbutton sbattr="scrollbar-down-top" type="increment" xbl:inherits="curpos,maxpos,disabled,sborient=orient"/>
       <xul:slider flex="1" xbl:inherits="disabled,curpos,maxpos,pageincrement,increment,orient,sborient=orient">
         <xul:thumb sbattr="scrollbar-thumb" xbl:inherits="orient,sborient=orient,collapsed=disabled" 
                    align="center" pack="center"/>
       </xul:slider>
       <xul:scrollbarbutton sbattr="scrollbar-up-bottom" type="decrement" xbl:inherits="curpos,maxpos,disabled,sborient=orient"/>
--- a/toolkit/content/widgets/tree.xml
+++ b/toolkit/content/widgets/tree.xml
@@ -33,18 +33,26 @@
       <children includes="treecols"/>
       <xul:stack class="tree-stack" flex="1">
         <xul:treerows class="tree-rows" flex="1" xbl:inherits="hidevscroll">
           <children/>
         </xul:treerows>
         <xul:textbox anonid="input" class="tree-input" left="0" top="0" hidden="true"/>
       </xul:stack>
       <xul:hbox xbl:inherits="collapsed=hidehscroll">
-        <xul:scrollbar orient="horizontal" flex="1" increment="16" style="position:relative; z-index:2147483647;"/>
-        <xul:scrollcorner xbl:inherits="collapsed=hidevscroll"/>
+        <xul:scrollbar orient="horizontal" flex="1" increment="16" style="position:relative; z-index:2147483647;"
+          oncontextmenu="event.stopPropagation(); event.preventDefault();"
+          onclick="event.stopPropagation(); event.preventDefault();"
+          ondblclick="event.stopPropagation();"
+          oncommand="event.stopPropagation();"/>
+        <xul:scrollcorner xbl:inherits="collapsed=hidevscroll"
+          oncontextmenu="event.stopPropagation(); event.preventDefault();"
+          onclick="event.stopPropagation(); event.preventDefault();"
+          ondblclick="event.stopPropagation();"
+          oncommand="event.stopPropagation();"/>
       </xul:hbox>
     </content>
 
     <implementation implements="nsIDOMXULTreeElement, nsIDOMXULMultiSelectControlElement">
 
       <!-- ///////////////// nsIDOMXULTreeElement ///////////////// -->
 
       <property name="columns"
@@ -1047,17 +1055,21 @@
     </implementation>
   </binding>
 
   <binding id="treerows" extends="chrome://global/content/bindings/tree.xml#tree-base">
     <content>
       <xul:hbox flex="1" class="tree-bodybox">
         <children/>
       </xul:hbox>
-      <xul:scrollbar height="0" minwidth="0" minheight="0" orient="vertical" xbl:inherits="collapsed=hidevscroll" style="position:relative; z-index:2147483647;"/>
+      <xul:scrollbar height="0" minwidth="0" minheight="0" orient="vertical" xbl:inherits="collapsed=hidevscroll" style="position:relative; z-index:2147483647;"
+        oncontextmenu="event.stopPropagation(); event.preventDefault();"
+        onclick="event.stopPropagation(); event.preventDefault();"
+        ondblclick="event.stopPropagation();"
+        oncommand="event.stopPropagation();"/>
     </content>
     <handlers>
       <handler event="underflow">
         <![CDATA[
           // Scrollport event orientation
           // 0: vertical
           // 1: horizontal
           // 2: both (not used)
--- a/toolkit/themes/osx/global/nativescrollbars.css
+++ b/toolkit/themes/osx/global/nativescrollbars.css
@@ -68,17 +68,16 @@ scrollbarbutton[type="decrement"] {
 scrollbar[orient="vertical"] > scrollbarbutton[type="decrement"] {
   -moz-appearance: scrollbarbutton-up;
 }
 
 /* ::::: square at the corner of two scrollbars ::::: */
 
 scrollcorner {
   /* XXX -moz-appearance: scrollcorner; */
-  -moz-binding: url(chrome://global/content/bindings/scrollbar.xml#scrollbar-base);
   width: 16px;
   cursor: default;
   background-color: white;
 }
 
 /* ::::::::::::::::::::: MEDIA PRINT :::::::::::::::::::::: */
 @media print {
   html|div scrollbar {
--- a/toolkit/themes/windows/global/xulscrollbars.css
+++ b/toolkit/themes/windows/global/xulscrollbars.css
@@ -60,17 +60,16 @@ scrollbarbutton {
   min-width: 16px;
   min-height: 16px;
 }
 
 /* ::::: square at the corner of two scrollbars ::::: */
 
 scrollcorner { 
   /* XXX -moz-appearance: scrollcorner; */
-  -moz-binding: url(chrome://global/content/bindings/scrollbar.xml#scrollbar-base);
   width: 16px;
   cursor: default;
   background-color: -moz-Dialog;
 }
 
 /* ..... increment .... */
 
 scrollbarbutton[type="increment"] {