Skip to content

Commit

Permalink
Issue #2051 - Part 1 - Initial changes to get UXP building on Mac 10.…
Browse files Browse the repository at this point in the history
…5 PowerPC.

Additionally update the version detection back to 10.5 and forward to 14.
Fill some parts with code from TenFourFox when changes are not obvious.
Using gcc 7 from MacPorts, the gcc 4.8 TenFourFox used is too old.
Don't use GNU as on MacPPC it is too old.
Fix struct/class sizes by limiting bool size.
  • Loading branch information
dbsoft committed Nov 23, 2023
1 parent 3a092d3 commit 8cffdc2
Show file tree
Hide file tree
Showing 77 changed files with 1,629 additions and 121 deletions.
4 changes: 4 additions & 0 deletions accessible/base/RoleMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
* ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule)
*/

#ifndef NSAccessibilityCellRole
#define NSAccessibilityCellRole NSAccessibilityUnknownRole
#endif

ROLE(NOTHING,
"nothing",
ATK_ROLE_UNKNOWN,
Expand Down
2 changes: 2 additions & 0 deletions accessible/mac/mozActionElements.mm
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ - (void)invalidateChildren

@implementation mozPaneAccessible

#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
- (NSUInteger)accessibilityArrayAttributeCount:(NSString*)attribute
{
AccessibleWrap* accWrap = [self getGeckoAccessible];
Expand All @@ -313,6 +314,7 @@ - (NSUInteger)accessibilityArrayAttributeCount:(NSString*)attribute

return [super accessibilityArrayAttributeCount:attribute];
}
#endif

- (NSArray*)children
{
Expand Down
38 changes: 34 additions & 4 deletions accessible/mac/mozTableAccessible.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,24 @@
return nativeArray;
}

// Convert to an object without @ syntax
static inline id
ConvertToId(NSInteger val)
{
return [NSString stringWithFormat:@"%i", val];
}

// Missing from SDK 10.5
#if !defined(MAC_OS_X_VERSION_10_6) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)
#define __IntToNSString(x) ([NSString stringWithFormat:@"%i", x])
#define NSAccessibilityRowIndexRangeAttribute @"AXRowIndexRange"
#define NSAccessibilityColumnIndexRangeAttribute @"AXColumnIndexRange"
#define NSAccessibilityRowHeaderUIElementsAttribute @"AXRowHeaderUIElements"
#define NSAccessibilityColumnHeaderUIElementsAttribute @"AXColumnHeaderUIElements"
#define NSAccessibilityRowCountAttribute @"AXRowCount"
#define NSAccessibilityColumnCountAttribute @"AXColumnCount"
#endif

@implementation mozTablePartAccessible
- (BOOL)isLayoutTablePart;
{
Expand Down Expand Up @@ -83,10 +101,14 @@ - (NSArray*)additionalAccessibilityAttributeNames
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;

#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
NSArray* additionalAttributes = [super additionalAccessibilityAttributeNames];
if ([self isLayoutTablePart]) {
return additionalAttributes;
}
#else
NSArray* additionalAttributes = [[NSArray alloc] init];
#endif

static NSArray* tableAttrs = nil;
if (!tableAttrs) {
Expand All @@ -108,9 +130,9 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
TableAccessible* table = accWrap->AsTable();
if ([attribute isEqualToString:NSAccessibilityRowCountAttribute])
return @(table->RowCount());
return ConvertToId(table->RowCount());
if ([attribute isEqualToString:NSAccessibilityColumnCountAttribute])
return @(table->ColCount());
return ConvertToId(table->ColCount());
if ([attribute isEqualToString:NSAccessibilityRowsAttribute]) {
// Create a new array with the list of table rows.
NSMutableArray* nativeArray = [[NSMutableArray alloc] init];
Expand All @@ -127,9 +149,9 @@ - (id)accessibilityAttributeValue:(NSString*)attribute
}
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
if ([attribute isEqualToString:NSAccessibilityRowCountAttribute])
return @(proxy->TableRowCount());
return ConvertToId(proxy->TableRowCount());
if ([attribute isEqualToString:NSAccessibilityColumnCountAttribute])
return @(proxy->TableColumnCount());
return ConvertToId(proxy->TableColumnCount());
if ([attribute isEqualToString:NSAccessibilityRowsAttribute]) {
// Create a new array with the list of table rows.
NSMutableArray* nativeArray = [[NSMutableArray alloc] init];
Expand All @@ -155,10 +177,14 @@ - (NSArray*)additionalAccessibilityAttributeNames
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;

#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
NSArray* additionalAttributes = [super additionalAccessibilityAttributeNames];
if ([self isLayoutTablePart]) {
return additionalAttributes;
}
#else
NSArray* additionalAttributes = [[NSArray alloc] init];
#endif

static NSArray* tableRowAttrs = nil;
if (!tableRowAttrs) {
Expand Down Expand Up @@ -214,10 +240,14 @@ - (NSArray*)additionalAccessibilityAttributeNames
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;

#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
NSArray* additionalAttributes = [super additionalAccessibilityAttributeNames];
if ([self isLayoutTablePart]) {
return additionalAttributes;
}
#else
NSArray* additionalAttributes = [[NSArray alloc] init];
#endif

static NSArray* tableCellAttrs = nil;
if (!tableCellAttrs) {
Expand Down
3 changes: 3 additions & 0 deletions config/external/icu/data/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ LOCAL_INCLUDES += ['.']
if CONFIG['HAVE_YASM']:
USE_YASM = True
SOURCES += ['icudata.s']
elif CONFIG['OS_ARCH'] == 'Darwin':
if CONFIG['CPU_ARCH'] != 'ppc':
SOURCES += ['icudata_gas.S']
elif CONFIG['GNU_AS']:
SOURCES += ['icudata_gas.S']
2 changes: 1 addition & 1 deletion config/external/nspr/pr/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ elif CONFIG['OS_TARGET'] == 'Darwin':
)
SOURCES += [
'/nsprpub/pr/src/md/unix/darwin.c',
'/nsprpub/pr/src/md/unix/os_Darwin.s',
'/nsprpub/pr/src/md/unix/os_Darwin.S',
]
if not CONFIG['MOZ_IOS']:
DEFINES['HAVE_CRT_EXTERNS_H'] = True
Expand Down
36 changes: 18 additions & 18 deletions dom/bindings/BindingUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -1986,10 +1986,10 @@ GetCallbackFromCallbackObject(T& aObj)
}

static inline bool
AtomizeAndPinJSString(JSContext* cx, jsid& id, const char* chars)
AtomizeAndPinJSString(JSContext* cx, jsid& jid, const char* chars)
{
if (JSString *str = ::JS_AtomizeAndPinString(cx, chars)) {
id = INTERNED_STRING_TO_JSID(cx, str);
jid = INTERNED_STRING_TO_JSID(cx, str);
return true;
}
return false;
Expand Down Expand Up @@ -2156,17 +2156,17 @@ ConvertJSValueToUSVString(JSContext* cx, JS::Handle<JS::Value> v, T& result)

template<typename T>
inline bool
ConvertIdToString(JSContext* cx, JS::HandleId id, T& result, bool& isSymbol)
ConvertIdToString(JSContext* cx, JS::HandleId hid, T& result, bool& isSymbol)
{
if (MOZ_LIKELY(JSID_IS_STRING(id))) {
if (!AssignJSString(cx, result, JSID_TO_STRING(id))) {
if (MOZ_LIKELY(JSID_IS_STRING(hid))) {
if (!AssignJSString(cx, result, JSID_TO_STRING(hid))) {
return false;
}
} else if (JSID_IS_SYMBOL(id)) {
} else if (JSID_IS_SYMBOL(hid)) {
isSymbol = true;
return true;
} else {
JS::RootedValue nameVal(cx, js::IdToValue(id));
JS::RootedValue nameVal(cx, js::IdToValue(hid));
if (!ConvertJSValueToString(cx, nameVal, eStringify, eStringify, result)) {
return false;
}
Expand Down Expand Up @@ -2502,10 +2502,10 @@ class MOZ_STACK_CLASS NullableRootedUnion : public Nullable<T>,
};

inline bool
IdEquals(jsid id, const char* string)
IdEquals(jsid jid, const char* string)
{
return JSID_IS_STRING(id) &&
JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(id), string);
return JSID_IS_STRING(jid) &&
JS_FlatStringEqualsAscii(JSID_TO_FLAT_STRING(jid), string);
}

inline bool
Expand Down Expand Up @@ -2543,7 +2543,7 @@ Constructor(JSContext* cx, unsigned argc, JS::Value* vp);
bool
XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj,
JS::Handle<jsid> id,
JS::Handle<jsid> jid,
JS::MutableHandle<JS::PropertyDescriptor> desc,
bool& cacheOnHolder);

Expand All @@ -2560,7 +2560,7 @@ XrayResolveOwnProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
*/
bool
XrayDefineProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JS::Handle<JSObject*> obj, JS::Handle<jsid> jid,
JS::Handle<JS::PropertyDescriptor> desc,
JS::ObjectOpResult &result,
bool *defined);
Expand Down Expand Up @@ -2635,7 +2635,7 @@ XrayGetExpandoClass(JSContext* cx, JS::Handle<JSObject*> obj);
*/
bool
XrayDeleteNamedProperty(JSContext* cx, JS::Handle<JSObject*> wrapper,
JS::Handle<JSObject*> obj, JS::Handle<jsid> id,
JS::Handle<JSObject*> obj, JS::Handle<jsid> jid,
JS::ObjectOpResult& opresult);

/**
Expand Down Expand Up @@ -3225,26 +3225,26 @@ CreateGlobal(JSContext* aCx, T* aNative, nsWrapperCache* aCache,
*/
class PinnedStringId
{
jsid id;
jsid jid;

public:
PinnedStringId() : id(JSID_VOID) {}
PinnedStringId() : jid(JSID_VOID) {}

bool init(JSContext *cx, const char *string) {
JSString* str = JS_AtomizeAndPinString(cx, string);
if (!str)
return false;
id = INTERNED_STRING_TO_JSID(cx, str);
jid = INTERNED_STRING_TO_JSID(cx, str);
return true;
}

operator const jsid& () {
return id;
return jid;
}

operator JS::Handle<jsid> () {
/* This is safe because we have pinned the string. */
return JS::Handle<jsid>::fromMarkedLocation(&id);
return JS::Handle<jsid>::fromMarkedLocation(&jid);
}
};

Expand Down
2 changes: 2 additions & 0 deletions dom/geolocation/nsGeolocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,12 @@ nsresult nsGeolocationService::Init()
#endif

#ifdef MOZ_WIDGET_COCOA
#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
if (Preferences::GetBool("geo.provider.use_corelocation", true)) {
mProvider = new CoreLocationLocationProvider();
}
#endif
#endif

#ifdef XP_WIN
if (Preferences::GetBool("geo.provider.ms-windows-location", false) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@
mTask = nullptr;
}

// NSSpeechSynthesizerDelegate is not a protocol in SDK 10.5
#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
@interface SpeechDelegate : NSObject<NSSpeechSynthesizerDelegate>
#else
@interface SpeechDelegate : NSObject
#endif
{
@private
SpeechTaskCallback* mCallback;
Expand Down Expand Up @@ -293,7 +298,8 @@ explicit EnumVoicesRunnable(OSXSpeechSynthesizerService* aSpeechService)
NSArray* voices = [NSSpeechSynthesizer availableVoices];
NSString* defaultVoice = [NSSpeechSynthesizer defaultVoice];

for (NSString* voice in voices) {
for (NSUInteger i = 0; i < [voices count]; i++) {
NSString* voice = (NSString *)[voices objectAtIndex:i];
OSXVoice item;

NSDictionary* attr = [NSSpeechSynthesizer attributesForVoice:voice];
Expand Down
4 changes: 2 additions & 2 deletions dom/plugins/ipc/PluginInterposeOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ void OnPluginShowWindow(uint32_t window_id,
plugin_fullscreen_windows_set_.end())) {
plugin_fullscreen_windows_set_.insert(window_id);

nsCocoaUtils::HideOSChromeOnScreen(true);
nsCocoaUtils::HideOSChromeOnScreen(true, nil);
}
}

Expand All @@ -606,7 +606,7 @@ static void ReleasePluginFullScreen(pid_t plugin_pid) {
// focus, but give it back to the plugin process if requested.
ActivateProcess(base::GetCurrentProcId());

nsCocoaUtils::HideOSChromeOnScreen(false);
nsCocoaUtils::HideOSChromeOnScreen(false, nil);

if (plugin_pid != -1) {
ActivateProcess(plugin_pid);
Expand Down
16 changes: 16 additions & 0 deletions dom/plugins/ipc/PluginUtilsOSX.mm
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,23 @@ - (void)setRemoteEvents:(RemoteProcessEvents) remoteEvents pluginModule:(void*)
NSMenu* nsmenu = reinterpret_cast<NSMenu*>(aMenu);
NSPoint screen_point = ::NSMakePoint(aX, aY);

#if defined(MAC_OS_X_VERSION_10_6) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6)
[nsmenu popUpMenuPositioningItem:nil atLocation:screen_point inView:nil];
#else
NSEvent *event = [[NSApplication sharedApplication] currentEvent];
NSWindow *window = [event window];
NSView *view = [window contentView];
NSEvent* fake = [NSEvent mouseEventWithType:NSRightMouseDown
location:screen_point
modifierFlags:0
timestamp:[event timestamp]
windowNumber:[window windowNumber]
context:[NSGraphicsContext currentContext]
eventNumber:1
clickCount:1
pressure:0.0];
[NSMenu popUpContextMenu:nsmenu withEvent:fake forView:view];
#endif

if (pluginModule) {
[eventTimer invalidate];
Expand Down
2 changes: 1 addition & 1 deletion dom/system/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolkit = CONFIG['MOZ_WIDGET_TOOLKIT']

if toolkit == 'windows':
DIRS += ['windows']
elif toolkit == 'cocoa':
elif toolkit == 'cocoa' and CONFIG['CPU_ARCH'] != 'ppc':
DIRS += ['mac']
elif toolkit in ('gtk2', 'gtk3'):
DIRS += ['linux']
Expand Down
5 changes: 5 additions & 0 deletions gfx/2d/PathCG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
#include "Logging.h"
#include "PathHelpers.h"

#if !defined(MAC_OS_X_VERSION_10_6) || (MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_6)
// CGContextCopyPath has existed since 10.2, but was not public until 10.6.
extern "C" CGPathRef CGContextCopyPath(CGContextRef cg);
#endif

namespace mozilla {
namespace gfx {

Expand Down
2 changes: 2 additions & 0 deletions gfx/gl/GLContextProviderCGL.mm
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ bool UseDoubleBufferedWindows() const {

static const NSOpenGLPixelFormatAttribute kAttribs_offscreen_coreProfile[] = {
NSOpenGLPFAAccelerated,
#if defined(MAC_OS_X_VERSION_10_7) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7)
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion3_2Core,
#endif
0
};

Expand Down
6 changes: 3 additions & 3 deletions gfx/graphite2/src/MozGrMalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

#include "mozilla/mozalloc.h"

#define malloc moz_xmalloc
#define calloc moz_xcalloc
#define realloc moz_xrealloc
#define malloc(a) moz_xmalloc(a)
#define calloc(a, b) moz_xcalloc(a, b)
#define realloc(a, b) moz_xrealloc(a, b)

#endif // MOZ_GR_MALLOC_H
Loading

0 comments on commit 8cffdc2

Please sign in to comment.