Attachment #375458: Patch v4.0 for bug #76053

View | Details | Raw Unified | Return to bug 76053
Collapse All | Expand All

(-)a/dom/base/nsGlobalWindow.cpp (+62 lines)
Line     Link Here 
 Lines 159-174    Link Here 
159
#include "nsIURIFixup.h"
159
#include "nsIURIFixup.h"
160
#include "nsCDefaultURIFixup.h"
160
#include "nsCDefaultURIFixup.h"
161
#include "nsEventDispatcher.h"
161
#include "nsEventDispatcher.h"
162
#include "nsIObserverService.h"
162
#include "nsIObserverService.h"
163
#include "nsIXULAppInfo.h"
163
#include "nsIXULAppInfo.h"
164
#include "nsNetUtil.h"
164
#include "nsNetUtil.h"
165
#ifdef MOZ_XUL
165
#ifdef MOZ_XUL
166
#include "nsXULPopupManager.h"
166
#include "nsXULPopupManager.h"
167
#include "nsIDOMXULControlElement.h"
168
#include "nsIFrame.h"
169
#include "nsPresShellIterator.h"
167
#endif
170
#endif
168
171
169
#include "plbase64.h"
172
#include "plbase64.h"
170
173
171
#ifdef NS_PRINTING
174
#ifdef NS_PRINTING
172
#include "nsIPrintSettings.h"
175
#include "nsIPrintSettings.h"
173
#include "nsIPrintSettingsService.h"
176
#include "nsIPrintSettingsService.h"
174
#include "nsIWebBrowserPrint.h"
177
#include "nsIWebBrowserPrint.h"
 Lines 3816-3831   nsGlobalWindow::GetMainWidget() Link Here 
3816
3819
3817
  if (treeOwnerAsWin) {
3820
  if (treeOwnerAsWin) {
3818
    treeOwnerAsWin->GetMainWidget(&widget);
3821
    treeOwnerAsWin->GetMainWidget(&widget);
3819
  }
3822
  }
3820
3823
3821
  return widget;
3824
  return widget;
3822
}
3825
}
3823
3826
3827
nsIWidget*
3828
nsGlobalWindow::GetNearetWidget()
3829
{
3830
  nsIDocShell* docShell = GetDocShell();
3831
  NS_ENSURE_TRUE(docShell, nsnull);
3832
  nsCOMPtr<nsIPresShell> winShell;
3833
  docShell->GetPresShell(getter_AddRefs(winShell));
3834
  NS_ENSURE_TRUE(winShell, nsnull);
3835
  nsIFrame* rootFrame = winShell->GetRootFrame();
3836
  NS_ENSURE_TRUE(rootFrame, nsnull);
3837
  return rootFrame->GetView()->GetNearestWidget(nsnull);
3838
}
3839
3824
NS_IMETHODIMP
3840
NS_IMETHODIMP
3825
nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
3841
nsGlobalWindow::SetFullScreen(PRBool aFullScreen)
3826
{
3842
{
3827
  FORWARD_TO_OUTER(SetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
3843
  FORWARD_TO_OUTER(SetFullScreen, (aFullScreen), NS_ERROR_NOT_INITIALIZED);
3828
3844
3829
  NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
3845
  NS_ENSURE_TRUE(mDocShell, NS_ERROR_FAILURE);
3830
3846
3831
  PRBool rootWinFullScreen;
3847
  PRBool rootWinFullScreen;
 Lines 8784-8799   nsGlobalChromeWindow::SetBrowserDOMWindo Link Here 
8784
{
8800
{
8785
  FORWARD_TO_OUTER_CHROME(SetBrowserDOMWindow, (aBrowserWindow),
8801
  FORWARD_TO_OUTER_CHROME(SetBrowserDOMWindow, (aBrowserWindow),
8786
                          NS_ERROR_NOT_INITIALIZED);
8802
                          NS_ERROR_NOT_INITIALIZED);
8787
8803
8788
  mBrowserDOMWindow = aBrowserWindow;
8804
  mBrowserDOMWindow = aBrowserWindow;
8789
  return NS_OK;
8805
  return NS_OK;
8790
}
8806
}
8791
8807
8808
NS_IMETHODIMP
8809
nsGlobalChromeWindow::NotifyDefaultButtonLoaded(nsIDOMElement* aDefaultButton)
8810
{
8811
#ifdef MOZ_XUL
8812
  NS_ENSURE_ARG(aDefaultButton);
8813
8814
  // Don't snap to a disabled button.
8815
  nsCOMPtr<nsIDOMXULControlElement> xulControl =
8816
                                      do_QueryInterface(aDefaultButton);
8817
  NS_ENSURE_TRUE(xulControl, NS_ERROR_FAILURE);
8818
  PRBool disabled;
8819
  nsresult rv = xulControl->GetDisabled(&disabled);
8820
  NS_ENSURE_SUCCESS(rv, rv);
8821
  if (disabled)
8822
    return NS_OK;
8823
8824
  // Get the button rect in screen coordinates.
8825
  nsCOMPtr<nsIContent> content(do_QueryInterface(aDefaultButton));
8826
  NS_ENSURE_TRUE(content, NS_ERROR_FAILURE);
8827
  nsIDocument *doc = content->GetDocument();
8828
  NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE);
8829
  nsIPresShell *shell = doc->GetPrimaryShell();
8830
  NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
8831
  nsIFrame *frame = shell->GetPrimaryFrameFor(content);
8832
  NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE);
8833
  nsIntRect buttonRect = frame->GetScreenRect();
8834
8835
  // Get the widget rect in screen coordinates.
8836
  nsIWidget *widget = GetNearetWidget();
8837
  NS_ENSURE_TRUE(widget, NS_ERROR_FAILURE);
8838
  nsIntRect widgetRect;
8839
  rv = widget->GetScreenBounds(widgetRect);
8840
  NS_ENSURE_SUCCESS(rv, rv);
8841
8842
  // Convert the buttonRect coordinates from screen to the widget.
8843
  buttonRect -= widgetRect.TopLeft();
8844
  rv = widget->OnDefaultButtonLoaded(buttonRect);
8845
  if (rv == NS_ERROR_NOT_IMPLEMENTED)
8846
    return NS_OK;
8847
  NS_ENSURE_SUCCESS(rv, rv);
8848
  return NS_OK;
8849
#else
8850
  return NS_ERROR_NOT_IMPLEMENTED;
8851
#endif
8852
}
8853
8792
// nsGlobalModalWindow implementation
8854
// nsGlobalModalWindow implementation
8793
8855
8794
// QueryInterface implementation for nsGlobalModalWindow
8856
// QueryInterface implementation for nsGlobalModalWindow
8795
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalModalWindow)
8857
NS_IMPL_CYCLE_COLLECTION_CLASS(nsGlobalModalWindow)
8796
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGlobalModalWindow,
8858
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsGlobalModalWindow,
8797
                                                  nsGlobalWindow)
8859
                                                  nsGlobalWindow)
8798
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mArguments)
8860
  NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mArguments)
8799
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
8861
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
(-)a/dom/base/nsGlobalWindow.h (+1 lines)
Line     Link Here 
 Lines 595-610   protected: Link Here 
595
  PRBool DispatchCustomEvent(const char *aEventName);
595
  PRBool DispatchCustomEvent(const char *aEventName);
596
596
597
  // If aLookForCallerOnJSStack is true, this method will look at the JS stack
597
  // If aLookForCallerOnJSStack is true, this method will look at the JS stack
598
  // to determine who the caller is.  If it's false, it'll use |this| as the
598
  // to determine who the caller is.  If it's false, it'll use |this| as the
599
  // caller.
599
  // caller.
600
  PRBool WindowExists(const nsAString& aName, PRBool aLookForCallerOnJSStack);
600
  PRBool WindowExists(const nsAString& aName, PRBool aLookForCallerOnJSStack);
601
601
602
  already_AddRefed<nsIWidget> GetMainWidget();
602
  already_AddRefed<nsIWidget> GetMainWidget();
603
  nsIWidget* GetNearetWidget();
603
604
604
  void Freeze()
605
  void Freeze()
605
  {
606
  {
606
    NS_ASSERTION(!IsFrozen(), "Double-freezing?");
607
    NS_ASSERTION(!IsFrozen(), "Double-freezing?");
607
    mIsFrozen = PR_TRUE;
608
    mIsFrozen = PR_TRUE;
608
  }
609
  }
609
610
610
  void Thaw()
611
  void Thaw()
(-)a/dom/interfaces/base/nsIDOMChromeWindow.idl (-1 / +8 lines)
Line     Link Here 
 Lines 34-51    Link Here 
34
 * the provisions above, a recipient may use your version of this file under
34
 * the provisions above, a recipient may use your version of this file under
35
 * the terms of any one of the MPL, the GPL or the LGPL.
35
 * the terms of any one of the MPL, the GPL or the LGPL.
36
 *
36
 *
37
 * ***** END LICENSE BLOCK ***** */
37
 * ***** END LICENSE BLOCK ***** */
