<http://webkit.org/b/57239> Use forward class declaration instead of including header
authorddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2011 17:07:44 +0000 (17:07 +0000)
committerddkilzer@apple.com <ddkilzer@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Mar 2011 17:07:44 +0000 (17:07 +0000)
Reviewed by Dan Bernstein.

Adding a "using namespace WebCore;" statement in a header may
cause issues when <WebCore/Length.h> is included before
<CoreText/CoreText.h>.

Length.h defines the LengthType enum with a 'Fixed' value.
CoreText.h includes MacTypes.h, which has a
"typedef SInt32 Fixed;" statement, and then CoreText.h includes
other headers that also use 'Fixed', but expect the typedef to
be defined, not the enum.  If another header includes
"using namespace WebCore;" before CoreText.h, the
following compiler errors result (paths abbreviated):

    CoreText.framework/Headers/SFNTLayoutTypes.h:689: error: reference to 'Fixed' is ambiguous
    MacTypes.h:184: error: candidates are: typedef SInt32 Fixed
    Length.h:37: error:                 WebCore::LengthType WebCore::Fixed
    SFNTLayoutTypes.h:689: error: 'Fixed' does not name a type

* platform/mac/HTMLConverter.h: Use forward declaration of
DocumentLoader class instead of including header.  Remove the
unused "using namespace WebCore;" statement.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@82128 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/mac/HTMLConverter.h

index 8584194a64f54c2b8ac31f0f5fb0091b9e38b17d..0ec985d7cce7519ee9ea1db3fb999dd0f28b0a4a 100644 (file)
@@ -1,3 +1,30 @@
+2011-03-28  David Kilzer  <ddkilzer@apple.com>
+
+        <http://webkit.org/b/57239> Use forward class declaration instead of including header
+
+        Reviewed by Dan Bernstein.
+
+        Adding a "using namespace WebCore;" statement in a header may
+        cause issues when <WebCore/Length.h> is included before
+        <CoreText/CoreText.h>.
+
+        Length.h defines the LengthType enum with a 'Fixed' value.
+        CoreText.h includes MacTypes.h, which has a
+        "typedef SInt32 Fixed;" statement, and then CoreText.h includes
+        other headers that also use 'Fixed', but expect the typedef to
+        be defined, not the enum.  If another header includes
+        "using namespace WebCore;" before CoreText.h, the
+        following compiler errors result (paths abbreviated):
+
+            CoreText.framework/Headers/SFNTLayoutTypes.h:689: error: reference to 'Fixed' is ambiguous
+            MacTypes.h:184: error: candidates are: typedef SInt32 Fixed
+            Length.h:37: error:                 WebCore::LengthType WebCore::Fixed
+            SFNTLayoutTypes.h:689: error: 'Fixed' does not name a type
+
+        * platform/mac/HTMLConverter.h: Use forward declaration of
+        DocumentLoader class instead of including header.  Remove the
+        unused "using namespace WebCore;" statement.
+
 2011-03-26  Dimitri Glazkov  <dglazkov@chromium.org>
 
         Reviewed by Eric Seidel.
index 3f65486406126d0bccfdcf465cbb99ee2db370c2..645c1d7821d467d86c2851a93d8e8ef5b5b50f1b 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#import "DocumentLoader.h"
 #import "DOM.h"
 #import "DOMDocument.h"
 #import "DOMRange.h"
 
-using namespace WebCore;
+namespace WebCore {
+class DocumentLoader;
+}
 
 @interface WebHTMLConverter : NSObject {
     NSMutableAttributedString *_attrStr;
@@ -36,7 +37,7 @@ using namespace WebCore;
     DOMDocument *_document;
     DOMRange *_domRange;
     NSMutableArray *_domStartAncestors;
-    DocumentLoader *_dataSource;
+    WebCore::DocumentLoader *_dataSource;
     NSString *_standardFontFamily;
     CGFloat _textSizeMultiplier;
     CGFloat _webViewTextSizeMultiplier;