JavaScriptCore:

        Reviewed by Darin.

        - patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10176
          Make WebCore compile with -Wundef

          * Adds -Wundef flag to Xcode project
          * Converts #ifs to #ifdef and #ifndefs where needed.
          * Added #define YYMAXDEPTH 10000 in kjs/grammar.y
            to fix a warning from within Bison.

        * JavaScriptCore.xcodeproj/project.pbxproj:
        * bindings/jni/jni_jsobject.cpp:
        (JavaJSObject::getSlot):
        (JavaJSObject::setSlot):
        * bindings/npapi.h:
        * bindings/objc/objc_class.mm:
        (KJS::Bindings::ObjcClass::methodsNamed):
        (KJS::Bindings::ObjcClass::fieldNamed):
        * bindings/objc/objc_instance.mm:
        (ObjcInstance::invokeMethod):
        * bindings/objc/objc_runtime.mm:
        (ObjcMethod::getMethodSignature):
        (ObjcField::name):
        (ObjcField::type):
        * kjs/grammar.y:
        * kjs/identifier.h:

JavaScriptGlue:

        Reviewed by Darin.

        - patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10176
          Make WebCore compile with -Wundef

          * Adds -Wundef flag to Xcode project

        * JavaScriptGlue.xcodeproj/project.pbxproj:

WebCore:

        Reviewed by Darin.

        - patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10176
          Make WebCore compile with -Wundef

          * Adds -Wundef flag to Xcode project
          * Converts #ifs to #ifdef and #ifndefs where needed.
          * Replaces #ifdef WIN32 with #if PLATFORM(WIN_OS) or PLATFORM(WIN)
            (and in one instance in config.h with #if !COMPILER(MSVC))
          * Added #define YYMAXDEPTH 10000 in XPathGrammar.y and CSSGrammar.y
            to fix a warning from within Bison.
          * Cleaned up style a little in surrounding code.

        * WebCore.xcodeproj/project.pbxproj:
        * bridge/mac/WebCoreAXObject.mm:
        (-[WebCoreAXObject doAXTextMarkerRangeForUnorderedTextMarkers:]):
        * config.h:
        * css/CSSGrammar.y:
        * css/MediaFeatureNames.cpp:
        * css/MediaFeatureNames.h:
        * css/cssparser.cpp:
        * dom/ContainerNode.cpp:
        (WebCore::ContainerNode::setActive):
        * dom/Element.cpp:
        (WebCore::Element::attach):
        * dom/Element.h:
        * dom/EventNames.cpp:
        * dom/EventNames.h:
        * dom/NamedAttrMap.h:
        * dom/Position.cpp:
        * dom/QualifiedName.cpp:
        * dom/QualifiedName.h:
        * dom/Range.h:
        * dom/XMLTokenizer.cpp:
        (WebCore::XMLTokenizer::error):
        * html/HTMLTokenizer.cpp:
        (WebCore::HTMLTokenizer::scriptHandler):
        (WebCore::HTMLTokenizer::scriptExecution):
        (WebCore::HTMLTokenizer::parseTag):
        (WebCore::HTMLTokenizer::continueProcessing):
        (WebCore::HTMLTokenizer::write):
        (WebCore::HTMLTokenizer::timerFired):
        (WebCore::HTMLTokenizer::notifyFinished):
        * kcanvas/device/quartz/KCanvasFilterQuartz.h:
        * kcanvas/device/quartz/KRenderingDeviceQuartz.h:
        * ksvg2/css/SVGRenderStyle.h:
        * ksvg2/css/SVGRenderStyleDefs.h:
        * ksvg2/scripts/make_names.pl:
        * loader/CachedResource.h:
        * loader/LoaderFunctions.h:
        * loader/loader.h:
        * page/Frame.cpp:
        * page/FrameTree.cpp:
        * page/FrameView.cpp:
        (WebCore::FrameView::clear):
        (WebCore::FrameView::layout):
        (WebCore::FrameView::layoutTimerFired):
        (WebCore::FrameView::scheduleRelayout):
        (WebCore::FrameView::unscheduleRelayout):
        * platform/AtomicString.cpp:
        * platform/AtomicString.h:
        * platform/Cursor.h:
        * platform/DeprecatedArray.h:
        * platform/DeprecatedString.cpp:
        (WebCore::allocateHandle):
        (WebCore::initializeHandleNodeBlock):
        (WebCore::freeHandle):
        * platform/FloatPoint.h:
        * platform/FloatRect.h:
        * platform/FloatSize.h:
        * platform/GraphicsContext.h:
        * platform/Image.h:
        * platform/IntPoint.h:
        * platform/IntRect.h:
        (WebCore::IntRect::inflateX):
        (WebCore::IntRect::inflateY):
        * platform/IntSize.h:
        * platform/PlatformKeyboardEvent.h:
        * platform/PlatformMouseEvent.h:
        * platform/PlatformString.h:
        * platform/ResourceLoader.h:
        * platform/ResourceLoaderInternal.h:
        (WebCore::ResourceLoaderInternal::ResourceLoaderInternal):
        * platform/ScrollView.h:
        * platform/StaticConstructors.h:
        * platform/StreamingTextDecoderICU.cpp:
        (WebCore::StreamingTextDecoderICU::convert):
        * platform/StringImpl.h:
        * platform/Widget.h:
        * platform/mac/BlockExceptions.mm:
        * platform/mac/ColorMac.mm:
        (+[WebCoreControlTintObserver WebCore]):
        * platform/mac/FloatPointMac.mm:
        * platform/mac/FloatRectMac.mm:
        * platform/mac/FloatSizeMac.mm:
        * platform/mac/FontMac.mm:
        * platform/mac/GraphicsContextMac.mm:
        (WebCore::GraphicsContext::drawFocusRing):
        * platform/mac/IntPointMac.mm:
        * platform/mac/IntRectMac.mm:
        * platform/mac/IntSizeMac.mm:
        * platform/mac/WebCoreSystemInterface.h:
        * rendering/RenderBlock.h:
        * rendering/RenderTableCell.h:
        * rendering/bidi.cpp:
        (WebCore::appendRun):
        (WebCore::RenderBlock::layoutInlineChildren):
        * xml/XSLTProcessor.cpp:
        (WebCore::parseErrorFunc):
        * xpath/impl/XPathGrammar.y:

WebKit:

        Reviewed by Darin.

        - patch for http://bugzilla.opendarwin.org/show_bug.cgi?id=10176
          Make WebCore compile with -Wundef

          * Adds -Wundef flag to Xcode project
          * Converts #ifs to #ifdef and #ifndefs where needed.

        * Carbon/CarbonUtils.m:
        * Carbon/CarbonWindowAdapter.m:
        * Carbon/HIViewAdapter.m:
        (+[NSView bindHIViewToNSView:nsView:]):
        * Carbon/HIWebView.m:
        (HIWebViewEventHandler):
        * Misc/WebFileDatabase.m:
        (UniqueFilePathForKey):
        * Misc/WebNSWindowExtras.m:
        (swizzleInstanceMethod):
        * Misc/WebTypesInternal.h:
        * Plugins/WebNetscapeDeprecatedFunctions.c:
        * Plugins/WebNetscapeDeprecatedFunctions.h:
        * Plugins/WebNetscapePluginPackage.h:
        * Plugins/WebNetscapePluginPackage.m:
        (-[WebNetscapePluginPackage unloadWithoutShutdown]):
        (-[WebNetscapePluginPackage load]):
        * WebKit.xcodeproj/project.pbxproj:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@15781 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/platform/AtomicString.cpp b/WebCore/platform/AtomicString.cpp
index 90a7cd6..0ae8379 100644
--- a/WebCore/platform/AtomicString.cpp
+++ b/WebCore/platform/AtomicString.cpp
@@ -22,7 +22,7 @@
 
 #include "config.h"
 
-#if AVOID_STATIC_CONSTRUCTORS
+#ifdef AVOID_STATIC_CONSTRUCTORS
 #define ATOMICSTRING_HIDE_GLOBALS 1
 #endif
 
diff --git a/WebCore/platform/AtomicString.h b/WebCore/platform/AtomicString.h
index de3a8ab..840ba5b 100644
--- a/WebCore/platform/AtomicString.h
+++ b/WebCore/platform/AtomicString.h
@@ -114,7 +114,7 @@
 inline bool equalIgnoringCase(const String& a, const AtomicString& b) { return equalIgnoringCase(a.impl(), b.impl()); }
 
 // Define external global variables for the commonly used atomic strings.
-#if !ATOMICSTRING_HIDE_GLOBALS
+#ifndef ATOMICSTRING_HIDE_GLOBALS
     extern const AtomicString nullAtom;
     extern const AtomicString emptyAtom;
     extern const AtomicString textAtom;
@@ -122,6 +122,6 @@
     extern const AtomicString starAtom;
 #endif
 
-}
+} // namespace WebCore
 
-#endif
+#endif // AtomicString_h
diff --git a/WebCore/platform/Cursor.h b/WebCore/platform/Cursor.h
index 94e9f31..ad4751a 100644
--- a/WebCore/platform/Cursor.h
+++ b/WebCore/platform/Cursor.h
@@ -26,7 +26,9 @@
 #ifndef CURSOR_H
 #define CURSOR_H
 
-#ifdef WIN32
+#include <wtf/Platform.h>
+
+#if PLATFORM(WIN)
 #include <windows.h>
 #elif PLATFORM(GDK)
 #include <gdk/gdk.h>
@@ -44,7 +46,7 @@
 
     class Image;
 
-#ifdef WIN32
+#if PLATFORM(WIN)
     typedef HCURSOR PlatformCursor;
 #elif defined(__APPLE__)
     typedef NSCursor* PlatformCursor;
@@ -92,6 +94,6 @@
     const Cursor& columnResizeCursor();
     const Cursor& rowResizeCursor();
 
-}
+} // namespace WebCore
 
-#endif
+#endif // CURSOR_H
diff --git a/WebCore/platform/DeprecatedArray.h b/WebCore/platform/DeprecatedArray.h
index a4e202e..239adc6 100644
--- a/WebCore/platform/DeprecatedArray.h
+++ b/WebCore/platform/DeprecatedArray.h
@@ -27,6 +27,7 @@
 #define ARRAY_H_
 
 #include "ArrayImpl.h"
+#include <wtf/Platform.h>
 
 namespace WebCore {
 
@@ -51,7 +52,7 @@
 
     T &operator[](int i) { return *(T *)impl.at(i); }
     const T &operator[](int i) const { return *(T *)impl.at(i); }
-#if WIN32
+#if PLATFORM(WIN_OS)
     // FIXME: Look into this strange compile error on Win32.
     T &operator[](unsigned i) { return *(T *)impl.at(i); }
     const T &operator[](unsigned i) const { return *(T *)impl.at(i); }
@@ -66,6 +67,6 @@
 
 typedef DeprecatedArray<char> DeprecatedByteArray;
 
-}
+} // namespace WebCore
 
-#endif
+#endif // ARRAY_H_
diff --git a/WebCore/platform/DeprecatedString.cpp b/WebCore/platform/DeprecatedString.cpp
index c8fd957..342a17c 100644
--- a/WebCore/platform/DeprecatedString.cpp
+++ b/WebCore/platform/DeprecatedString.cpp
@@ -31,9 +31,11 @@
 #include "TextEncoding.h"
 #include <kjs/dtoa.h>
 #include <kjs/identifier.h>
-#include <stdio.h>
 #include <stdarg.h>
-#ifdef WIN32
+#include <stdio.h>
+#include <wtf/Platform.h>
+
+#if PLATFORM(WIN_OS)
 #include <windows.h>
 #endif
 
@@ -72,7 +74,7 @@
 
 static inline DeprecatedStringData **allocateHandle()
 {
-#if CHECK_FOR_HANDLE_LEAKS
+#ifdef CHECK_FOR_HANDLE_LEAKS
     return static_cast<DeprecatedStringData **>(fastMalloc(sizeof(DeprecatedStringData *)));
 #endif
 
@@ -814,7 +816,7 @@
     }
 }
 
-#ifdef WIN32
+#if PLATFORM(WIN_OS)
 inline int strncasecmp(const char *first, const char *second, size_t maxLength)
 {
     return _strnicmp(first, second, maxLength);
@@ -2437,7 +2439,7 @@
     HandleNode* block;
     HandleNode* aNode;
 
-#ifdef WIN32
+#if PLATFORM(WIN_OS)
     block = (HandleNode*)VirtualAlloc(0, pageSize, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
 #else
     block = (HandleNode*)valloc(pageSize);
@@ -2506,7 +2508,7 @@
 
 void freeHandle(DeprecatedStringData **_free)
 {
-#if CHECK_FOR_HANDLE_LEAKS
+#ifdef CHECK_FOR_HANDLE_LEAKS
     fastFree(_free);
     return;
 #endif
diff --git a/WebCore/platform/FloatPoint.h b/WebCore/platform/FloatPoint.h
index 5b6cf3a..b25aa0f 100644
--- a/WebCore/platform/FloatPoint.h
+++ b/WebCore/platform/FloatPoint.h
@@ -33,7 +33,7 @@
 
 typedef struct CGPoint CGPoint;
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGPoint NSPoint;
 #else
 typedef struct _NSPoint NSPoint;
@@ -63,7 +63,7 @@
     FloatPoint(const CGPoint&);
     operator CGPoint() const;
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
     FloatPoint(const NSPoint&);
     operator NSPoint() const;
 #endif
diff --git a/WebCore/platform/FloatRect.h b/WebCore/platform/FloatRect.h
index 06f5b2d..0fb7c89 100644
--- a/WebCore/platform/FloatRect.h
+++ b/WebCore/platform/FloatRect.h
@@ -33,7 +33,7 @@
 
 typedef struct CGRect CGRect;
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGRect NSRect;
 #else
 typedef struct _NSRect NSRect;
@@ -100,7 +100,7 @@
     FloatRect(const CGRect&);
     operator CGRect() const;
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
     FloatRect(const NSRect&);
     operator NSRect() const;
 #endif
diff --git a/WebCore/platform/FloatSize.h b/WebCore/platform/FloatSize.h
index 346fc17..618815a 100644
--- a/WebCore/platform/FloatSize.h
+++ b/WebCore/platform/FloatSize.h
@@ -31,7 +31,7 @@
 
 typedef struct CGSize CGSize;
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGSize NSSize;
 #else
 typedef struct _NSSize NSSize;
@@ -118,6 +118,6 @@
     return a.width() != b.width() || a.height() != b.height();
 }
 
-}
+} // namespace WebCore
 
