Commit 931b0f03 authored by mark@chromium.org's avatar mark@chromium.org

[Mac] Rely on science, not chance, to get the proper definition of the macro...

[Mac] Rely on science, not chance, to get the proper definition of the macro NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES.

NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES is used in
{Int,Float}{Point,Size,Rect}.h to determine whether to provide distinct
conversion constructors and operators for Foundation NS{Point,Size,Rect} types
in addition to the CoreGraphics CG{Point,Size,Rect} types. When this macro is
defined (as in 64-bit Mac OS X), the NS and CG types are identical and no
additional overloads are needed. When not defined (as in 32-bit Mac OS X), the
types are distinct and additional overrides are needed for the NS types.

This macro is set (or not) by <Foundation/NSGeometry.h>. It is an error to
consider this macro without first #importing this header or its umbrella,
<Foundation/Foundation.h> or <Cocoa/Cocoa.h>. It is also an error to #import
these headers from non-Objective-C code, but in that case, it is impossible to
correctly use the NS types. The net effect is that the overloads for the
distinct NS types will available in Objective-C translation units when the
types are in fact distinct from the CG ones, and not available in
non-Objective-C translation units where they wouldn't be useful anyway, even
if the types are distinct. Where the types are not distinct, the conversion
constructor and operator for CG types is able to handle NS ones as well.

This backs out a previous hack fix for this problem, Blink r169826.

BUG=355576
TEST=compile, both 32-bit and 64-bit

Review URL: https://codereview.chromium.org/208333020

git-svn-id: svn://svn.chromium.org/blink/trunk@169976 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent e9454f0a
......@@ -35,10 +35,8 @@
#if OS(MACOSX)
typedef struct CGPoint CGPoint;
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#endif
......@@ -133,7 +131,7 @@ public:
#if OS(MACOSX)
FloatPoint(const CGPoint&);
operator CGPoint() const;
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
FloatPoint(const NSPoint&);
operator NSPoint() const;
#endif
......
......@@ -32,10 +32,9 @@
#if OS(MACOSX)
typedef struct CGRect CGRect;
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#endif
......@@ -167,7 +166,7 @@ public:
#if OS(MACOSX)
FloatRect(const CGRect&);
operator CGRect() const;
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
FloatRect(const NSRect&);
operator NSRect() const;
#endif
......
......@@ -31,14 +31,11 @@
#include "platform/geometry/IntPoint.h"
#include "wtf/MathExtras.h"
#if OS(MACOSX)
typedef struct CGSize CGSize;
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
typedef struct _NSSize NSSize;
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#endif
......@@ -108,7 +105,7 @@ public:
#if OS(MACOSX)
explicit FloatSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit FloatSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
......
......@@ -32,10 +32,9 @@
#if OS(MACOSX)
typedef struct CGPoint CGPoint;
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGPoint NSPoint;
#else
typedef struct _NSPoint NSPoint;
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#endif
......@@ -92,7 +91,7 @@ public:
explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
operator CGPoint() const;
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lossy
operator NSPoint() const;
#endif
......
......@@ -33,10 +33,8 @@
#if OS(MACOSX)
typedef struct CGRect CGRect;
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGRect NSRect;
#else
typedef struct _NSRect NSRect;
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#endif
......@@ -154,7 +152,7 @@ public:
#if OS(MACOSX)
operator CGRect() const;
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
operator NSRect() const;
#endif
#endif
......@@ -195,7 +193,7 @@ inline bool operator!=(const IntRect& a, const IntRect& b)
#if OS(MACOSX)
PLATFORM_EXPORT IntRect enclosingIntRect(const CGRect&);
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
PLATFORM_EXPORT IntRect enclosingIntRect(const NSRect&);
#endif
#endif
......
......@@ -32,10 +32,8 @@
#if OS(MACOSX)
typedef struct CGSize CGSize;
#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
typedef struct CGSize NSSize;
#else
typedef struct _NSSize NSSize;
#ifdef __OBJC__
#import <Foundation/Foundation.h>
#endif
#endif
......@@ -118,7 +116,7 @@ public:
explicit IntSize(const CGSize&); // don't do this implicitly since it's lossy
operator CGSize() const;
#if !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
#if defined(__OBJC__) && !defined(NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES)
explicit IntSize(const NSSize &); // don't do this implicitly since it's lossy
operator NSSize() const;
#endif
......
......@@ -29,11 +29,6 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// Temporary hack to avoid breaking build during WebFrame -> WebLocalFrame transition.
#if __LP64__
#define NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES 1
#endif
#include "config.h"
#include "WebSubstringUtil.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment