Changeset 121923 in webkit


Ignore:
Timestamp:
Jul 5, 2012 1:19:08 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Code refactoring: move mimeTypeFromUTITree to a separate file.
https://bugs.webkit.org/show_bug.cgi?id=90619

We should move UTI handling related code to a separate file.

Patch by Yongjun Zhang <yongjun_zhang@apple.com> on 2012-07-05
Reviewed by David Kilzer.

  • WebCore.xcodeproj/project.pbxproj: Add UTIUtilities.h/UTIUtilities.mm to xcode project, and drive-by fix

that happened when editing the Xcode project file.

  • platform/network/mac/UTIUtilities.h: Added.

(WebCore):

  • platform/network/mac/UTIUtilities.mm: Added. move mimeTypeFromUTITree to UTIUtilities.mm.

(WebCore):
(WebCore::mimeTypeFromUTITree):

  • platform/network/mac/WebCoreURLResponse.mm: include UTIUtilities.h to use mimeTypeFromUTITree.

(WebCore):

Location:
trunk/Source/WebCore
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r121921 r121923  
     12012-07-05  Yongjun Zhang  <yongjun_zhang@apple.com>
     2
     3        Code refactoring: move mimeTypeFromUTITree to a separate file.
     4        https://bugs.webkit.org/show_bug.cgi?id=90619
     5
     6        We should move UTI handling related code to a separate file.
     7
     8        Reviewed by David Kilzer.
     9
     10        * WebCore.xcodeproj/project.pbxproj: Add UTIUtilities.h/UTIUtilities.mm to xcode project, and drive-by fix
     11            that happened when editing the Xcode project file.
     12        * platform/network/mac/UTIUtilities.h: Added.
     13        (WebCore):
     14        * platform/network/mac/UTIUtilities.mm: Added.  move mimeTypeFromUTITree to UTIUtilities.mm.
     15        (WebCore):
     16        (WebCore::mimeTypeFromUTITree):
     17        * platform/network/mac/WebCoreURLResponse.mm: include UTIUtilities.h to use mimeTypeFromUTITree.
     18        (WebCore):
     19
    1202012-07-05  Leandro Gracia Gil  <leandrogracia@chromium.org>
    221
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r121900 r121923  
    670670                1F3C3BEB135CAF3C00B8C1AC /* MediaControls.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3C3BE9135CAF3C00B8C1AC /* MediaControls.h */; };
    671671                1F3F19531499CA7600A5AEA7 /* PODFreeListArena.h in Headers */ = {isa = PBXBuildFile; fileRef = 1F3F19521499CA7600A5AEA7 /* PODFreeListArena.h */; settings = {ATTRIBUTES = (Private, ); }; };
     672                1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */; };
     673                1FAFBF1915A5FA7400083A20 /* UTIUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = 1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */; };
    672674                20D629261253690B00081543 /* InspectorInstrumentation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 20D629241253690B00081543 /* InspectorInstrumentation.cpp */; };
    673675                20D629271253690B00081543 /* InspectorInstrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = 20D629251253690B00081543 /* InspectorInstrumentation.h */; };
     
    76557657                1F3C3BE9135CAF3C00B8C1AC /* MediaControls.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControls.h; sourceTree = "<group>"; };
    76567658                1F3F19521499CA7600A5AEA7 /* PODFreeListArena.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PODFreeListArena.h; sourceTree = "<group>"; };
     7659                1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UTIUtilities.h; sourceTree = "<group>"; };
     7660                1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = UTIUtilities.mm; sourceTree = "<group>"; };
    76577661                20D629241253690B00081543 /* InspectorInstrumentation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorInstrumentation.cpp; sourceTree = "<group>"; };
    76587662                20D629251253690B00081543 /* InspectorInstrumentation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorInstrumentation.h; sourceTree = "<group>"; };
     
    79527956                3314ACEA10892086000F0E56 /* JSExceptionBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExceptionBase.h; sourceTree = "<group>"; };
    79537957                333F704E0FB49CA2008E12A6 /* Notification.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Notification.idl; path = Modules/notifications/Notification.idl; sourceTree = "<group>"; };
    7954                 333F704F0FB49CA2008E12A6 /* Notification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Notification.h; path =Modules/notifications/Notification.h; sourceTree = "<group>"; };
     7958                333F704F0FB49CA2008E12A6 /* Notification.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Notification.h; path = Modules/notifications/Notification.h; sourceTree = "<group>"; };
    79557959                33503C9910179A74003B47E1 /* NotificationClient.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; name = NotificationClient.h; path = Modules/notifications/NotificationClient.h; sourceTree = "<group>"; };
    79567960                33503C9F10179AD7003B47E1 /* JSNotification.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNotification.cpp; sourceTree = "<group>"; };
     
    1542815432                                514C76490CE9234E007EF3CD /* ResourceRequestMac.mm */,
    1542915433                                514C764B0CE9234E007EF3CD /* ResourceResponseMac.mm */,
     15434                                1FAFBF1615A5FA5200083A20 /* UTIUtilities.h */,
     15435                                1FAFBF1715A5FA5200083A20 /* UTIUtilities.mm */,
    1543015436                                37F818FB0D657606005E1F05 /* WebCoreURLResponse.h */,
    1543115437                                37F818FC0D657606005E1F05 /* WebCoreURLResponse.mm */,
     
    2517325179                                4F32BB1B14FA85E800F6C1A3 /* MemoryInstrumentation.h in Headers */,
    2517425180                                A882DA231593848D000115ED /* CSSToStyleMap.h in Headers */,
     25181                                1FAFBF1915A5FA7400083A20 /* UTIUtilities.h in Headers */,
    2517525182                        );
    2517625183                        runOnlyForDeploymentPostprocessing = 0;
     
    2816628173                                9712A611150090CE0048AF10 /* WorkerContextIndexedDatabase.cpp in Sources */,
    2816728174                                97F8E665151D4A4B00D2D181 /* WorkerContextNotifications.cpp in Sources */,
    28168                                 A8CCBB4C151F833B00AB7CE9 /* WorkerContextWebDatabase.cpp in Sources */, F34742E01343631F00531BC2 /* WorkerDebuggerAgent.cpp in Sources */,
     28175                                A8CCBB4C151F833B00AB7CE9 /* WorkerContextWebDatabase.cpp in Sources */,
     28176                                F34742E01343631F00531BC2 /* WorkerDebuggerAgent.cpp in Sources */,
    2816928177                                A3E2643014748991005A8588 /* WorkerEventQueue.cpp in Sources */,
    2817028178                                F36E07A41358A8BE00AACBC9 /* WorkerInspectorController.cpp in Sources */,
     
    2822628234                                50987C26157D676D00BDA835 /* CustomFilterGlobalContext.cpp in Sources */,
    2822728235                                A882DA201593846A000115ED /* CSSToStyleMap.cpp in Sources */,
     28236                                1FAFBF1815A5FA6E00083A20 /* UTIUtilities.mm in Sources */,
    2822828237                        );
    2822928238                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/platform/network/mac/WebCoreURLResponse.mm

    r95901 r121923  
    3131
    3232#import "MIMETypeRegistry.h"
     33#import "UTIUtilities.h"
    3334#import "WebCoreSystemInterface.h"
    3435#import <wtf/Assertions.h>
     
    448449}
    449450
    450 static RetainPtr<CFStringRef> mimeTypeFromUTITree(CFStringRef uti)
    451 {
    452     // Check if this UTI has a MIME type.
    453     RetainPtr<CFStringRef> mimeType(AdoptCF, UTTypeCopyPreferredTagWithClass(uti, kUTTagClassMIMEType));
    454     if (mimeType)
    455         return mimeType.get();
    456    
    457     // If not, walk the ancestory of this UTI via its "ConformsTo" tags and return the first MIME type we find.
    458     RetainPtr<CFDictionaryRef> decl(AdoptCF, UTTypeCopyDeclaration(uti));
    459     if (!decl)
    460         return nil;
    461     CFTypeRef value = CFDictionaryGetValue(decl.get(), kUTTypeConformsToKey);
    462     if (!value)
    463         return nil;
    464     CFTypeID typeID = CFGetTypeID(value);
    465    
    466     if (typeID == CFStringGetTypeID())
    467         return mimeTypeFromUTITree((CFStringRef)value);
    468 
    469     if (typeID == CFArrayGetTypeID()) {
    470         CFArrayRef newTypes = (CFArrayRef)value;
    471         CFIndex count = CFArrayGetCount(newTypes);
    472         for (CFIndex i = 0; i < count; ++i) {
    473             CFTypeRef object = CFArrayGetValueAtIndex(newTypes, i);
    474             if (CFGetTypeID(object) != CFStringGetTypeID())
    475                 continue;
    476 
    477             if (RetainPtr<CFStringRef> mimeType = mimeTypeFromUTITree((CFStringRef)object))
    478                 return mimeType;
    479         }
    480     }
    481    
    482     return nil;
    483 }
    484 
    485451void adjustMIMETypeIfNecessary(CFURLResponseRef cfResponse)
    486452{
Note: See TracChangeset for help on using the changeset viewer.