-#endif
+#endif // FloatSize_h
diff --git a/WebCore/platform/GraphicsContext.h b/WebCore/platform/GraphicsContext.h
index 030741c..3bc3c66 100644
--- a/WebCore/platform/GraphicsContext.h
+++ b/WebCore/platform/GraphicsContext.h
@@ -26,18 +26,20 @@
 #ifndef GraphicsContext_h
 #define GraphicsContext_h
 
-#include "Font.h"
 #include "FloatRect.h"
+#include "Font.h"
 #include "Image.h"
 #include "IntRect.h"
 #include "Pen.h"
 #include "TextDirection.h"
-#include <wtf/Noncopyable.h>
 #include <unicode/umachine.h>
+#include <wtf/Noncopyable.h>
+#include <wtf/Platform.h>
 
+// FIXME: how should Cairo figure into the platform macros?
 #if __APPLE__
 typedef struct CGContext PlatformGraphicsContext;
-#elif WIN32
+#elif PLATFORM(WIN)
 typedef struct HDC__* HDC;
 typedef struct _cairo PlatformGraphicsContext;
 #elif PLATFORM(GDK)
@@ -158,7 +160,7 @@
         KRenderingDeviceContext* createRenderingDeviceContext();
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
         GraphicsContext(HDC); // FIXME: To be removed.
 #endif
 
@@ -177,6 +179,6 @@
         GraphicsContextPlatformPrivate* m_data;
     };
 
-}
+} // namespace WebCore
 
-#endif
+#endif // GraphicsContext_h
diff --git a/WebCore/platform/Image.h b/WebCore/platform/Image.h
index 4b071da..8d1c8a1 100644
--- a/WebCore/platform/Image.h
+++ b/WebCore/platform/Image.h
@@ -34,7 +34,7 @@
 #include "FloatSize.h"
 
 #if __APPLE__
-#if __OBJC__
+#ifdef __OBJC__
 @class NSImage;
 #else
 class NSImage;
diff --git a/WebCore/platform/IntPoint.h b/WebCore/platform/IntPoint.h
index 0291ea3..278c779 100644
--- a/WebCore/platform/IntPoint.h
+++ b/WebCore/platform/IntPoint.h
@@ -27,20 +27,21 @@
 #define INTPOINT_H_
 
 #include "IntSize.h"
+#include <wtf/Platform.h>
 
 #if __APPLE__
 
 typedef struct CGPoint CGPoint;
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGPoint NSPoint;
 #else
 typedef struct _NSPoint NSPoint;
 #endif
 
-#endif
+#endif // __APPLE__
 
-#if WIN32
+#if PLATFORM(WIN)
 typedef struct tagPOINT POINT;
 #endif
 
@@ -64,14 +65,14 @@
     explicit IntPoint(const CGPoint&); // don't do this implicitly since it's lossy
     operator CGPoint() const;
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
     explicit IntPoint(const NSPoint&); // don't do this implicitly since it's lossy
     operator NSPoint() const;
 #endif
 
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
     IntPoint(const POINT&);
     operator POINT() const;
 #endif
@@ -117,6 +118,6 @@
     return a.x() != b.x() || a.y() != b.y();
 }
 
-}
+} // namespace WebCore
 
-#endif
+#endif // INTPOINT_H_
diff --git a/WebCore/platform/IntRect.h b/WebCore/platform/IntRect.h
index cde166f..3fd0664 100644
--- a/WebCore/platform/IntRect.h
+++ b/WebCore/platform/IntRect.h
@@ -27,20 +27,21 @@
 #define INTRECT_H_
 
 #include "IntPoint.h"
+#include <wtf/Platform.h>
 
 #if __APPLE__
 
 typedef struct CGRect CGRect;
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGRect NSRect;
 #else
 typedef struct _NSRect NSRect;
 #endif
 
