Fix popup positioning when window is scrolled.

This commit is contained in:
hyatt%netscape.com 2002-04-25 09:22:07 +00:00
Родитель 5c88264a39
Коммит 0009949240
8 изменённых файлов: 128 добавлений и 0 удалений

Просмотреть файл

@ -54,6 +54,8 @@
#include "nsIDOMHTMLSelectElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
@ -64,6 +66,8 @@
// Common helper routines (also used by the context menu code)
#include "CHGeckoUtils.h"
#import "CHBrowserView.h"
static void FindOptionWithContentID(nsIDOMHTMLSelectElement* aSel, PRUint32 aID, nsIDOMHTMLOptionElement** aResult)
{
*aResult = nsnull;
@ -211,6 +215,13 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRInt32 xDelta = clientX - left;
PRInt32 yDelta = top + height - clientY;
nsCOMPtr<nsIDOMWindow> window = getter_AddRefs([[[mBrowserController getBrowserWrapper] getBrowserView] getContentWindow]);
PRInt32 scrollX, scrollY;
window->GetScrollX(&scrollX);
window->GetScrollY(&scrollY);
xDelta += scrollX; // Normal direction.
yDelta -= scrollY; // Remember, y is flipped.
#define XMENUOFFSET 20
#define MENUHEIGHT 20

Просмотреть файл

@ -388,5 +388,26 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
}
static PRBool gSetupSmoothTextMenu = PR_FALSE;
-(BOOL)validateMenuItem: (id <NSMenuItem> )aMenuItem
{
// XXXDWH I should not be using strings here. Not localizable.
// SHould use tags instead.
if ([[aMenuItem title] isEqualToString: @"Smooth Text"] &&
!gSetupSmoothTextMenu) {
gSetupSmoothTextMenu = PR_TRUE;
// Grab the prefs service and just set the pref directly.
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
int mode;
pref->GetIntPref("nglayout.mac.renderingmode", &mode);
if (mode == 0)
[aMenuItem setState: NSOffState];
else
[aMenuItem setState: NSOnState];
}
return YES;
}
@end

Просмотреть файл

@ -388,5 +388,26 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
}
static PRBool gSetupSmoothTextMenu = PR_FALSE;
-(BOOL)validateMenuItem: (id <NSMenuItem> )aMenuItem
{
// XXXDWH I should not be using strings here. Not localizable.
// SHould use tags instead.
if ([[aMenuItem title] isEqualToString: @"Smooth Text"] &&
!gSetupSmoothTextMenu) {
gSetupSmoothTextMenu = PR_TRUE;
// Grab the prefs service and just set the pref directly.
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
int mode;
pref->GetIntPref("nglayout.mac.renderingmode", &mode);
if (mode == 0)
[aMenuItem setState: NSOffState];
else
[aMenuItem setState: NSOnState];
}
return YES;
}
@end

Просмотреть файл