38
38
39
#include "domstubs.idl"
39
#include "domstubs.idl"
40
40
41
interface nsIBrowserDOMWindow;
41
interface nsIBrowserDOMWindow;
42
interface nsIDOMElement;
42
43
43
[scriptable, uuid(77a20f5a-68ad-41d3-97ac-6ff721512908)]
44
[scriptable, uuid(09b86cbd-9784-4fe4-9be6-70b9bbca3a9c)]
44
interface nsIDOMChromeWindow : nsISupports
45
interface nsIDOMChromeWindow : nsISupports
45
{
46
{
46
  const unsigned short STATE_MAXIMIZED = 1;
47
  const unsigned short STATE_MAXIMIZED = 1;
47
  const unsigned short STATE_MINIMIZED = 2;
48
  const unsigned short STATE_MINIMIZED = 2;
48
  const unsigned short STATE_NORMAL = 3;
49
  const unsigned short STATE_NORMAL = 3;
49
50
50
  readonly attribute unsigned short              windowState;
51
  readonly attribute unsigned short              windowState;
51
52
 Lines 60-68   interface nsIDOMChromeWindow : nsISuppor Link Here 
60
61
61
  void                      getAttentionWithCycleCount(in long aCycleCount);
62
  void                      getAttentionWithCycleCount(in long aCycleCount);
62
63
63
  void                      setCursor(in DOMString cursor);
64
  void                      setCursor(in DOMString cursor);
64
65
65
  void                      maximize();
66
  void                      maximize();
66
  void                      minimize();
67
  void                      minimize();
67
  void                      restore();
68
  void                      restore();
69
70
  /**
71
   * Notify a default button is loaded on a dialog or a wizard.
72
   * defaultButton is the default button.
73
   */
74
  void notifyDefaultButtonLoaded(in nsIDOMElement defaultButton);
68
};
75
};
(-)a/toolkit/content/tests/chrome/Makefile.in (+3 lines)
Line     Link Here 
 Lines 79-94   _TEST_FILES = findbar_window.xul \ Link Here 
79
		test_preferences.xul \
79
		test_preferences.xul \
80
		window_preferences.xul \
80
		window_preferences.xul \
81
		window_preferences2.xul \
81
		window_preferences2.xul \
82
		window_preferences3.xul \
82
		window_preferences3.xul \
83
		test_autocomplete2.xul \
83
		test_autocomplete2.xul \
84
		test_autocomplete3.xul \
84
		test_autocomplete3.xul \
85
		test_keys.xul \
85
		test_keys.xul \
86
		window_keys.xul \
86
		window_keys.xul \
87
		test_cursorsnap.xul \
88
		window_cursorsnap_dialog.xul \
89
		window_cursorsnap_wizard.xul \
87
		$(NULL)
90
		$(NULL)
88
91
89
# test_panel_focus.xul won't work if the Full Keyboard Access preference is set to
92
# test_panel_focus.xul won't work if the Full Keyboard Access preference is set to
90
# textboxes and lists only, so skip this test on Mac
93
# textboxes and lists only, so skip this test on Mac
91
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
94
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
92
_TEST_FILES += test_panel_focus.xul \
95
_TEST_FILES += test_panel_focus.xul \
93
               window_panel_focus.xul
96
               window_panel_focus.xul
94
else
97
else
(-)a/toolkit/content/tests/chrome/test_cursorsnap.xul (+104 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0"?>
2
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
4
                 type="text/css"?>
5
<window title="Cursor snapping test"
6
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
7
8
  <script type="application/javascript" 
9
          src="chrome://mochikit/content/MochiKit/packed.js"/>
10
  <script type="application/javascript"
11
          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js" />
12
  <script type="application/javascript"
13
          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js" />
14
15
<body  xmlns="http://www.w3.org/1999/xhtml">
16
<div id="content" style="display: none">
17
  
18
</div>
19
<pre id="test">
20
</pre>
21
</body>
22
23
<script class="testbody" type="application/javascript">
24
<![CDATA[
25
26
SimpleTest.waitForExplicitFinish();
27
28
var gTestingIndex = 0;
29
var gDisable = false;
30
var gHidden = false;
31
32
function runNextTest() {
33
  switch (gTestingIndex) {
34
    case 0:
35
      gDisable = false;
36
      gHidden = false;
37
      window.open("window_cursorsnap_dialog.xul", "_blank",
38
                  "chrome,width=100,height=100");
39
      break;
40
    case 1:
41
      gDisable = true;
42
      gHidden = false;
43
      window.open("window_cursorsnap_dialog.xul", "_blank",
44
                  "chrome,width=100,height=100");
45
      break;
46
    case 2:
47
      gDisable = false;
48
      gHidden = true;
49
      window.open("window_cursorsnap_dialog.xul", "_blank",
50
                  "chrome,width=100,height=100");
51
      break;
52
    case 3:
53
      gDisable = false;
54
      gHidden = false;
55
      window.open("window_cursorsnap_wizard.xul", "_blank",
56
                  "chrome,width=100,height=100");
57
      break;
58
    case 4:
59
      gDisable = true;
60
      gHidden = false;
61
      window.open("window_cursorsnap_wizard.xul", "_blank",
62
                  "chrome,width=100,height=100");
63
      break;
64
    case 5:
65
      gDisable = false;
66
      gHidden = true;
67
      window.open("window_cursorsnap_wizard.xul", "_blank",
68
                  "chrome,width=100,height=100");
69
      break;
70
    default:
71
      disableNonTestMouseEvents(false);
72
      SetPrefs(false);
73
      SimpleTest.finish();
74
      return;
75
  }
76
  gTestingIndex++;
77
}
78
79
function SetPrefs(aSet)
80
{
81
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
82
  var prefSvc = Components.classes["@mozilla.org/preferences-service;1"].
83
                           getService(Components.interfaces.nsIPrefBranch2);
84
  const kPrefName = "ui.snap_cursor_testing";
85
  if (aSet) {
86
    prefSvc.setBoolPref(kPrefName, true);
87
  } else {
88
    prefSvc.clearUserPref(kPrefName);
89
  }
90
}
91
92
if (navigator.platform.indexOf("Win") != 0) {
93
  // We don't support this feature on the platform.
94
  SimpleTest.finish();
95
} else {
96
  disableNonTestMouseEvents(true);
97
  SetPrefs(true);
98
  runNextTest();
99
}
100
101
102
]]>
103
</script>
104
</window>
(-)a/toolkit/content/tests/chrome/window_cursorsnap_wizard.xul (+91 lines)
Line     Link Here 
Line 0    Link Here 
1
<?xml version="1.0"?>
2
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
3
<wizard title="Cursor snapping test" id="wizard"
4
  width="600" height="600"
5
  onload="onload();"
6
  onunload="onunload();"
7
  buttons="accept,cancel"
8
  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
9
10
  <wizardpage>
11
    <label value="first page"/>
12
  </wizardpage>
13
14
  <wizardpage>
15
    <label value="second page"/>
16
  </wizardpage>
17
18
<script class="testbody" type="application/javascript">
19
<![CDATA[
20
21
function ok(aCondition, aMessage)
22
{
23
  window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage);
24
}
25
26
function is(aLeft, aRight, aMessage)
27
{
28
  window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage);
29
}
30
31
function isnot(aLeft, aRight, aMessage)
32
{
33
  window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage);
34
}
35
36
var gTimer;
37
38
function finishByTimeout()
39
{
40
  var button = document.getElementById("wizard").getButton("next");
41
  if (button.disabled)
42
    ok(true, "cursor is NOT snapped to the disabled button (wizard)");
43
  else if (button.hidden)
44
    ok(true, "cursor is NOT snapped to the hidden button (wizard)");
45
  else
46
    ok(false, "cursor is NOT snapped to the default button (wizard)");
47
  finish();
48
}
49
50
function finish()
51
{
52
  window.close();
53
}
54
55
function onMouseMove()
56
{
57
  var button = document.getElementById("wizard").getButton("next");
58
  if (button.disabled)
59
    ok(false, "cursor IS snapped to the disabled button (wizard)");
60
  else if (button.hidden)
61
    ok(false, "cursor IS snapped to the hidden button (wizard)");
62
  else
63
    ok(true, "cursor IS snapped to the default button (wizard)");
64
  clearTimeout(gTimer);
65
  finish();
66
}
67
68
function onload()
69
{
70
  var button = document.getElementById("wizard").getButton("next");
71
  button.addEventListener("mousemove", onMouseMove, false);
72
73
  if (window.opener.wrappedJSObject.gDisable) {
74
    button.disabled = true;
75
  }
76
  if (window.opener.wrappedJSObject.gHidden) {
77
    button.hidden = true;
78
  }
79
  // XXX this could cause a random failure...
80
  gTimer = setTimeout(finishByTimeout, 1000);
81
}
82
83
function onunload()
84
{
85
  window.opener.wrappedJSObject.runNextTest();
86
}
87
88
]]>
89
</script>
90
91
</wizard>
(-)a/toolkit/content/widgets/dialog.xml (-3 / +8 lines)
Line     Link Here 
 Lines 153-192    Link Here 
153
      ]]>
153
      ]]>
154
      </constructor>
154
      </constructor>
155
155
156
      <method name="postLoadInit">
156
      <method name="postLoadInit">
157
        <parameter name="aEvent"/>