-#endif
+#endif // __APPLE__
 
-#if WIN32
+#if PLATFORM(WIN)
 typedef struct tagRECT RECT;
 #endif
 
@@ -90,18 +91,20 @@
     void intersect(const IntRect&);
     void unite(const IntRect&);
 
-    void inflateX(int dx) {
+    void inflateX(int dx)
+    {
         m_location.setX(m_location.x() - dx);
         m_size.setWidth(m_size.width() + dx + dx);
     }
-    void inflateY(int dy) {
+    void inflateY(int dy)
+    {
         m_location.setY(m_location.y() - dy);
         m_size.setHeight(m_size.height() + dy + dy);
     }
     void inflate(int d) { inflateX(d); inflateY(d); }
     void scale(float s);
 
-#if WIN32
+#if PLATFORM(WIN)
     IntRect(const RECT&);
     operator RECT() const;
 #endif
@@ -110,7 +113,7 @@
 
     operator CGRect() const;
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
     operator NSRect() const;
 #endif
 
@@ -149,7 +152,7 @@
 
 IntRect enclosingIntRect(const CGRect&);
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 IntRect enclosingIntRect(const NSRect&);
 
@@ -157,6 +160,6 @@
 
 #endif
 
-}
+} // namespace WebCore
 
-#endif
+#endif // INTRECT_H_
diff --git a/WebCore/platform/IntSize.h b/WebCore/platform/IntSize.h
index bd0cf38..d2cb6c5 100644
--- a/WebCore/platform/IntSize.h
+++ b/WebCore/platform/IntSize.h
@@ -26,19 +26,21 @@
 #ifndef INTSIZE_H_
 #define INTSIZE_H_
 
+#include <wtf/Platform.h>
+
 #if __APPLE__
 
 typedef struct CGSize CGSize;
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGSize NSSize;
 #else
 typedef struct _NSSize NSSize;
 #endif
 
-#endif
+#endif // __APPLE__
 
-#if WIN32
+#if PLATFORM(WIN)
 typedef struct tagSIZE SIZE;
 #endif
 
@@ -86,7 +88,7 @@
 
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
     IntSize(const SIZE&);
     operator SIZE() const;
 #endif
@@ -134,6 +136,6 @@
     return a.width() != b.width() || a.height() != b.height();
 }
 
-}
+} // namespace WebCore
 
-#endif
+#endif // INTSIZE_H_
diff --git a/WebCore/platform/PlatformKeyboardEvent.h b/WebCore/platform/PlatformKeyboardEvent.h
index 9470e3e..4cd984c 100644
--- a/WebCore/platform/PlatformKeyboardEvent.h
+++ b/WebCore/platform/PlatformKeyboardEvent.h
@@ -27,6 +27,7 @@
 #define PlatformKeyboardEvent_h
 
 #include "PlatformString.h"
+#include <wtf/Platform.h>
 
 #ifdef __OBJC__
 @class NSEvent;
@@ -34,7 +35,7 @@
 class NSEvent;
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
 typedef struct HWND__ *HWND;
 typedef unsigned    WPARAM;
 typedef long        LPARAM;
@@ -65,7 +66,7 @@
         PlatformKeyboardEvent(NSEvent*, bool forceAutoRepeat = false);
 #endif
 
-#ifdef WIN32
+#if PLATFORM(WIN)
         PlatformKeyboardEvent(HWND, WPARAM, LPARAM);
 #endif
 
diff --git a/WebCore/platform/PlatformMouseEvent.h b/WebCore/platform/PlatformMouseEvent.h
index 13be8d1..8f74077 100644
--- a/WebCore/platform/PlatformMouseEvent.h
+++ b/WebCore/platform/PlatformMouseEvent.h
@@ -27,6 +27,7 @@
 #define PlatformMouseEvent_h
 
 #include "IntPoint.h"
+#include <wtf/Platform.h>
 
 #if __APPLE__
 #ifdef __OBJC__
@@ -36,7 +37,7 @@
 #endif
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
 typedef struct HWND__* HWND;
 typedef unsigned WPARAM;
 typedef long LPARAM;
@@ -93,7 +94,7 @@
 #if __APPLE__
         PlatformMouseEvent(NSEvent*);
 #endif
-#if WIN32
+#if PLATFORM(WIN)
         PlatformMouseEvent(HWND, WPARAM, LPARAM, int clickCount);
 #endif
 #if PLATFORM(GDK) 
diff --git a/WebCore/platform/PlatformString.h b/WebCore/platform/PlatformString.h
index 992ba49..d1dae8f 100644
--- a/WebCore/platform/PlatformString.h
+++ b/WebCore/platform/PlatformString.h
@@ -133,7 +133,7 @@
     String(CFStringRef);
     CFStringRef createCFString() const { return m_impl ? m_impl->createCFString() : CFSTR(""); }
 #endif