@ -54,6 +54,8 @@
#include "nsIDOMHTMLSelectElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
@ -64,6 +66,8 @@
// Common helper routines (also used by the context menu code)
#include "CHGeckoUtils.h"
#import "CHBrowserView.h"
static void FindOptionWithContentID(nsIDOMHTMLSelectElement* aSel, PRUint32 aID, nsIDOMHTMLOptionElement** aResult)
{
*aResult = nsnull;
@ -211,6 +215,13 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRInt32 xDelta = clientX - left;
PRInt32 yDelta = top + height - clientY;
nsCOMPtr<nsIDOMWindow> window = getter_AddRefs([[[mBrowserController getBrowserWrapper] getBrowserView] getContentWindow]);
PRInt32 scrollX, scrollY;
window->GetScrollX(&scrollX);
window->GetScrollY(&scrollY);
xDelta += scrollX; // Normal direction.
yDelta -= scrollY; // Remember, y is flipped.
#define XMENUOFFSET 20
#define MENUHEIGHT 20

Просмотреть файл

@ -54,6 +54,8 @@
#include "nsIDOMHTMLSelectElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
@ -64,6 +66,8 @@
// Common helper routines (also used by the context menu code)
#include "CHGeckoUtils.h"
#import "CHBrowserView.h"
static void FindOptionWithContentID(nsIDOMHTMLSelectElement* aSel, PRUint32 aID, nsIDOMHTMLOptionElement** aResult)
{
*aResult = nsnull;
@ -211,6 +215,13 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRInt32 xDelta = clientX - left;
PRInt32 yDelta = top + height - clientY;
nsCOMPtr<nsIDOMWindow> window = getter_AddRefs([[[mBrowserController getBrowserWrapper] getBrowserView] getContentWindow]);
PRInt32 scrollX, scrollY;
window->GetScrollX(&scrollX);
window->GetScrollY(&scrollY);
xDelta += scrollX; // Normal direction.
yDelta -= scrollY; // Remember, y is flipped.
#define XMENUOFFSET 20
#define MENUHEIGHT 20

Просмотреть файл

@ -388,5 +388,26 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
}
static PRBool gSetupSmoothTextMenu = PR_FALSE;
-(BOOL)validateMenuItem: (id <NSMenuItem> )aMenuItem
{
// XXXDWH I should not be using strings here. Not localizable.
// SHould use tags instead.
if ([[aMenuItem title] isEqualToString: @"Smooth Text"] &&
!gSetupSmoothTextMenu) {
gSetupSmoothTextMenu = PR_TRUE;
// Grab the prefs service and just set the pref directly.
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
int mode;
pref->GetIntPref("nglayout.mac.renderingmode", &mode);
if (mode == 0)
[aMenuItem setState: NSOffState];
else
[aMenuItem setState: NSOnState];
}
return YES;
}
@end

Просмотреть файл

@ -388,5 +388,26 @@ static const char* ioServiceContractID = "@mozilla.org/network/io-service;1";
}
}
static PRBool gSetupSmoothTextMenu = PR_FALSE;
-(BOOL)validateMenuItem: (id <NSMenuItem> )aMenuItem
{
// XXXDWH I should not be using strings here. Not localizable.
// SHould use tags instead.
if ([[aMenuItem title] isEqualToString: @"Smooth Text"] &&
!gSetupSmoothTextMenu) {
gSetupSmoothTextMenu = PR_TRUE;
// Grab the prefs service and just set the pref directly.
nsCOMPtr<nsIPrefBranch> pref(do_GetService("@mozilla.org/preferences-service;1"));
int mode;
pref->GetIntPref("nglayout.mac.renderingmode", &mode);
if (mode == 0)
[aMenuItem setState: NSOffState];
else
[aMenuItem setState: NSOnState];
}
return YES;
}
@end

Просмотреть файл

@ -54,6 +54,8 @@
#include "nsIDOMHTMLSelectElement.h"
#include "nsIDOMHTMLOptionElement.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMWindow.h"
#include "nsIScriptGlobalObject.h"
#include "nsIDocument.h"
#include "nsIPresShell.h"
#include "nsIPresContext.h"
@ -64,6 +66,8 @@
// Common helper routines (also used by the context menu code)
#include "CHGeckoUtils.h"
#import "CHBrowserView.h"
static void FindOptionWithContentID(nsIDOMHTMLSelectElement* aSel, PRUint32 aID, nsIDOMHTMLOptionElement** aResult)
{
*aResult = nsnull;
@ -211,6 +215,13 @@ ContentClickListener::MouseDown(nsIDOMEvent* aEvent)
PRInt32 xDelta = clientX - left;
PRInt32 yDelta = top + height - clientY;
nsCOMPtr<nsIDOMWindow> window = getter_AddRefs([[[mBrowserController getBrowserWrapper] getBrowserView] getContentWindow]);
PRInt32 scrollX, scrollY;
window->GetScrollX(&scrollX);
window->GetScrollY(&scrollY);
xDelta += scrollX; // Normal direction.
yDelta -= scrollY; // Remember, y is flipped.
#define XMENUOFFSET 20
#define MENUHEIGHT 20