157
        <parameter name="aEvent"/>
158
        <body>
158
        <body>
159
        <![CDATA[
159
        <![CDATA[
160
          function focusInit() {
160
          function focusInit() {
161
            const dialog = document.documentElement;
162
            const defaultButton = dialog.getButton(dialog.defaultButton);
161
            // give focus to the first focusable element in the dialog
163
            // give focus to the first focusable element in the dialog
162
            if (!document.commandDispatcher.focusedElement) {
164
            if (!document.commandDispatcher.focusedElement) {
163
              document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
165
              document.commandDispatcher.advanceFocusIntoSubtree(dialog);
164
              var focusedElt = document.commandDispatcher.focusedElement;
166
              var focusedElt = document.commandDispatcher.focusedElement;
165
              if (focusedElt) {
167
              if (focusedElt) {
166
                if (focusedElt.localName == 'tab') {
168
                if (focusedElt.localName == 'tab') {
167
                  // Move focus into the tab
169
                  // Move focus into the tab
168
                  document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
170
                  document.commandDispatcher.advanceFocusIntoSubtree(focusedElt);
169
                  if (document.commandDispatcher.focusedElement.hasAttribute("dlgtype")) {
171
                  if (document.commandDispatcher.focusedElement.hasAttribute("dlgtype")) {
170
                    // We don't want to focus on anonymous OK, Cancel, etc. buttons,
172
                    // We don't want to focus on anonymous OK, Cancel, etc. buttons,
171
                    // so return focus to the tab itself
173
                    // so return focus to the tab itself
172
                    focusedElt.focus();
174
                    focusedElt.focus();
173
                  }
175
                  }
174
                }
176
                }
175
#ifndef XP_MACOSX
177
#ifndef XP_MACOSX
176
                else {
178
                else {
177
                  const dialog = document.documentElement;
178
                  const defaultButton = dialog.getButton(dialog.defaultButton);
179
                  if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton)
179
                  if (focusedElt.hasAttribute("dlgtype") && focusedElt != defaultButton)
180
                    defaultButton.focus();
180
                    defaultButton.focus();
181
                }
181
                }
182
#endif
182
#endif
183
              }
183
              }
184
            }
184
            }
185
186
            try {
187
              if (defaultButton)
188
                window.notifyDefaultButtonLoaded(defaultButton);
189
            } catch (e) { }
185
          }
190
          }
186
191
187
          // Give focus after onload completes, see bug 103197.
192
          // Give focus after onload completes, see bug 103197.
188
          setTimeout(focusInit, 0);
193
          setTimeout(focusInit, 0);
189
        ]]>
194
        ]]>
190
        </body>
195
        </body>
191
      </method>                
196
      </method>                
192
197
(-)a/toolkit/content/widgets/wizard.xml (+22 lines)
Line     Link Here 
 Lines 319-334    Link Here 
319
        <body>
319
        <body>
320
        <![CDATA[
320
        <![CDATA[
321
          document.documentElement._hasLoaded = true;
321
          document.documentElement._hasLoaded = true;
322
          var focusInit = 
322
          var focusInit = 
323
            function() {
323
            function() {
324
              // give focus to the first focusable element in the dialog
324
              // give focus to the first focusable element in the dialog
325
              if (!document.commandDispatcher.focusedElement)
325
              if (!document.commandDispatcher.focusedElement)
326
                document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
326
                document.commandDispatcher.advanceFocusIntoSubtree(document.documentElement);
327
328
              try {
329
                var button =
330
                      document.documentElement._wizardButtons.defaultButton;
331
                if (button)
332
                  window.notifyDefaultButtonLoaded(button);
333
              } catch (e) { }
327
            };
334
            };
328
335
329
          // Give focus after onload completes, see bug 103197.
336
          // Give focus after onload completes, see bug 103197.
330
          setTimeout(focusInit, 0);
337
          setTimeout(focusInit, 0);
331
        ]]>
338
        ]]>
332
        </body>
339
        </body>
333
      </method>                
340
      </method>                
334
341
 Lines 576-588    Link Here 
576
        <body><![CDATA[
583
        <body><![CDATA[
577
          if (this.getAttribute("lastpage") == "true") {
584
          if (this.getAttribute("lastpage") == "true") {
578
            this._wizardButtonDeck.setAttribute("selectedIndex", 0);
585
            this._wizardButtonDeck.setAttribute("selectedIndex", 0);
579
          } else {
586
          } else {
580
            this._wizardButtonDeck.setAttribute("selectedIndex", 1);
587
            this._wizardButtonDeck.setAttribute("selectedIndex", 1);
581
          }
588
          }
582
        ]]></body>
589
        ]]></body>