-#if __OBJC__
+#ifdef __OBJC__
     String(NSString*);
     operator NSString*() const { if (!m_impl) return @""; return *m_impl; }
 #endif
diff --git a/WebCore/platform/ResourceLoader.h b/WebCore/platform/ResourceLoader.h
index faa84a5..c06992a 100644
--- a/WebCore/platform/ResourceLoader.h
+++ b/WebCore/platform/ResourceLoader.h
@@ -26,12 +26,13 @@
 #ifndef ResourceLoader_H_
 #define ResourceLoader_H_
 
+#include "ResourceLoaderClient.h" // for PlatformResponse
 #include "StringHash.h"
 #include "Timer.h"
-#include "ResourceLoaderClient.h" // for PlatformResponse
 #include <wtf/HashMap.h>
+#include <wtf/Platform.h>
 
-#ifdef WIN32
+#if PLATFORM(WIN)
 typedef unsigned long DWORD;
 typedef unsigned long DWORD_PTR;
 typedef void* LPVOID;
@@ -82,7 +83,7 @@
 #if __APPLE__
     void setLoader(WebCoreResourceLoaderImp*);
 #endif
-#if WIN32
+#if PLATFORM(WIN)
     void fileLoadTimer(Timer<ResourceLoader>* timer);
     friend void __stdcall transferJobStatusCallback(HINTERNET, DWORD_PTR, DWORD, LPVOID, DWORD);
     friend LRESULT __stdcall ResourceLoaderWndProc(HWND, unsigned message, WPARAM, LPARAM);
diff --git a/WebCore/platform/ResourceLoaderInternal.h b/WebCore/platform/ResourceLoaderInternal.h
index 3e37508..f228894 100644
--- a/WebCore/platform/ResourceLoaderInternal.h
+++ b/WebCore/platform/ResourceLoaderInternal.h
@@ -27,11 +27,12 @@
 #ifndef ResourceLoaderInternal_H_
 #define ResourceLoaderInternal_H_
 
-#include "KURL.h"
 #include "FormData.h"
+#include "KURL.h"
 #include <wtf/HashMap.h>
+#include <wtf/Platform.h>
 
-#ifdef WIN32
+#if PLATFORM(WIN)
 typedef void* HANDLE;
 #endif
 
@@ -59,7 +60,7 @@
             , loader(nil)
             , response(nil)
 #endif
-#if WIN32
+#if PLATFORM(WIN)
             , m_fileHandle(0)
             , m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
             , m_resourceHandle(0)
@@ -89,7 +90,7 @@
             , loader(nil)
             , response(nil)
 #endif
-#if WIN32
+#if PLATFORM(WIN)
             , m_fileHandle(0)
             , m_fileLoadTimer(job, &ResourceLoader::fileLoadTimer)
             , m_resourceHandle(0)
@@ -125,7 +126,7 @@
         WebCoreResourceLoaderImp* loader;
         NSURLResponse* response;
 #endif
-#if WIN32
+#if PLATFORM(WIN)
         HANDLE m_fileHandle;
         Timer<ResourceLoader> m_fileLoadTimer;
         HINTERNET m_resourceHandle;
diff --git a/WebCore/platform/ScrollView.h b/WebCore/platform/ScrollView.h
index 585d718..af495d4 100644
--- a/WebCore/platform/ScrollView.h
+++ b/WebCore/platform/ScrollView.h
@@ -28,6 +28,7 @@
 
 #include "ScrollBarMode.h"
 #include "Widget.h"
+#include <wtf/Platform.h>
 
 namespace WebCore {
     class FloatRect;
@@ -76,7 +77,7 @@
         NSView* getDocumentView() const;
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
         ScrollView();
         ~ScrollView();
     private:
@@ -87,7 +88,7 @@
         ScrollViewPrivate* m_data;
 #endif
 
-#if  PLATFORM(GDK)
+#if PLATFORM(GDK)
         void updateView(const IntRect&, bool now = false);
         virtual void setDrawable(GdkDrawable* drawable);
         virtual void setFrameGeometry(const IntRect&);
@@ -102,6 +103,6 @@
 #endif
     };
 
-}
+} // namespace WebCore
 
-#endif
+#endif // ScrollView_H
diff --git a/WebCore/platform/StaticConstructors.h b/WebCore/platform/StaticConstructors.h
index b65ff56..448adcf 100644
--- a/WebCore/platform/StaticConstructors.h
+++ b/WebCore/platform/StaticConstructors.h
@@ -26,7 +26,7 @@
 // portable, and it would be good to figure out a 100% clean way that still avoids code that
 // runs at init time.
 
-#if !AVOID_STATIC_CONSTRUCTORS
+#ifndef AVOID_STATIC_CONSTRUCTORS
     // Define an global in the normal way.
 #define DEFINE_GLOBAL(type, name, ...) \
     const type name;
diff --git a/WebCore/platform/StreamingTextDecoderICU.cpp b/WebCore/platform/StreamingTextDecoderICU.cpp
index 1be1ef8..d6e7301 100644
--- a/WebCore/platform/StreamingTextDecoderICU.cpp
+++ b/WebCore/platform/StreamingTextDecoderICU.cpp
@@ -27,8 +27,8 @@
 #include "config.h"
 #include "StreamingTextDecoderICU.h"
 
-#include <wtf/Assertions.h>
 #include <unicode/unorm.h>
+#include <wtf/Assertions.h>
 
 using std::min;
 
@@ -273,7 +273,7 @@
     }
 
     //#define PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE 1000
-#if PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE
+#ifdef PARTIAL_CHARACTER_HANDLING_TEST_CHUNK_SIZE
     DeprecatedString result;
     int chunkSize;
     for (int i = 0; i != len; i += chunkSize) {
diff --git a/WebCore/platform/StringImpl.h b/WebCore/platform/StringImpl.h
index 0a553d0..fb3c8067 100644
--- a/WebCore/platform/StringImpl.h
+++ b/WebCore/platform/StringImpl.h
@@ -36,7 +36,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 #endif
 
-#if __OBJC__
+#ifdef __OBJC__
 @class NSString;
 #endif
 
@@ -122,7 +122,7 @@
     StringImpl(CFStringRef);
     CFStringRef createCFString() const;
 #endif
-#if __OBJC__
+#ifdef __OBJC__
     StringImpl(NSString*);
     operator NSString*() const;
 #endif
diff --git a/WebCore/platform/Widget.h b/WebCore/platform/Widget.h
index 3ee78a42..f74a699 100644
--- a/WebCore/platform/Widget.h
+++ b/WebCore/platform/Widget.h
@@ -26,6 +26,8 @@
 #ifndef WEBCORE_PLATFORM_WIDGET_H_
 #define WEBCORE_PLATFORM_WIDGET_H_
 
+#include <wtf/Platform.h>
+
 #if __APPLE__
 #ifdef __OBJC__
 @class NSView;
@@ -34,7 +36,7 @@
 #endif
 #endif
 
-#if WIN32
+#if PLATFORM(WIN)
 typedef struct HWND__ *HWND;
 typedef struct HINSTANCE__ *HINSTANCE;
 #endif
@@ -125,7 +127,7 @@
 
         virtual bool isFrameView() const;
 
-#if WIN32
+#if PLATFORM(WIN)
         Widget(HWND);
         HWND windowHandle() const;
         void setWindowHandle(HWND);
@@ -161,6 +163,6 @@
         WidgetPrivate* data;
     };
 
-}
+} // namespace WebCore
 
-#endif
+#endif // WEBCORE_PLATFORM_WIDGET_H_
diff --git a/WebCore/platform/mac/BlockExceptions.mm b/WebCore/platform/mac/BlockExceptions.mm
index da55e34..0ce50d7 100644
--- a/WebCore/platform/mac/BlockExceptions.mm
+++ b/WebCore/platform/mac/BlockExceptions.mm
@@ -25,6 +25,7 @@
 
 #import "config.h"
 #import "BlockExceptions.h"
+
 #import <wtf/Assertions.h>
 
 void ReportBlockedObjCException(NSException *localException)
diff --git a/WebCore/platform/mac/ColorMac.mm b/WebCore/platform/mac/ColorMac.mm
index 086898b..50e8b248 100644
--- a/WebCore/platform/mac/ColorMac.mm
+++ b/WebCore/platform/mac/ColorMac.mm
@@ -66,7 +66,7 @@
                 if (cachedRGBAValues[i] == c)
                     return cachedColors[i];
 