583
      </method>
590
      </method>
591
592
      <property name="defaultButton">
593
        <getter><![CDATA[
594
          const kXULNS =
595
            "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
596
          var buttons = this._wizardButtonDeck.selectedPanel
597
                            .getElementsByTagNameNS(kXULNS, "button");
598
          for (var i = 0; i < buttons.length; i++) {
599
            if (buttons[i].getAttribute("default") == "true" &&
600
                !buttons[i].hidden && !buttons[i].disabled)
601
              return buttons[i];
602
          }
603
          return null;
604
        ]]></getter>
605
      </property>
584
    </implementation>
606
    </implementation>
585
  </binding>
607
  </binding>
586
#endif
608
#endif
587
609
588
</bindings>
610
</bindings>
(-)a/widget/public/nsIWidget.h (-3 / +9 lines)
Line     Link Here 
 Lines 95-114   typedef nsEventStatus (* EVENT_CALLBACK) Link Here 
95
#define NS_NATIVE_PLUGIN_PORT_CG    101
95
#define NS_NATIVE_PLUGIN_PORT_CG    101
96
#endif
96
#endif
97
#ifdef XP_WIN
97
#ifdef XP_WIN
98
#define NS_NATIVE_TSF_THREAD_MGR       100
98
#define NS_NATIVE_TSF_THREAD_MGR       100
99
#define NS_NATIVE_TSF_CATEGORY_MGR     101
99
#define NS_NATIVE_TSF_CATEGORY_MGR     101
100
#define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
100
#define NS_NATIVE_TSF_DISPLAY_ATTR_MGR 102
101
#endif
101
#endif
102
102
103
// af70b716-2e34-463f-8f1c-273dbddd845b
103
// {a395289d-b344-42c3-ae7e-34d64282b6e0}
104
#define NS_IWIDGET_IID \
104
#define NS_IWIDGET_IID \
105
{ 0xaf70b716, 0x2e34, 0x463f, \
105
{ 0xa395289d, 0xb344, 0x42c3, \
106
  { 0x8f, 0x1c, 0x27, 0x3d, 0xbd, 0xdd, 0x84, 0x5b } }
106
  { 0xae, 0x7e, 0x34, 0xd6, 0x42, 0x82, 0xb6, 0xe0 } }
107
107
108
/*
108
/*
109
 * Window shadow styles
109
 * Window shadow styles
110
 * Also used for the -moz-window-shadow CSS property
110
 * Also used for the -moz-window-shadow CSS property
111
 */
111
 */
112
112
113
#define NS_STYLE_WINDOW_SHADOW_NONE             0
113
#define NS_STYLE_WINDOW_SHADOW_NONE             0
114
#define NS_STYLE_WINDOW_SHADOW_DEFAULT          1
114
#define NS_STYLE_WINDOW_SHADOW_DEFAULT          1
 Lines 1057-1072   class nsIWidget : public nsISupports { Link Here 
1057
                               PRUint32 aOldEnd,
1057
                               PRUint32 aOldEnd,
1058
                               PRUint32 aNewEnd) = 0;
1058
                               PRUint32 aNewEnd) = 0;
1059
1059
1060
    /*
1060
    /*
1061
     * Selection has changed in the focused node
1061
     * Selection has changed in the focused node
1062
     */
1062
     */
1063
    NS_IMETHOD OnIMESelectionChange(void) = 0;
1063
    NS_IMETHOD OnIMESelectionChange(void) = 0;
1064
1064
1065
    /*
1066
     * When a default button loaded on dialog or something, this method is
1067
     * called.  aButtonRect coordinates are relative to this widget.
1068
     */ 
1069
    NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect) = 0;
1070
1065
protected:
1071
protected:
1066
    // keep the list of children.  We also keep track of our siblings.
1072
    // keep the list of children.  We also keep track of our siblings.
1067
    // The ownership model is as follows: parent holds a strong ref to
1073
    // The ownership model is as follows: parent holds a strong ref to
1068
    // the first element of the list, and each element holds a strong
1074
    // the first element of the list, and each element holds a strong
1069
    // ref to the next element in the list.  The prevsibling and
1075
    // ref to the next element in the list.  The prevsibling and
1070
    // lastchild pointers are weak, which is fine as long as they are
1076
    // lastchild pointers are weak, which is fine as long as they are
1071
    // maintained properly.
1077
    // maintained properly.
1072
    nsCOMPtr<nsIWidget> mFirstChild;
1078
    nsCOMPtr<nsIWidget> mFirstChild;