-#if COLORMATCH_EVERYTHING
+#ifdef COLORMATCH_EVERYTHING
             NSColor* result = [NSColor colorWithCalibratedRed:color.red() / 255.0
                                                         green:color.green() / 255.0
                                                          blue:color.blue() / 255.0
diff --git a/WebCore/platform/mac/FloatPointMac.mm b/WebCore/platform/mac/FloatPointMac.mm
index 6e3a569..ae019a6 100644
--- a/WebCore/platform/mac/FloatPointMac.mm
+++ b/WebCore/platform/mac/FloatPointMac.mm
@@ -38,7 +38,7 @@
     return CGPointMake(m_x, m_y);
 }
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 FloatPoint::FloatPoint(const NSPoint& p) : m_x(p.x), m_y(p.y)
 {
diff --git a/WebCore/platform/mac/FloatRectMac.mm b/WebCore/platform/mac/FloatRectMac.mm
index 6b2d685..1e008dc 100644
--- a/WebCore/platform/mac/FloatRectMac.mm
+++ b/WebCore/platform/mac/FloatRectMac.mm
@@ -38,7 +38,7 @@
     return CGRectMake(x(), y(), width(), height());
 }
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 FloatRect::FloatRect(const NSRect& r) : m_location(r.origin), m_size(r.size)
 {
diff --git a/WebCore/platform/mac/FloatSizeMac.mm b/WebCore/platform/mac/FloatSizeMac.mm
index 6b45b23..e43ae39 100644
--- a/WebCore/platform/mac/FloatSizeMac.mm
+++ b/WebCore/platform/mac/FloatSizeMac.mm
@@ -38,7 +38,7 @@
     return CGSizeMake(m_width, m_height);
 }
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 FloatSize::FloatSize(const NSSize& s) : m_width(s.width), m_height(s.height)
 {
diff --git a/WebCore/platform/mac/FontMac.mm b/WebCore/platform/mac/FontMac.mm
index cc3769e..39bc24b 100644
--- a/WebCore/platform/mac/FontMac.mm
+++ b/WebCore/platform/mac/FontMac.mm
@@ -47,7 +47,7 @@
 #define LEFT_TO_RIGHT_OVERRIDE 0x202D
 #define RIGHT_TO_LEFT_OVERRIDE 0x202E
 
-#if defined(__LP64__)
+#ifdef __LP64__
 #define URefCon void*
 #else
 #define URefCon UInt32
diff --git a/WebCore/platform/mac/GraphicsContextMac.mm b/WebCore/platform/mac/GraphicsContextMac.mm
index bb4da2f..b7c85a1 100644
--- a/WebCore/platform/mac/GraphicsContextMac.mm
+++ b/WebCore/platform/mac/GraphicsContextMac.mm
@@ -106,7 +106,7 @@
     ASSERT(view);
 
     const NSRect* drawRects;
-#if defined(__LP64__)
+#ifdef __LP64__
     long count;
 #else
     int count;
diff --git a/WebCore/platform/mac/IntPointMac.mm b/WebCore/platform/mac/IntPointMac.mm
index def4040..8eb012e 100644
--- a/WebCore/platform/mac/IntPointMac.mm
+++ b/WebCore/platform/mac/IntPointMac.mm
@@ -37,7 +37,7 @@
     return CGPointMake(m_x, m_y);
 }
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 IntPoint::IntPoint(const NSPoint& p) : m_x(static_cast<int>(p.x)), m_y(static_cast<int>(p.y))
 {
diff --git a/WebCore/platform/mac/IntRectMac.mm b/WebCore/platform/mac/IntRectMac.mm
index f4bc11b..7997919 100644
--- a/WebCore/platform/mac/IntRectMac.mm
+++ b/WebCore/platform/mac/IntRectMac.mm
@@ -42,7 +42,7 @@
     return IntRect(l, t, r - l, b - t);
 }
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 IntRect::operator NSRect() const
 {
diff --git a/WebCore/platform/mac/IntSizeMac.mm b/WebCore/platform/mac/IntSizeMac.mm
index b784867..a80eaca 100644
--- a/WebCore/platform/mac/IntSizeMac.mm
+++ b/WebCore/platform/mac/IntSizeMac.mm
@@ -37,7 +37,7 @@
     return CGSizeMake(m_width, m_height);
 }
 
-#if !NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifndef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 
 IntSize::IntSize(const NSSize& s) : m_width(static_cast<int>(s.width)), m_height(static_cast<int>(s.height))
 {
diff --git a/WebCore/platform/mac/WebCoreSystemInterface.h b/WebCore/platform/mac/WebCoreSystemInterface.h
index e438fd6..08e1d22 100644
--- a/WebCore/platform/mac/WebCoreSystemInterface.h
+++ b/WebCore/platform/mac/WebCoreSystemInterface.h
@@ -32,7 +32,7 @@
 typedef struct CGRect CGRect;
 #endif
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGRect NSRect;
 #else
 typedef struct _NSRect NSRect;
@@ -42,7 +42,7 @@
 typedef struct CGPoint CGPoint;
 #endif
 
-#if NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
+#ifdef NSGEOMETRY_TYPES_SAME_AS_CGGEOMETRY_TYPES
 typedef struct CGPoint NSPoint;
 #else
 typedef struct _NSPoint NSPoint;