(-)a/widget/src/windows/nsWindow.cpp (+65 lines)
Line     Link Here 
 Lines 8539-8554   nsWindow :: DealWithPopups ( HWND inWnd, Link Here 
8539
        }
8539
        }
8540
      }
8540
      }
8541
    } // if event that might trigger a popup to rollup
8541
    } // if event that might trigger a popup to rollup
8542
  } // if rollup listeners registered
8542
  } // if rollup listeners registered
8543
8543
8544
  return FALSE;
8544
  return FALSE;
8545
} // DealWithPopups
8545
} // DealWithPopups
8546
8546
8547
NS_IMETHODIMP
8548
nsWindow::OnDefaultButtonLoaded(const nsIntRect &aButtonRect)
8549
{
8550
  if (aButtonRect.IsEmpty())
8551
    return NS_OK;
8552
8553
  // Check whether we are testing the feature of "to snap mouse cursor to center
8554
  // of the default window".  That is not easy to test in normal conditions.
8555
  // The tests disables all mouse event handling and they need the synthesized
8556
  // mouse event on the default button.  And also they hope that the snapping
8557
  // should be happend always.
8558
  PRBool isCursorSnapTesting = PR_FALSE;
8559
  nsCOMPtr<nsIPrefService> prefs = do_GetService(NS_PREFSERVICE_CONTRACTID);
8560
  if (prefs) {
8561
    nsCOMPtr<nsIPrefBranch> prefBranch;
8562
    prefs->GetBranch(nsnull, getter_AddRefs(prefBranch));
8563
    if (prefBranch) {
8564
      prefBranch->GetBoolPref("ui.snap_cursor_testing", &isCursorSnapTesting);
8565
    }
8566
  }
8567
8568
  // We don't need to check whether we should snap the mouse cursor.
8569
  if (!isCursorSnapTesting) {
8570
    // Don't snap when we are not active.
8571
    if (::GetActiveWindow() != ::GetForegroundWindow())
8572
      return NS_OK;
8573
8574
    BOOL snapDefaultButton;
8575
    if (!::SystemParametersInfo(SPI_GETSNAPTODEFBUTTON, 0,
8576
                                &snapDefaultButton, 0) || !snapDefaultButton)
8577
      return NS_OK;
8578
  }
8579
8580
  nsIntRect widgetRect;
8581
  nsresult rv = GetScreenBounds(widgetRect);
8582
  NS_ENSURE_SUCCESS(rv, rv);
8583
  nsIntRect buttonRect(aButtonRect + widgetRect.TopLeft());
8584
8585
  nsIntPoint centerOfButton(buttonRect.x + buttonRect.width / 2,
8586
                            buttonRect.y + buttonRect.height / 2);
8587
8588
  // The button can be outside of the widget.
8589
  // E.g., it could be hidden by scrolling.
8590
  if (!widgetRect.Intersects(buttonRect) ||
8591
      !widgetRect.Contains(centerOfButton)) {
8592
    return NS_OK;
8593
  }
8594
8595
  rv = ::SetCursorPos(centerOfButton.x, centerOfButton.y) ? NS_OK :
8596
                                                            NS_ERROR_FAILURE;
8597
  NS_ENSURE_SUCCESS(rv, rv);
8598
8599
  if (!isCursorSnapTesting)
8600
    return NS_OK;
8601
8602
  // Generate a fake event for automated testing of this feature.
8603
  nsMouseEvent event(PR_TRUE, NS_MOUSE_MOVE, this, nsMouseEvent::eReal,
8604
                     nsMouseEvent::eNormal);
8605
  event.flags |= NS_EVENT_FLAG_SYNTETIC_TEST_EVENT;
8606
  event.time = PR_IntervalNow();
8607
  event.refPoint = centerOfButton - widgetRect.TopLeft();
8608
  nsEventStatus status;
8609
  return DispatchEvent(&event, status);
8610
}
8611
8547
8612
8548
8613
8549
#ifdef ACCESSIBILITY
8614
#ifdef ACCESSIBILITY
8550
already_AddRefed<nsIAccessible> nsWindow::GetRootAccessible()
8615
already_AddRefed<nsIAccessible> nsWindow::GetRootAccessible()
8551
{
8616
{
8552
  nsWindow::gIsAccessibilityOn = TRUE;
8617
  nsWindow::gIsAccessibilityOn = TRUE;
8553
8618
8554
  if (mIsDestroying || mOnDestroyCalled || mWindowType == eWindowType_invisible) {
8619
  if (mIsDestroying || mOnDestroyCalled || mWindowType == eWindowType_invisible) {
(-)a/widget/src/windows/nsWindow.h (+2 lines)
Line     Link Here 
 Lines 228-243   public: Link Here 
228
  NS_IMETHOD CancelIMEComposition();
228
  NS_IMETHOD CancelIMEComposition();
229
  NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState);
229
  NS_IMETHOD GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState);
230
230
231
#ifdef NS_ENABLE_TSF
231
#ifdef NS_ENABLE_TSF
232
  NS_IMETHOD OnIMEFocusChange(PRBool aFocus);
232
  NS_IMETHOD OnIMEFocusChange(PRBool aFocus);
233
  NS_IMETHOD OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd);
233
  NS_IMETHOD OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd);
234
  NS_IMETHOD OnIMESelectionChange(void);
234
  NS_IMETHOD OnIMESelectionChange(void);
235
#endif //NS_ENABLE_TSF
235
#endif //NS_ENABLE_TSF
236
237
  NS_IMETHOD OnDefaultButtonLoaded(const nsIntRect &aButtonRect);
236
238
237
  PRBool IMEMouseHandling(PRInt32 aAction, LPARAM lParam);
239
  PRBool IMEMouseHandling(PRInt32 aAction, LPARAM lParam);
238
  PRBool IMECompositionHitTest(POINT * ptPos);
240
  PRBool IMECompositionHitTest(POINT * ptPos);
239
  PRBool HandleMouseActionOfIME(PRInt32 aAction, POINT* ptPos);
241
  PRBool HandleMouseActionOfIME(PRInt32 aAction, POINT* ptPos);
240
242
241
  // nsSwitchToUIThread interface
243
  // nsSwitchToUIThread interface
242
  virtual BOOL            CallMethod(MethodInfo *info);
244
  virtual BOOL            CallMethod(MethodInfo *info);
243
245
(-)a/widget/src/xpwidgets/nsBaseWidget.h (+1 lines)
Line     Link Here 
 Lines 136-151   public: Link Here 
136
  NS_IMETHOD              GetIMEOpenState(PRBool* aState) { return NS_ERROR_NOT_IMPLEMENTED; }
136
  NS_IMETHOD              GetIMEOpenState(PRBool* aState) { return NS_ERROR_NOT_IMPLEMENTED; }
137
  NS_IMETHOD              SetIMEEnabled(PRUint32 aState) { return NS_ERROR_NOT_IMPLEMENTED; }
137
  NS_IMETHOD              SetIMEEnabled(PRUint32 aState) { return NS_ERROR_NOT_IMPLEMENTED; }
138
  NS_IMETHOD              GetIMEEnabled(PRUint32* aState) { return NS_ERROR_NOT_IMPLEMENTED; }
138
  NS_IMETHOD              GetIMEEnabled(PRUint32* aState) { return NS_ERROR_NOT_IMPLEMENTED; }
139
  NS_IMETHOD              CancelIMEComposition() { return NS_OK; }
139
  NS_IMETHOD              CancelIMEComposition() { return NS_OK; }
140
  NS_IMETHOD              GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
140
  NS_IMETHOD              GetToggledKeyState(PRUint32 aKeyCode, PRBool* aLEDState) { return NS_ERROR_NOT_IMPLEMENTED; }
141
  NS_IMETHOD              OnIMEFocusChange(PRBool aFocus) { return NS_ERROR_NOT_IMPLEMENTED; }
141
  NS_IMETHOD              OnIMEFocusChange(PRBool aFocus) { return NS_ERROR_NOT_IMPLEMENTED; }
142
  NS_IMETHOD              OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
142
  NS_IMETHOD              OnIMETextChange(PRUint32 aStart, PRUint32 aOldEnd, PRUint32 aNewEnd) { return NS_ERROR_NOT_IMPLEMENTED; }
143
  NS_IMETHOD              OnIMESelectionChange(void) { return NS_ERROR_NOT_IMPLEMENTED; }
143
  NS_IMETHOD              OnIMESelectionChange(void) { return NS_ERROR_NOT_IMPLEMENTED; }
144
  NS_IMETHOD              OnDefaultButtonLoaded(const nsIntRect &aButtonRect) { return NS_ERROR_NOT_IMPLEMENTED; }
144
145
145
protected:
146
protected:
146
147
147
  virtual void            ResolveIconName(const nsAString &aIconName,
148
  virtual void            ResolveIconName(const nsAString &aIconName,
148
                                          const nsAString &aIconSuffix,
149
                                          const nsAString &aIconSuffix,
149
                                          nsILocalFile **aResult);
150
                                          nsILocalFile **aResult);
150
  virtual void            OnDestroy();
151
  virtual void            OnDestroy();
151
  virtual void            BaseCreate(nsIWidget *aParent,
152
  virtual void            BaseCreate(nsIWidget *aParent,

Return to bug 76053